Owner of a device on Android 5.0 (and others) without root devices, provision of NFC devices

I need to know how to configure the application as the owner of the device in Android 5.0, 4.4 and 4.3 (?). I have also tried the method for root devices ( described there ), successfully. I saw that it works fine in android 5.0 and 4.4.2 emulator and in CyanoGen AOSP 4.4.4 (all root devices). But I need to try this on other undisturbed devices, in the Android 5.0 Developer API you can read this

"To deploy and activate the device owner, you must complete the NFC data transition from the programming application to the device while the device is in its unexpected state."

but I don’t understand what this means, or better, what I should do. Can someone help me or explain me what to do?

PS. I know what NFC is and how it works, but I cannot figure out how to use this problem.

+11
android android-5.0-lollipop provisioning nfc
Nov 13 '14 at 10:07
source share
2 answers

Create an NFC trigger application and install it on the device (different from the one on which you want to make your application the owner of the device) with NFC.

Below is the NFC startup code

public class MainActivity extends Activity implements CreateNdefMessageCallback { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this); nfcAdapter.setNdefPushMessageCallback(this, this); } @Override public NdefMessage createNdefMessage(NfcEvent event) { try { Properties p = new Properties(); p.setProperty( DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, "apk package name"); p.setProperty( DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION, "app download url"); p.setProperty( DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM, "apk checksum"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); OutputStream out = new ObjectOutputStream(bos); p.store(out, ""); final byte[] bytes = bos.toByteArray(); NdefMessage msg = new NdefMessage(NdefRecord.createMime( DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC, bytes)); return msg; } catch (Exception e) { throw new RuntimeException(e); } } } 

For the checksum, run the following command

cat your_device_owner_app_name.apk | openssl dgst -binary -sha1 | openssl base64 | tr '+ /' '-_' | tr -d '='

  • Insert the generated checksum into the NFC startup code.
  • Compile and run the NFC trigger application on the device.

Now download the apk app that you want to make the device owner on the Google drive or Dropbox.

Take the new device or factory reset the device on which you want to install the application as the owner of the device.

Reboot the device and on the initial screen, bring your device containing the NFC trigger application and tap to transmit the beam.

Your application will be downloaded and installed as the owner of the device.

+20
Nov 19 '14 at 4:48
source share

If necessary, it is also possible to set the owner of the device using adb, as indicated here: http://sdgsystems.com/blog/implementing-kiosk-mode-android-part-3-android-lollipop

+1
Aug 27 '15 at 18:19
source share



All Articles