How to enrol an Android device to WSO2 MDM server with device owner mode

Anuradh
6 min readAug 7, 2018

--

What is device owner mode : simply we can say it manages the entire device. actually it is an application that runs as a device administrator on your Android device. The device owner app can use the programming methods in the DevicepolicyManager Class to take control of the configuration, security and other applications on the device. no other applications can utilize the methods in that class to control the device.device can have only one device owner. if you added a google account before you do the enrolment, then it will take the google account as your primary account.

S T E P 01 : Not a new device, remove all your google accounts or factory reset the phone.

If your device is a new one (just unboxed) then you can continue from the next step. otherwise you have to remove all the google accounts added to your device by going to settings ----> search for Accounts and then remove all the google accounts or else you can do a factory reset to remove all added google accounts to your android device and keep in mind, do not add any google account until we enable the Device owner mode using Android Debug Bridge (ADB) and finish the enrolment process.

S T E P 02 : Install ADB (android debug bridge) on your machine (laptop or desktop).

How to install adb (android debug bridge) in windows, linux an macOS.

S T E P 03 : Enable developer mode.

  • go to settings — → About device — → tap seven(7) times on Build Number . then it will activate the developer mode. or go to settings — → type build number and tap on it — → then again tap on Build Number seven time

S T E P 04 : Enable usb debuggin.

  • got to Developer Options — -> Scroll down and enable Debugging. this will enable the debug for you device.

S T E P 05: Connect your device to laptop/desktop and check if ADB is working properly by typing adb devices on your cmd, powershell or terminal . then the output should like below:

S T E P 06 : Install android agent apk (agent application) via ADB

  • navigate to the directory where your android-agent.apk exists using terminal, cmd or powershell.
  • then type adb install android-agent.apk .
  • in your device it will ask for the permission to install the .apk . allow to install. then it will install the wso2 agent application on your mobile device.

S T E P 07 : Change the Configurations.

  • go to you device management dash board in web.
Device management Dashboard.
  • You will get a window like below. from there you can change the policy monitoring which is minimum time to sync with changed policies. keep it as 60. ( minimum time take to sync with your device this will run as a background process to transmit data from server to a particular app instance. for local polling better to have it as 90).
  • Then click on Android Configuration to change the communication protocol configuration like below. when we enrolled a device as device owner mode initially the type of communication should be local polling ( minimum time that takes to sync with your device. this will run as a background process to transmit data from server to a particular app instance) , because we are in device owner mode 😃 and didn't configure any google account yet to activate FCM (firebase cloud messaging) which is reliable and quick data transmit process than local polling. we will configure in upcoming steps. select the values as below screen. and save.

S T E P 08 : Enrol a device (make sure your internet connection)

  • Open the installed app in S T E P 06. you will see a view like below. select Continue
  • Select SKIP AND GO TO ENROLMENT in next view like below.
  • Type your server Address with the port. port should be 8280. make sure the port is opened in your server . Ex: 111.342.50.144:8280 .it should be like below. and tap on START REGISTRATION button.
  • then give your credentials to register as below. leave the Organization as it is or type carbon.super . type your username and the password . and then continue the steps.

S T E P 09: set device owner permission to installed wso2 agent app.

Now we should give the device owner permission to wso2 agent application which we installed in previous step. to do that in your cmd or powershell or terminal use below command. copy and paste whole lines together.

adb shell dpm set-device-owner org.wso2.iot.agent/.services.AgentDeviceAdminReceiver

above command will set the agent app as device owner.

you can test by sending a message from dashboard to the device. it will take bit time. because we have configured it with local polling. now its time to change the local polling to FCM (firebase cloud messaging).

S T E P 10: Allow firebase instead of local polling.

FCM -Firebase Cloud Messaging (FCM) is a lightweight mechanism used to transmit data from a server to a particular app instance. Using FCM, your server can notify your app running on a particular device that there is new data available for it.

above step will change the Local polling to FCM. now check again by sending a message to triggering any other feature from dashboard. it will trigger quickly than before.

Hope this will help to you. Credit should goes to Kasun Delgolla for sharing his knowledge. Thank You and cheers 🥂.

--

--