Merge "Merge Android 24Q1 Release (ab/11220357)" into aosp-main-future

This commit is contained in:
Xin Li
2024-01-30 22:44:00 +00:00
committed by Android (Google) Code Review
2736 changed files with 121765 additions and 67693 deletions

View File

@@ -30,7 +30,6 @@ import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -45,7 +44,8 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
OnDestroy {
@VisibleForTesting
static final int STREAMING_LABEL_ID = R.string.bluetooth_select_a2dp_codec_streaming_label;
static final int STREAMING_LABEL_ID =
com.android.settingslib.R.string.bluetooth_select_a2dp_codec_streaming_label;
protected final BluetoothA2dpConfigStore mBluetoothA2dpConfigStore;
protected BluetoothA2dp mBluetoothA2dp;

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -51,7 +51,7 @@ public class AdbAuthorizationTimeoutPreferenceController extends
Settings.Global.DEFAULT_ADB_ALLOWED_CONNECTION_TIME);
// An authTimeout of 0 indicates this preference is enabled and adb authorizations will not
// be automatically revoked.
((SwitchPreference) mPreference).setChecked(authTimeout == 0);
((TwoStatePreference) mPreference).setChecked(authTimeout == 0);
}
@Override
@@ -64,7 +64,7 @@ public class AdbAuthorizationTimeoutPreferenceController extends
public void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeSetting(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
private void writeSetting(boolean isEnabled) {

View File

@@ -70,7 +70,7 @@ public class AdbDeviceDetailsActionController extends AbstractPreferenceControll
mButtonsPref = ((ActionButtonsPreference) screen.findPreference(getPreferenceKey()))
.setButton1Visible(false)
.setButton2Icon(R.drawable.ic_settings_delete)
.setButton2Text(R.string.adb_device_forget)
.setButton2Text(com.android.settingslib.R.string.adb_device_forget)
.setButton2OnClickListener(view -> forgetDevice());
}

View File

@@ -23,7 +23,6 @@ import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.widget.FooterPreference;
@@ -71,7 +70,7 @@ public class AdbDeviceDetailsFingerprintController extends AbstractPreferenceCon
mFingerprintCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mFingerprintPref = new FooterPreference(mFingerprintCategory.getContext());
final CharSequence titleFormat = mContext.getText(
R.string.adb_device_fingerprint_title_format);
com.android.settingslib.R.string.adb_device_fingerprint_title_format);
mFingerprintPref.setTitle(String.format(
titleFormat.toString(), mPairedDevice.guid));
mFingerprintCategory.addPreference(mFingerprintPref);

View File

@@ -82,7 +82,7 @@ public class AdbDeviceDetailsHeaderController extends AbstractPreferenceControll
mEntityHeaderController
.setIcon(mContext.getDrawable(com.android.internal.R.drawable.ic_bt_laptop))
.setLabel(mPairedDevice.name)
.done(mFragment.getActivity(), true);
.done(true);
}
}

View File

@@ -29,7 +29,6 @@ import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.deviceinfo.AbstractConnectivityPreferenceController;
@@ -110,13 +109,13 @@ public class AdbIpAddressPreferenceController extends AbstractConnectivityPrefer
if (ipAddress != null) {
int port = getPort();
if (port <= 0) {
mAdbIpAddrPref.setSummary(R.string.status_unavailable);
mAdbIpAddrPref.setSummary(com.android.settingslib.R.string.status_unavailable);
} else {
ipAddress += ":" + port;
}
mAdbIpAddrPref.setSummary(ipAddress);
} else {
mAdbIpAddrPref.setSummary(R.string.status_unavailable);
mAdbIpAddrPref.setSummary(com.android.settingslib.R.string.status_unavailable);
}
}

View File

@@ -75,11 +75,11 @@ public class AdbPairedDevicePreference extends Preference {
gearNoBg.setVisibility(View.VISIBLE);
}
static void setTitle(AdbPairedDevicePreference preference,
PairDevice pairedDevice) {
static void setTitle(AdbPairedDevicePreference preference, PairDevice pairedDevice) {
preference.setTitle(pairedDevice.name);
preference.setSummary(pairedDevice.connected
? preference.getContext().getText(R.string.adb_wireless_device_connected_summary)
? preference.getContext()
.getText(com.android.settingslib.R.string.adb_wireless_device_connected_summary)
: "");
}

View File

@@ -177,7 +177,7 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
mVerifyingTextView = view.findViewById(R.id.verifying_textview);
setHeaderTitle(R.string.wifi_dpp_scan_qr_code);
mSummary.setText(R.string.adb_wireless_qrcode_pairing_description);
mSummary.setText(com.android.settingslib.R.string.adb_wireless_qrcode_pairing_description);
mErrorMessage = view.findViewById(R.id.error_message);
}

View File

@@ -59,22 +59,26 @@ public class AdbWirelessDialogController {
switch (mMode) {
case AdbWirelessDialogUiBase.MODE_PAIRING:
String title = res.getString(R.string.adb_pairing_device_dialog_title);
String title = res.getString(
com.android.settingslib.R.string.adb_pairing_device_dialog_title);
mUi.setTitle(title);
mView.findViewById(R.id.l_pairing_six_digit).setVisibility(View.VISIBLE);
mUi.setCancelButton(res.getString(R.string.cancel));
mUi.setCanceledOnTouchOutside(false);
break;
case AdbWirelessDialogUiBase.MODE_PAIRING_FAILED:
String msg = res.getString(R.string.adb_pairing_device_dialog_failed_msg);
mUi.setTitle(R.string.adb_pairing_device_dialog_failed_title);
String msg = res.getString(
com.android.settingslib.R.string.adb_pairing_device_dialog_failed_msg);
mUi.setTitle(
com.android.settingslib.R.string.adb_pairing_device_dialog_failed_title);
mView.findViewById(R.id.l_pairing_failed).setVisibility(View.VISIBLE);
mFailedMsg = (TextView) mView.findViewById(R.id.pairing_failed_label);
mFailedMsg.setText(msg);
mUi.setSubmitButton(res.getString(R.string.okay));
break;
case AdbWirelessDialogUiBase.MODE_QRCODE_FAILED:
mUi.setTitle(R.string.adb_pairing_device_dialog_failed_title);
mUi.setTitle(
com.android.settingslib.R.string.adb_pairing_device_dialog_failed_title);
mView.findViewById(R.id.l_qrcode_pairing_failed).setVisibility(View.VISIBLE);
mUi.setSubmitButton(res.getString(R.string.okay));
break;

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class AllowAppsOnExternalPreferenceController extends DeveloperOptionsPre
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +67,6 @@ public class AllowAppsOnExternalPreferenceController extends DeveloperOptionsPre
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -25,7 +25,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -48,9 +47,10 @@ public class AnimatorDurationScalePreferenceController extends DeveloperOptionsP
mWindowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService(Context.WINDOW_SERVICE));
mListValues = context.getResources().getStringArray(R.array.animator_duration_scale_values);
mListValues = context.getResources()
.getStringArray(com.android.settingslib.R.array.animator_duration_scale_values);
mListSummaries = context.getResources().getStringArray(
R.array.animator_duration_scale_entries);
com.android.settingslib.R.array.animator_duration_scale_entries);
}
@Override

View File

