Allow developer options in retail mode
Also, add new tests and fix existing tests. Bug: 70985064 Test: make -j100 && make RunSettingsRoboTests -j100 Change-Id: Ied84cf0de02e18c10949eed4f3642782c1246e7b
This commit is contained in:
@@ -63,6 +63,7 @@ import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.core.gateway.SettingsGateway;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardSummary;
|
||||
import com.android.settings.development.DevelopmentSettingsDashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.wfd.WifiDisplaySettings;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
@@ -686,10 +687,10 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
|
||||
&& !Utils.isMonkeyRunning();
|
||||
|
||||
final boolean isAdminOrDemo = um.isAdminUser() || um.isDemoUser();
|
||||
somethingChanged = setTileEnabled(new ComponentName(packageName,
|
||||
Settings.DevelopmentSettingsDashboardActivity.class.getName()),
|
||||
showDev, isAdmin)
|
||||
showDev, isAdminOrDemo)
|
||||
|| somethingChanged;
|
||||
|
||||
// Enable/disable backup settings depending on whether the user is admin.
|
||||
@@ -724,10 +725,11 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
final int tileCount = category.getTilesCount();
|
||||
for (int i = 0; i < tileCount; i++) {
|
||||
final ComponentName component = category.getTile(i).intent.getComponent();
|
||||
|
||||
final String name = component.getClassName();
|
||||
final boolean isEnabledForRestricted = ArrayUtils.contains(
|
||||
SettingsGateway.SETTINGS_FOR_RESTRICTED, name);
|
||||
SettingsGateway.SETTINGS_FOR_RESTRICTED, name) || (isAdminOrDemo
|
||||
&& Settings.DevelopmentSettingsDashboardActivity.class.getName()
|
||||
.equals(name));
|
||||
if (packageName.equals(component.getPackageName())
|
||||
&& !isEnabledForRestricted) {
|
||||
somethingChanged = setTileEnabled(component, false, isAdmin)
|
||||
|
@@ -18,8 +18,10 @@ package com.android.settings.deviceinfo;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -118,8 +120,8 @@ public class BuildNumberPreferenceController extends AbstractPreferenceControlle
|
||||
if (Utils.isMonkeyRunning()) {
|
||||
return false;
|
||||
}
|
||||
// Don't enable developer options for secondary users.
|
||||
if (!mUm.isAdminUser()) {
|
||||
// Don't enable developer options for secondary non-demo users.
|
||||
if (!(mUm.isAdminUser() || mUm.isDemoUser())) {
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, MetricsEvent.ACTION_SETTINGS_BUILD_NUMBER_PREF);
|
||||
return false;
|
||||
@@ -133,6 +135,21 @@ public class BuildNumberPreferenceController extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
|
||||
if (mUm.isDemoUser()) {
|
||||
// Route to demo device owner to lift the debugging restriction.
|
||||
final ComponentName componentName = Utils.getDeviceOwnerComponent(mContext);
|
||||
if (componentName != null) {
|
||||
final Intent requestDebugFeatures = new Intent()
|
||||
.setPackage(componentName.getPackageName())
|
||||
.setAction("com.android.settings.action.REQUEST_DEBUG_FEATURES");
|
||||
final ResolveInfo resolveInfo = mContext.getPackageManager().resolveActivity(
|
||||
requestDebugFeatures, 0);
|
||||
if (resolveInfo != null) {
|
||||
mContext.startActivity(requestDebugFeatures);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mDebuggingFeaturesDisallowedAdmin != null &&
|
||||
!mDebuggingFeaturesDisallowedBySystem) {
|
||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext,
|
||||
|
Reference in New Issue
Block a user