Merge "Reflect satellite api refactoring to Settings" into main
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 357818c..0e35fed 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -233,6 +233,26 @@
<!-- Bluetooth Settings -->
+ <!-- Bluetooth developer settings: Bluetooth LE Audio modes -->
+ <string-array name="bluetooth_leaudio_mode">
+ <!-- Do not translate. -->
+ <item>Disabled</item>
+ <!-- Do not translate. -->
+ <item>Unicast</item>
+ <!-- Do not translate. -->
+ <item>Unicast and Broadcast</item>
+ </string-array>
+
+ <!-- Values for Bluetooth LE Audio mode -->
+ <string-array name="bluetooth_leaudio_mode_values" translatable="false">
+ <!-- Do not translate. -->
+ <item>disabled</item>
+ <!-- Do not translate. -->
+ <item>unicast</item>
+ <!-- Do not translate. -->
+ <item>broadcast</item>
+ </string-array>
+
<!-- Bluetooth developer settings: Titles for maximum number of connected audio devices -->
<string-array name="bluetooth_max_connected_audio_devices">
<item>Use System Default: <xliff:g id="default_bluetooth_max_connected_audio_devices">%1$d</xliff:g></item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 491d58f..b760f68 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -249,7 +249,8 @@
<string name="bluetooth_disable_leaudio">Disable Bluetooth LE audio</string>
<!-- Summary of toggle for disabling Bluetooth LE audio [CHAR LIMIT=none]-->
<string name="bluetooth_disable_leaudio_summary">Disables Bluetooth LE audio feature if the device supports LE audio hardware capabilities.</string>
-
+ <!-- Setting toggle title for switch Bluetooth LE Audio mode. [CHAR LIMIT=40] -->
+ <string name="bluetooth_leaudio_mode">Bluetooth LE Audio mode</string>
<!-- Setting toggle title for enabling Bluetooth LE Audio toggle in Device Details. [CHAR LIMIT=40] -->
<string name="bluetooth_show_leaudio_device_details">Show LE audio toggle in Device Details</string>
@@ -9623,10 +9624,6 @@
<string name="permit_voice_activation_apps">Allow voice activation</string>
<!-- Description for a setting which controls whether an app can be voice activated [CHAR LIMIT=NONE] -->
<string name ="allow_voice_activation_apps_description">Voice activation turns-on approved apps, hands-free, using voice command. Built-in adaptive sensing ensures data stays private only to you.\n\n<a href="">More about protected adaptive sensing</a></string>
- <!-- Label for a setting which controls whether an app can receive sandboxed detection training data [CHAR LIMIT=NONE] -->
- <string name = "permit_receive_sandboxed_detection_training_data">Improve voice activation</string>
- <!-- Description for a setting which controls whether an app can receive sandboxed detection training data [CHAR LIMIT=NONE] -->
- <string name= "receive_sandboxed_detection_training_data_description">This device uses private intelligence to improve the voice activation model. Apps can receive summarized updates that are aggregated across many users to maintain privacy while improving the model for everyone.\n\n<a href="">More about private intelligence</a></string>
<!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
<string name="full_screen_intent_title">Full screen notifications</string>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index d44927f..fb5e280 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -373,6 +373,13 @@
android:title="@string/bluetooth_disable_leaudio"
android:summary="@string/bluetooth_disable_leaudio_summary" />
+ <ListPreference
+ android:key="bluetooth_leaudio_mode"
+ android:title="@string/bluetooth_leaudio_mode"
+ android:summary="@string/summary_placeholder"
+ android:entries="@array/bluetooth_leaudio_mode"
+ android:entryValues="@array/bluetooth_leaudio_mode_values"/>
+
<SwitchPreferenceCompat
android:key="bluetooth_show_leaudio_device_details"
android:title="@string/bluetooth_show_leaudio_device_details"/>
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 2023299..2f04b62 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -20,6 +20,7 @@
import android.app.Activity;
import android.app.Dialog;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -656,7 +657,11 @@
CombinedProviderInfo.createSettingsActivityIntent(
mContext, packageName, settingsActivity, getUser());
if (settingsIntent != null) {
- mContext.startActivity(settingsIntent);
+ try {
+ mContext.startActivity(settingsIntent);
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Failed to open settings activity", e);
+ }
}
}
});
diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
index d2400bb..0fb1769 100644
--- a/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.applications.credentials;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.credentials.CredentialManager;
@@ -26,6 +27,7 @@
import android.service.autofill.AutofillService;
import android.service.autofill.AutofillServiceInfo;
import android.view.autofill.AutofillManager;
+import android.util.Slog;
import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
@@ -132,7 +134,11 @@
new PrimaryProviderPreference.Delegate() {
public void onOpenButtonClicked() {
if (settingsActivityIntent != null) {
- startActivity(settingsActivityIntent);
+ try {
+ startActivity(settingsActivityIntent);
+ } catch (ActivityNotFoundException e) {
+ Slog.e(TAG, "Failed to open settings activity", e);
+ }
}
}
diff --git a/src/com/android/settings/development/BluetoothLeAudioModePreferenceController.java b/src/com/android/settings/development/BluetoothLeAudioModePreferenceController.java
new file mode 100644
index 0000000..06cfe65
--- /dev/null
+++ b/src/com/android/settings/development/BluetoothLeAudioModePreferenceController.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2024 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.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.BluetoothStatusCodes;
+import android.content.Context;
+import android.os.SystemProperties;
+import android.sysprop.BluetoothProperties;
+import android.text.TextUtils;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+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;
+
+
+/**
+ * Preference controller to control Bluetooth LE audio mode
+ */
+public class BluetoothLeAudioModePreferenceController
+ extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ private static final String PREFERENCE_KEY = "bluetooth_leaudio_mode";
+
+ static final String LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY =
+ "persist.bluetooth.leaudio_dynamic_switcher.mode";
+
+ @Nullable private final DevelopmentSettingsDashboardFragment mFragment;
+
+ private final String[] mListValues;
+ private final String[] mListSummaries;
+ @VisibleForTesting
+ @Nullable String mNewMode;
+ @VisibleForTesting
+ BluetoothAdapter mBluetoothAdapter;
+
+ boolean mChanged = false;
+
+ public BluetoothLeAudioModePreferenceController(@NonNull Context context,
+ @Nullable DevelopmentSettingsDashboardFragment fragment) {
+ super(context);
+ mFragment = fragment;
+ mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
+
+ mListValues = context.getResources().getStringArray(R.array.bluetooth_leaudio_mode_values);
+ mListSummaries = context.getResources().getStringArray(R.array.bluetooth_leaudio_mode);
+ }
+
+ @Override
+ @NonNull public String getPreferenceKey() {
+ return PREFERENCE_KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
+ }
+
+ @Override
+ public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
+ if (mFragment == null) {
+ return false;
+ }
+
+ BluetoothRebootDialog.show(mFragment);
+ mChanged = true;
+ mNewMode = newValue.toString();
+ return false;
+ }
+
+ @Override
+ public void updateState(@NonNull Preference preference) {
+ if (mBluetoothAdapter == null) {
+ return;
+ }
+
+ if (mBluetoothAdapter.isLeAudioBroadcastSourceSupported()
+ == BluetoothStatusCodes.FEATURE_SUPPORTED) {
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "broadcast");
+ } else if (mBluetoothAdapter.isLeAudioSupported()
+ == BluetoothStatusCodes.FEATURE_SUPPORTED) {
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "unicast");
+ } else {
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "disabled");
+ }
+
+ final String currentValue = SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY);
+ int index = 0;
+ for (int i = 0; i < mListValues.length; i++) {
+ if (TextUtils.equals(currentValue, mListValues[i])) {
+ index = i;
+ break;
+ }
+ }
+
+ final ListPreference listPreference = (ListPreference) preference;
+ listPreference.setValue(mListValues[index]);
+ listPreference.setSummary(mListSummaries[index]);
+ }
+
+ /**
+ * Called when the RebootDialog confirm is clicked.
+ */
+ public void onRebootDialogConfirmed() {
+ if (!mChanged) {
+ return;
+ }
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mNewMode);
+ }
+
+ /**
+ * Called when the RebootDialog cancel is clicked.
+ */
+ public void onRebootDialogCanceled() {
+ mChanged = false;
+ }
+}
diff --git a/src/com/android/settings/development/BluetoothLeAudioPreferenceController.java b/src/com/android/settings/development/BluetoothLeAudioPreferenceController.java
index f1b81b4..2a544f2 100644
--- a/src/com/android/settings/development/BluetoothLeAudioPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothLeAudioPreferenceController.java
@@ -21,6 +21,7 @@
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
+import android.sysprop.BluetoothProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -65,6 +66,12 @@
}
@Override
+ public boolean isAvailable() {
+ return BluetoothProperties.isProfileBapUnicastClientEnabled().orElse(false)
+ && !BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
+ }
+
+ @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
BluetoothRebootDialog.show(mFragment);
mChanged = true;
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 73567bc..504eda8 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -454,6 +454,11 @@
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogConfirmed();
+
+ final BluetoothLeAudioModePreferenceController leAudioModeController =
+ getDevelopmentOptionsController(
+ BluetoothLeAudioModePreferenceController.class);
+ leAudioModeController.onRebootDialogConfirmed();
}
@Override
@@ -471,6 +476,11 @@
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogCanceled();
+
+ final BluetoothLeAudioModePreferenceController leAudioModeController =
+ getDevelopmentOptionsController(
+ BluetoothLeAudioModePreferenceController.class);
+ leAudioModeController.onRebootDialogCanceled();
}
@Override
@@ -670,6 +680,7 @@
controllers.add(new BluetoothAvrcpVersionPreferenceController(context));
controllers.add(new BluetoothMapVersionPreferenceController(context));
controllers.add(new BluetoothLeAudioPreferenceController(context, fragment));
+ controllers.add(new BluetoothLeAudioModePreferenceController(context, fragment));
controllers.add(new BluetoothLeAudioDeviceDetailsPreferenceController(context));
controllers.add(new BluetoothLeAudioAllowListPreferenceController(context, fragment));
controllers.add(new BluetoothA2dpHwOffloadPreferenceController(context, fragment));
diff --git a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
index c40212b..c6b1bdb 100644
--- a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
+++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java
@@ -41,6 +41,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceScreen;
+import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityGestureNavigationTutorial;
import com.android.settings.core.SubSettingLauncher;
@@ -353,7 +354,7 @@
private boolean isAnyServiceSupportAccessibilityButton() {
final AccessibilityManager ams = getContext().getSystemService(AccessibilityManager.class);
final List<String> targets = ams.getAccessibilityShortcutTargets(
- AccessibilityManager.ACCESSIBILITY_BUTTON);
+ ShortcutConstants.UserShortcutType.SOFTWARE);
return !targets.isEmpty();
}
diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
index aafe493..1225806 100644
--- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
+++ b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
@@ -20,24 +20,12 @@
import android.app.AppOpsManager
import android.app.settings.SettingsEnums
import android.content.Context
-import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.livedata.observeAsState
-import androidx.compose.runtime.mutableStateOf
-import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
-import androidx.compose.ui.platform.LocalContext
import com.android.settings.R
import com.android.settings.overlay.FeatureFactory
-import com.android.settingslib.spa.widget.preference.SwitchPreference
-import com.android.settingslib.spa.widget.preference.SwitchPreferenceModel
-import com.android.settingslib.spaprivileged.model.app.AppOpsController
import com.android.settingslib.spaprivileged.model.app.PackageManagers.hasGrantPermission
import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel
import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord
import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
-import kotlinx.coroutines.Dispatchers
/**
* This class builds an App List under voice activation apps and the individual page which
@@ -56,97 +44,15 @@
override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO
override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
override val setModeByUid = true
- private var receiveDetectionTrainingDataOpController:AppOpsController? = null
+
override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) {
super.setAllowed(record, newAllowed)
- if (!newAllowed && receiveDetectionTrainingDataOpController != null) {
- receiveDetectionTrainingDataOpController!!.setAllowed(false)
- }
logPermissionChange(newAllowed)
}
override fun isChangeable(record: AppOpPermissionRecord): Boolean =
super.isChangeable(record) && record.app.hasGrantPermission(permission)
- @Composable
- override fun InfoPageAdditionalContent(
- record: AppOpPermissionRecord,
- isAllowed: () -> Boolean?,
- ) {
- SwitchPreference(createReceiveDetectionTrainingDataOpSwitchModel(record, isAllowed))
- }
-
- @Composable
- private fun createReceiveDetectionTrainingDataOpSwitchModel(
- record: AppOpPermissionRecord,
- isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean?
- ): ReceiveDetectionTrainingDataOpSwitchModel {
- val context = LocalContext.current
- receiveDetectionTrainingDataOpController = remember {
- AppOpsController(
- context = context,
- app = record.app,
- op = AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA,
- )
- }
- val isReceiveDetectionTrainingDataOpAllowed = isReceiveDetectionTrainingDataOpAllowed(record, receiveDetectionTrainingDataOpController!!)
-
- return remember(record) {
- ReceiveDetectionTrainingDataOpSwitchModel(
- context,
- record,
- isReceiveSandBoxTriggerAudioOpAllowed,
- receiveDetectionTrainingDataOpController!!,
- isReceiveDetectionTrainingDataOpAllowed,
- )
- }.also { model -> LaunchedEffect(model, Dispatchers.Default) { model.initState() } }
- }
-
- private inner class ReceiveDetectionTrainingDataOpSwitchModel(
- context: Context,
- private val record: AppOpPermissionRecord,
- isReceiveSandBoxTriggerAudioOpAllowed: () -> Boolean?,
- receiveDetectionTrainingDataOpController: AppOpsController,
- isReceiveDetectionTrainingDataOpAllowed: () -> Boolean?,
- ) : SwitchPreferenceModel {
- private var appChangeable by mutableStateOf(true)
-
- override val title: String = context.getString(R.string.permit_receive_sandboxed_detection_training_data)
- override val summary: () -> String = { context.getString(R.string.receive_sandboxed_detection_training_data_description) }
- override val checked = { isReceiveDetectionTrainingDataOpAllowed() == true && isReceiveSandBoxTriggerAudioOpAllowed() == true }
- override val changeable = { appChangeable && isReceiveSandBoxTriggerAudioOpAllowed() == true }
-
- fun initState() {
- appChangeable = isChangeable(record)
- }
-
- override val onCheckedChange: (Boolean) -> Unit = { newChecked ->
- receiveDetectionTrainingDataOpController.setAllowed(newChecked)
- }
- }
-
- @Composable
- private fun isReceiveDetectionTrainingDataOpAllowed(
- record: AppOpPermissionRecord,
- controller: AppOpsController
- ): () -> Boolean? {
- if (record.hasRequestBroaderPermission) {
- // Broader permission trumps the specific permission.
- return { true }
- }
-
- val mode = controller.mode.observeAsState()
- return {
- when (mode.value) {
- null -> null
- AppOpsManager.MODE_ALLOWED -> true
- AppOpsManager.MODE_DEFAULT -> record.app.hasGrantPermission(
- Manifest.permission.RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA)
- else -> false
- }
- }
- }
-
private fun logPermissionChange(newAllowed: Boolean) {
val category = when {
newAllowed -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_ALLOW
diff --git a/tests/robotests/src/com/android/settings/development/BluetoothLeAudioModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioModePreferenceControllerTest.java
new file mode 100644
index 0000000..f35fb17
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/BluetoothLeAudioModePreferenceControllerTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2022 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 com.android.settings.development.BluetoothLeAudioModePreferenceController
+ .LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
+import android.os.SystemProperties;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class BluetoothLeAudioModePreferenceControllerTest {
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private DevelopmentSettingsDashboardFragment mFragment;
+ @Mock
+ private BluetoothAdapter mBluetoothAdapter;
+ @Mock
+ private ListPreference mPreference;
+
+ private Context mContext;
+ private BluetoothLeAudioModePreferenceController mController;
+ private String[] mListValues;
+ private String[] mListSummaries;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mListValues = mContext.getResources().getStringArray(
+ R.array.bluetooth_leaudio_mode_values);
+ mListSummaries = mContext.getResources().getStringArray(
+ R.array.bluetooth_leaudio_mode);
+ mController = spy(new BluetoothLeAudioModePreferenceController(mContext, mFragment));
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.mBluetoothAdapter = mBluetoothAdapter;
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onRebootDialogConfirmed_changeLeAudioMode_shouldSetLeAudioMode() {
+ mController.mChanged = true;
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]);
+ mController.mNewMode = mListValues[1];
+
+ mController.onRebootDialogConfirmed();
+ assertThat(SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0])
+ .equals(mController.mNewMode)).isTrue();
+ }
+
+ @Test
+ public void onRebootDialogConfirmed_notChangeLeAudioMode_shouldNotSetLeAudioMode() {
+ mController.mChanged = false;
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]);
+ mController.mNewMode = mListValues[1];
+
+ mController.onRebootDialogConfirmed();
+ assertThat(SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0])
+ .equals(mController.mNewMode)).isFalse();
+ }
+
+ @Test
+ public void onRebootDialogCanceled_shouldNotSetLeAudioMode() {
+ mController.mChanged = true;
+ SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0]);
+ mController.mNewMode = mListValues[1];
+
+ mController.onRebootDialogCanceled();
+ assertThat(SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mListValues[0])
+ .equals(mController.mNewMode)).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
index d1cbd0e..886a4bc 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiDialogActivityTest.java
@@ -57,8 +57,10 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.LooperMode;
@RunWith(RobolectricTestRunner.class)
+@LooperMode(LooperMode.Mode.LEGACY)
public class WifiDialogActivityTest {
static final String CALLING_PACKAGE = "calling_package";