@@ -32,8 +32,6 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.android.settings.R;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -168,7 +166,7 @@ public class AppPicker extends ListActivity {
Collections.sort(mPackageInfoList, sDisplayNameComparator);
if (mIncludeNothing) {
MyApplicationInfo info = new MyApplicationInfo();
info.label = context.getText(R.string.no_application);
info.label = context.getText(com.android.settingslib.R.string.no_application);
mPackageInfoList.add(0, info);
}
addAll(mPackageInfoList);

View File

@@ -21,7 +21,6 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settingslib.applications.ApplicationsState;
// View Holder used when displaying views
@@ -36,7 +35,8 @@ public class AppViewHolder {
static public AppViewHolder createOrRecycle(LayoutInflater inflater, View convertView) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.preference_app, null);
convertView =
inflater.inflate(com.android.settingslib.widget.preference.app.R.layout.preference_app, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
@@ -45,7 +45,8 @@ public class AppViewHolder {
holder.appName = convertView.findViewById(android.R.id.title);
holder.appIcon = convertView.findViewById(android.R.id.icon);
holder.summary = convertView.findViewById(android.R.id.summary);
holder.disabled = convertView.findViewById(R.id.appendix);
holder.disabled =
convertView.findViewById(com.android.settingslib.widget.preference.app.R.id.appendix);
holder.widget = convertView.findViewById(android.R.id.widget_frame);
convertView.setTag(holder);
return holder;

View File

@@ -20,7 +20,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,7 +57,7 @@ public class AppsNotRespondingPreferenceController extends DeveloperOptionsPrefe
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -65,6 +65,6 @@ public class AppsNotRespondingPreferenceController extends DeveloperOptionsPrefe
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class ArtVerifierPreferenceController extends DeveloperOptionsPreferenceC
final int verifyDebuggable = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.ART_VERIFIER_VERIFY_DEBUGGABLE, SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(verifyDebuggable != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(verifyDebuggable != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +67,6 @@ public class ArtVerifierPreferenceController extends DeveloperOptionsPreferenceC
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ART_VERIFIER_VERIFY_DEBUGGABLE, SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
}
}

View File

@@ -22,7 +22,7 @@ import android.os.UserManager;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -71,7 +71,7 @@ public class AutomaticSystemServerHeapDumpPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -79,6 +79,6 @@ public class AutomaticSystemServerHeapDumpPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -16,18 +16,19 @@
package com.android.settings.development;
import static com.android.window.flags.Flags.predictiveBackSystemAnimations;
import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import java.util.Objects;
/**
* PreferenceController for enabling/disabling animation related to back button and back gestures.
*/
@@ -49,12 +50,16 @@ public class BackAnimationPreferenceController extends DeveloperOptionsPreferenc
public BackAnimationPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) {
@Nullable DevelopmentSettingsDashboardFragment fragment) {
super(context);
Objects.requireNonNull(fragment);
mFragment = fragment;
}
@Override
public boolean isAvailable() {
return !predictiveBackSystemAnimations();
}
@Override
public String getPreferenceKey() {
return BACK_NAVIGATION_ANIMATION_KEY;
@@ -76,7 +81,7 @@ public class BackAnimationPreferenceController extends DeveloperOptionsPreferenc
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_BACK_ANIMATION, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -84,6 +89,6 @@ public class BackAnimationPreferenceController extends DeveloperOptionsPreferenc
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_BACK_ANIMATION, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -27,7 +27,6 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
/**
@@ -66,8 +65,8 @@ public class BackAnimationPreferenceDialog extends InstrumentedDialogFragment
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.back_navigation_animation)
.setMessage(R.string.back_navigation_animation_dialog)
.setTitle(com.android.settingslib.R.string.back_navigation_animation)
.setMessage(com.android.settingslib.R.string.back_navigation_animation_dialog)
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.create();
}

View File

@@ -25,8 +25,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BackgroundProcessLimitPreferenceController extends

View File

@@ -23,7 +23,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -66,10 +66,10 @@ public class BluetoothA2dpHwOffloadPreferenceController extends DeveloperOptions
if (offloadSupported) {
final boolean offloadDisabled =
SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);
((SwitchPreference) mPreference).setChecked(offloadDisabled);
((TwoStatePreference) mPreference).setChecked(offloadDisabled);
} else {
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
}
}
@@ -79,7 +79,7 @@ public class BluetoothA2dpHwOffloadPreferenceController extends DeveloperOptions
final boolean offloadSupported =
SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false);
if (offloadSupported) {
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
SystemProperties.set(A2DP_OFFLOAD_DISABLED_PROPERTY, "false");
}
}

View File

@@ -21,7 +21,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,13 +57,13 @@ public class BluetoothAbsoluteVolumePreferenceController extends
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, "false");
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -24,8 +24,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothAvrcpVersionPreferenceController extends DeveloperOptionsPreferenceController

View File

@@ -21,7 +21,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,13 +57,13 @@ public class BluetoothDeviceNoNamePreferenceController extends
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, "false");
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -21,10 +21,11 @@ import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
import android.sysprop.BluetoothProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,27 +37,27 @@ public class BluetoothLeAudioAllowListPreferenceController
extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String PREFERENCE_KEY = "bluetooth_enable_leaudio_allow_list";
private static final String PREFERENCE_KEY = "bluetooth_bypass_leaudio_allowlist";
private static final String LE_AUDIO_ALLOW_LIST_SWITCH_SUPPORT_PROPERTY =
"ro.bluetooth.leaudio_allow_list.supported";
static final String LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY =
"ro.bluetooth.leaudio.le_audio_connection_by_default";
@VisibleForTesting
static final String LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY =
"persist.bluetooth.leaudio.enable_allow_list";
static final String BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY =
"persist.bluetooth.leaudio.bypass_allow_list";
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
@VisibleForTesting boolean mLeAudioConnectionByDefault;
private final DevelopmentSettingsDashboardFragment mFragment;
@VisibleForTesting
boolean mChanged = false;
public BluetoothLeAudioAllowListPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) {
super(context);
mFragment = fragment;
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
mLeAudioConnectionByDefault =
SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true);
}
@Override
@@ -64,53 +65,49 @@ public class BluetoothLeAudioAllowListPreferenceController
return PREFERENCE_KEY;
}
@Override
public boolean isAvailable() {
return BluetoothProperties.isProfileBapUnicastClientEnabled().orElse(false)
&& mLeAudioConnectionByDefault;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
BluetoothRebootDialog.show(mFragment);
mChanged = true;
return false;
final boolean isBypassed = (Boolean) newValue;
SystemProperties.set(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY,
isBypassed ? "true" : "false");
return true;
}
@Override
public void updateState(Preference preference) {
if (mBluetoothAdapter == null) {
return;
}
final int leAudioSupportedState = mBluetoothAdapter.isLeAudioSupported();
final boolean leAudioEnabled =
(leAudioSupportedState == BluetoothStatusCodes.FEATURE_SUPPORTED);
final boolean leAudioAllowListSupport =
SystemProperties.getBoolean(LE_AUDIO_ALLOW_LIST_SWITCH_SUPPORT_PROPERTY, false);
if (leAudioEnabled && leAudioAllowListSupport) {
final boolean leAudioAllowListEnabled =
SystemProperties.getBoolean(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false);
((SwitchPreference) mPreference).setChecked(leAudioAllowListEnabled);
} else {
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false);
}
}
/**
* Called when the RebootDialog confirm is clicked.
*/
public void onRebootDialogConfirmed() {
if (!mChanged) {
return;
}
final boolean leAudioAllowListEnabled =
SystemProperties.getBoolean(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY, false);
SystemProperties.set(LE_AUDIO_ALLOW_LIST_ENABLED_PROPERTY,
Boolean.toString(!leAudioAllowListEnabled));
final boolean isLeAudioSupported =
(mBluetoothAdapter.isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
if (!isLeAudioSupported) {
mPreference.setEnabled(false);
((TwoStatePreference) mPreference).setChecked(false);
return;
}
mPreference.setEnabled(true);
final boolean isLeAudioAllowlistBypassed =
SystemProperties.getBoolean(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, false);
((TwoStatePreference) mPreference).setChecked(isLeAudioAllowlistBypassed);
}
/**
* Called when the RebootDialog cancel is clicked.
*/
public void onRebootDialogCanceled() {
mChanged = false;
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final boolean isBypassed =
SystemProperties.getBoolean(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, false);
if (isBypassed) {
SystemProperties.set(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, Boolean.toString(false));
((TwoStatePreference) mPreference).setChecked(false);
}
}
}

View File

@@ -21,11 +21,10 @@ import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -39,7 +38,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String PREFERENCE_KEY = "bluetooth_show_leaudio_device_details";
private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default";
private static final String LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY =
"ro.bluetooth.leaudio.le_audio_connection_by_default";
private static final boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true;
static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN;
@@ -48,10 +48,13 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
@VisibleForTesting boolean mLeAudioEnabledByDefault;
public BluetoothLeAudioDeviceDetailsPreferenceController(Context context) {
super(context);
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
mLeAudioEnabledByDefault =
SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true);
}
@Override
@@ -70,7 +73,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
}
// Display the option only if LE Audio is supported
return (sLeAudioSupportedStateCache == BluetoothStatusCodes.FEATURE_SUPPORTED);
return !mLeAudioEnabledByDefault
&& (sLeAudioSupportedStateCache == BluetoothStatusCodes.FEATURE_SUPPORTED);
}
@Override
@@ -88,11 +92,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
final boolean isLeAudioToggleVisible = SystemProperties.getBoolean(
LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE);
final boolean leAudioEnabledByDefault = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false);
mPreference.setEnabled(!leAudioEnabledByDefault);
((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible
|| leAudioEnabledByDefault);
((TwoStatePreference) mPreference).setChecked(isLeAudioToggleVisible);
}
}

