Merge tm-qpr-dev-plus-aosp-without-vendor@9129937
Bug: 248070379 Merged-In: I9ebe26c6a8058798ea654523ad1405a8447268b8 Change-Id: Ib8c6441f2165784804a1863bcfce6b05d20ecfd3
This commit is contained in:
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.dumpstate.V1_0.IDumpstateDevice;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -40,8 +41,12 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
|
||||
private static final String ENABLE_VERBOSE_VENDOR_LOGGING_KEY = "enable_verbose_vendor_logging";
|
||||
private static final int DUMPSTATE_HAL_VERSION_UNKNOWN = -1;
|
||||
private static final int DUMPSTATE_HAL_VERSION_1_0 = 0;
|
||||
private static final int DUMPSTATE_HAL_VERSION_1_1 = 1;
|
||||
private static final int DUMPSTATE_HAL_VERSION_1_0 = 0; // HIDL v1.0
|
||||
private static final int DUMPSTATE_HAL_VERSION_1_1 = 1; // HIDL v1.1
|
||||
private static final int DUMPSTATE_HAL_VERSION_2_0 = 2; // AIDL v1
|
||||
|
||||
private static final String DUMP_STATE_AIDL_SERVICE_NAME =
|
||||
android.hardware.dumpstate.IDumpstateDevice.DESCRIPTOR + "/default";
|
||||
|
||||
private int mDumpstateHalVersion;
|
||||
|
||||
@@ -57,9 +62,8 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
// Only show preference when IDumpstateDevice v1.1 is avalaible
|
||||
// This is temperary strategy that may change later.
|
||||
return isIDumpstateDeviceV1_1ServiceAvailable();
|
||||
// Only show preference when IDumpstateDevice AIDL or HIDL v1.1 service is available
|
||||
return isIDumpstateDeviceAidlServiceAvailable() || isIDumpstateDeviceV1_1ServiceAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,15 +90,31 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
boolean isIDumpstateDeviceV1_1ServiceAvailable() {
|
||||
IDumpstateDevice service = getDumpstateDeviceService();
|
||||
if (service == null) {
|
||||
if (DBG) Log.d(TAG, "IDumpstateDevice service is not available.");
|
||||
if (DBG) Log.d(TAG, "IDumpstateDevice v1.1 service is not available.");
|
||||
}
|
||||
return service != null && mDumpstateHalVersion >= DUMPSTATE_HAL_VERSION_1_1;
|
||||
return service != null && mDumpstateHalVersion == DUMPSTATE_HAL_VERSION_1_1;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isIDumpstateDeviceAidlServiceAvailable() {
|
||||
android.hardware.dumpstate.IDumpstateDevice aidlService = getDumpstateDeviceAidlService();
|
||||
return aidlService != null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setVerboseLoggingEnabled(boolean enable) {
|
||||
IDumpstateDevice service = getDumpstateDeviceService();
|
||||
// First check if AIDL service is available
|
||||
android.hardware.dumpstate.IDumpstateDevice aidlService = getDumpstateDeviceAidlService();
|
||||
if (aidlService != null) {
|
||||
try {
|
||||
aidlService.setVerboseLoggingEnabled(enable);
|
||||
} catch (RemoteException re) {
|
||||
if (DBG) Log.e(TAG, "aidlService.setVerboseLoggingEnabled fail: " + re);
|
||||
}
|
||||
}
|
||||
|
||||
// Then check HIDL v1.1 service
|
||||
IDumpstateDevice service = getDumpstateDeviceService();
|
||||
if (service == null || mDumpstateHalVersion < DUMPSTATE_HAL_VERSION_1_1) {
|
||||
if (DBG) Log.d(TAG, "setVerboseLoggingEnabled not supported.");
|
||||
return;
|
||||
@@ -107,14 +127,24 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
service11.setVerboseLoggingEnabled(enable);
|
||||
}
|
||||
} catch (RemoteException | RuntimeException e) {
|
||||
if (DBG) Log.e(TAG, "setVerboseLoggingEnabled fail: " + e);
|
||||
if (DBG) Log.e(TAG, "HIDL v1.1 setVerboseLoggingEnabled fail: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean getVerboseLoggingEnabled() {
|
||||
IDumpstateDevice service = getDumpstateDeviceService();
|
||||
// First check if AIDL service is available
|
||||
android.hardware.dumpstate.IDumpstateDevice aidlService = getDumpstateDeviceAidlService();
|
||||
if (aidlService != null) {
|
||||
try {
|
||||
return aidlService.getVerboseLoggingEnabled();
|
||||
} catch (RemoteException re) {
|
||||
if (DBG) Log.e(TAG, "aidlService.getVerboseLoggingEnabled fail: " + re);
|
||||
}
|
||||
}
|
||||
|
||||
// Then check HIDL v1.1 service
|
||||
IDumpstateDevice service = getDumpstateDeviceService();
|
||||
if (service == null || mDumpstateHalVersion < DUMPSTATE_HAL_VERSION_1_1) {
|
||||
if (DBG) Log.d(TAG, "getVerboseLoggingEnabled not supported.");
|
||||
return false;
|
||||
@@ -127,7 +157,7 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
return service11.getVerboseLoggingEnabled();
|
||||
}
|
||||
} catch (RemoteException | RuntimeException e) {
|
||||
if (DBG) Log.e(TAG, "getVerboseLoggingEnabled fail: " + e);
|
||||
if (DBG) Log.e(TAG, "HIDL v1.1 getVerboseLoggingEnabled fail: " + e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -141,6 +171,7 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
.getService(true /* retry */);
|
||||
mDumpstateHalVersion = DUMPSTATE_HAL_VERSION_1_1;
|
||||
} catch (NoSuchElementException | RemoteException e) {
|
||||
if (DBG) Log.e(TAG, "Get HIDL v1.1 service fail: " + e);
|
||||
}
|
||||
|
||||
if (service == null) {
|
||||
@@ -149,6 +180,7 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
.getService(true /* retry */);
|
||||
mDumpstateHalVersion = DUMPSTATE_HAL_VERSION_1_0;
|
||||
} catch (NoSuchElementException | RemoteException e) {
|
||||
if (DBG) Log.e(TAG, "Get HIDL v1.0 service fail: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,4 +189,24 @@ public class EnableVerboseVendorLoggingPreferenceController
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link android.hardware.dumpstate.IDumpstateDevice} instance or null if service is
|
||||
* not available.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
@Nullable android.hardware.dumpstate.IDumpstateDevice getDumpstateDeviceAidlService() {
|
||||
android.hardware.dumpstate.IDumpstateDevice service = null;
|
||||
try {
|
||||
service = android.hardware.dumpstate.IDumpstateDevice.Stub.asInterface(
|
||||
ServiceManager.waitForDeclaredService(DUMP_STATE_AIDL_SERVICE_NAME));
|
||||
} catch (NoSuchElementException e) {
|
||||
if (DBG) Log.e(TAG, "Get AIDL service fail: " + e);
|
||||
}
|
||||
|
||||
if (service != null) {
|
||||
mDumpstateHalVersion = DUMPSTATE_HAL_VERSION_2_0;
|
||||
}
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
@@ -38,10 +38,6 @@ public class NotificationChannelWarningsPreferenceController extends
|
||||
final static int SETTING_VALUE_ON = 1;
|
||||
@VisibleForTesting
|
||||
final static int SETTING_VALUE_OFF = 0;
|
||||
@VisibleForTesting
|
||||
final static int DEBUGGING_ENABLED = 1;
|
||||
@VisibleForTesting
|
||||
final static int DEBUGGING_DISABLED = 0;
|
||||
|
||||
public NotificationChannelWarningsPreferenceController(Context context) {
|
||||
super(context);
|
||||
@@ -64,9 +60,8 @@ public class NotificationChannelWarningsPreferenceController extends
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final int defaultWarningEnabled = isDebuggable() ? DEBUGGING_ENABLED : DEBUGGING_DISABLED;
|
||||
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled);
|
||||
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, 0);
|
||||
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@ public class StayAwakePreferenceController extends DeveloperOptionsPreferenceCon
|
||||
@VisibleForTesting
|
||||
static final int SETTING_VALUE_ON =
|
||||
BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB
|
||||
| BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
| BatteryManager.BATTERY_PLUGGED_WIRELESS | BatteryManager.BATTERY_PLUGGED_DOCK;
|
||||
@VisibleForTesting
|
||||
SettingsObserver mSettingsObserver;
|
||||
|
||||
|
@@ -40,7 +40,11 @@ public abstract class AbstractBluetoothDialogPreferenceController extends
|
||||
|
||||
private static final String TAG = "AbstractBtDlgCtr";
|
||||
|
||||
protected static final int[] CODEC_TYPES = {BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO(b/240635097): remove in U
|
||||
|
||||
protected static final int[] CODEC_TYPES = {SOURCE_CODEC_TYPE_OPUS,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
|
||||
BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC,
|
||||
|
@@ -61,6 +61,8 @@ public class BluetoothCodecDialogPreference extends BaseBluetoothDialogPreferenc
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_aptx_hd);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_ldac);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_lc3);
|
||||
mRadioButtonIds.add(R.id.bluetooth_audio_codec_opus);
|
||||
String[] stringArray = context.getResources().getStringArray(
|
||||
R.array.bluetooth_a2dp_codec_titles);
|
||||
for (int i = 0; i < stringArray.length; i++) {
|
||||
|
@@ -40,6 +40,8 @@ public class BluetoothCodecDialogPreferenceController extends
|
||||
private static final String KEY = "bluetooth_audio_codec_settings";
|
||||
private static final String TAG = "BtCodecCtr";
|
||||
|
||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO remove in U
|
||||
|
||||
private final Callback mCallback;
|
||||
|
||||
public BluetoothCodecDialogPreferenceController(Context context, Lifecycle lifecycle,
|
||||
@@ -118,6 +120,14 @@ public class BluetoothCodecDialogPreferenceController extends
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 6:
|
||||
codecTypeValue = BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3;
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 7:
|
||||
codecTypeValue = SOURCE_CODEC_TYPE_OPUS; // TODO update in U
|
||||
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -180,6 +190,9 @@ public class BluetoothCodecDialogPreferenceController extends
|
||||
case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
|
||||
index = 5;
|
||||
break;
|
||||
case SOURCE_CODEC_TYPE_OPUS: // TODO update in U
|
||||
index = 7;
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unsupported config:" + config);
|
||||
break;
|
||||
|
@@ -24,6 +24,7 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.service.quicksettings.TileService;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -61,9 +62,23 @@ public class DevelopmentTilePreferenceController extends BasePreferenceControlle
|
||||
final Intent intent = new Intent(TileService.ACTION_QS_TILE)
|
||||
.setPackage(context.getPackageName());
|
||||
final List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent,
|
||||
PackageManager.MATCH_DISABLED_COMPONENTS);
|
||||
PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.GET_META_DATA);
|
||||
for (ResolveInfo info : resolveInfos) {
|
||||
ServiceInfo sInfo = info.serviceInfo;
|
||||
|
||||
// Check if the tile requires a flag. If it does, hide tile if flag is off.
|
||||
if (sInfo.metaData != null) {
|
||||
String flag = sInfo.metaData.getString(
|
||||
DevelopmentTiles.META_DATA_REQUIRES_SYSTEM_PROPERTY);
|
||||
if (flag != null) {
|
||||
boolean enabled = SystemProperties.getBoolean(flag, false);
|
||||
if (!enabled) {
|
||||
// Flagged tile, flag is not enabled
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int enabledSetting = mPackageManager.getComponentEnabledSetting(
|
||||
new ComponentName(sInfo.packageName, sInfo.name));
|
||||
boolean checked = enabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
|
||||
|
@@ -58,6 +58,22 @@ import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.development.SystemPropPoker;
|
||||
|
||||
public abstract class DevelopmentTiles extends TileService {
|
||||
|
||||
/**
|
||||
* Meta-data for a development tile to declare a sysprop flag that needs to be enabled for
|
||||
* the tile to be available.
|
||||
*
|
||||
* To define the flag, set this meta-data on the tile's manifest declaration.
|
||||
* <pre class="prettyprint">
|
||||
* {@literal
|
||||
* <meta-data android:name="com.android.settings.development.qstile.REQUIRES_SYSTEM_PROPERTY"
|
||||
* android:value="persist.debug.flag_name_here" />
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static final String META_DATA_REQUIRES_SYSTEM_PROPERTY =
|
||||
"com.android.settings.development.qstile.REQUIRES_SYSTEM_PROPERTY";
|
||||
|
||||
private static final String TAG = "DevelopmentTiles";
|
||||
|
||||
protected abstract boolean isEnabled();
|
||||
@@ -476,4 +492,77 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
Settings.System.SHOW_TOUCHES, isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile to enable desktop mode
|
||||
*/
|
||||
public static class DesktopMode extends DevelopmentTiles {
|
||||
|
||||
private static final int SETTING_VALUE_ON = 1;
|
||||
private static final int SETTING_VALUE_OFF = 0;
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mContext = getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.DESKTOP_MODE, SETTING_VALUE_OFF) == SETTING_VALUE_ON;
|
||||
}
|
||||
|
||||
private boolean isDesktopModeFlagEnabled() {
|
||||
return SystemProperties.getBoolean("persist.wm.debug.desktop_mode", false);
|
||||
}
|
||||
|
||||
private boolean isFreeformFlagEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF)
|
||||
== SETTING_VALUE_ON;
|
||||
}
|
||||
|
||||
private boolean isCaptionOnShellEnabled() {
|
||||
return SystemProperties.getBoolean("persist.wm.debug.caption_on_shell", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setIsEnabled(boolean isEnabled) {
|
||||
if (isEnabled) {
|
||||
// Check that all required features are enabled
|
||||
if (!isDesktopModeFlagEnabled()) {
|
||||
closeShade();
|
||||
showMessage(
|
||||
"Enable 'Desktop Windowing Proto 1' from the Flag Flipper app");
|
||||
return;
|
||||
}
|
||||
if (!isCaptionOnShellEnabled()) {
|
||||
closeShade();
|
||||
showMessage("Enable 'Captions in Shell' from the Flag Flipper app");
|
||||
return;
|
||||
}
|
||||
if (!isFreeformFlagEnabled()) {
|
||||
closeShade();
|
||||
showMessage(
|
||||
"Enable freeform windows from developer settings");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Settings.System.putInt(mContext.getContentResolver(),
|
||||
Settings.System.DESKTOP_MODE,
|
||||
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
|
||||
closeShade();
|
||||
}
|
||||
|
||||
private void closeShade() {
|
||||
sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
}
|
||||
|
||||
private void showMessage(String message) {
|
||||
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user