Tech Blog

Android, Coding, Programming, Technology

Set up work profile on company owned android 11 and above device

By Kumar gaurav3 min read
← Back to blog

Android 11 introduces work profiles for company owned devices with improved support for work profiles. If a work profile is created from a setup wizard using QR code or zero touch enrollment, the device is recognized as Work profile on company owned devices. If a work profile is created using any other method except the above mentioned techniques, the device is recognized as a work profile on a personally owned device.

A new intent extra allows DPC’s (Device Policy controller) to decide whether the user wants to enroll the device as a fully managed device or work profile on Company owned device. An activity associated with this filter is launched by the system during provisioning and its purpose is to decide whether to enroll the device as fully managed or work profile on company owned device. We can also receive all the provisioning extras or values needed to enroll the device and then decide to enroll the device with appropriate management mode. For users, this means that the devices will have improved privacy benefits.

For example :-

<activity
    android:name=”com.example.GetProvisioningModeActivity”
    android:label=”@string/app_name”
    android:permission=”android.permission.BIND_DEVICE_ADMIN”>
    <intent-filter>
        <action
            android:name=”android.app.action.GET_PROVISIONING_MODE” />
        <category android:name=”android.intent.category.DEFAULT”/>
    </intent-filter>
</activity>

Now, the activity GetProvisioningModeActivity will be launched from the system during the device provisioning and we can get all the provisioning extras by calling getIntent().getExtras() in onCreate() of this activity and based on the inputs received we can decide on the appropriate management mode. These extras will be sent by the system during the provisioning process.

The getIntent().getExtras() called in the GetProvisioningModeActivity can retrieve the following extras as given below :-

  • EXTRA_PROVISIONING_IMEI – A string extra which contains the IMEI of the device.
    For example –
    final String lStrImei =
    getIntent.getExtras.getString(DevicePolicyManager.EXTRA_PROVISIONING_IMEI)
  • EXTRA_PROVISIONING_SERIAL_NUMBER – A string extra which contains the serial number of the device.
    For example –
    final String lStrSerialNumber =
    getIntent.getExtras.getString(DevicePolicyManager.EXTRA_PROVISIONING_SERIAL_NUMBER)
  • EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE – A parcelable extra that allows a mobile device management application to pass the data to management application after provisioning.
    For example –
    final PersistableBundle lObjPersistableBundle = getIntent.getExtras.getParcelable(DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE)

To set the management mode on the device, we need to call the following Intent with the desired mode of management as shown in the example below :-

Intent intent = new Intent();

//For Fully Managed Mode

intent.putExtra(EXTRA_PROVISIONING_MODE, PROVISIONING_MODE_FULLY_MANAGED_DEVICE);

          //OR

//For Work Profile Mode

intent.putExtra(EXTRA_PROVISIONING_MODE, PROVISIONING_MODE_MANAGED_PROFILE);

Now we can complete the management mode as Work Profile or Fully managed mode by sending the provisioning details back to setup via-

setResult(RESULT_OK, intent);

and finishing all the active activities by calling –

finish();

Keep reading

You may be interested in

Browse all articles →
Disable MAC Randomization in Android 10 and above devices
June 1, 20223 min read

Disable MAC Randomization in Android 10 and above devices

Recently we came across an interesting feature, to set static MAC address for the wifi ssids for Android 10 and above devices.MAC Randomization generates a random MAC address for a wifi ssid for the following conditions mentioned below :- When connecting with that particular network for the first time=- Forget and rejoin the network. in […]

By Kumar gauravRead More →
Getting Notification related to our application using microphone even though microphone permission is not declared in application’s Manifest file (Android).
March 24, 20224 min read

Getting Notification related to our application using microphone even though microphone permission is not declared in application’s Manifest file (Android).

Recently, we found an interesting bug while working with one of our partners. The issue was that even though our application and the libraries needed for our application were not using the microphone permission,still we were getting notifications related to our application using the microphone.The issue was easily reproducible on their set of devices as […]

By Kumar gauravRead More →
How Angular is Different from AngularJS
September 27, 20227 min read

How Angular is Different from AngularJS

What is Angular? Angular is a popular open-source Typescript framework and free to use. Considered to be a JavaScript-based framework,TypeScript.is its primary programming language. TypeScript is Developed by Microsoft and its superset of JavaScript, which simply means that TypeScript has all the capabilities that JS has and more additional features. Angular is majorly used for […]

By Sachin DevadigaRead More →