PhoneStateReadTest need to be compatible with Android Q
See original GitHub issuehttps://developer.android.com/preview/privacy/data-identifiers#device-ids
从 Android Q 开始,应用必须具有 READ_PRIVILEGED_PHONE_STATE 签名权限才能访问设备的不可重置标识符(包含 IMEI 和序列号)。许多用例不需要不可重置的设备标识符。如果您的应用没有该权限,但您仍尝试查询标识符的相关信息。会返回空值或报错。
class PhoneStateReadTest implements PermissionTest {
private Context mContext;
PhoneStateReadTest(Context context) {
this.mContext = context;
}
@Override
public boolean test() throws Throwable {
PackageManager packageManager = mContext.getPackageManager();
if (!packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) return true;
TelephonyManager telephonyManager = (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE ||
!TextUtils.isEmpty(telephonyManager.getDeviceId()) ||
!TextUtils.isEmpty(telephonyManager.getSubscriberId());
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Device compatibility overview - Android Developers
As an app developer, you don't need to worry about whether a device is Android compatible, because only devices that are Android compatible...
Read more >Sharing what's new in Android Q
With Android Q, we'll update important OS components in the background, similar to the way we update apps.
Read more >All you need to know about the latest Android Q - Peerbits
After a long wait, Android has finally came up with its latest version Android Q. This time they introduced their new update with...
Read more >Android Q: everything you need to know about Google's update
Google has released the third public beta of Android Q this week, so if you have a ... so be warned: not everything...
Read more >Intune Support for Android Q | Android 10
Both our Intune App Protection Policy (APP or MAM) team and our Mobile Device Management (MDM) team have been testing each beta release...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s just a new feature, but currently only supports AndroidP, AndroidQ is still in beta, I will follow up on this issue later.
#478