View File

@@ -18,7 +18,6 @@ package com.android.settings.development;
import static com.android.settings.development.BluetoothA2dpHwOffloadPreferenceController.A2DP_OFFLOAD_DISABLED_PROPERTY;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
@@ -27,7 +26,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -87,10 +86,10 @@ public class BluetoothLeAudioHwOffloadPreferenceController
if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
final boolean offloadDisabled =
SystemProperties.getBoolean(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, true);
((SwitchPreference) mPreference).setChecked(offloadDisabled);
((TwoStatePreference) mPreference).setChecked(offloadDisabled);
} else {
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
}
}
@@ -108,7 +107,7 @@ public class BluetoothLeAudioHwOffloadPreferenceController
final boolean a2dpOffloadDisabled =
SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);
if (leAudioEnabled && leAudioOffloadSupported && !a2dpOffloadDisabled) {
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
SystemProperties.set(LE_AUDIO_OFFLOAD_DISABLED_PROPERTY, "true");
} else {
mPreference.setEnabled(false);

View File

@@ -24,7 +24,7 @@ import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -84,7 +84,7 @@ public class BluetoothLeAudioPreferenceController
final boolean leAudioEnabled =
(isLeAudioSupportedStatus == BluetoothStatusCodes.FEATURE_SUPPORTED);
((SwitchPreference) mPreference).setChecked(!leAudioEnabled);
((TwoStatePreference) mPreference).setChecked(!leAudioEnabled);
// Disable option if Bluetooth is disabled or if switch is not supported
if (isLeAudioSupportedStatus == BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED

View File

@@ -24,8 +24,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**

View File

@@ -56,10 +56,12 @@ public class BluetoothSnoopLogFilterProfileMapPreferenceController
super(context);
mListValues =
context.getResources()
.getStringArray(R.array.bt_hci_snoop_log_profile_filter_values);
.getStringArray(com.android.settingslib.R
.array.bt_hci_snoop_log_profile_filter_values);
mListEntries =
context.getResources()
.getStringArray(R.array.bt_hci_snoop_log_profile_filter_entries);
.getStringArray(com.android.settingslib.R
.array.bt_hci_snoop_log_profile_filter_entries);
mProfilesFilterDisabledEntry =
context.getResources()
.getString(R.string.bt_hci_snoop_log_filtered_mode_disabled_summary);

View File

@@ -56,10 +56,12 @@ public class BluetoothSnoopLogFilterProfilePbapPreferenceController
super(context);
mListValues =
context.getResources()
.getStringArray(R.array.bt_hci_snoop_log_profile_filter_values);
.getStringArray(com.android.settingslib.R
.array.bt_hci_snoop_log_profile_filter_values);
mListEntries =
context.getResources()
.getStringArray(R.array.bt_hci_snoop_log_profile_filter_entries);
.getStringArray(com.android.settingslib.R
.array.bt_hci_snoop_log_profile_filter_entries);
mProfilesFilterDisabledEntry =
context.getResources()
.getString(R.string.bt_hci_snoop_log_filtered_mode_disabled_summary);

View File

@@ -26,7 +26,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -48,8 +47,10 @@ public class BluetoothSnoopLogPreferenceController extends DeveloperOptionsPrefe
public BluetoothSnoopLogPreferenceController(
Context context, DevelopmentSettingsDashboardFragment fragment) {
super(context);
mListValues = context.getResources().getStringArray(R.array.bt_hci_snoop_log_values);
mListEntries = context.getResources().getStringArray(R.array.bt_hci_snoop_log_entries);
mListValues = context.getResources()
.getStringArray(com.android.settingslib.R.array.bt_hci_snoop_log_values);
mListEntries = context.getResources()
.getStringArray(com.android.settingslib.R.array.bt_hci_snoop_log_entries);
mFragment = fragment;
}

View File

@@ -22,7 +22,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -68,7 +68,7 @@ public class BugReportInPowerPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -76,6 +76,6 @@ public class BugReportInPowerPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -29,7 +29,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -46,9 +45,10 @@ public class CachedAppsFreezerPreferenceController extends DeveloperOptionsPrefe
public CachedAppsFreezerPreferenceController(Context context) {
super(context);
mListValues = context.getResources().getStringArray(R.array.cached_apps_freezer_values);
mListValues = context.getResources()
.getStringArray(com.android.settingslib.R.array.cached_apps_freezer_values);
mListSummaries = context.getResources().getStringArray(
R.array.cached_apps_freezer_entries);
com.android.settingslib.R.array.cached_apps_freezer_entries);
}
@Override
@@ -76,7 +76,8 @@ public class CachedAppsFreezerPreferenceController extends DeveloperOptionsPrefe
if (!newValue.equals(currentValue)) {
final AlertDialog dialog = new AlertDialog.Builder(mContext)
.setMessage(R.string.cached_apps_freezer_reboot_dialog_text)
.setMessage(
com.android.settingslib.R.string.cached_apps_freezer_reboot_dialog_text)
.setPositiveButton(android.R.string.ok, getRebootDialogOkListener(newValue))
.setNegativeButton(android.R.string.cancel, getRebootDialogCancelListener())
.create();

View File

@@ -22,7 +22,7 @@ import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
@@ -72,7 +72,7 @@ public class CameraLaserSensorPreferenceController extends DeveloperOptionsPrefe
@Override
public void updateState(Preference preference) {
final boolean enabled = isLaserSensorEnabled();
((SwitchPreference) mPreference).setChecked(enabled);
((TwoStatePreference) mPreference).setChecked(enabled);
}
// There should be no impact on the current

View File

@@ -25,7 +25,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class ClearAdbKeysWarningDialog extends InstrumentedDialogFragment implements
@@ -51,7 +50,7 @@ public class ClearAdbKeysWarningDialog extends InstrumentedDialogFragment implem
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(R.string.adb_keys_warning_message)
.setMessage(com.android.settingslib.R.string.adb_keys_warning_message)
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.cancel, null /* onClickListener */)
.create();

View File

@@ -24,14 +24,14 @@ import android.os.Looper;
import android.util.AttributeSet;
import android.view.Display;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settingslib.R;
import java.util.ArrayList;
import java.util.List;
public class ColorModePreference extends SwitchPreference implements DisplayListener {
public class ColorModePreference extends TwoStatePreference implements DisplayListener {
private DisplayManager mDisplayManager;
private Display mDisplay;

View File

@@ -22,7 +22,7 @@ import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
@@ -65,14 +65,14 @@ public class CoolColorTemperaturePreferenceController extends DeveloperOptionsPr
public void updateState(Preference preference) {
final boolean enableColorTemperature = SystemProperties.getBoolean(
COLOR_TEMPERATURE_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(enableColorTemperature);
((TwoStatePreference) mPreference).setChecked(enableColorTemperature);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(COLOR_TEMPERATURE_PROPERTY, Boolean.toString(false));
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -24,7 +24,6 @@ import android.view.ThreadedRenderer;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker;
@@ -41,8 +40,10 @@ public class DebugGpuOverdrawPreferenceController extends
public DebugGpuOverdrawPreferenceController(Context context) {
super(context);
mListValues = context.getResources().getStringArray(R.array.debug_hw_overdraw_values);
mListSummaries = context.getResources().getStringArray(R.array.debug_hw_overdraw_entries);
mListValues = context.getResources().getStringArray(
com.android.settingslib.R.array.debug_hw_overdraw_values);
mListSummaries = context.getResources().getStringArray(
com.android.settingslib.R.array.debug_hw_overdraw_entries);
}
@Override

View File

@@ -24,7 +24,6 @@ import android.view.ThreadedRenderer;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker;
@@ -41,8 +40,10 @@ public class DebugNonRectClipOperationsPreferenceController extends
public DebugNonRectClipOperationsPreferenceController(Context context) {
super(context);
mListValues = context.getResources().getStringArray(R.array.show_non_rect_clip_values);
mListSummaries = context.getResources().getStringArray(R.array.show_non_rect_clip_entries);
mListValues = context.getResources().getStringArray(
com.android.settingslib.R.array.show_non_rect_clip_values);
mListSummaries = context.getResources().getStringArray(
com.android.settingslib.R.array.show_non_rect_clip_entries);
}
@Override

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class DebugViewAttributesPreferenceController extends
public void updateState(Preference preference) {
final int debugViewAttrMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0 /* default */);
((SwitchPreference) mPreference).setChecked(debugViewAttrMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(debugViewAttrMode != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +67,6 @@ public class DebugViewAttributesPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -24,7 +24,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
@@ -71,7 +71,7 @@ public class DesktopModePreferenceController extends DeveloperOptionsPreferenceC
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -79,7 +79,7 @@ public class DesktopModePreferenceController extends DeveloperOptionsPreferenceC
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -0,0 +1,150 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import static android.app.Activity.RESULT_OK;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.UserHandle;
import com.android.settings.R;
import com.android.settings.applications.defaultapps.DefaultAppPickerFragment;
import com.android.settingslib.applications.DefaultAppInfo;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class DevelopmentAppPicker extends DefaultAppPickerFragment {
public static final String EXTRA_REQUESTING_PERMISSION = "REQUESTING_PERMISSION";
public static final String EXTRA_DEBUGGABLE = "DEBUGGABLE";
public static final String EXTRA_SELECTING_APP = "SELECTING_APP";
private String mPermissionName;
private boolean mDebuggableOnly;
private String mSelectingApp;
@Override
public void onAttach(Context context) {
super.onAttach(context);
Bundle arguments = getArguments();
if (arguments == null) {
return;
}
mPermissionName = arguments.getString(EXTRA_REQUESTING_PERMISSION);
mDebuggableOnly = arguments.getBoolean(EXTRA_DEBUGGABLE);
mSelectingApp = arguments.getString(EXTRA_SELECTING_APP);
}
@Override
public int getMetricsCategory() {
return SettingsEnums.DEVELOPMENT_APP_PICKER;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.development_app_picker;
}
@Override
protected boolean shouldShowItemNone() {
return true;
}
@Override
protected List<DefaultAppInfo> getCandidates() {
List<DefaultAppInfo> packageInfoList = new ArrayList<DefaultAppInfo>();
Context context = getContext();
List<ApplicationInfo> installedApps = mPm.getInstalledApplications(0);
for (ApplicationInfo ai : installedApps) {
if (ai.uid == Process.SYSTEM_UID) {
continue;
}
// Filter out apps that are not debuggable if required.
if (mDebuggableOnly) {
// On a user build, we only allow debugging of apps that
// are marked as debuggable, otherwise (for platform development)
// we allow all apps.
if ((ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0
&& "user".equals(Build.TYPE)) {
continue;
}
}
// Filter out apps that do not request the permission if required.
if (mPermissionName != null) {
boolean requestsPermission = false;
try {
PackageInfo pi = mPm.getPackageInfo(ai.packageName,
PackageManager.GET_PERMISSIONS);
if (pi.requestedPermissions == null) {
continue;
}
for (String requestedPermission : pi.requestedPermissions) {
if (requestedPermission.equals(mPermissionName)) {
requestsPermission = true;
break;
}
}
if (!requestsPermission) {
continue;
}
} catch (PackageManager.NameNotFoundException e) {
continue;
}
}
DefaultAppInfo appInfo = new DefaultAppInfo(context, mPm, UserHandle.myUserId(), ai);
packageInfoList.add(appInfo);
}
Collections.sort(packageInfoList, sLabelComparator);
return packageInfoList;
}
@Override
protected String getDefaultKey() {
return mSelectingApp;
}
@Override
protected boolean setDefaultKey(String key) {
DefaultAppInfo appInfo = (DefaultAppInfo) getCandidate(key);
Intent intent = new Intent();
if (appInfo != null && appInfo.packageItemInfo != null) {
intent.setAction(appInfo.packageItemInfo.packageName);
}
setResult(RESULT_OK, intent);
finish();
return true;
}
private static final Comparator<DefaultAppInfo> sLabelComparator =
new Comparator<DefaultAppInfo>() {
public int compare(DefaultAppInfo a, DefaultAppInfo b) {
return Collator.getInstance().compare(a.loadLabel(), b.loadLabel());
}
};
}

View File

@@ -45,8 +45,11 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -80,7 +83,6 @@ import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.development.SystemPropPoker;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.OnMainSwitchChangeListener;
import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -89,7 +91,7 @@ import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFragment
implements OnMainSwitchChangeListener, OemUnlockDialogHost, AdbDialogHost,
implements OnCheckedChangeListener, OemUnlockDialogHost, AdbDialogHost,
AdbClearKeysDialogHost, LogPersistDialogHost,
BluetoothRebootDialog.OnRebootDialogListener,
AbstractBluetoothPreferenceController.Callback,
@@ -230,6 +232,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getActivity().finish();
return;
}
Context context = requireContext();
if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)) {
Toast.makeText(context, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT)
.show();
finish();
}
}
@Override
@@ -243,7 +251,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
mIsAvailable = false;
// Show error message
if (!isUiRestrictedByOnlyAdmin()) {
getEmptyTextView().setText(R.string.development_settings_not_available);
getEmptyTextView().setText(
com.android.settingslib.R.string.development_settings_not_available);
}
getPreferenceScreen().removeAll();
return;
@@ -332,10 +341,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
}
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
if (switchView != mSwitchBar.getSwitch()) {
return;
}
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
final boolean developmentEnabledState =
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext());
if (isChecked != developmentEnabledState) {
@@ -371,8 +377,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
DisableDevSettingsDialogFragment.show(this /* host */);
}
}
FeatureFactory.getFactory(
getContext()).getSearchFeatureProvider().sendPreIndexIntent(getContext());
FeatureFactory.getFeatureFactory().getSearchFeatureProvider()
.sendPreIndexIntent(getContext());
}
}
@@ -441,11 +447,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogConfirmed();
final BluetoothLeAudioAllowListPreferenceController leAudioAllowListController =
getDevelopmentOptionsController(
BluetoothLeAudioAllowListPreferenceController.class);
leAudioAllowListController.onRebootDialogConfirmed();
}
@Override
@@ -463,11 +464,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogCanceled();
final BluetoothLeAudioAllowListPreferenceController leAudioAllowListController =
getDevelopmentOptionsController(
BluetoothLeAudioAllowListPreferenceController.class);
leAudioAllowListController.onRebootDialogCanceled();
}
@Override
@@ -611,8 +607,9 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
}
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Activity activity, Lifecycle lifecycle, DevelopmentSettingsDashboardFragment fragment,
BluetoothA2dpConfigStore bluetoothA2dpConfigStore) {
@Nullable Activity activity, @Nullable Lifecycle lifecycle,
@Nullable DevelopmentSettingsDashboardFragment fragment,
@Nullable BluetoothA2dpConfigStore bluetoothA2dpConfigStore) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new MemoryUsagePreferenceController(context));
controllers.add(new BugReportPreferenceController(context));
@@ -679,6 +676,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new ShowKeyPressesPreferenceController(context));
controllers.add(new ShowSurfaceUpdatesPreferenceController(context));
controllers.add(new ShowLayoutBoundsPreferenceController(context));
controllers.add(new ShowHdrSdrRatioPreferenceController(context));
controllers.add(new ShowRefreshRatePreferenceController(context));
controllers.add(new RtlLayoutPreferenceController(context));
controllers.add(new WindowAnimationScalePreferenceController(context));
@@ -745,6 +743,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new ContrastPreferenceController(
context, context.getSystemService(UiModeManager.class)));
controllers.add(new ForceEnableNotesRolePreferenceController(context));
controllers.add(new GrammaticalGenderPreferenceController(context));
return controllers;
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -63,7 +63,7 @@ public class DisableAutomaticUpdatesPreferenceController extends
final int updatesEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0 /* default */);
((SwitchPreference) mPreference).setChecked(updatesEnabled != DISABLE_UPDATES_SETTING);
((TwoStatePreference) mPreference).setChecked(updatesEnabled != DISABLE_UPDATES_SETTING);
}
@Override
@@ -71,6 +71,6 @@ public class DisableAutomaticUpdatesPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, DISABLE_UPDATES_SETTING);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -25,7 +25,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class DisableLogPersistWarningDialog extends InstrumentedDialogFragment implements
@@ -55,8 +54,8 @@ public class DisableLogPersistWarningDialog extends InstrumentedDialogFragment i
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.dev_logpersist_clear_warning_title)
.setMessage(R.string.dev_logpersist_clear_warning_message)
.setTitle(com.android.settingslib.R.string.dev_logpersist_clear_warning_title)
.setMessage(com.android.settingslib.R.string.dev_logpersist_clear_warning_message)
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create();

