Android10平台不能使用TelephonyManager.getDeviceId()获取IMEI了。
为了方便,可以把权限验证去掉:
//packages/services/Telephony
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 4c4c30f..a7f8bc2 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2194,10 +2194,11 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
return null;
}
int subId = phone.getSubId();
+ /*
if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId,
callingPackage, "getImeiForSlot")) {
return null;
- }
+ }*/
final long identity = Binder.clearCallingIdentity();
try {
PS: 我思考还有一种方案,把权限验证时的包名替换为一种系统包名,应该也可行。
网友评论