I recently noticed that when a Device Owner application is set, it's not possible to create a restricted profile.
First case : When my device owner app is not set.
From Settings>Users : I can "Add user or Profile", and then choose between a User or a Restricted Profile.
Second case : When my device owner app is set.
From Settings>Users : I can only "Add user", and then i get the confirmation to create a new user. In this second case, it's not possible to create a restricted profile.
I'd like to know why it's not available in this case and how I could possibly create a restricted profile in this case ?
The second part of my question is : how can I programmatically create a restricted profile - or an equivalent behavior - using the existing DevicePolicyManager API (as far as I can see, there's no public API to create restricted profile) ?
UPDATE: I made a sample app to illustrate this. It's available on Github.
Steps to reproduce :
- Compile the app
- Upload the application to your device
- Set the application as device owner using dpm command line tool:
adb shell dpm set-device-owner com.mytest.minimalistdeviceowner/.DeviceAdminRcvr
. - Check that the creation of profile is not available in Settings>Users
- Unset the application as device owner by clicking, in the app, on "Unset Device Owner".
- Check that the creation is now available in Settings>Users