Device owner on an untouched device (Android L), without NFC, using adb shell, dpm set-device-owner

The final intention is to have the device in kiosk mode.

They tell you you do not need NFC or rooting in order for the application to become the owner of the device . I have not seen a complete example of this method yet, but I will try:

adb shell dpm set-device-owner <package>/.<ReceiverImplementation> 

should do ... so I do this and get:

 java.lang.SecurityException: Neither user 2000 nor current process has android.permission.BIND_DEVICE_ADMIN. 

Thus, the following code returns false.

 ((DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE)) .isDeviceOwnerApp(getApplicationContext().getPackageName()) 

This STO question poses a similar question, but does not indicate an actual failure.

The manifest file and the rest of the source are mostly inspired by 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> 

The device I'm trying to make at the moment is the LG G Pad.

+6
source share
2 answers

The manifest file seems correct. You should be aware that this may come from the state of your system when executing this command. Before executing the dpm command, dpm need to check many points:

  • Make sure your application is already installed, like any other random application.
  • Make sure the account is not already set for the current user (make sure the account is not set in Settings> Accounts) before using it.
  • there should not be an already registered device owner

The best thing to do (what I really did when experimenting) is to completely factory - restore your phone and avoid most of the configuration steps (except for the “configure Wi-Fi” and “Name” mandarin steps) and do not link your Google account .
Once you have prepared, you will surely be in a clean state. Then,

  • Activate debugging
  • install the application with your IDE (or using pm install ...)
  • run adb shell dpm set-device-owner ...

I wrote an article explaining most of these steps on my blog , take a look at it, it can be useful in your case,

+3
source

I'm not sure if this will help you, but if not you, maybe someone else will use this solution. I had a very similar problem with the Samsung Tab A. I could not establish ownership of my application. Always at work:

 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 a long search, I finally found that I need to add special permissions for Samsung to my permission permissions:

 <uses-permission android:name="com.samsung.accessory.permission.ACCESSORY_FRAMEWORK" /> 

This did the trick, and now my application can go to kiosk mode on demand. Perhaps you are looking at a similar problem - there may be one or more resolution options that need to be set for your LG. My solution worked on a non-root device (and, obviously, without adding an account - after factory reset).

+1
source

Source: https://habr.com/ru/post/985776/


All Articles