Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
agenew_a16_sos
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e4abb500
authored
Jan 11, 2020
by
hanqianqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉手机号码前缀 + 无论插卡1或插卡2,定位服务都能正常使用
1 parent
ac7813ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
13 deletions
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceApplyActivity.java
app/src/main/java/com/toscl/location/hengfeng/util/PhoneUtils.java
app/src/main/java/com/toscl/location/hengfeng/activity/ServiceApplyActivity.java
View file @
e4abb50
...
...
@@ -38,7 +38,7 @@ public class ServiceApplyActivity extends Activity implements View.OnClickListen
/*
* has sim card ?
* */
if
(
PhoneUtils
.
getSubId
(
this
,
PreferencesUtil
.
HENG_FENG_DEFAULT_SLOT
)
==
SubscriptionManager
.
INVALID_SUBSCRIPTION_ID
){
if
(
PhoneUtils
.
getSubId
(
this
,
PreferencesUtil
.
HENG_FENG_DEFAULT_SLOT
)
==
-
1
){
Toast
.
makeText
(
this
,
getResources
().
getString
(
R
.
string
.
location_service_failed_tips
),
Toast
.
LENGTH_SHORT
).
show
();
finish
();
}
...
...
app/src/main/java/com/toscl/location/hengfeng/util/PhoneUtils.java
View file @
e4abb50
...
...
@@ -48,6 +48,8 @@ public class PhoneUtils {
private
static
final
String
TAG
=
"PhoneUtils"
;
private
static
final
ArrayMap
<
String
,
String
>
mobileAlias
=
new
ArrayMap
<>();
private
static
boolean
mDebugTest
=
false
;
public
static
final
int
SIM_CARD_1
=
0
;
public
static
final
int
SIM_CARD_2
=
1
;
public
static
int
getSimState
(
int
slot
)
{
int
state
=
-
1
;
...
...
@@ -476,11 +478,19 @@ public class PhoneUtils {
}
}
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
){
number
=
getPhoneNumberK
(
context
,
slot
);
int
simId
=
getSubId
(
context
,
PreferencesUtil
.
HENG_FENG_DEFAULT_SLOT
);
if
(
simId
==
-
1
){
simId
=
slot
;
}
number
=
getPhoneNumberK
(
context
,
simId
);
}
if
(
number
==
null
)
{
number
=
""
;
}
String
prefix
=
"+86"
;
if
(!
TextUtils
.
isEmpty
(
number
))
{
number
=
trimNum
(
prefix
,
number
);
}
return
number
;
}
...
...
@@ -588,21 +598,28 @@ public class PhoneUtils {
}
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
){
boolean
isSimInsert
=
false
;
TelephonyManager
tm
=
getTM
(
context
,
slotId
);
if
(
tm
!=
null
)
{
isSimInsert
=
tm
.
hasIccCard
();
if
(
isSimInserted
(
context
,
SIM_CARD_1
)){
return
SIM_CARD_1
;
}
if
(
isSimInsert
){
subId
=
slotId
+
1
;
if
(
isSimInserted
(
context
,
SIM_CARD_2
)){
return
SIM_CARD_2
;
}
Log
.
d
(
"qqh"
,
"Sim is insert:"
+
isSimInsert
);
}
Log
.
d
(
TAG
,
"sdk:"
+
Build
.
VERSION
.
SDK_INT
);
Log
.
d
(
TAG
,
"getSubid slotid: "
+
slotId
+
", subid: "
+
subId
);
return
subId
;
}
public
static
boolean
isSimInserted
(
Context
context
,
int
slotId
)
{
boolean
isSimInsert
=
false
;
TelephonyManager
tm
=
getTM
(
context
,
slotId
);
if
(
tm
!=
null
)
{
isSimInsert
=
tm
.
hasIccCard
();
}
return
isSimInsert
;
}
public
static
String
getMccMnc
(
Context
context
,
int
subId
)
{
String
imsi
=
""
;
if
(
subId
<
0
)
{
...
...
@@ -615,7 +632,10 @@ public class PhoneUtils {
Method
getSubscriberId
=
telephonyManagerClazz
.
getMethod
(
"getSubscriberId"
,
int
.
class
);
imsi
=
(
String
)
getSubscriberId
.
invoke
(
telephonyManager
,
subId
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
){
TelephonyManager
tm
=
getTM
(
context
,
0
);
if
(
subId
==
-
1
){
subId
=
0
;
}
TelephonyManager
tm
=
getTM
(
context
,
subId
);
if
(
tm
!=
null
)
{
imsi
=
tm
.
getSubscriberId
();
}
...
...
@@ -705,7 +725,11 @@ public class PhoneUtils {
}
if
(
TextUtils
.
isEmpty
(
meid
)){
TelephonyManager
tm
=
getTM
(
context
,
0
);
int
simId
=
getSubId
(
context
,
PreferencesUtil
.
HENG_FENG_DEFAULT_SLOT
);
if
(
simId
==
-
1
){
simId
=
0
;
}
TelephonyManager
tm
=
getTM
(
context
,
simId
);
if
(
tm
!=
null
)
{
String
deviceId
=
tm
.
getDeviceId
();
if
(
deviceId
!=
null
)
{
...
...
@@ -713,7 +737,6 @@ public class PhoneUtils {
}
}
}
Log
.
d
(
TAG
,
" K meid:"
+
meid
);
}
return
meid
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment