Merge 10952656

Merged-In: Ib02ae9caef06a46938947806dac8aabb1fa12d94
Change-Id: Ib1f728fef6241ddd7a2ce1522093f4a62a4a9d81
This commit is contained in:
Xin Li
2023-10-18 15:05:14 -07:00
698 changed files with 37975 additions and 20889 deletions

View File

@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import androidx.annotation.VisibleForTesting;
@@ -27,7 +28,6 @@ import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
@@ -40,8 +40,12 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
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 boolean LE_AUDIO_TOGGLE_VISIBLE_DEFAULT_VALUE = true;
static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN;
static final String LE_AUDIO_TOGGLE_VISIBLE_PROPERTY =
"persist.bluetooth.leaudio.toggle_visible";
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
@@ -72,10 +76,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
DeviceConfig.setProperty(
DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED,
isEnabled ? "true" : "false", false);
SystemProperties.set(LE_AUDIO_TOGGLE_VISIBLE_PROPERTY, Boolean.toString(isEnabled));
return true;
}
@@ -85,23 +86,13 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
return;
}
final boolean leAudioDeviceDetailEnabled = DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false);
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(leAudioDeviceDetailEnabled
((SwitchPreference) mPreference).setChecked(isLeAudioToggleVisible
|| leAudioEnabledByDefault);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
// Reset the toggle to null when the developer option is disabled
DeviceConfig.setProperty(
DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "null", false);
}
}

View File

@@ -25,12 +25,4 @@ public interface DevelopmentOptionsActivityRequestCodes {
int REQUEST_CODE_DEBUG_APP = 1;
int REQUEST_MOCK_LOCATION_APP = 2;
int REQUEST_CODE_ANGLE_ALL_USE_ANGLE = 3;
int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
int REQUEST_COMPAT_CHANGE_APP = 6;
}

View File

@@ -675,6 +675,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new NfcVerboseVendorLogPreferenceController(context, fragment));
controllers.add(new ShowTapsPreferenceController(context));
controllers.add(new PointerLocationPreferenceController(context));
controllers.add(new ShowKeyPressesPreferenceController(context));
controllers.add(new ShowSurfaceUpdatesPreferenceController(context));
controllers.add(new ShowLayoutBoundsPreferenceController(context));
controllers.add(new ShowRefreshRatePreferenceController(context));

View File

@@ -29,6 +29,7 @@ import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.utils.ThreadUtils;
import java.util.NoSuchElementException;
@@ -66,23 +67,34 @@ public class EnableVerboseVendorLoggingPreferenceController
return isIDumpstateDeviceAidlServiceAvailable() || isIDumpstateDeviceV1_1ServiceAvailable();
}
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
setVerboseLoggingEnabled(isEnabled);
// IDumpstateDevice IPC may be blocking when system is extremely heavily-loaded.
// Post to background thread to avoid ANR. Ignore the returned Future.
ThreadUtils.postOnBackgroundThread(() ->
setVerboseLoggingEnabled(isEnabled));
return true;
}
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void updateState(Preference preference) {
final boolean enabled = getVerboseLoggingEnabled();
((SwitchPreference) mPreference).setChecked(enabled);
ThreadUtils.postOnBackgroundThread(() -> {
final boolean enabled = getVerboseLoggingEnabled();
ThreadUtils.getUiThreadHandler().post(() ->
((SwitchPreference) mPreference).setChecked(enabled));
}
);
}
@SuppressWarnings("FutureReturnValueIgnored")
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
setVerboseLoggingEnabled(false);
ThreadUtils.postOnBackgroundThread(() ->
setVerboseLoggingEnabled(false));
((SwitchPreference) mPreference).setChecked(false);
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright 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.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/** PreferenceController that controls the "Show key presses" developer option. */
public class ShowKeyPressesPreferenceController extends
DeveloperOptionsPreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String SHOW_KEY_PRESSES_KEY = "show_key_presses";
@VisibleForTesting
static final int SETTING_VALUE_ON = 1;
@VisibleForTesting
static final int SETTING_VALUE_OFF = 0;
public ShowKeyPressesPreferenceController(Context context) {
super(context);
}
@Override
public String getPreferenceKey() {
return SHOW_KEY_PRESSES_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.System.putInt(mContext.getContentResolver(),
Settings.System.SHOW_KEY_PRESSES, isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
return true;
}
@Override
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);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.SHOW_KEY_PRESSES,
SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

@@ -17,21 +17,16 @@
package com.android.settings.development.compat;
import static com.android.internal.compat.OverrideAllowedState.ALLOWED;
import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.settings.SettingsEnums;
import android.compat.Compatibility.ChangeConfig;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.text.TextUtils;
import android.util.ArraySet;
import androidx.annotation.VisibleForTesting;
@@ -40,35 +35,28 @@ import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
import com.android.internal.compat.AndroidBuildClassifier;
import com.android.internal.compat.CompatibilityChangeConfig;
import com.android.internal.compat.CompatibilityChangeInfo;
import com.android.internal.compat.IPlatformCompat;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.development.AppPicker;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* Dashboard for Platform Compat preferences.
*/
public class PlatformCompatDashboard extends DashboardFragment {
private static final String TAG = "PlatformCompatDashboard";
private static final String COMPAT_APP = "compat_app";
public static final String COMPAT_APP = "compat_app";
private IPlatformCompat mPlatformCompat;
private CompatibilityChangeInfo[] mChanges;
private AndroidBuildClassifier mAndroidBuildClassifier = new AndroidBuildClassifier();
private boolean mShouldStartAppPickerOnResume = true;
@VisibleForTesting
String mSelectedApp;
@@ -108,32 +96,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
} catch (RemoteException e) {
throw new RuntimeException("Could not list changes!", e);
}
if (icicle != null) {
mShouldStartAppPickerOnResume = false;
mSelectedApp = icicle.getString(COMPAT_APP);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
mShouldStartAppPickerOnResume = false;
switch (resultCode) {
case Activity.RESULT_OK:
mSelectedApp = data.getAction();
break;
case Activity.RESULT_CANCELED:
if (TextUtils.isEmpty(mSelectedApp)) {
finish();
}
break;
case AppPicker.RESULT_NO_MATCHING_APPS:
mSelectedApp = null;
break;
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
@@ -142,33 +104,18 @@ public class PlatformCompatDashboard extends DashboardFragment {
if (isFinishingOrDestroyed()) {
return;
}
if (!mShouldStartAppPickerOnResume) {
if (TextUtils.isEmpty(mSelectedApp)) {
new AlertDialog.Builder(getContext())
.setTitle(R.string.platform_compat_dialog_title_no_apps)
.setMessage(R.string.platform_compat_dialog_text_no_apps)
.setPositiveButton(R.string.okay, (dialog, which) -> finish())
.setOnDismissListener(dialog -> finish())
.setCancelable(false)
.show();
return;
}
try {
final ApplicationInfo applicationInfo = getApplicationInfo();
addPreferences(applicationInfo);
return;
} catch (PackageManager.NameNotFoundException e) {
mShouldStartAppPickerOnResume = true;
mSelectedApp = null;
}
Bundle arguments = getArguments();
if (arguments == null) {
finish();
return;
}
mSelectedApp = arguments.getString(COMPAT_APP);
try {
final ApplicationInfo applicationInfo = getApplicationInfo();
addPreferences(applicationInfo);
} catch (PackageManager.NameNotFoundException ignored) {
finish();
}
startAppPicker();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(COMPAT_APP, mSelectedApp);
}
private void addPreferences(ApplicationInfo applicationInfo) {
@@ -266,12 +213,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
appPreference.setIcon(icon);
appPreference.setSummary(getString(R.string.platform_compat_selected_app_summary,
mSelectedApp, applicationInfo.targetSdkVersion));
appPreference.setKey(mSelectedApp);
appPreference.setOnPreferenceClickListener(
preference -> {
startAppPicker();
return true;
});
return appPreference;
}
@@ -294,17 +235,6 @@ public class PlatformCompatDashboard extends DashboardFragment {
}
}
private void startAppPicker() {
final Intent intent = new Intent(getContext(), AppPicker.class)
.putExtra(AppPicker.EXTRA_INCLUDE_NOTHING, false);
// If build is neither userdebug nor eng, only include debuggable apps
final boolean debuggableBuild = mAndroidBuildClassifier.isDebuggableBuild();
if (!debuggableBuild) {
intent.putExtra(AppPicker.EXTRA_DEBUGGABLE, true /* value */);
}
startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
}
private class CompatChangePreferenceChangeListener implements OnPreferenceChangeListener {
private final long changeId;