Final intention here is to have a device in 'kiosk mod'.
They say you don't need NFC nor rooting to achieve application becoming device owner. I've yet to see a full example of this method but lets try:
adb shell dpm set-device-owner <package>/.<ReceiverImplementation>
should do... So I do so, and get:
java.lang.SecurityException:
Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN.
Following code, therefore, returns false.
((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE))
.isDeviceOwnerApp(getApplicationContext().getPackageName())
This STO question poses a similar question but doesn't specify an actual failure..
Manifest file and the rest of the source is mostly inspired from this google sample
<manifest
package="com.example.android.deviceowner"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver
android:name=".DeviceOwnerReceiver"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_owner_receiver"/>
<intent-filter>
<action android:name="android.app.action.ACTION_DEVICE_ADMIN_ENABLED"/>
</intent-filter>
</receiver>
</application>
</manifest>
Device I am trying to do this currently is LG G Pad.
Your manifest file seems correct.
You should be aware that it may come from the state of your system when you are executing this command. Many points should be checked before running the dpm
command successfully :
The best thing to do (That's what I did when experimenting indeed) is to completely factory-reboot your phone and avoid most configuration steps (except the mandatories steps "configure Wi-Fi", and "Name"), and do not associate any Google account.
Once provisioned, you are sure to be in a clean state.
Then,
pm install
...)adb shell dpm set-device-owner ...
I've written an article explaining most of these steps on my blog, take a look at it, it may be useful in your case.
I am not sure if this is going to help you, but if not you, maybe someone else will use this solution. I had a very similar problem with Samsung Tab A. I could not set the ownership to my application. Always while running:
adb shell dpm set-device-owner cy.com.myapp/.AdminReceiver
I was getting:
java.lang.SecurityException: Neither user 2000 nor current process has
com.sec.enterprise.permission.MDM_PROXY_ADMIN_INTERNAL.
After long search I finally found that I needed to add to my manifest permissions special permissions of Samsung:
<uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" />
That did the trick and now my app can go to the kiosk mode on demand. Possibly you are looking at a similar problem - maybe there is one or more permission setting that you need to set for your LG. My solution worked for a non-rooted device (and obviously without any account added - fresh after factory reset).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With