View File

@@ -25,7 +25,6 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class EnableAdbWarningDialog extends InstrumentedDialogFragment implements
@@ -50,8 +49,8 @@ public class EnableAdbWarningDialog extends InstrumentedDialogFragment implement
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.adb_warning_title)
.setMessage(R.string.adb_warning_message)
.setTitle(com.android.settingslib.R.string.adb_warning_title)
.setMessage(com.android.settingslib.R.string.adb_warning_message)
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create();

View File

@@ -23,7 +23,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -69,7 +69,7 @@ public final class EnableBlursPreferenceController extends DeveloperOptionsPrefe
public void updateState(Preference preference) {
boolean isEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DISABLE_WINDOW_BLURS, 0) == 0;
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override

View File

@@ -24,8 +24,8 @@ import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.R;
public class EnableDevelopmentSettingWarningDialog extends InstrumentedDialogFragment
implements DialogInterface.OnClickListener {

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,8 @@ public class EnableGnssRawMeasFullTrackingPreferenceController extends
final int enableGnssRawMeasFullTrackingMode =
Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(enableGnssRawMeasFullTrackingMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference)
.setChecked(enableGnssRawMeasFullTrackingMode != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +68,6 @@ public class EnableGnssRawMeasFullTrackingPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -58,7 +58,8 @@ public class EnableGpuDebugLayersPreferenceController extends DeveloperOptionsPr
public void updateState(Preference preference) {
final int enableGpuDebugLayersMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(enableGpuDebugLayersMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference)
.setChecked(enableGpuDebugLayersMode != SETTING_VALUE_OFF);
}
@Override
@@ -66,6 +67,6 @@ public class EnableGpuDebugLayersPreferenceController extends DeveloperOptionsPr
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -51,8 +51,8 @@ public class EnableOemUnlockSettingWarningDialog extends InstrumentedDialogFragm
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.confirm_enable_oem_unlock_title)
.setMessage(R.string.confirm_enable_oem_unlock_text)
.setTitle(com.android.settingslib.R.string.confirm_enable_oem_unlock_title)
.setMessage(com.android.settingslib.R.string.confirm_enable_oem_unlock_text)
.setPositiveButton(R.string.enable_text, this /* onClickListener */)
.setNegativeButton(android.R.string.cancel, this /* onClickListener */)
.create();

View File

@@ -25,7 +25,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -84,7 +84,7 @@ public class EnableVerboseVendorLoggingPreferenceController
ThreadUtils.postOnBackgroundThread(() -> {
final boolean enabled = getVerboseLoggingEnabled();
ThreadUtils.getUiThreadHandler().post(() ->
((SwitchPreference) mPreference).setChecked(enabled));
((TwoStatePreference) mPreference).setChecked(enabled));
}
);
}
@@ -95,7 +95,7 @@ public class EnableVerboseVendorLoggingPreferenceController
super.onDeveloperOptionsSwitchDisabled();
ThreadUtils.postOnBackgroundThread(() ->
setVerboseLoggingEnabled(false));
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -21,7 +21,7 @@ import android.os.SystemProperties;
import android.view.ThreadedRenderer;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -54,13 +54,13 @@ public class ForceDarkPreferenceController extends DeveloperOptionsPreferenceCon
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_FORCE_DARK, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_FORCE_DARK, null);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -39,7 +39,7 @@ import android.os.ServiceManager;
import android.os.UserManager;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -81,13 +81,13 @@ public class ForceEnableNotesRolePreferenceController
@Override
public void updateState(Preference preference) {
((SwitchPreference) mPreference).setChecked(isEnabled());
((TwoStatePreference) mPreference).setChecked(isEnabled());
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
setEnabled(false);
}

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.sysprop.DisplayProperties;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -51,13 +51,13 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
@Override
public void updateState(Preference preference) {
final boolean isEnabled = DisplayProperties.debug_force_msaa().orElse(false);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
DisplayProperties.debug_force_msaa(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -16,16 +16,17 @@
package com.android.settings.development;
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
import static com.android.internal.display.RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.provider.Settings;
import android.util.Log;
import android.view.Display;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
@@ -34,9 +35,6 @@ import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
@VisibleForTesting
static float DEFAULT_REFRESH_RATE = 60f;
@VisibleForTesting
static float NO_CONFIG = 0f;
@@ -48,17 +46,7 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
public ForcePeakRefreshRatePreferenceController(Context context) {
super(context);
final DisplayManager dm = context.getSystemService(DisplayManager.class);
final Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);
if (display == null) {
Log.w(TAG, "No valid default display device");
mPeakRefreshRate = DEFAULT_REFRESH_RATE;
} else {
mPeakRefreshRate = findPeakRefreshRate(display.getSupportedModes());
}
mPeakRefreshRate = findHighestRefreshRateForDefaultDisplay(context);
Log.d(TAG, "DEFAULT_REFRESH_RATE : " + DEFAULT_REFRESH_RATE
+ " mPeakRefreshRate : " + mPeakRefreshRate);
}
@@ -84,7 +72,7 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
@Override
public void updateState(Preference preference) {
((SwitchPreference) mPreference).setChecked(isForcePeakRefreshRateEnabled());
((TwoStatePreference) mPreference).setChecked(isForcePeakRefreshRateEnabled());
}
@Override
@@ -102,12 +90,12 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
Settings.System.putFloat(mContext.getContentResolver(),
Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting
void forcePeakRefreshRate(boolean enable) {
final float peakRefreshRate = enable ? mPeakRefreshRate : NO_CONFIG;
final float peakRefreshRate = enable ? Float.POSITIVE_INFINITY : NO_CONFIG;
Settings.System.putFloat(mContext.getContentResolver(),
Settings.System.MIN_REFRESH_RATE, peakRefreshRate);
}
@@ -116,17 +104,7 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
final float peakRefreshRate = Settings.System.getFloat(mContext.getContentResolver(),
Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
return peakRefreshRate >= mPeakRefreshRate;
}
private float findPeakRefreshRate(Display.Mode[] modes) {
float peakRefreshRate = DEFAULT_REFRESH_RATE;
for (Display.Mode mode : modes) {
if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
peakRefreshRate = mode.getRefreshRate();
}
}
return peakRefreshRate;
return Math.round(peakRefreshRate) == Math.round(mPeakRefreshRate)
|| Float.isInfinite(peakRefreshRate);
}
}

