Merge "Apply satellite feature flag to Settings activity" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cf13dfb..bcf6474 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5164,8 +5164,8 @@
<string name="accessibility_hearingaid_instruction_continue_button">Continue</string>
<!-- Title for the accessibility preference for hearing devices. [CHAR LIMIT=35] -->
<string name="accessibility_hearingaid_title">Hearing devices</string>
- <!-- Introduction for the Hearing devices page to introduce feature. [CHAR LIMIT=NONE] -->
- <string name="accessibility_hearingaid_intro">You can use hearing aids, cochlear implants, and other amplification devices with your phone</string>
+ <!-- Introduction for the Hearing devices page to introduce feature. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=5856992709195963850] -->
+ <string name="accessibility_hearingaid_intro">Set up and manage ASHA and LE Audio hearing aids, cochlear implants, and other amplification devices</string>
<!-- Summary for the accessibility preference for hearing aid when not connected. [CHAR LIMIT=50] -->
<string name="accessibility_hearingaid_not_connected_summary">No hearing devices connected</string>
<!-- Summary for the accessibility preference for hearing aid when adding new devices. [CHAR LIMIT=50] -->
@@ -5200,6 +5200,8 @@
<string name="accessibility_hac_mode_summary">Improves compatibility with telecoils and reduces unwanted noise</string>
<!-- Title for accessibility hearing device page footer. [CHAR LIMIT=40] -->
<string name="accessibility_hearing_device_about_title">About hearing devices</string>
+ <!-- Description for text in accessibility hearing aids footer. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=7451899224828040581] -->
+ <string name="accessibility_hearing_device_footer_summary">To find other hearing devices that aren’t supported by ASHA or LE Audio, tap <b>Pair new device</b> > <b>See more devices</b></string>
<!-- Title for the pair hearing device page. [CHAR LIMIT=25] -->
<string name="accessibility_hearing_device_pairing_page_title">Pair hearing device</string>
<!-- Subtitle for the pair hearing device page. [CHAR LIMIT=NONE] -->
diff --git a/res/xml/accessibility_hearing_aids.xml b/res/xml/accessibility_hearing_aids.xml
index 27a4212..57a0fe2 100644
--- a/res/xml/accessibility_hearing_aids.xml
+++ b/res/xml/accessibility_hearing_aids.xml
@@ -60,4 +60,11 @@
settings:searchable="true"
settings:controller="com.android.settings.accessibility.HearingAidCompatibilityPreferenceController"/>
</PreferenceCategory>
+
+ <com.android.settings.accessibility.AccessibilityFooterPreference
+ android:key="hearing_device_footer"
+ android:title="@string/accessibility_hearing_device_footer_summary"
+ android:selectable="false"
+ settings:searchable="false"
+ settings:controller="com.android.settings.accessibility.HearingDeviceFooterPreferenceController"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/hearing_device_pairing_fragment.xml b/res/xml/hearing_device_pairing_fragment.xml
index ce7f39f..d84f22b 100644
--- a/res/xml/hearing_device_pairing_fragment.xml
+++ b/res/xml/hearing_device_pairing_fragment.xml
@@ -38,5 +38,4 @@
settings:useAdminDisabledSummary="true"
settings:controller="com.android.settings.accessibility.ViewAllBluetoothDevicesPreferenceController"/>
</PreferenceCategory>
-
</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/network/SimOnboardingActivity.kt b/src/com/android/settings/network/SimOnboardingActivity.kt
index 6347d7b..98bb5d7 100644
--- a/src/com/android/settings/network/SimOnboardingActivity.kt
+++ b/src/com/android/settings/network/SimOnboardingActivity.kt
@@ -45,6 +45,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@@ -63,7 +64,10 @@
import com.android.settingslib.spa.SpaBaseDialogActivity
import com.android.settingslib.spa.framework.theme.SettingsDimension
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
+import com.android.settingslib.spa.widget.dialog.AlertDialogButton
import com.android.settingslib.spa.widget.dialog.getDialogWidth
+import com.android.settingslib.spa.widget.dialog.rememberAlertDialogPresenter
+import com.android.settingslib.spa.widget.editor.SettingsOutlinedTextField
import com.android.settingslib.spa.widget.ui.SettingsTitle
import com.android.settingslib.spaprivileged.framework.common.userManager
import kotlinx.coroutines.CoroutineScope
@@ -77,7 +81,7 @@
class SimOnboardingActivity : SpaBaseDialogActivity() {
lateinit var scope: CoroutineScope
lateinit var showBottomSheet: MutableState<Boolean>
- lateinit var showError: MutableState<Boolean>
+ lateinit var showError: MutableState<ErrorType>
lateinit var showProgressDialog: MutableState<Boolean>
private var switchToEuiccSubscriptionSidecar: SwitchToEuiccSubscriptionSidecar? = null
@@ -102,7 +106,7 @@
if (onboardingService.activeSubInfoList.isEmpty()) {
// TODO: refactor and replace the ToggleSubscriptionDialogActivity
- Log.e(TAG, "onboardingService.activeSubInfoList is empty" +
+ Log.d(TAG, "onboardingService.activeSubInfoList is empty" +
", start ToggleSubscriptionDialogActivity")
this.startActivity(ToggleSubscriptionDialogActivity
.getIntent(this.applicationContext, targetSubId, true))
@@ -113,10 +117,6 @@
switchToEuiccSubscriptionSidecar = SwitchToEuiccSubscriptionSidecar.get(fragmentManager)
switchToRemovableSlotSidecar = SwitchToRemovableSlotSidecar.get(fragmentManager)
enableMultiSimSidecar = EnableMultiSimSidecar.get(fragmentManager)
-
- setContent {
- Content()
- }
}
override fun finish() {
@@ -125,15 +125,14 @@
super.finish()
}
- var callbackListener: (Int) -> Unit = {
+ var callbackListener: (CallbackType) -> Unit = {
Log.d(TAG, "Receive the CALLBACK: $it")
when (it) {
- CALLBACK_ERROR -> {
+ CallbackType.CALLBACK_ERROR -> {
setProgressDialog(false)
- showError.value = true
}
- CALLBACK_ONBOARDING_COMPLETE -> {
+ CallbackType.CALLBACK_ONBOARDING_COMPLETE -> {
showBottomSheet.value = false
setProgressDialog(true)
scope.launch {
@@ -143,19 +142,19 @@
}
}
- CALLBACK_SETUP_NAME -> {
+ CallbackType.CALLBACK_SETUP_NAME -> {
scope.launch {
onboardingService.startSetupName()
}
}
- CALLBACK_SETUP_PRIMARY_SIM -> {
+ CallbackType.CALLBACK_SETUP_PRIMARY_SIM -> {
scope.launch {
onboardingService.startSetupPrimarySim(this@SimOnboardingActivity)
}
}
- CALLBACK_FINISH -> {
+ CallbackType.CALLBACK_FINISH -> {
finish()
}
}
@@ -178,16 +177,14 @@
@Composable
override fun Content() {
showBottomSheet = remember { mutableStateOf(false) }
- showError = remember { mutableStateOf(false) }
+ showError = remember { mutableStateOf(ErrorType.ERROR_NONE) }
showProgressDialog = remember { mutableStateOf(false) }
scope = rememberCoroutineScope()
registerSidecarReceiverFlow()
- if(showError.value){
- // show error
- return
- }
+ ErrorDialogImpl()
+
LaunchedEffect(Unit) {
if (onboardingService.activeSubInfoList.isNotEmpty()) {
showBottomSheet.value = true
@@ -255,6 +252,56 @@
}
@Composable
+ fun ErrorDialogImpl(){
+ // EuiccSlotSidecar showErrorDialog
+ val errorDialogPresenterForEuiccSlotSidecar = rememberAlertDialogPresenter(
+ confirmButton = AlertDialogButton(
+ stringResource(android.R.string.ok)
+ ) {
+ finish()
+ },
+ title = stringResource(R.string.privileged_action_disable_fail_title),
+ text = {
+ Text(stringResource(R.string.privileged_action_disable_fail_text))
+ },
+ )
+
+ // RemovableSlotSidecar showErrorDialog
+ val errorDialogPresenterForRemovableSlotSidecar = rememberAlertDialogPresenter(
+ confirmButton = AlertDialogButton(
+ stringResource(android.R.string.ok)
+ ) {
+ finish()
+ },
+ title = stringResource(R.string.sim_action_enable_sim_fail_title),
+ text = {
+ Text(stringResource(R.string.sim_action_enable_sim_fail_text))
+ },
+ )
+
+ // enableDSDS showErrorDialog
+ val errorDialogPresenterForMultiSimSidecar = rememberAlertDialogPresenter(
+ confirmButton = AlertDialogButton(
+ stringResource(android.R.string.ok)
+ ) {
+ finish()
+ },
+ title = stringResource(R.string.dsds_activation_failure_title),
+ text = {
+ Text(stringResource(R.string.dsds_activation_failure_body_msg2))
+ },
+ )
+
+ // show error
+ when (showError.value) {
+ ErrorType.ERROR_EUICC_SLOT -> errorDialogPresenterForEuiccSlotSidecar.open()
+ ErrorType.ERROR_REMOVABLE_SLOT -> errorDialogPresenterForRemovableSlotSidecar.open()
+ ErrorType.ERROR_ENABLE_DSDS -> errorDialogPresenterForMultiSimSidecar.open()
+ else -> {}
+ }
+ }
+
+ @Composable
fun registerSidecarReceiverFlow(){
switchToEuiccSubscriptionSidecar?.sidecarReceiverFlow()
?.collectLatestWithLifecycle(LocalLifecycleOwner.current) {
@@ -321,13 +368,14 @@
SidecarFragment.State.SUCCESS -> {
Log.i(TAG, "Successfully enable the eSIM profile.")
switchToEuiccSubscriptionSidecar!!.reset()
- callbackListener(CALLBACK_SETUP_NAME)
+ callbackListener(CallbackType.CALLBACK_SETUP_NAME)
}
SidecarFragment.State.ERROR -> {
Log.i(TAG, "Failed to enable the eSIM profile.")
switchToEuiccSubscriptionSidecar!!.reset()
- callbackListener(CALLBACK_ERROR)
+ showError.value = ErrorType.ERROR_EUICC_SLOT
+ callbackListener(CallbackType.CALLBACK_ERROR)
// TODO: showErrorDialog and using privileged_action_disable_fail_title and
// privileged_action_disable_fail_text
}
@@ -340,13 +388,14 @@
Log.i(TAG, "Successfully switched to removable slot.")
switchToRemovableSlotSidecar!!.reset()
onboardingService.handleTogglePsimAction()
- callbackListener(CALLBACK_SETUP_NAME)
+ callbackListener(CallbackType.CALLBACK_SETUP_NAME)
}
SidecarFragment.State.ERROR -> {
Log.e(TAG, "Failed switching to removable slot.")
switchToRemovableSlotSidecar!!.reset()
- callbackListener(CALLBACK_ERROR)
+ showError.value = ErrorType.ERROR_REMOVABLE_SLOT
+ callbackListener(CallbackType.CALLBACK_ERROR)
// TODO: showErrorDialog and using sim_action_enable_sim_fail_title and
// sim_action_enable_sim_fail_text
}
@@ -364,7 +413,8 @@
SidecarFragment.State.ERROR -> {
enableMultiSimSidecar!!.reset()
Log.i(TAG, "Failed to switch to DSDS without rebooting.")
- callbackListener(CALLBACK_ERROR)
+ showError.value = ErrorType.ERROR_ENABLE_DSDS
+ callbackListener(CallbackType.CALLBACK_ERROR)
// TODO: showErrorDialog and using dsds_activation_failure_title and
// dsds_activation_failure_body_msg2
}
@@ -387,7 +437,7 @@
}
Log.i(TAG, "DSDS enabled, start to enable pSIM profile.")
onboardingService.handleTogglePsimAction()
- callbackListener(CALLBACK_FINISH)
+ callbackListener(CallbackType.CALLBACK_FINISH)
}
@Composable
@@ -443,7 +493,7 @@
Log.i(TAG, "setProgressState:$state")
}
- fun initServiceData(context: Context,targetSubId: Int, callback:(Int)->Unit) {
+ fun initServiceData(context: Context,targetSubId: Int, callback:(CallbackType)->Unit) {
onboardingService.initData(targetSubId, context,callback)
}
@@ -462,10 +512,20 @@
var onboardingService:SimOnboardingService = SimOnboardingService()
const val TAG = "SimOnboardingActivity"
const val SUB_ID = "sub_id"
- const val CALLBACK_ERROR = -1
- const val CALLBACK_ONBOARDING_COMPLETE = 1
- const val CALLBACK_SETUP_NAME = 2
- const val CALLBACK_SETUP_PRIMARY_SIM = 3
- const val CALLBACK_FINISH = 4
+
+ enum class ErrorType(val value:Int){
+ ERROR_NONE(-1),
+ ERROR_EUICC_SLOT(1),
+ ERROR_REMOVABLE_SLOT(2),
+ ERROR_ENABLE_DSDS(3)
+ }
+
+ enum class CallbackType(val value:Int){
+ CALLBACK_ERROR(-1),
+ CALLBACK_ONBOARDING_COMPLETE(1),
+ CALLBACK_SETUP_NAME(2),
+ CALLBACK_SETUP_PRIMARY_SIM(3),
+ CALLBACK_FINISH(4)
+ }
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/network/SimOnboardingService.kt b/src/com/android/settings/network/SimOnboardingService.kt
index 5387ad4..962741f 100644
--- a/src/com/android/settings/network/SimOnboardingService.kt
+++ b/src/com/android/settings/network/SimOnboardingService.kt
@@ -23,6 +23,7 @@
import android.telephony.UiccCardInfo
import android.telephony.UiccSlotInfo
import android.util.Log
+import com.android.settings.network.SimOnboardingActivity.Companion.CallbackType
import com.android.settings.spa.network.setAutomaticData
import com.android.settings.spa.network.setDefaultData
import com.android.settings.spa.network.setDefaultSms
@@ -31,7 +32,6 @@
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-
private const val TAG = "SimOnboardingService"
private const val INVALID = SubscriptionManager.INVALID_SUBSCRIPTION_ID
@@ -60,7 +60,7 @@
.map { it.subscriptionId }
.firstOrNull() ?: SubscriptionManager.INVALID_SUBSCRIPTION_ID
}
- var callback: (Int) -> Unit = {}
+ var callback: (CallbackType) -> Unit = {}
var isMultipleEnabledProfilesSupported: Boolean = false
get() {
@@ -135,7 +135,9 @@
userSelectedSubInfoList.clear()
}
- fun initData(inputTargetSubId:Int,context: Context, callback: (Int) -> Unit) {
+ fun initData(inputTargetSubId: Int,
+ context: Context,
+ callback: (CallbackType) -> Unit) {
this.callback = callback
targetSubId = inputTargetSubId
subscriptionManager = context.getSystemService(SubscriptionManager::class.java)
@@ -261,7 +263,7 @@
fun startActivatingSim(){
// TODO: start to activate sim
- callback(SimOnboardingActivity.CALLBACK_FINISH)
+ callback(CallbackType.CALLBACK_FINISH)
}
suspend fun startSetupName() {
@@ -273,7 +275,7 @@
)
}
// next action is SETUP_PRIMARY_SIM
- callback(SimOnboardingActivity.CALLBACK_SETUP_PRIMARY_SIM)
+ callback(CallbackType.CALLBACK_SETUP_PRIMARY_SIM)
}
}
@@ -302,7 +304,7 @@
}
// no next action, send finish
- callback(SimOnboardingActivity.CALLBACK_FINISH)
+ callback(CallbackType.CALLBACK_FINISH)
}
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/notification/MediaVolumePreferenceController.java b/src/com/android/settings/notification/MediaVolumePreferenceController.java
index 79df55a..e70cf95 100644
--- a/src/com/android/settings/notification/MediaVolumePreferenceController.java
+++ b/src/com/android/settings/notification/MediaVolumePreferenceController.java
@@ -37,6 +37,7 @@
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.flags.Flags;
import com.android.settingslib.media.BluetoothMediaDevice;
import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputConstants;
@@ -94,7 +95,9 @@
@VisibleForTesting
boolean isSupportEndItem() {
- return getWorker() != null && getWorker().isBroadcastSupported()
+ return Flags.legacyLeAudioSharing()
+ && getWorker() != null
+ && getWorker().isBroadcastSupported()
&& (getWorker().isDeviceBroadcasting() || isConnectedBLEDevice());
}
@@ -114,8 +117,9 @@
if (mPreference != null) {
if (mPreference.isMuted()) {
mPreference.updateContentDescription(
- mContext.getString(R.string.volume_content_description_silent_mode,
- mPreference.getTitle()));
+ mContext.getString(
+ R.string.volume_content_description_silent_mode,
+ mPreference.getTitle()));
} else {
mPreference.updateContentDescription(mPreference.getTitle());
}
@@ -134,11 +138,16 @@
if (getWorker().isDeviceBroadcasting()) {
intent.setPackage(MediaOutputConstants.SYSTEMUI_PACKAGE_NAME);
intent.setAction(MediaOutputConstants.ACTION_LAUNCH_MEDIA_OUTPUT_BROADCAST_DIALOG);
- intent.putExtra(MediaOutputConstants.EXTRA_PACKAGE_NAME,
+ intent.putExtra(
+ MediaOutputConstants.EXTRA_PACKAGE_NAME,
getWorker().getActiveLocalMediaController().getPackageName());
- pi = PendingIntent.getBroadcast(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+ pi =
+ PendingIntent.getBroadcast(
+ context,
+ 0 /* requestCode */,
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
final CachedBluetoothDevice bluetoothDevice =
((BluetoothMediaDevice) mMediaDevice).getCachedDevice();
@@ -147,15 +156,21 @@
return null;
}
intent.setAction(ACTION_LAUNCH_BROADCAST_DIALOG);
- intent.putExtra(BluetoothBroadcastDialog.KEY_APP_LABEL,
+ intent.putExtra(
+ BluetoothBroadcastDialog.KEY_APP_LABEL,
Utils.getApplicationLabel(mContext, getWorker().getPackageName()));
- intent.putExtra(BluetoothBroadcastDialog.KEY_DEVICE_ADDRESS,
- bluetoothDevice.getAddress());
- intent.putExtra(BluetoothBroadcastDialog.KEY_MEDIA_STREAMING, getWorker() != null
- && getWorker().getActiveLocalMediaController() != null);
+ intent.putExtra(
+ BluetoothBroadcastDialog.KEY_DEVICE_ADDRESS, bluetoothDevice.getAddress());
+ intent.putExtra(
+ BluetoothBroadcastDialog.KEY_MEDIA_STREAMING,
+ getWorker() != null && getWorker().getActiveLocalMediaController() != null);
- pi = PendingIntent.getActivity(context, 0 /* requestCode */, intent,
- PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+ pi =
+ PendingIntent.getActivity(
+ context,
+ 0 /* requestCode */,
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
final IconCompat icon = getBroadcastIcon(context);
@@ -164,8 +179,8 @@
}
private IconCompat getBroadcastIcon(Context context) {
- final Drawable drawable = context.getDrawable(
- com.android.settingslib.R.drawable.settings_input_antenna);
+ final Drawable drawable =
+ context.getDrawable(com.android.settingslib.R.drawable.settings_input_antenna);
if (drawable != null) {
drawable.setTint(Utils.getColorAccentDefaultColor(context));
return Utils.createIconWithDrawable(drawable);
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index 4544e73..8840994 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -136,9 +136,7 @@
}
if (Flags.isDualSimOnboardingEnabled()
- && getProgressState() == SubscriptionActionDialogActivity.PROGRESS_IS_SHOWING
- && (dialogType == PREFERRED_PICK
- || dialogType == DATA_PICK
+ && (dialogType == DATA_PICK
|| dialogType == CALLS_PICK
|| dialogType == SMS_PICK)) {
Log.d(TAG, "Finish the sim dialog since the sim onboarding is shown");
diff --git a/src/com/android/settings/spa/network/SimOnboardingPageProvider.kt b/src/com/android/settings/spa/network/SimOnboardingPageProvider.kt
index cc17f93..838154f 100644
--- a/src/com/android/settings/spa/network/SimOnboardingPageProvider.kt
+++ b/src/com/android/settings/spa/network/SimOnboardingPageProvider.kt
@@ -34,6 +34,7 @@
import androidx.navigation.navArgument
import com.android.settings.R
import com.android.settings.network.SimOnboardingActivity
+import com.android.settings.network.SimOnboardingActivity.Companion.CallbackType
import com.android.settings.network.SimOnboardingService
import com.android.settingslib.spa.framework.common.SettingsEntryBuilder
import com.android.settingslib.spa.framework.common.SettingsPageProvider
@@ -93,7 +94,7 @@
val context = LocalContext.current
var finishOnboarding: () -> Unit = {
context.getActivity()?.finish()
- onboardingService.callback(SimOnboardingActivity.CALLBACK_FINISH)
+ onboardingService.callback(CallbackType.CALLBACK_FINISH)
}
NavHost(
@@ -120,7 +121,7 @@
composable(route = SimOnboardingScreen.PrimarySim.name) {
SimOnboardingPrimarySimImpl(
nextAction = {
- onboardingService.callback(SimOnboardingActivity.CALLBACK_ONBOARDING_COMPLETE)
+ onboardingService.callback(CallbackType.CALLBACK_ONBOARDING_COMPLETE)
context.getActivity()?.finish()
},
cancelAction = finishOnboarding,
diff --git a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
index ed93473..a25f472 100644
--- a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
@@ -31,17 +31,23 @@
import android.media.AudioManager;
import android.media.session.MediaController;
import android.net.Uri;
+import android.platform.test.annotations.RequiresFlagsDisabled;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import androidx.slice.builders.SliceAction;
import com.android.settings.media.MediaOutputIndicatorWorker;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.flags.Flags;
import com.android.settingslib.media.BluetoothMediaDevice;
import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputConstants;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -60,16 +66,16 @@
"android.settings.MEDIA_BROADCAST_DIALOG";
private static MediaOutputIndicatorWorker sMediaOutputIndicatorWorker;
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
private MediaVolumePreferenceController mController;
private Context mContext;
- @Mock
- private MediaController mMediaController;
- @Mock
- private MediaDevice mDevice1;
- @Mock
- private MediaDevice mDevice2;
+ @Mock private MediaController mMediaController;
+ @Mock private MediaDevice mDevice1;
+ @Mock private MediaDevice mDevice2;
@Before
public void setUp() {
@@ -77,8 +83,8 @@
mContext = RuntimeEnvironment.application;
mController = new MediaVolumePreferenceController(mContext);
- sMediaOutputIndicatorWorker = spy(
- new MediaOutputIndicatorWorker(mContext, VOLUME_MEDIA_URI));
+ sMediaOutputIndicatorWorker =
+ spy(new MediaOutputIndicatorWorker(mContext, VOLUME_MEDIA_URI));
when(mDevice1.isBLEDevice()).thenReturn(true);
when(mDevice2.isBLEDevice()).thenReturn(false);
}
@@ -101,8 +107,8 @@
@Test
public void isSliceableCorrectKey_returnsTrue() {
- final MediaVolumePreferenceController controller = new MediaVolumePreferenceController(
- mContext);
+ final MediaVolumePreferenceController controller =
+ new MediaVolumePreferenceController(mContext);
assertThat(controller.isSliceable()).isTrue();
}
@@ -112,6 +118,17 @@
}
@Test
+ @RequiresFlagsDisabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
+ public void isSupportEndItem_flagOff_returnsFalse() {
+ doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
+ doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
+ doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
+
+ assertThat(mController.isSupportEndItem()).isFalse();
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void isSupportEndItem_withBleDevice_returnsTrue() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
@@ -121,6 +138,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void isSupportEndItem_notSupportedBroadcast_returnsFalse() {
doReturn(false).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
@@ -129,6 +147,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void isSupportEndItem_withNonBleDevice_returnsFalse() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
@@ -138,6 +157,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void isSupportEndItem_deviceIsBroadcastingAndConnectedToNonBleDevice_returnsTrue() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
@@ -147,6 +167,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void isSupportEndItem_deviceIsNotBroadcastingAndConnectedToNonBleDevice_returnsFalse() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
@@ -155,8 +176,20 @@
assertThat(mController.isSupportEndItem()).isFalse();
}
+ @Test
+ @RequiresFlagsDisabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
+ public void getSliceEndItem_flagOff_getsNullSliceAction() {
+ doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
+ doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
+ doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
+
+ final SliceAction sliceAction = mController.getSliceEndItem(mContext);
+
+ assertThat(sliceAction).isNull();
+ }
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void getSliceEndItem_NotSupportEndItem_getsNullSliceAction() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
@@ -168,22 +201,26 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void getSliceEndItem_deviceIsBroadcasting_getsBroadcastIntent() {
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
- doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
+ doReturn(mMediaController)
+ .when(sMediaOutputIndicatorWorker)
.getActiveLocalMediaController();
final SliceAction sliceAction = mController.getSliceEndItem(mContext);
final PendingIntent endItemPendingIntent = sliceAction.getAction();
- final PendingIntent expectedToggleIntent = getBroadcastIntent(
- MediaOutputConstants.ACTION_LAUNCH_MEDIA_OUTPUT_BROADCAST_DIALOG);
+ final PendingIntent expectedToggleIntent =
+ getBroadcastIntent(
+ MediaOutputConstants.ACTION_LAUNCH_MEDIA_OUTPUT_BROADCAST_DIALOG);
assertThat(endItemPendingIntent).isEqualTo(expectedToggleIntent);
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_LEGACY_LE_AUDIO_SHARING)
public void getSliceEndItem_deviceIsNotBroadcasting_getsActivityIntent() {
final MediaDevice device = mock(BluetoothMediaDevice.class);
final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
@@ -192,7 +229,8 @@
doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
doReturn(device).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
- doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
+ doReturn(mMediaController)
+ .when(sMediaOutputIndicatorWorker)
.getActiveLocalMediaController();
final SliceAction sliceAction = mController.getSliceEndItem(mContext);
@@ -215,13 +253,19 @@
private PendingIntent getBroadcastIntent(String action) {
final Intent intent = new Intent(action);
intent.setPackage(MediaOutputConstants.SYSTEMUI_PACKAGE_NAME);
- return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
+ return PendingIntent.getBroadcast(
+ mContext,
+ 0 /* requestCode */,
+ intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
private PendingIntent getActivityIntent(String action) {
final Intent intent = new Intent(action);
- return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent,
+ return PendingIntent.getActivity(
+ mContext,
+ 0 /* requestCode */,
+ intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
}
diff --git a/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java b/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
index d696342..4b05b91 100644
--- a/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
@@ -34,7 +34,6 @@
import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -44,7 +43,6 @@
import java.util.ArrayList;
import java.util.List;
-@Ignore("b/315133235")
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowUserManager.class, ShadowDevicePolicyManager.class})
public class RestrictedButtonTest {
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 35dc666..530517f 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -35,18 +35,19 @@
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowSettingsMediaPlayer;
import org.junit.Before;
-import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.androidx.fragment.FragmentController;
@@ -55,7 +56,8 @@
public class VideoPreferenceTest {
private static final int VIDEO_WIDTH = 100;
private static final int VIDEO_HEIGHT = 150;
-
+ @Rule
+ public final MockitoRule mMockitoRule = MockitoJUnit.rule();
private VideoPreference.AnimationController mAnimationController;
@Mock
private ImageView fakePreview;
@@ -68,9 +70,7 @@
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = RuntimeEnvironment.application;
+ mContext = ApplicationProvider.getApplicationContext();
mAnimationController = spy(
new MediaAnimationController(mContext, R.raw.sample_video));
mVideoPreference = new VideoPreference(mContext, null /* attrs */);
@@ -141,7 +141,6 @@
assertThat(mAnimationController.isPlaying()).isTrue();
}
- @Ignore("b/315133235")
@Test
@Config(qualifiers = "mcc999")
public void onViewVisible_createAnimationController() {