|
52 | 52 | import android.security.KeyChain;
|
53 | 53 | import android.security.KeyChainAliasCallback;
|
54 | 54 | import android.service.notification.NotificationListenerService;
|
55 |
| -import android.support.annotation.Nullable; |
56 | 55 | import android.support.annotation.RequiresApi;
|
57 | 56 | import android.support.annotation.StringRes;
|
58 | 57 | import android.support.v14.preference.SwitchPreference;
|
@@ -283,13 +282,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
|
283 | 282 | private static final String MANAGE_APP_RESTRICTIONS_KEY = "manage_app_restrictions";
|
284 | 283 | private static final String MANAGED_PROFILE_SPECIFIC_POLICIES_KEY = "managed_profile_policies";
|
285 | 284 | private static final String MANAGE_LOCK_TASK_LIST_KEY = "manage_lock_task";
|
286 |
| - private static final String MANDATORY_BACKUPS = "mandatory_backups"; |
287 |
| - private static final String MANDATORY_BACKUP_ACCOUNT_CHANGED_ACTION = |
288 |
| - "com.google.android.gms.backup.MANDATORY_BACKUP_ACCOUNT_CHANGED"; |
289 |
| - private static final String MANDATORY_BACKUP_ACCOUNT_NAME_APP_RESTRICTION = |
290 |
| - "mandatoryBackupAccountName"; |
291 |
| - private static final String MANDATORY_BACKUP_ACCOUNT_TYPE_APP_RESTRICTION = |
292 |
| - "mandatoryBackupAccountType"; |
293 | 285 | private static final String MUTE_AUDIO_KEY = "mute_audio";
|
294 | 286 | private static final String NETWORK_STATS_KEY = "network_stats";
|
295 | 287 | private static final String PASSWORD_CONSTRAINTS_KEY = "password_constraints";
|
@@ -375,9 +367,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
|
375 | 367 | BatteryManager.BATTERY_PLUGGED_USB |
|
376 | 368 | BatteryManager.BATTERY_PLUGGED_WIRELESS);
|
377 | 369 | private static final String DONT_STAY_ON = "0";
|
378 |
| - public static final String GMSCORE_PACKAGE = "com.google.android.gms"; |
379 |
| - public static final String GMSCORE_BACKUP_TRANSPORT = |
380 |
| - "com.google.android.gms.backup.BackupTransportService"; |
381 | 370 |
|
382 | 371 | private static final int USER_OPERATION_ERROR_UNKNOWN = 1;
|
383 | 372 | private static final int USER_OPERATION_SUCCESS = 0;
|
@@ -405,7 +394,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
|
405 | 394 | private DpcSwitchPreference mInstallNonMarketAppsPreference;
|
406 | 395 |
|
407 | 396 | private SwitchPreference mEnableBackupServicePreference;
|
408 |
| - private SwitchPreference mMandatoryBackupsPreference; |
409 | 397 | private SwitchPreference mEnableSecurityLoggingPreference;
|
410 | 398 | private SwitchPreference mEnableNetworkLoggingPreference;
|
411 | 399 | private SwitchPreference mSetAutoTimeRequiredPreference;
|
@@ -523,8 +511,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
523 | 511 | findPreference(REMOVE_DEVICE_OWNER_KEY).setOnPreferenceClickListener(this);
|
524 | 512 | mEnableBackupServicePreference = (SwitchPreference) findPreference(ENABLE_BACKUP_SERVICE);
|
525 | 513 | mEnableBackupServicePreference.setOnPreferenceChangeListener(this);
|
526 |
| - mMandatoryBackupsPreference = (SwitchPreference) findPreference(MANDATORY_BACKUPS); |
527 |
| - mMandatoryBackupsPreference.setOnPreferenceChangeListener(this); |
528 | 514 | findPreference(REQUEST_BUGREPORT_KEY).setOnPreferenceClickListener(this);
|
529 | 515 | mEnableSecurityLoggingPreference =
|
530 | 516 | (SwitchPreference) findPreference(ENABLE_SECURITY_LOGGING);
|
@@ -637,7 +623,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
637 | 623 | reloadScreenCaptureDisableUi();
|
638 | 624 | reloadMuteAudioUi();
|
639 | 625 | reloadEnableBackupServiceUi();
|
640 |
| - reloadMandatoryBackupsUi(); |
641 | 626 | reloadEnableSecurityLoggingUi();
|
642 | 627 | reloadEnableNetworkLoggingUi();
|
643 | 628 | reloadSetAutoTimeRequiredUi();
|
@@ -1137,16 +1122,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
1137 | 1122 | case ENABLE_BACKUP_SERVICE:
|
1138 | 1123 | setBackupServiceEnabled((Boolean) newValue);
|
1139 | 1124 | reloadEnableBackupServiceUi();
|
1140 |
| - reloadMandatoryBackupsUi(); |
1141 | 1125 | return true;
|
1142 |
| - case MANDATORY_BACKUPS: |
1143 |
| - if ((Boolean) newValue) { |
1144 |
| - showMandatoryBackupAccountPicker(); |
1145 |
| - return false; |
1146 |
| - } else { |
1147 |
| - setupMandatoryBackups(null); |
1148 |
| - return true; |
1149 |
| - } |
1150 | 1126 | case ENABLE_SECURITY_LOGGING:
|
1151 | 1127 | setSecurityLoggingEnabled((Boolean) newValue);
|
1152 | 1128 | reloadEnableSecurityLoggingUi();
|
@@ -2090,14 +2066,6 @@ private void reloadEnableBackupServiceUi() {
|
2090 | 2066 | }
|
2091 | 2067 | }
|
2092 | 2068 |
|
2093 |
| - @TargetApi(28) |
2094 |
| - private void reloadMandatoryBackupsUi() { |
2095 |
| - if (mMandatoryBackupsPreference.isEnabled()) { |
2096 |
| - mMandatoryBackupsPreference.setChecked( |
2097 |
| - null != mDevicePolicyManager.getMandatoryBackupTransport()); |
2098 |
| - } |
2099 |
| - } |
2100 |
| - |
2101 | 2069 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
2102 | 2070 | private void reloadScreenCaptureDisableUi() {
|
2103 | 2071 | boolean isScreenCaptureDisabled = mDevicePolicyManager.getScreenCaptureDisabled(
|
@@ -3382,65 +3350,6 @@ private int validateAffiliatedUserAfterP() {
|
3382 | 3350 | }
|
3383 | 3351 | }
|
3384 | 3352 |
|
3385 |
| - @TargetApi(28) |
3386 |
| - private void showMandatoryBackupAccountPicker() { |
3387 |
| - if (!BuildCompat.isAtLeastP()) { |
3388 |
| - return; |
3389 |
| - } |
3390 |
| - if (getActivity() == null || getActivity().isFinishing()) { |
3391 |
| - return; |
3392 |
| - } |
3393 |
| - List<Account> accounts = Arrays.asList(mAccountManager.getAccounts()); |
3394 |
| - if (accounts.isEmpty()) { |
3395 |
| - showToast(R.string.no_accounts_available); |
3396 |
| - } else { |
3397 |
| - AccountArrayAdapter accountArrayAdapter = |
3398 |
| - new AccountArrayAdapter(getActivity(), R.id.account_name, accounts); |
3399 |
| - new AlertDialog.Builder(getActivity()) |
3400 |
| - .setTitle(R.string.mandatory_backup_account) |
3401 |
| - .setAdapter( |
3402 |
| - accountArrayAdapter, |
3403 |
| - (dialog, position) -> setupMandatoryBackups(accounts.get(position))) |
3404 |
| - .show(); |
3405 |
| - } |
3406 |
| - } |
3407 |
| - |
3408 |
| - @TargetApi(28) |
3409 |
| - private void setupMandatoryBackups(@Nullable Account account) { |
3410 |
| - boolean makeBackupsMandatory = account != null; |
3411 |
| - // For the data to be backed up to Google Drive, set the backup transport to the GmsCore's |
3412 |
| - // backup transport. |
3413 |
| - mDevicePolicyManager.setMandatoryBackupTransport(mAdminComponentName, makeBackupsMandatory ? |
3414 |
| - new ComponentName(GMSCORE_PACKAGE, GMSCORE_BACKUP_TRANSPORT) : null); |
3415 |
| - |
3416 |
| - // Set app restrictions with the account type and name on GmsCore to let it know which |
3417 |
| - // account it should use for backing up the data and notify GmsCore about the change by |
3418 |
| - // sending a broadcast to it. |
3419 |
| - String name = account != null ? account.name : null; |
3420 |
| - String type = account != null ? account.type: null; |
3421 |
| - Bundle appRestrictions = mDevicePolicyManager.getApplicationRestrictions( |
3422 |
| - mAdminComponentName, GMSCORE_PACKAGE); |
3423 |
| - if (name == null) { |
3424 |
| - appRestrictions.remove(MANDATORY_BACKUP_ACCOUNT_NAME_APP_RESTRICTION); |
3425 |
| - } else { |
3426 |
| - appRestrictions.putString(MANDATORY_BACKUP_ACCOUNT_NAME_APP_RESTRICTION, name); |
3427 |
| - } |
3428 |
| - if (type == null) { |
3429 |
| - appRestrictions.remove(MANDATORY_BACKUP_ACCOUNT_TYPE_APP_RESTRICTION); |
3430 |
| - } else { |
3431 |
| - appRestrictions.putString(MANDATORY_BACKUP_ACCOUNT_TYPE_APP_RESTRICTION, type); |
3432 |
| - } |
3433 |
| - mDevicePolicyManager.setApplicationRestrictions( |
3434 |
| - mAdminComponentName, GMSCORE_PACKAGE, appRestrictions); |
3435 |
| - Intent intent = new Intent(MANDATORY_BACKUP_ACCOUNT_CHANGED_ACTION); |
3436 |
| - intent.setPackage(GMSCORE_PACKAGE); |
3437 |
| - getContext().sendBroadcast(intent); |
3438 |
| - |
3439 |
| - // Update the UI for backup-related policies. |
3440 |
| - reloadEnableBackupServiceUi(); |
3441 |
| - reloadMandatoryBackupsUi(); |
3442 |
| - } |
3443 |
| - |
3444 | 3353 | abstract class ManageLockTaskListCallback {
|
3445 | 3354 | public abstract void onPositiveButtonClicked(String[] lockTaskArray);
|
3446 | 3355 | }
|
|
0 commit comments