View File

@@ -22,7 +22,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
@@ -69,7 +69,7 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -77,7 +77,7 @@ public class FreeformWindowsPreferenceController extends DeveloperOptionsPrefere
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -67,13 +67,13 @@ public abstract class GlobalSettingSwitchPreferenceController extends
public void updateState(Preference preference) {
final int mode =
Settings.Global.getInt(mContext.getContentResolver(), mSettingsKey, mDefault);
((SwitchPreference) mPreference).setChecked(mode != mOff);
((TwoStatePreference) mPreference).setChecked(mode != mOff);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), mSettingsKey, mOff);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -21,7 +21,7 @@ import android.os.SystemProperties;
import android.view.ThreadedRenderer;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -54,13 +54,13 @@ public class GpuViewUpdatesPreferenceController extends DeveloperOptionsPreferen
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, null);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -0,0 +1,103 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.app.ActivityManager;
import android.app.IActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Preference controller to control Grammatical Gender
*/
public class GrammaticalGenderPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String GRAMMATICAL_GENDER_KEY =
"grammatical_gender";
@VisibleForTesting
static final String GRAMMATICAL_GENDER_PROPERTY = "persist.sys.grammatical_gender";
private final String[] mListValues;
private final String[] mListSummaries;
private IActivityManager mActivityManager;
public GrammaticalGenderPreferenceController(Context context) {
this(context, ActivityManager.getService());
}
@VisibleForTesting
GrammaticalGenderPreferenceController(Context context,
IActivityManager activityManager) {
super(context);
mListValues = context.getResources()
.getStringArray(com.android.settingslib.R.array.grammatical_gender_values);
mListSummaries = context.getResources()
.getStringArray(com.android.settingslib.R.array.grammatical_gender_entries);
mActivityManager = activityManager;
}
@Override
public String getPreferenceKey() {
return GRAMMATICAL_GENDER_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
SystemProperties.set(GRAMMATICAL_GENDER_PROPERTY, newValue.toString());
updateState(mPreference);
try {
Configuration config = mActivityManager.getConfiguration();
config.setGrammaticalGender(Integer.parseInt(newValue.toString()));
mActivityManager.updatePersistentConfiguration(config);
} catch (RemoteException ex) {
// intentional no-op
}
return true;
}
@Override
public void updateState(Preference preference) {
final ListPreference listPreference = (ListPreference) preference;
final String currentValue = SystemProperties.get(GRAMMATICAL_GENDER_PROPERTY);
int index = 0; // Defaults to Not Selected
for (int i = 0; i < mListValues.length; i++) {
if (TextUtils.equals(currentValue, mListValues[i])) {
index = i;
break;
}
}
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
}
@Override
public boolean isAvailable() {
return android.app.Flags.systemTermsOfAddressEnabled();
}
}

