Disable developer options when development_settings_enabled is disabled
Bug: 270966670 Test: manual Change-Id: If4296c564ee64804b35a3357f40f8d1d49cd284a
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import static android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED;
|
||||
import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -27,12 +28,18 @@ import android.bluetooth.BluetoothCodecStatus;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -173,10 +180,47 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
}
|
||||
};
|
||||
|
||||
private final Uri mDevelopEnabled = Settings.Global.getUriFor(DEVELOPMENT_SETTINGS_ENABLED);
|
||||
private final ContentObserver mDeveloperSettingsObserver = new ContentObserver(new Handler(
|
||||
Looper.getMainLooper())) {
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
super.onChange(selfChange, uri);
|
||||
final boolean developmentEnabledState =
|
||||
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext());
|
||||
final boolean switchState = mSwitchBar.isChecked();
|
||||
|
||||
// when developer options is enabled, but it is disabled by other privilege apps like:
|
||||
// adb command, we should disable all items and finish the activity.
|
||||
if (developmentEnabledState != switchState) {
|
||||
if (developmentEnabledState) {
|
||||
return;
|
||||
}
|
||||
disableDeveloperOptions();
|
||||
getActivity().runOnUiThread(() -> finishFragment());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public DevelopmentSettingsDashboardFragment() {
|
||||
super(UserManager.DISALLOW_DEBUGGING_FEATURES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final ContentResolver cr = getContext().getContentResolver();
|
||||
cr.registerContentObserver(mDevelopEnabled, false, mDeveloperSettingsObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
final ContentResolver cr = getContext().getContentResolver();
|
||||
cr.unregisterContentObserver(mDeveloperSettingsObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
Reference in New Issue
Block a user