I need to know how to set my application as Device owner in Android 5.0, 4.4 and 4.3(?). I've yet tried the method for rooted devices (described in there), successfully. I saw that works great in android 5.0 and 4.4.2 emulator and in CyanoGen AOSP 4.4.4 (all rooted devices). But I must need to try this on other non rooted devices, in Android 5.0 Developer API you can read this
"To deploy and activate a device owner, you must perform an NFC data transfer from a programming app to the device while the device is in its unprovisioned state."
but I don't understand what it means, or better, what I've to do. Can someone help me, or explain me the step to do?
PS. I know what NFC is and how it works but I can't understand how to use for this issue.
The Sophos NFC Provisioning app is designed to help administrators to enroll Android Enterprise devices using the Device Owner mode. This app should be installed on a administrative device and then used to transmit the configuration to new devices.
Provisioning is the process of setting up a device to be managed via policies by an enterprise . During the process a device installs Android Device Policy, which is used to receive and enforce policies . If provisioning is successful, the API creates a devices object, binding the device to an enterprise.
Device Owner mode gives options to configure policies and customize hardware and software functions for Android devices. You will also need a Mobile Device Management solution like Hexnode to set up, secure and manage Android Enterprise devices for your organization.
To manually enable provisioning mode on the applicable devices: Go to Settings > Honeywell Settings > Provisioning Mode. Move the slider to the 'On' position.
Create a NFC trigger application and install that on a device (other than the one on which you want to make your app as device owner) having NFC.
Following is the code for NFC trigger
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 checksum run following command
cat your_device_owner_app_name.apk | openssl dgst -binary -sha1 | openssl base64 | tr '+/' '-_' | tr -d '='
Now upload your application apk which you want to make as device owner on google drive or dropbox.
Take a fresh device or factory reset the device on which you want to set your application as device owner.
Reboot the device and on first screen bring your device containing NFC trigger application and touch for beam transfer.
Your application will be downloaded and will get installed as device owner.
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