View File

@@ -21,7 +21,7 @@ import android.os.SystemProperties;
import android.view.ThreadedRenderer;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -54,13 +54,13 @@ public class HardwareLayersUpdatesPreferenceController extends DeveloperOptionsP
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, null);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -24,7 +24,7 @@ import android.os.ServiceManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -71,7 +71,7 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final SwitchPreference switchPreference = (SwitchPreference) mPreference;
final TwoStatePreference switchPreference = (TwoStatePreference) mPreference;
if (switchPreference.isChecked()) {
// Writing false to the preference when the setting is already off will have a
// side effect of turning on the preference that we wish to avoid
@@ -96,7 +96,7 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
@SuppressWarnings("unused") final int showUpdates = reply.readInt();
@SuppressWarnings("unused") final int showBackground = reply.readInt();
final int disableOverlays = reply.readInt();
((SwitchPreference) mPreference).setChecked(disableOverlays != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(disableOverlays != SETTING_VALUE_OFF);
reply.recycle();
data.recycle();
} catch (RemoteException ex) {

View File

@@ -25,8 +25,8 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker;

View File

@@ -25,7 +25,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -68,14 +68,14 @@ public class KeepActivitiesPreferenceController extends DeveloperOptionsPreferen
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ALWAYS_FINISH_ACTIVITIES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeImmediatelyDestroyActivitiesOptions(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
private void writeImmediatelyDestroyActivitiesOptions(boolean isEnabled) {

View File

@@ -25,8 +25,8 @@ import android.os.UserManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class LocalBackupPasswordPreferenceController extends DeveloperOptionsPreferenceController

View File

@@ -7,7 +7,7 @@ import android.os.UserManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -63,7 +63,7 @@ public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenc
public void updateState(Preference preference) {
final boolean isTerminalEnabled = mPackageManager.getApplicationEnabledSetting(
TERMINAL_APP_PACKAGE) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
((SwitchPreference) mPreference).setChecked(isTerminalEnabled);
((TwoStatePreference) mPreference).setChecked(isTerminalEnabled);
}
@Override
@@ -78,7 +78,7 @@ public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenc
super.onDeveloperOptionsSwitchDisabled();
mPackageManager.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0 /* flags */);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class MobileDataAlwaysOnPreferenceController extends
final int mobileDataAlwaysOnMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.MOBILE_DATA_ALWAYS_ON, SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(mobileDataAlwaysOnMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mobileDataAlwaysOnMode != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +67,6 @@ public class MobileDataAlwaysOnPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
SETTING_VALUE_ON);
((SwitchPreference) mPreference).setChecked(true);
((TwoStatePreference) mPreference).setChecked(true);
}
}

View File

@@ -21,17 +21,20 @@ import static com.android.settings.development.DevelopmentOptionsActivityRequest
import android.Manifest;
import android.app.Activity;
import android.app.AppOpsManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import java.util.List;
@@ -65,10 +68,26 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
return false;
}
final Intent intent = new Intent(mContext, AppPicker.class);
intent.putExtra(AppPicker.EXTRA_REQUESTIING_PERMISSION,
Manifest.permission.ACCESS_MOCK_LOCATION);
mFragment.startActivityForResult(intent, REQUEST_MOCK_LOCATION_APP);
if (Flags.deprecateListActivity()) {
final Bundle args = new Bundle();
args.putString(DevelopmentAppPicker.EXTRA_REQUESTING_PERMISSION,
Manifest.permission.ACCESS_MOCK_LOCATION);
final String debugApp = Settings.Global.getString(
mContext.getContentResolver(), Settings.Global.DEBUG_APP);
args.putString(DevelopmentAppPicker.EXTRA_SELECTING_APP, debugApp);
new SubSettingLauncher(mContext)
.setDestination(DevelopmentAppPicker.class.getName())
.setSourceMetricsCategory(SettingsEnums.DEVELOPMENT)
.setArguments(args)
.setTitleRes(com.android.settingslib.R.string.select_application)
.setResultListener(mFragment, REQUEST_MOCK_LOCATION_APP)
.launch();
} else {
final Intent intent = new Intent(mContext, AppPicker.class);
intent.putExtra(AppPicker.EXTRA_REQUESTIING_PERMISSION,
Manifest.permission.ACCESS_MOCK_LOCATION);
mFragment.startActivityForResult(intent, REQUEST_MOCK_LOCATION_APP);
}
return true;
}
@@ -98,11 +117,13 @@ public class MockLocationAppPreferenceController extends DeveloperOptionsPrefere
if (!TextUtils.isEmpty(mockLocationApp)) {
mPreference.setSummary(
mContext.getResources().getString(R.string.mock_location_app_set,
getAppLabel(mockLocationApp)));
mContext.getResources()
.getString(com.android.settingslib.R.string.mock_location_app_set,
getAppLabel(mockLocationApp)));
} else {
mPreference.setSummary(
mContext.getResources().getString(R.string.mock_location_app_not_set));
mContext.getResources()
.getString(com.android.settingslib.R.string.mock_location_app_not_set));
}
}

View File

