How to enable task locking in Android 5.0 producti

2019-07-26 01:10发布

I have an app for my company(Enterprise) owned devices , which works as single use app, so it locks itself and becomes single use app, for that it needs to be enabled as device owner, for testing i am using adb shell command and it works.

my problem is how do i achieve it for production so my enterprise will be able to install and use this as required.

1条回答
叼着烟拽天下
2楼-- · 2019-07-26 01:12

This answer will work if your Android 5.0 devices have NFC. Otherwise, Google supported a method using a Google Account with an activiation code within the Google Setup Wizard, but you need to be a Google EMM partner. I also don't know if they still support activation codes in 5.0/5.1. It was a Lollipop specific implementation.


If your devices DON'T have NFC, this link might help you set the device-owner programmatically, but it's not a recommended solution for production apps: How to make my app device owner without NFC and ADB shell command


But finally, if your devices DO have NFC:

You will need a provisioning wifi network that can connect to a server hosting the app that will be the device owner.

You can modify this project to create a quick provisioning app: https://github.com/googlesamples/android-NfcProvisioning

Be sure the NFC provisioning app sends, at a minimum, this information over NFC for an Android 5.0 device:

  • EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME
  • EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
  • EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION
  • EXTRA_PROVISIONING_LOCALE
  • EXTRA_PROVISIONING_TIME_ZONE
  • EXTRA_PROVISIONING_WIFI_SSID
  • EXTRA_PROVISIONING_WIFI_SECURITY_TYPE
  • EXTRA_PROVISIONING_WIFI_PASSWORD

When your corporate owned device is at the welcome screen of the Google Setup Wizard, place this device back-to-back with the provisioner device with the NFC provisioning app running. You will then tap the NFC provisioning app when it senses another NFC device. This sends across all the information the Google Setup Wizard requires to get on the network, download the app, verify the app, and then installs the app as the device owner.

Here's a good reference for creating package checksum: Checksum Error while provisioning Android Lollipop

查看更多
登录 后发表回答