Use Settings instead of DeviceConfig to relax device ID dev option
am: 9e3b3d77a2
Change-Id: Ib2338724fcbf2cba26f8305499c547a84f445fdf
This commit is contained in:
@@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
@@ -32,8 +34,30 @@ public class DeviceIdentifierAccessRestrictionsPreferenceController
|
|||||||
private static final String DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_KEY =
|
private static final String DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_KEY =
|
||||||
"device_identifier_access_restrictions";
|
"device_identifier_access_restrictions";
|
||||||
|
|
||||||
|
// The settings that should be set when the new device identifier access restrictions are
|
||||||
|
// disabled.
|
||||||
|
private static final String[] RELAX_DEVICE_IDENTIFIER_CHECK_SETTINGS = {
|
||||||
|
Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_3P_CHECK_RELAXED,
|
||||||
|
Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_NON_PRIV_CHECK_RELAXED,
|
||||||
|
Settings.Global.PRIVILEGED_DEVICE_IDENTIFIER_PRIV_CHECK_RELAXED
|
||||||
|
};
|
||||||
|
|
||||||
|
private ContentResolver mContentResolver;
|
||||||
|
|
||||||
public DeviceIdentifierAccessRestrictionsPreferenceController(Context context) {
|
public DeviceIdentifierAccessRestrictionsPreferenceController(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
mContentResolver = context.getContentResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
// If the new access restrictions have been disabled from the server side then do not
|
||||||
|
// display the option.
|
||||||
|
boolean disabledFromServerSide = Boolean.parseBoolean(
|
||||||
|
DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
|
||||||
|
DeviceConfig.Privacy.
|
||||||
|
PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED));
|
||||||
|
return !disabledFromServerSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,16 +72,20 @@ public class DeviceIdentifierAccessRestrictionsPreferenceController
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeSetting(boolean isEnabled) {
|
private void writeSetting(boolean isEnabled) {
|
||||||
DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
|
for (String relaxCheckSetting : RELAX_DEVICE_IDENTIFIER_CHECK_SETTINGS) {
|
||||||
DeviceConfig.Privacy.PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED,
|
Settings.Global.putInt(mContentResolver, relaxCheckSetting, isEnabled ? 1 : 0);
|
||||||
String.valueOf(isEnabled), false);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
boolean isEnabled = Boolean.parseBoolean(
|
boolean isEnabled = true;
|
||||||
DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
|
for (String relaxCheckSetting : RELAX_DEVICE_IDENTIFIER_CHECK_SETTINGS) {
|
||||||
DeviceConfig.Privacy.PROPERTY_DEVICE_IDENTIFIER_ACCESS_RESTRICTIONS_DISABLED));
|
if (Settings.Global.getInt(mContentResolver, relaxCheckSetting, 0) == 0) {
|
||||||
|
isEnabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
((SwitchPreference) mPreference).setChecked(isEnabled);
|
((SwitchPreference) mPreference).setChecked(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +93,6 @@ public class DeviceIdentifierAccessRestrictionsPreferenceController
|
|||||||
protected void onDeveloperOptionsSwitchDisabled() {
|
protected void onDeveloperOptionsSwitchDisabled() {
|
||||||
super.onDeveloperOptionsSwitchDisabled();
|
super.onDeveloperOptionsSwitchDisabled();
|
||||||
writeSetting(false);
|
writeSetting(false);
|
||||||
((SwitchPreference) mPreference).setChecked(true);
|
((SwitchPreference) mPreference).setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user