Merge tm-qpr-dev-plus-aosp-without-vendor@9129937
Bug: 248070379 Merged-In: I9ebe26c6a8058798ea654523ad1405a8447268b8 Change-Id: Ib8c6441f2165784804a1863bcfce6b05d20ecfd3
This commit is contained in:
@@ -47,6 +47,8 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@Mock
|
||||
IDumpstateDevice mIDumpstateDevice;
|
||||
@Mock
|
||||
android.hardware.dumpstate.IDumpstateDevice mIDumpstateDeviceAidl;
|
||||
|
||||
private Context mContext;
|
||||
private EnableVerboseVendorLoggingPreferenceController mController;
|
||||
@@ -57,6 +59,7 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = spy(new EnableVerboseVendorLoggingPreferenceController(mContext));
|
||||
doReturn(mIDumpstateDevice).when(mController).getDumpstateDeviceService();
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
|
||||
// mock with Dumpstate HAL v1.1
|
||||
Field f = EnableVerboseVendorLoggingPreferenceController.class
|
||||
@@ -70,7 +73,9 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingEnable_enableVendorLoggingShouldBeOn() throws Exception {
|
||||
public void onPreferenceChange_settingEnableByHidl_enableVendorLoggingShouldBeOn()
|
||||
throws Exception {
|
||||
doReturn(null).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(true).when(mIDumpstateDevice).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||
@@ -80,8 +85,21 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingDisable_enableVendorLoggingShouldBeOff()
|
||||
public void onPreferenceChange_settingEnableByAidl_enableVendorLoggingShouldBeOn()
|
||||
throws Exception {
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(true).when(mIDumpstateDeviceAidl).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onPreferenceChange(mPreference, true /* new value */);
|
||||
|
||||
final boolean enabled = mController.getVerboseLoggingEnabled();
|
||||
assertTrue(enabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingDisableByHidl_enableVendorLoggingShouldBeOff()
|
||||
throws Exception {
|
||||
doReturn(null).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDevice).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||
@@ -91,7 +109,20 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingDisabled_preferenceShouldNotBeChecked() throws Exception {
|
||||
public void onPreferenceChange_settingDisableByAidl_enableVendorLoggingShouldBeOff()
|
||||
throws Exception {
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDeviceAidl).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onPreferenceChange(mPreference, false /* new value */);
|
||||
|
||||
final boolean enabled = mController.getVerboseLoggingEnabled();
|
||||
assertFalse(enabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingDisabledByHidl_preferenceShouldNotBeChecked() throws Exception {
|
||||
doReturn(null).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDevice).getVerboseLoggingEnabled();
|
||||
|
||||
mController.setVerboseLoggingEnabled(false);
|
||||
@@ -101,7 +132,19 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingEnabled_preferenceShouldBeChecked() throws Exception {
|
||||
public void updateState_settingDisabledByAidl_preferenceShouldNotBeChecked() throws Exception {
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDeviceAidl).getVerboseLoggingEnabled();
|
||||
|
||||
mController.setVerboseLoggingEnabled(false);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingEnabledByHidl_preferenceShouldBeChecked() throws Exception {
|
||||
doReturn(null).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(true).when(mIDumpstateDevice).getVerboseLoggingEnabled();
|
||||
|
||||
mController.setVerboseLoggingEnabled(true);
|
||||
@@ -111,7 +154,19 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionDisabled_shouldDisablePreference() throws Exception {
|
||||
public void updateState_settingEnabledByAidl_preferenceShouldBeChecked() throws Exception {
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(true).when(mIDumpstateDeviceAidl).getVerboseLoggingEnabled();
|
||||
|
||||
mController.setVerboseLoggingEnabled(true);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionDisabled_byHidl_shouldDisablePreference() throws Exception {
|
||||
doReturn(null).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDevice).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
@@ -121,4 +176,17 @@ public final class EnableVerboseVendorLoggingPreferenceControllerTest {
|
||||
verify(mPreference).setChecked(false);
|
||||
verify(mPreference).setEnabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDeveloperOptionDisabled_byAidl_shouldDisablePreference() throws Exception {
|
||||
doReturn(mIDumpstateDeviceAidl).when(mController).getDumpstateDeviceAidlService();
|
||||
doReturn(false).when(mIDumpstateDeviceAidl).getVerboseLoggingEnabled();
|
||||
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
final boolean enabled = mController.getVerboseLoggingEnabled();
|
||||
assertFalse(enabled);
|
||||
verify(mPreference).setChecked(false);
|
||||
verify(mPreference).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ public class NotificationChannelWarningsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldBeChecked() {
|
||||
public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldNotBeChecked() {
|
||||
mController = spy(mController);
|
||||
doReturn(true).when(mController).isDebuggable();
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
@@ -110,18 +110,6 @@ public class NotificationChannelWarningsPreferenceControllerTest {
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_settingUndefinedDebuggingDisabled_preferenceShouldNotBeChecked() {
|
||||
mController = spy(mController);
|
||||
doReturn(false).when(mController).isDebuggable();
|
||||
Settings.Global.putString(mContext.getContentResolver(),
|
||||
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, "NotAnInteger");
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
|
@@ -52,6 +52,8 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
|
||||
private static final int SOURCE_CODEC_TYPE_OPUS = 6; // TODO(b/240635097): remove in U
|
||||
|
||||
private static final String DEVICE_ADDRESS = "00:11:22:33:44:55";
|
||||
|
||||
@Mock
|
||||
@@ -72,6 +74,7 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
private BluetoothCodecConfig mCodecConfigAPTX;
|
||||
private BluetoothCodecConfig mCodecConfigAPTXHD;
|
||||
private BluetoothCodecConfig mCodecConfigLDAC;
|
||||
private BluetoothCodecConfig mCodecConfigOPUS;
|
||||
private BluetoothDevice mActiveDevice;
|
||||
private Context mContext;
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
@@ -119,13 +122,17 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mCodecConfigLDAC = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC)
|
||||
.build();
|
||||
mCodecConfigOPUS = new BluetoothCodecConfig.Builder()
|
||||
.setCodecType(SOURCE_CODEC_TYPE_OPUS)
|
||||
.build();
|
||||
when(mBluetoothAdapter.getActiveDevices(eq(BluetoothProfile.A2DP)))
|
||||
.thenReturn(Arrays.asList(mActiveDevice));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_selectDefault_setHighest() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC,
|
||||
mCodecConfigSBC};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigSBC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -136,13 +143,14 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
mController.writeConfigurationValues(0);
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC);
|
||||
// TODO(b/240635097): update in U
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_checkCodec() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigOPUS, mCodecConfigAAC,
|
||||
mCodecConfigSBC, mCodecConfigAPTX, mCodecConfigAPTXHD, mCodecConfigLDAC};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigSBC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -167,12 +175,15 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.writeConfigurationValues(5);
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC);
|
||||
|
||||
mController.writeConfigurationValues(7);
|
||||
// TODO(b/240635097): update in U
|
||||
verify(mBluetoothA2dpConfigStore).setCodecType(SOURCE_CODEC_TYPE_OPUS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeConfigurationValues_resetHighestConfig() {
|
||||
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
|
||||
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigOPUS};
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(Arrays.asList(mCodecConfigs))
|
||||
@@ -197,6 +208,14 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
mController.convertCfgToBtnIndex(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentIndexByConfig_verifyOpusIndex() {
|
||||
assertThat(mController.getCurrentIndexByConfig(mCodecConfigOPUS)).isEqualTo(
|
||||
mController.convertCfgToBtnIndex(SOURCE_CODEC_TYPE_OPUS));
|
||||
// TODO(b/240635097): update in U
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void onIndexUpdated_notifyPreference() {
|
||||
mController.onIndexUpdated(0);
|
||||
@@ -204,9 +223,29 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
verify(mCallback).onBluetoothCodecChanged();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsOpus() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigOPUS)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
.build();
|
||||
when(mBluetoothA2dp.getCodecStatus(mActiveDevice)).thenReturn(mCodecStatus);
|
||||
when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
|
||||
BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
|
||||
mController.onBluetoothServiceConnected(mBluetoothA2dp);
|
||||
|
||||
mController.onHDAudioEnabled(/* enabled= */ true);
|
||||
|
||||
verify(mBluetoothA2dpConfigStore, atLeastOnce()).setCodecType(
|
||||
eq(SOURCE_CODEC_TYPE_OPUS)); // TODO(b/240635097): update in U
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecEnabled_setsCodecTypeAsAAC() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
@@ -223,7 +262,8 @@ public class BluetoothCodecDialogPreferenceControllerTest {
|
||||
}
|
||||
@Test
|
||||
public void onHDAudioEnabled_optionalCodecDisabled_setsCodecTypeAsSBC() {
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigAAC, mCodecConfigSBC);
|
||||
List<BluetoothCodecConfig> mCodecConfigs = Arrays.asList(mCodecConfigOPUS,
|
||||
mCodecConfigAAC, mCodecConfigSBC);
|
||||
mCodecStatus = new BluetoothCodecStatus.Builder()
|
||||
.setCodecConfig(mCodecConfigAAC)
|
||||
.setCodecsSelectableCapabilities(mCodecConfigs)
|
||||
|
@@ -19,7 +19,9 @@ package com.android.settings.development.qstile;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -30,6 +32,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.service.quicksettings.TileService;
|
||||
|
||||
@@ -50,6 +53,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
import org.robolectric.shadows.ShadowPackageManager;
|
||||
import org.robolectric.shadows.ShadowSystemProperties;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -88,11 +92,7 @@ public class DevelopmentTilePreferenceControllerTest {
|
||||
public void display_hasTileService_shouldDisplay() {
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE)
|
||||
.setPackage(mContext.getPackageName());
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.name = "abc";
|
||||
info.serviceInfo.icon = R.drawable.ic_settings_24dp;
|
||||
info.serviceInfo.packageName = mContext.getPackageName();
|
||||
final ResolveInfo info = createFakeInfo("abc");
|
||||
mShadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
@@ -100,6 +100,36 @@ public class DevelopmentTilePreferenceControllerTest {
|
||||
verify(mScreen, atLeastOnce()).addPreference(any(Preference.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_flagDefinedAndOn_shouldDisplay() {
|
||||
ShadowSystemProperties.override("tile_flag", "1");
|
||||
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE)
|
||||
.setPackage(mContext.getPackageName());
|
||||
final ResolveInfo info = createFakeInfo("abc");
|
||||
info.serviceInfo.metaData = createFlagMetadata("tile_flag");
|
||||
mShadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mScreen, atLeastOnce()).addPreference(argThat(pref -> pref.getKey().equals("abc")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void display_flagDefinedAndOff_shouldHide() {
|
||||
ShadowSystemProperties.override("tile_flag" , "0");
|
||||
|
||||
final Intent tileProbe = new Intent(TileService.ACTION_QS_TILE)
|
||||
.setPackage(mContext.getPackageName());
|
||||
final ResolveInfo info = createFakeInfo("abc");
|
||||
info.serviceInfo.metaData = createFlagMetadata("tile_flag");
|
||||
mShadowPackageManager.setResolveInfosForIntent(tileProbe, Arrays.asList(info));
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
verify(mScreen, never()).addPreference(argThat(pref -> pref.getKey().equals("abc")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preferenceChecked_shouldAddTile() throws RemoteException {
|
||||
SwitchPreference preference = createPreference(/* defaultCheckedState = */ false);
|
||||
@@ -132,6 +162,21 @@ public class DevelopmentTilePreferenceControllerTest {
|
||||
return preference;
|
||||
}
|
||||
|
||||
private ResolveInfo createFakeInfo(String name) {
|
||||
final ResolveInfo info = new ResolveInfo();
|
||||
info.serviceInfo = new FakeServiceInfo();
|
||||
info.serviceInfo.name = name;
|
||||
info.serviceInfo.icon = R.drawable.ic_settings_24dp;
|
||||
info.serviceInfo.packageName = mContext.getPackageName();
|
||||
return info;
|
||||
}
|
||||
|
||||
private Bundle createFlagMetadata(String flag) {
|
||||
Bundle metaData = new Bundle();
|
||||
metaData.putString(DevelopmentTiles.META_DATA_REQUIRES_SYSTEM_PROPERTY, flag);
|
||||
return metaData;
|
||||
}
|
||||
|
||||
private static class FakeServiceInfo extends ServiceInfo {
|
||||
|
||||
public String loadLabel(PackageManager mgr) {
|
||||
|
Reference in New Issue
Block a user