@@ -22,7 +22,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -67,7 +67,7 @@ public class MockModemPreferenceController extends
try {
final boolean isEnabled = SystemProperties.getBoolean(
ALLOW_MOCK_MODEM_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get radio system property: " + e.getMessage());
}
@@ -78,7 +78,7 @@ public class MockModemPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
try {
SystemProperties.set(ALLOW_MOCK_MODEM_PROPERTY, "false");
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set radio system property: " + e.getMessage());
}

View File

@@ -22,7 +22,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -69,7 +69,7 @@ public class NfcSnoopLogPreferenceController extends
public void updateState(Preference preference) {
try {
final String currentValue = SystemProperties.get(NFC_NFCSNOOP_LOG_MODE_PROPERTY);
((SwitchPreference) mPreference).setChecked(currentValue.equals(NFCSNOOP_MODE_FULL));
((TwoStatePreference) mPreference).setChecked(currentValue.equals(NFCSNOOP_MODE_FULL));
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get nfc system property: " + e.getMessage());
}
@@ -80,7 +80,7 @@ public class NfcSnoopLogPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
try {
SystemProperties.set(NFC_NFCSNOOP_LOG_MODE_PROPERTY, NFCSNOOP_MODE_FILTERED);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set nfc system property: " + e.getMessage());
}

View File

@@ -22,7 +22,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -63,7 +63,7 @@ public class NfcStackDebugLogPreferenceController extends
try {
final boolean isEnabled = SystemProperties.getBoolean(
NFC_STACK_DEBUGLOG_ENABLED_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get nfc system property: " + e.getMessage());
}
@@ -74,7 +74,7 @@ public class NfcStackDebugLogPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
try {
SystemProperties.set(NFC_STACK_DEBUGLOG_ENABLED_PROPERTY, "false");
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set nfc system property: " + e.getMessage());
}

View File

@@ -22,7 +22,7 @@ import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -69,7 +69,7 @@ public class NfcVerboseVendorLogPreferenceController
public void updateState(Preference preference) {
try {
final String currentValue = SystemProperties.get(NFC_VERBOSE_VENDOR_LOG_PROPERTY);
((SwitchPreference) mPreference)
((TwoStatePreference) mPreference)
.setChecked(currentValue.equals(VERBOSE_VENDOR_LOG_ENABLED));
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get nfc system property: " + e.getMessage());
@@ -81,7 +81,7 @@ public class NfcVerboseVendorLogPreferenceController
super.onDeveloperOptionsSwitchDisabled();
try {
SystemProperties.set(NFC_VERBOSE_VENDOR_LOG_PROPERTY, VERBOSE_VENDOR_LOG_DISABLED);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set nfc system property: " + e.getMessage());
}

View File

@@ -23,7 +23,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -66,7 +66,7 @@ public class NonResizableMultiWindowPreferenceController
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -74,6 +74,6 @@ public class NonResizableMultiWindowPreferenceController
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -22,7 +22,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -62,7 +62,7 @@ public class NotificationChannelWarningsPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, 0);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -70,7 +70,7 @@ public class NotificationChannelWarningsPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -0,0 +1,5 @@
# ShowHdrSdrRatioPreferenceController
per-file ShowHdrSdrRatioPreferenceController.java=file:platform/frameworks/native:/services/surfaceflinger/OWNERS
# ShowRefreshRatePreferenceController
per-file ShowRefreshRatePreferenceController.java=file:platform/frameworks/native:/services/surfaceflinger/OWNERS

View File

@@ -159,7 +159,7 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
}
private void updateOemUnlockSettingDescription() {
int oemUnlockSummary = R.string.oem_unlock_enable_summary;
int oemUnlockSummary = com.android.settingslib.R.string.oem_unlock_enable_summary;
if (isBootloaderUnlocked()) {
oemUnlockSummary = R.string.oem_unlock_enable_disabled_summary_bootloader_unlocked;
} else if (isSimLockedDevice()) {
@@ -203,7 +203,7 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
final ChooseLockSettingsHelper.Builder builder =
new ChooseLockSettingsHelper.Builder(mActivity, mFragment);
return builder.setRequestCode(requestCode)
.setTitle(resources.getString(R.string.oem_unlock_enable))
.setTitle(resources.getString(com.android.settingslib.R.string.oem_unlock_enable))
.show();
}

View File

@@ -23,7 +23,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class OverlaySettingsPreferenceController extends DeveloperOptionsPrefere
@Override
public void updateState(Preference preference) {
((SwitchPreference) preference).setChecked(isOverlaySettingsEnabled(mContext));
((TwoStatePreference) preference).setChecked(isOverlaySettingsEnabled(mContext));
}
/**

View File

@@ -23,7 +23,7 @@ import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -66,7 +66,7 @@ public class PhantomProcessPreferenceController extends
try {
final boolean isEnabled = !FeatureFlagUtils.isEnabled(mContext,
SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get feature flag: " + e.getMessage());
}
@@ -79,7 +79,7 @@ public class PhantomProcessPreferenceController extends
FeatureFlagUtils.setEnabled(mContext,
SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS,
true /* Enable the monitoring */);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set feature flag: " + e.getMessage());
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,7 +57,7 @@ public class PointerLocationPreferenceController extends DeveloperOptionsPrefere
public void updateState(Preference preference) {
final int pointerLocationMode = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.POINTER_LOCATION, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(pointerLocationMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(pointerLocationMode != SETTING_VALUE_OFF);
}
@Override
@@ -65,6 +65,6 @@ public class PointerLocationPreferenceController extends DeveloperOptionsPrefere
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.POINTER_LOCATION,
SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -24,7 +24,6 @@ import android.view.ThreadedRenderer;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker;
@@ -40,8 +39,10 @@ public class ProfileGpuRenderingPreferenceController extends DeveloperOptionsPre
public ProfileGpuRenderingPreferenceController(Context context) {
super(context);
mListValues = context.getResources().getStringArray(R.array.track_frame_time_values);
mListSummaries = context.getResources().getStringArray(R.array.track_frame_time_entries);
mListValues = context.getResources()
.getStringArray(com.android.settingslib.R.array.track_frame_time_values);
mListSummaries = context.getResources()
.getStringArray(com.android.settingslib.R.array.track_frame_time_entries);
}
@Override

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -58,7 +58,7 @@ public class ResizableActivityPreferenceController extends DeveloperOptionsPrefe
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -66,6 +66,6 @@ public class ResizableActivityPreferenceController extends DeveloperOptionsPrefe
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -22,7 +22,7 @@ import android.sysprop.DisplayProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.internal.app.LocalePicker;
import com.android.settings.core.PreferenceControllerMixin;
@@ -59,7 +59,7 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
public void updateState(Preference preference) {
int rtlLayoutMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(rtlLayoutMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(rtlLayoutMode != SETTING_VALUE_OFF);
}
@Override
@@ -67,7 +67,7 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
super.onDeveloperOptionsSwitchDisabled();
writeToForceRtlLayoutSetting(false);
updateLocales();
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

@@ -23,8 +23,8 @@ import android.text.TextUtils;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.R;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class SecondaryDisplayPreferenceController extends DeveloperOptionsPreferenceController

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -54,13 +54,13 @@ public abstract class SecureSettingSwitchPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(
mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -19,17 +19,20 @@ package com.android.settings.development;
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_CODE_DEBUG_APP;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferenceController
@@ -54,13 +57,29 @@ public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferen
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (DEBUG_APP_KEY.equals(preference.getKey())) {
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
return false;
}
if (Flags.deprecateListActivity()) {
final Bundle args = new Bundle();
args.putBoolean(DevelopmentAppPicker.EXTRA_DEBUGGABLE, true /* value */);
final String debugApp = Settings.Global.getString(
mContext.getContentResolver(), Settings.Global.DEBUG_APP);
args.putString(DevelopmentAppPicker.EXTRA_SELECTING_APP, debugApp);
new SubSettingLauncher(mContext)
.setDestination(DevelopmentAppPicker.class.getName())
.setSourceMetricsCategory(SettingsEnums.DEVELOPMENT)
.setArguments(args)
.setTitleRes(com.android.settingslib.R.string.select_application)
.setResultListener(mFragment, REQUEST_CODE_DEBUG_APP)
.launch();
} else {
final Intent intent = getActivityStartIntent();
intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true /* value */);
mFragment.startActivityForResult(intent, REQUEST_CODE_DEBUG_APP);
return true;
}
return false;
return true;
}
@Override
@@ -82,7 +101,8 @@ public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferen
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
mPreference.setSummary(mContext.getResources().getString(R.string.debug_app_not_set));
mPreference.setSummary(mContext.getResources()
.getString(com.android.settingslib.R.string.debug_app_not_set));
}
@VisibleForTesting
@@ -94,10 +114,12 @@ public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferen
final String debugApp = Settings.Global.getString(
mContext.getContentResolver(), Settings.Global.DEBUG_APP);
if (debugApp != null && debugApp.length() > 0) {
mPreference.setSummary(mContext.getResources().getString(R.string.debug_app_set,
getAppLabel(debugApp)));
mPreference.setSummary(mContext.getResources()
.getString(com.android.settingslib.R.string.debug_app_set,
getAppLabel(debugApp)));
} else {
mPreference.setSummary(mContext.getResources().getString(R.string.debug_app_not_set));
mPreference.setSummary(mContext.getResources()
.getString(com.android.settingslib.R.string.debug_app_not_set));
}
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -66,7 +66,7 @@ public class ShowFirstCrashDialogPreferenceController extends DeveloperOptionsPr
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
@@ -74,6 +74,6 @@ public class ShowFirstCrashDialogPreferenceController extends DeveloperOptionsPr
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -0,0 +1,144 @@
/**
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.view.Display;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.flags.Flags;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Controller class for controlling the hdr/sdr ratio on SurfaceFlinger
*/
public class ShowHdrSdrRatioPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String SHOW_REFRESH_RATE_KEY = "show_hdr_sdr_ratio";
private static final int SETTING_VALUE_QUERY = 2;
private static final int SETTING_VALUE_ON = 1;
private static final int SETTING_VALUE_OFF = 0;
private static final String SURFACE_FLINGER_SERVICE_KEY = "SurfaceFlinger";
private static final int SURFACE_FLINGER_CODE = 1043;
private static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer";
private final IBinder mSurfaceFlinger;
private final boolean mIsHdrSdrRatioAvailable;
public ShowHdrSdrRatioPreferenceController(Context context) {
super(context);
mSurfaceFlinger = ServiceManager.getService(SURFACE_FLINGER_SERVICE_KEY);
DisplayManager displayManager = context.getSystemService(DisplayManager.class);
Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
mIsHdrSdrRatioAvailable = display != null && display.isHdrSdrRatioAvailable();
}
@VisibleForTesting
ShowHdrSdrRatioPreferenceController(Context context, IBinder surfaceFlinger,
boolean isHdrSdrRatioAvailable) {
super(context);
mSurfaceFlinger = surfaceFlinger;
mIsHdrSdrRatioAvailable = isHdrSdrRatioAvailable;
}
@Override
public String getPreferenceKey() {
return SHOW_REFRESH_RATE_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
writeShowHdrSdrRatioSetting(isEnabled);
return true;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
updateShowHdrSdrRatioSetting();
}
@Override
public boolean isAvailable() {
return Flags.developmentHdrSdrRatio() && mIsHdrSdrRatioAvailable;
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final TwoStatePreference preference = (TwoStatePreference) mPreference;
if (preference.isChecked()) {
// Writing false to the preference when the setting is already off will have a
// side effect of turning on the preference that we wish to avoid
writeShowHdrSdrRatioSetting(false);
preference.setChecked(false);
}
}
private void updateShowHdrSdrRatioSetting() {
// magic communication with surface flinger.
try {
if (mSurfaceFlinger != null) {
final Parcel data = Parcel.obtain();
final Parcel reply = Parcel.obtain();
data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);
data.writeInt(SETTING_VALUE_QUERY);
mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, reply, 0 /* flags */);
final boolean enabled = reply.readBoolean();
((TwoStatePreference) mPreference).setChecked(enabled);
reply.recycle();
data.recycle();
}
} catch (RemoteException ex) {
// intentional no-op
}
}
@VisibleForTesting
void writeShowHdrSdrRatioSetting(boolean isEnabled) {
try {
if (mSurfaceFlinger != null) {
final Parcel data = Parcel.obtain();
data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);
final int showHdrSdrRatio = isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF;
data.writeInt(showHdrSdrRatio);
mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data,
null /* reply */, 0 /* flags */);
data.recycle();
}
} catch (RemoteException ex) {
// intentional no-op
}
updateShowHdrSdrRatioSetting();
}
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -59,7 +59,7 @@ public class ShowKeyPressesPreferenceController extends
public void updateState(Preference preference) {
int showKeyPresses = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.SHOW_KEY_PRESSES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(showKeyPresses != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(showKeyPresses != SETTING_VALUE_OFF);
}
@Override
@@ -67,6 +67,6 @@ public class ShowKeyPressesPreferenceController extends
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.SHOW_KEY_PRESSES,
SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.sysprop.DisplayProperties;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -51,13 +51,13 @@ public class ShowLayoutBoundsPreferenceController extends DeveloperOptionsPrefer
@Override
public void updateState(Preference preference) {
final boolean isEnabled = DisplayProperties.debug_layout().orElse(false);
((SwitchPreference) mPreference).setChecked(isEnabled);
((TwoStatePreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
DisplayProperties.debug_layout(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -24,7 +24,7 @@ import android.os.ServiceManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -75,7 +75,7 @@ public class ShowRefreshRatePreferenceController extends DeveloperOptionsPrefere
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final SwitchPreference preference = (SwitchPreference) mPreference;
final TwoStatePreference preference = (TwoStatePreference) mPreference;
if (preference.isChecked()) {
// Writing false to the preference when the setting is already off will have a
// side effect of turning on the preference that we wish to avoid
@@ -95,7 +95,7 @@ public class ShowRefreshRatePreferenceController extends DeveloperOptionsPrefere
data.writeInt(SETTING_VALUE_QUERY);
mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, reply, 0 /* flags */);
final boolean enabled = reply.readBoolean();
((SwitchPreference) mPreference).setChecked(enabled);
((TwoStatePreference) mPreference).setChecked(enabled);
reply.recycle();
data.recycle();
}

View File

@@ -24,7 +24,7 @@ import android.os.ServiceManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -72,7 +72,7 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final SwitchPreference preference = (SwitchPreference) mPreference;
final TwoStatePreference preference = (TwoStatePreference) mPreference;
if (preference.isChecked()) {
// Writing false to the preference when the setting is already off will have a
// side effect of turning on the preference that we wish to avoid
@@ -93,7 +93,7 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
@SuppressWarnings("unused") final int showCpu = reply.readInt();
@SuppressWarnings("unused") final int enableGL = reply.readInt();
final int showUpdates = reply.readInt();
((SwitchPreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
reply.recycle();
data.recycle();
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,7 +57,7 @@ public class ShowTapsPreferenceController extends DeveloperOptionsPreferenceCont
public void updateState(Preference preference) {
int showTapsMode = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.SHOW_TOUCHES, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(showTapsMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(showTapsMode != SETTING_VALUE_OFF);
}
@Override
@@ -65,6 +65,6 @@ public class ShowTapsPreferenceController extends DeveloperOptionsPreferenceCont
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.SHOW_TOUCHES,
SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -26,7 +26,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -83,8 +82,10 @@ public class SimulateColorSpacePreferenceController extends DeveloperOptionsPref
if (index < 0) {
final Resources res = mContext.getResources();
// We're using a mode controlled by accessibility preferences.
listPreference.setSummary(res.getString(R.string.daltonizer_type_overridden,
res.getString(R.string.accessibility_display_daltonizer_preference_title)));
listPreference.setSummary(
res.getString(com.android.settingslib.R.string.daltonizer_type_overridden,
res.getString(com.android.settingslib.R
.string.accessibility_display_daltonizer_preference_title)));
} else {
listPreference.setSummary("%s");
}

View File

@@ -25,7 +25,7 @@ import android.view.IWindowManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -64,14 +64,14 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
@Override
public void updateState(Preference preference) {
((SwitchPreference) mPreference).setChecked(isStrictModeEnabled());
((TwoStatePreference) mPreference).setChecked(isStrictModeEnabled());
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeStrictModeVisualOptions(false);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
private boolean isStrictModeEnabled() {

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -57,7 +57,7 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
}
@Override
@@ -66,6 +66,6 @@ class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceCo
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.STYLUS_HANDWRITING_ENABLED,
Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -20,7 +20,7 @@ import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -54,13 +54,13 @@ public abstract class SystemSettingSwitchPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.System.getInt(
mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -21,7 +21,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -61,7 +61,7 @@ public class TetheringHardwareAccelPreferenceController extends DeveloperOptions
final int tetheringMode = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, 0 /* default */);
((SwitchPreference) mPreference).setChecked(tetheringMode != SETTING_VALUE_OFF);
((TwoStatePreference) mPreference).setChecked(tetheringMode != SETTING_VALUE_OFF);
}
@Override
@@ -69,6 +69,6 @@ public class TetheringHardwareAccelPreferenceController extends DeveloperOptions
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
}

View File

@@ -25,7 +25,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -50,9 +49,9 @@ public class TransitionAnimationScalePreferenceController extends
mWindowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService(Context.WINDOW_SERVICE));
mListValues = context.getResources().getStringArray(
R.array.transition_animation_scale_values);
com.android.settingslib.R.array.transition_animation_scale_values);
mListSummaries = context.getResources().getStringArray(
R.array.transition_animation_scale_entries);
com.android.settingslib.R.array.transition_animation_scale_entries);
}
@Override

View File

@@ -24,7 +24,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -62,13 +62,13 @@ public class TransparentNavigationBarPreferenceController
@Override
public void updateState(Preference preference) {
((SwitchPreference) mPreference).setChecked(isEnabled());
((TwoStatePreference) mPreference).setChecked(isEnabled());
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
final boolean enabled = isEnabled();
if (!enabled) {
setEnabled(false);

View File

@@ -25,7 +25,7 @@ import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -81,7 +81,7 @@ public class UsbAudioRoutingPreferenceController extends DeveloperOptionsPrefere
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
((TwoStatePreference) mPreference).setChecked(false);
}
@Override

Some files were not shown because too many files have changed in this diff Show More