android - Checking active password is sufficient with DevicePolicyManager is crashed -
caused java.lang.securityexception: permission denial: isuserrunning() pid=13462, uid=101010 requires android.permission.interact_across_users @ android.os.parcel.readexception(parcel.java:1683) @ android.os.parcel.readexception(parcel.java:1636) @ android.app.admin.idevicepolicymanager$stub$proxy.isactivepasswordsufficient(idevicepolicymanager.java:3714) @ android.app.admin.devicepolicymanager.isactivepasswordsufficient(devicepolicymanager.java:2003)
public boolean ispasswordsufficient() { return mdpm.isactivepasswordsufficient(); }
above crash log , method caused this. crash log taken online crash reporting tool crashlytics. per official documentation here calling isactivepasswordsufficient() method can throw securityexception in 2 scenarios
- if calling application not own active administrator uses uses_policy_limit_password
- if user not unlocked.
and seems first scenario not happen have mdpm.isadminactive() check before calling method device admin have
<device-admin> <uses-policies> <limit-password/>
in meta data. think 2nd scenario. question if user not unlocked means? , how reproduce issue(if possible. tried creating multiple user , switched between user account, tried screen lock enabled), , there way handle crash rather adding try catch block(if ok please tell me why)?. crash happened motorola nexus 6 android 7.0 far.
try add android:protectionlevel="signature"
in manifest file
as below in manifest file:
<permission android:name="android.permission.interact_across_users_full" android:protectionlevel="signature"/>
to know more permission-element
syntax:
<permission android:description="string resource" android:icon="drawable resource" android:label="string resource" android:name="string" android:permissiongroup="string" android:protectionlevel=["normal" | "dangerous" | "signature" | "signatureorsystem"] />
Comments
Post a Comment