Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 4.3 DeviceAdmin error for non owner profile

I am using a Nexus 7 which is updated to Android 4.3. I have an application which requires Device Admin rights to Lock/ Wipe device. I have given Device Admin right to my application on Owner Profile. So when i switch to another user profile, i can see my application in list of Device Admin apps. However when i give a Lock command on this non Owner user profile, i get the exception as

"java.lang.SecurityException: No active admin owned by uid XXXXXX".

DevicePolicyManager isActiveAdmin () method also returns true on this profile still it fails to take action and crashes the application.

I assume that once device admin is set for Owner user profile, its automatically applied to all other user profiles.Any idea then why is this happening ? Also, is there any documentation that points out on what care should my application take in order to handle Multiple user profiles in case my app requires device admin rights

like image 733
Alok Kulkarni Avatar asked Sep 23 '13 13:09

Alok Kulkarni


People also ask

How do I bypass administrator on Android?

Go to your phone's settings and then click on “Security.” You'll see “Device Administration” as a security category. Click on it to see a list of apps that have been given administrator privileges. Click the app you want to remove and confirm that you want to deactivate administrator privileges.

What is activate device administrator?

For those who are unfamiliar, Device Administrator applications are the Android-equivalent of Mobile Device Management (MDM) software. Like other MDM software, Device Administrator applications can set policies on usage of the phone.


1 Answers

Have you set in device_admin_sample.xml what admin policy comply with your App expected behaviour?

Set the admin paramenters as

 android:label="@string/enterprise_device_admin" 
        android:permission="android.permission.BIND_DEVICE_ADMIN"> 
     android:resource="@xml/enterprise_device_admin" /> 

Here is a typical content for your file device_admin_sample.xml:

<activity android:name=".app.DeviceAdminSample"
        android:label="@string/activity_sample_device_admin">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.SAMPLE_CODE" />
    </intent-filter>
</activity>
<receiver android:name=".app.DeviceAdminSample$DeviceAdminSampleReceiver"
    android:label="@string/sample_device_admin"
    android:description="@string/sample_device_admin_description"
    android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
        android:resource="@xml/device_admin_sample" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>

Further reading with step by step instructions that is also worth checking:

  • Make your application a device administrator
  • Device Administration
like image 96
Avanz Avatar answered Sep 29 '22 15:09

Avanz