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


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();

Leave A Comment

Your email address will not be published. Required fields are marked *