139
139
* <li> {@link DevicePolicyManager#setAccountManagementDisabled(android.content.ComponentName,
140
140
* String, boolean)} </li>
141
141
* <li> {@link DevicePolicyManager#getAccountTypesWithManagementDisabled()} </li>
142
- * <li> {@link DevicePolicyManager#createAndInitializeUser(android.content.ComponentName, String,
143
- * String, android.content.ComponentName, android.os.Bundle)} </li>
144
142
* <li> {@link DevicePolicyManager#removeUser(android.content.ComponentName,
145
143
android.os.UserHandle)} </li>
146
144
* <li> {@link DevicePolicyManager#setUninstallBlocked(android.content.ComponentName, String,
@@ -198,7 +196,6 @@ public class PolicyManagementFragment extends PreferenceFragment implements
198
196
private static final String CAPTURE_IMAGE_KEY = "capture_image" ;
199
197
private static final String CAPTURE_VIDEO_KEY = "capture_video" ;
200
198
private static final String CHECK_LOCK_TASK_PERMITTED_KEY = "check_lock_task_permitted" ;
201
- private static final String CREATE_AND_INITIALIZE_USER_KEY = "create_and_initialize_user" ;
202
199
private static final String CREATE_AND_MANAGE_USER_KEY = "create_and_manage_user" ;
203
200
private static final String DELEGATED_CERT_INSTALLER_KEY = "manage_cert_installer" ;
204
201
private static final String DEVICE_OWNER_STATUS_KEY = "device_owner_status" ;
@@ -257,7 +254,6 @@ public class PolicyManagementFragment extends PreferenceFragment implements
257
254
private static final String SYSTEM_UPDATE_POLICY_KEY = "system_update_policy" ;
258
255
private static final String UNHIDE_APPS_KEY = "unhide_apps" ;
259
256
private static final String UNSUSPEND_APPS_KEY = "unsuspend_apps" ;
260
- private static final String USER_MANAGEMENT_CATEGORY_KEY = "user_management" ;
261
257
private static final String WIPE_DATA_KEY = "wipe_data" ;
262
258
private static final String CREATE_WIFI_CONFIGURATION_KEY = "create_wifi_configuration" ;
263
259
private static final String WIFI_CONFIG_LOCKDOWN_ENABLE_KEY = "enable_wifi_config_lockdown" ;
@@ -275,7 +271,7 @@ public class PolicyManagementFragment extends PreferenceFragment implements
275
271
private static final String DONT_STAY_ON = "0" ;
276
272
277
273
private static final String [] PRIMARY_USER_ONLY_PREFERENCES = {
278
- WIPE_DATA_KEY , REMOVE_DEVICE_OWNER_KEY , CREATE_AND_INITIALIZE_USER_KEY , REMOVE_USER_KEY ,
274
+ WIPE_DATA_KEY , REMOVE_DEVICE_OWNER_KEY , REMOVE_USER_KEY ,
279
275
MANAGE_LOCK_TASK_LIST_KEY , CHECK_LOCK_TASK_PERMITTED_KEY , START_LOCK_TASK ,
280
276
STOP_LOCK_TASK , DISABLE_STATUS_BAR , REENABLE_STATUS_BAR , DISABLE_KEYGUARD ,
281
277
REENABLE_KEYGUARD , START_KIOSK_MODE , SYSTEM_UPDATE_POLICY_KEY , STAY_ON_WHILE_PLUGGED_IN ,
@@ -361,7 +357,6 @@ public void onCreate(Bundle savedInstanceState) {
361
357
findPreference (CHECK_LOCK_TASK_PERMITTED_KEY ).setOnPreferenceClickListener (this );
362
358
findPreference (START_LOCK_TASK ).setOnPreferenceClickListener (this );
363
359
findPreference (STOP_LOCK_TASK ).setOnPreferenceClickListener (this );
364
- findPreference (CREATE_AND_INITIALIZE_USER_KEY ).setOnPreferenceClickListener (this );
365
360
findPreference (CREATE_AND_MANAGE_USER_KEY ).setOnPreferenceClickListener (this );
366
361
findPreference (REMOVE_USER_KEY ).setOnPreferenceClickListener (this );
367
362
mDisableCameraSwitchPreference = (SwitchPreference ) findPreference (DISABLE_CAMERA_KEY );
@@ -536,9 +531,6 @@ public void onPositiveButtonClicked(String[] lockTaskArray) {
536
531
case GET_DISABLE_ACCOUNT_MANAGEMENT_KEY :
537
532
showDisableAccountTypeList ();
538
533
return true ;
539
- case CREATE_AND_INITIALIZE_USER_KEY :
540
- showCreateAndInitializeUserPrompt ();
541
- return true ;
542
534
case CREATE_AND_MANAGE_USER_KEY :
543
535
showCreateAndManageUserPrompt ();
544
536
return true ;
@@ -1070,14 +1062,6 @@ private void disableIncompatibleManagementOptionsByApiLevel() {
1070
1062
for (String preference : NYC_PLUS_PREFERENCES ) {
1071
1063
findPreference (preference ).setEnabled (false );
1072
1064
}
1073
- } else {
1074
- // DevicePolicyManager.createAndInitializeUser() was deprecated in M and removed in N.
1075
- // TODO: removePreference is not recursive, so the parent PreferenceGroup has to be
1076
- // known for removal, calling from the root PreferenceScreen does not work. For now,
1077
- // this is the only removed preference. If removing needs to be done more often, a
1078
- // recursive implementation for removePreference might be better.
1079
- ((PreferenceCategory ) findPreference (USER_MANAGEMENT_CATEGORY_KEY ))
1080
- .removePreference (findPreference (CREATE_AND_INITIALIZE_USER_KEY ));
1081
1065
}
1082
1066
}
1083
1067
@@ -1202,43 +1186,6 @@ private void showDisableAccountTypeList() {
1202
1186
}
1203
1187
}
1204
1188
1205
- /**
1206
- * For user creation:
1207
- * Shows a prompt to ask for the username that would be used for creating a new user.
1208
- */
1209
- private void showCreateAndInitializeUserPrompt () {
1210
- if (getActivity () == null || getActivity ().isFinishing ()) {
1211
- return ;
1212
- }
1213
- View view = LayoutInflater .from (getActivity ()).inflate (R .layout .simple_edittext , null );
1214
- final EditText input = (EditText ) view .findViewById (R .id .input );
1215
- input .setHint (R .string .enter_username_hint );
1216
-
1217
- new AlertDialog .Builder (getActivity ())
1218
- .setTitle (R .string .create_and_initialize_user )
1219
- .setView (view )
1220
- .setPositiveButton (android .R .string .ok , new DialogInterface .OnClickListener () {
1221
- @ Override
1222
- public void onClick (DialogInterface dialogInterface , int i ) {
1223
- String name = input .getText ().toString ();
1224
- String ownerName = getString (R .string .app_name );
1225
- if (!TextUtils .isEmpty (name )) {
1226
- UserHandle userHandle = mDevicePolicyManager .createAndInitializeUser (
1227
- mAdminComponentName , name , ownerName , mAdminComponentName ,
1228
- new Bundle ());
1229
- if (userHandle != null ) {
1230
- long serialNumber = mUserManager .getSerialNumberForUser (userHandle );
1231
- showToast (R .string .user_created , serialNumber );
1232
- return ;
1233
- }
1234
- showToast (R .string .failed_to_create_user );
1235
- }
1236
- }
1237
- })
1238
- .setNegativeButton (android .R .string .cancel , null )
1239
- .show ();
1240
- }
1241
-
1242
1189
/**
1243
1190
* For user creation:
1244
1191
* Shows a prompt asking for the username of the new user and whether the setup wizard should
0 commit comments