Skip to content

Commit f83bd52

Browse files
author
bernardchau
committed
Revert "Add UI for testing forced re-enrollment."
This reverts commit fe471ff4db4339ceb2b492a7cab9268cbbb0b09e. Reason for revert: Forced re-enrollment (FRE) is deprecated and support has been removed from GmsCore. Cleaning up related code in TestDpc. Change-Id: I60e1e0ce1ebc7ef18e75a2bd40871b94e4d09d9c
1 parent d7e605f commit f83bd52

File tree

7 files changed

+0
-194
lines changed

7 files changed

+0
-194
lines changed

app/src/main/java/com/afwsamples/testdpc/common/Util.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import android.net.Uri;
3131
import android.os.Build.VERSION;
3232
import android.os.Build.VERSION_CODES;
33-
import android.os.Bundle;
3433
import android.os.UserHandle;
3534
import android.os.UserManager;
3635
import androidx.preference.PreferenceFragment;
@@ -54,11 +53,6 @@ public class Util {
5453
private static final String TAG = "Util";
5554
private static final int DEFAULT_BUFFER_SIZE = 4096;
5655

57-
private static final String BROADCAST_ACTION_FRP_CONFIG_CHANGED =
58-
"com.google.android.gms.auth.FRP_CONFIG_CHANGED";
59-
private static final String GMSCORE_PACKAGE = "com.google.android.gms";
60-
private static final String PERSISTENT_DEVICE_OWNER_STATE = "persistentDeviceOwnerState";
61-
6256
// TODO: Update to S when VERSION_CODES.R becomes available.
6357
public static final int R_VERSION_CODE = 30;
6458

@@ -205,42 +199,6 @@ public static boolean installCaCertificate(InputStream certificateInputStream,
205199
return false;
206200
}
207201

208-
/**
209-
* Returns the persistent device owner state which has been set by the device owner as an app
210-
* restriction on GmsCore or null if there is no such restriction set.
211-
*/
212-
@TargetApi(VERSION_CODES.O)
213-
public static String getPersistentDoStateFromApplicationRestriction(
214-
DevicePolicyManager dpm, ComponentName admin) {
215-
Bundle restrictions = dpm.getApplicationRestrictions(admin, GMSCORE_PACKAGE);
216-
return restrictions.getString(PERSISTENT_DEVICE_OWNER_STATE);
217-
}
218-
219-
/**
220-
* Sets the persistent device owner state by setting a special app restriction on GmsCore and
221-
* notifies GmsCore about the change by sending a broadcast.
222-
*
223-
* @param state The device owner state to be preserved across factory resets. If null, the
224-
* persistent device owner state and the corresponding restiction are cleared.
225-
*/
226-
@TargetApi(VERSION_CODES.O)
227-
public static void setPersistentDoStateWithApplicationRestriction(
228-
Context context, DevicePolicyManager dpm, ComponentName admin, String state) {
229-
Bundle restrictions = dpm.getApplicationRestrictions(admin, GMSCORE_PACKAGE);
230-
if (state == null) {
231-
// Clear the restriction
232-
restrictions.remove(PERSISTENT_DEVICE_OWNER_STATE);
233-
} else {
234-
// Set the restriction
235-
restrictions.putString(PERSISTENT_DEVICE_OWNER_STATE, state);
236-
}
237-
dpm.setApplicationRestrictions(admin, GMSCORE_PACKAGE, restrictions);
238-
Intent broadcastIntent = new Intent(BROADCAST_ACTION_FRP_CONFIG_CHANGED);
239-
broadcastIntent.setPackage(GMSCORE_PACKAGE);
240-
broadcastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
241-
context.sendBroadcast(broadcastIntent);
242-
}
243-
244202
/** @return Intent for the default home activity */
245203
public static Intent getHomeIntent() {
246204
final Intent intent = new Intent(Intent.ACTION_MAIN);

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

Lines changed: 0 additions & 77 deletions
This file was deleted.

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ public class PolicyManagementFragment extends BaseSearchablePolicyPreferenceFrag
371371
private static final String CLEAR_APP_DATA_KEY = "clear_app_data";
372372
private static final String KEEP_UNINSTALLED_PACKAGES = "keep_uninstalled_packages";
373373
private static final String WIPE_DATA_KEY = "wipe_data";
374-
private static final String PERSISTENT_DEVICE_OWNER_KEY = "persistent_device_owner";
375374
private static final String CREATE_WIFI_CONFIGURATION_KEY = "create_wifi_configuration";
376375
private static final String CREATE_EAP_TLS_WIFI_CONFIGURATION_KEY
377376
= "create_eap_tls_wifi_configuration";
@@ -608,7 +607,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
608607
STAY_ON_WHILE_PLUGGED_IN);
609608
mStayOnWhilePluggedInSwitchPreference.setOnPreferenceChangeListener(this);
610609
findPreference(WIPE_DATA_KEY).setOnPreferenceClickListener(this);
611-
findPreference(PERSISTENT_DEVICE_OWNER_KEY).setOnPreferenceClickListener(this);
612610
findPreference(REMOVE_DEVICE_OWNER_KEY).setOnPreferenceClickListener(this);
613611
mEnableBackupServicePreference = (DpcSwitchPreference) findPreference(
614612
ENABLE_BACKUP_SERVICE);
@@ -937,9 +935,6 @@ public void onPositiveButtonClicked(String[] lockTaskArray) {
937935
case WIPE_DATA_KEY:
938936
showWipeDataPrompt();
939937
return true;
940-
case PERSISTENT_DEVICE_OWNER_KEY:
941-
showFragment(new PersistentDeviceOwnerFragment());
942-
return true;
943938
case REMOVE_DEVICE_OWNER_KEY:
944939
showRemoveDeviceOwnerPrompt();
945940
return true;

app/src/main/java/com/afwsamples/testdpc/provision/PostProvisioningTask.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import android.os.PersistableBundle;
3636
import android.util.Log;
3737
import com.afwsamples.testdpc.AddAccountActivity;
38-
import com.afwsamples.testdpc.DeviceAdminReceiver;
3938
import com.afwsamples.testdpc.FinalizeActivity;
4039
import com.afwsamples.testdpc.common.LaunchIntentUtil;
4140
import com.afwsamples.testdpc.common.Util;
@@ -63,8 +62,6 @@ public class PostProvisioningTask {
6362
"com.afwsamples.testdpc.SetupManagementLaunchActivity";
6463
private static final String POST_PROV_PREFS = "post_prov_prefs";
6564
private static final String KEY_POST_PROV_DONE = "key_post_prov_done";
66-
private static final String KEY_DEVICE_OWNER_STATE =
67-
"android.app.extra.PERSISTENT_DEVICE_OWNER_STATE";
6865

6966
private final Context mContext;
7067
private final DevicePolicyManager mDevicePolicyManager;
@@ -97,18 +94,6 @@ public boolean performPostProvisioningOperations(Intent intent) {
9794
maybeSetAffiliationIds(extras);
9895
}
9996

100-
// If TestDPC asked GmsCore to store its state in the FRP area before factory reset, the
101-
// state will be handed over to it during the next device setup.
102-
if (Util.SDK_INT >= VERSION_CODES.O_MR1
103-
&& extras != null
104-
&& extras.containsKey(KEY_DEVICE_OWNER_STATE)) {
105-
Util.setPersistentDoStateWithApplicationRestriction(
106-
mContext,
107-
mDevicePolicyManager,
108-
DeviceAdminReceiver.getComponentName(mContext),
109-
extras.getString(KEY_DEVICE_OWNER_STATE));
110-
}
111-
11297
// Hide the setup launcher when this app is the admin
11398
mContext.getPackageManager().setComponentEnabledSetting(
11499
new ComponentName(mContext, SETUP_MANAGEMENT_LAUNCH_ACTIVITY),

app/src/main/res/layout/persistent_device_owner_fragment.xml

Lines changed: 0 additions & 46 deletions
This file was deleted.

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,13 @@
133133
<string name="wipe_data_title">Wipe data?</string>
134134
<string name="wipe_data_confirmation">Are you sure you want to wipe the data?</string>
135135
<string name="wipe_data_include">Also wipe:</string>
136-
<string name="persistent_device_owner">Persistent device owner state</string>
137136
<string name="external_storage">External storage</string>
138137
<string name="reset_protection_data">Factory reset protection</string>
139138
<string name="remove_device_owner">Remove this device owner</string>
140139
<string name="remove_device_owner_title">Remove device owner?</string>
141140
<string name="remove_device_owner_confirmation">Policies and restrictions will continue to be
142141
active and may require a factory reset to clear.</string>
143142
<string name="device_owner_removed">This app is no longer a device owner.</string>
144-
<string name="persistent_device_owner_state_hint">Test state to be restored alongside the device owner after factory reset.</string>
145-
<string name="set_persistent_device_owner_label">Set</string>
146-
<string name="clear_persistent_device_owner_label">Clear</string>
147143
<!-- Corporate-owned work profile falls under device owner management, for convenience. -->
148144
<string name="factory_reset_org_owned">Factory reset Org-Owned Work Profile device</string>
149145
<string name="set_factory_reset_protection_policy">Set factory reset protection policy</string>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,6 @@
743743
android:title="@string/reboot"
744744
testdpc:admin="deviceOwner"
745745
testdpc:minSdkVersion="N" />
746-
<com.afwsamples.testdpc.common.preference.DpcPreference
747-
android:key="persistent_device_owner"
748-
android:title="@string/persistent_device_owner"
749-
testdpc:admin="deviceOwner"
750-
testdpc:minSdkVersion="O_MR1" />
751746
<com.afwsamples.testdpc.common.preference.DpcPreference
752747
android:key="set_factory_reset_protection_policy"
753748
android:title="@string/set_factory_reset_protection_policy"

0 commit comments

Comments
 (0)