Skip to content

Commit dab1264

Browse files
author
Lenka Trochtova
committed
Revert "Add UI for mandatory backups' policy."
It was decided to hide the mandatory backup's API in a recent review. Bug: 77801801 Bug: 73750212 This reverts commit 8f29eb499682b7054a6e826d6e2ca388759608d3. Change-Id: I0e3a0a499895f55c7afb7b0a0f8f9a72d0227bbd
1 parent 29edaf5 commit dab1264

File tree

3 files changed

+0
-98
lines changed

3 files changed

+0
-98
lines changed

app/src/main/java/com/afwsamples/testdpc/policy/PolicyManagementFragment.java

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import android.security.KeyChain;
5353
import android.security.KeyChainAliasCallback;
5454
import android.service.notification.NotificationListenerService;
55-
import android.support.annotation.Nullable;
5655
import android.support.annotation.RequiresApi;
5756
import android.support.annotation.StringRes;
5857
import android.support.v14.preference.SwitchPreference;
@@ -283,13 +282,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
283282
private static final String MANAGE_APP_RESTRICTIONS_KEY = "manage_app_restrictions";
284283
private static final String MANAGED_PROFILE_SPECIFIC_POLICIES_KEY = "managed_profile_policies";
285284
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";
293285
private static final String MUTE_AUDIO_KEY = "mute_audio";
294286
private static final String NETWORK_STATS_KEY = "network_stats";
295287
private static final String PASSWORD_CONSTRAINTS_KEY = "password_constraints";
@@ -375,9 +367,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
375367
BatteryManager.BATTERY_PLUGGED_USB |
376368
BatteryManager.BATTERY_PLUGGED_WIRELESS);
377369
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";
381370

382371
private static final int USER_OPERATION_ERROR_UNKNOWN = 1;
383372
private static final int USER_OPERATION_SUCCESS = 0;
@@ -405,7 +394,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
405394
private DpcSwitchPreference mInstallNonMarketAppsPreference;
406395

407396
private SwitchPreference mEnableBackupServicePreference;
408-
private SwitchPreference mMandatoryBackupsPreference;
409397
private SwitchPreference mEnableSecurityLoggingPreference;
410398
private SwitchPreference mEnableNetworkLoggingPreference;
411399
private SwitchPreference mSetAutoTimeRequiredPreference;
@@ -523,8 +511,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
523511
findPreference(REMOVE_DEVICE_OWNER_KEY).setOnPreferenceClickListener(this);
524512
mEnableBackupServicePreference = (SwitchPreference) findPreference(ENABLE_BACKUP_SERVICE);
525513
mEnableBackupServicePreference.setOnPreferenceChangeListener(this);
526-
mMandatoryBackupsPreference = (SwitchPreference) findPreference(MANDATORY_BACKUPS);
527-
mMandatoryBackupsPreference.setOnPreferenceChangeListener(this);
528514
findPreference(REQUEST_BUGREPORT_KEY).setOnPreferenceClickListener(this);
529515
mEnableSecurityLoggingPreference =
530516
(SwitchPreference) findPreference(ENABLE_SECURITY_LOGGING);
@@ -637,7 +623,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
637623
reloadScreenCaptureDisableUi();
638624
reloadMuteAudioUi();
639625
reloadEnableBackupServiceUi();
640-
reloadMandatoryBackupsUi();
641626
reloadEnableSecurityLoggingUi();
642627
reloadEnableNetworkLoggingUi();
643628
reloadSetAutoTimeRequiredUi();
@@ -1137,16 +1122,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
11371122
case ENABLE_BACKUP_SERVICE:
11381123
setBackupServiceEnabled((Boolean) newValue);
11391124
reloadEnableBackupServiceUi();
1140-
reloadMandatoryBackupsUi();
11411125
return true;
1142-
case MANDATORY_BACKUPS:
1143-
if ((Boolean) newValue) {
1144-
showMandatoryBackupAccountPicker();
1145-
return false;
1146-
} else {
1147-
setupMandatoryBackups(null);
1148-
return true;
1149-
}
11501126
case ENABLE_SECURITY_LOGGING:
11511127
setSecurityLoggingEnabled((Boolean) newValue);
11521128
reloadEnableSecurityLoggingUi();
@@ -2090,14 +2066,6 @@ private void reloadEnableBackupServiceUi() {
20902066
}
20912067
}
20922068

2093-
@TargetApi(28)
2094-
private void reloadMandatoryBackupsUi() {
2095-
if (mMandatoryBackupsPreference.isEnabled()) {
2096-
mMandatoryBackupsPreference.setChecked(
2097-
null != mDevicePolicyManager.getMandatoryBackupTransport());
2098-
}
2099-
}
2100-
21012069
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
21022070
private void reloadScreenCaptureDisableUi() {
21032071
boolean isScreenCaptureDisabled = mDevicePolicyManager.getScreenCaptureDisabled(
@@ -3382,65 +3350,6 @@ private int validateAffiliatedUserAfterP() {
33823350
}
33833351
}
33843352

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-
34443353
abstract class ManageLockTaskListCallback {
34453354
public abstract void onPositiveButtonClicked(String[] lockTaskArray);
34463355
}

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,6 @@
546546

547547
<!-- Backup and Restore for Device Owner -->
548548
<string name="enable_backup_service">Enable backup service</string>
549-
<string name="mandatory_backups">Make backups mandatory</string>
550-
<string name="mandatory_backup_account">Select mandatory backup account</string>
551549

552550
<!-- Enterprise security logging -->
553551
<string name="enable_security_logging">Enable security logging</string>

app/src/main/res/xml/device_policy_header.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,6 @@
599599
android:title="@string/enable_backup_service"
600600
testdpc:admin="deviceOwner"
601601
testdpc:minSdkVersion="O" />
602-
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference
603-
android:key="mandatory_backups"
604-
android:title="@string/mandatory_backups"
605-
testdpc:admin="deviceOwner"
606-
testdpc:minSdkVersion="P" />
607602
<com.afwsamples.testdpc.common.preference.DpcPreference
608603
android:key="wipe_data"
609604
android:title="@string/wipe_data"

0 commit comments

Comments
 (0)