Search code examples
androidbroadcastreceiverandroid-logcatbootcompleted

Logcat : Not granting permission android.permission.BIND_DEVICE_ADMIN to package com.myprojects.myapp (protectionLevel=2 flags=0xbe46)


I have a boot complete broadcast receiver but it wasnt working as expected. Nor is the Full Screen activity that requires STATUS_BAR permission.

I tried to go through the LogCat logs while the phone was booting up and this is what I found :

LOG

 04-11 14:23:48.718: W/PackageManager(133): Not granting permission 
    android.permission.BIND_DEVICE_ADMIN to package com.myprojects.myapp (protectionLevel=2 flags=0xbe46)

Any clue why would this be happening?

My Manifest file has :

<uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"/>

<receiver android:name="com.myprojects.myapp.DeviceAdministrationReceiver"
        android:permission="android.permission.BIND_DEVICE_ADMIN">  
       <meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin_policies" />

    <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>

<receiver android:name="com.myprojects.myapp.BootCompleteReceiver">  
        <intent-filter>  
            <action android:name="android.intent.action.BOOT_COMPLETED" />  
        </intent-filter>  
</receiver>

EDIT And other two similar logs :

04-11 14:24:17.810: W/PackageManager(133): Not granting permission android.permission.STATUS_BAR to package com.myprojects.myapp (protectionLevel=3 flags=0xbe46)

04-11 14:24:17.810: W/PackageManager(133): Not granting permission android.permission.WRITE_SECURE_SETTINGS to package com.myprojects.myapp (protectionLevel=3 flags=0xbe46)

Solution

  • if you are extend DeviceAdminReceiver then must add meta-data and description for receiver like:

    <receiver 
        android:name=".AdminReceiver" 
        android:description="@string/description" 
        android:label="@string/labelValue" 
        android:permission="android.permission.BIND_DEVICE_ADMIN" 
     > 
     <meta-data  
      android:name="android.app.device_admin" 
      android:resource="@xml/lockourscreen"/> 
      <intent-filter> 
       <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /> 
      </intent-filter> 
    </receiver> 
    

    BIND_DEVICE_ADMIN as doc say : Must be required by device administration receiver, to ensure that only the system can interact with it.

    so remove <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN"/> line from application level