Merge "Add settings search synonyms for touchpad." into main
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 55ba8ac..949577b 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -32,6 +32,7 @@
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.pm.UserProperties;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@@ -156,12 +157,23 @@
mAdmins.clear();
final List<UserHandle> profiles = mUm.getUserProfiles();
for (UserHandle profile : profiles) {
+ if (shouldSkipProfile(profile)) {
+ continue;
+ }
final int profileId = profile.getIdentifier();
updateAvailableAdminsForProfile(profileId);
}
Collections.sort(mAdmins);
}
+ private boolean shouldSkipProfile(UserHandle profile) {
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
+ && mUm.isQuietModeEnabled(profile)
+ && mUm.getUserProperties(profile).getShowInQuietMode()
+ == UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
+ }
+
private void refreshUI() {
if (mPreferenceGroup == null) {
return;
diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
index 23ba4f6..8250f70 100644
--- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
@@ -23,7 +23,7 @@
import androidx.preference.Preference;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
-import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -72,6 +72,32 @@
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
Log.d(TAG, "isFilterMatched() current audio profile : " + currentAudioProfile);
+ // If device is LE Audio, it is compatible with HFP and A2DP.
+ // It would show in Available Devices group if the audio sharing flag is disabled or
+ // the device is not in the audio sharing session.
+ if (cachedDevice.isConnectedLeAudioDevice()) {
+ boolean isAudioSharingFilterMatched =
+ FeatureFactory.getFeatureFactory()
+ .getAudioSharingFeatureProvider()
+ .isAudioSharingFilterMatched(cachedDevice, mLocalManager);
+ if (!isAudioSharingFilterMatched) {
+ Log.d(
+ TAG,
+ "isFilterMatched() device : "
+ + cachedDevice.getName()
+ + ", the LE Audio profile is connected and not in sharing "
+ + "if broadcast enabled.");
+ return true;
+ } else {
+ Log.d(
+ TAG,
+ "Filter out device : "
+ + cachedDevice.getName()
+ + ", it is in audio sharing.");
+ return false;
+ }
+ }
+
// If device is Hearing Aid, it is compatible with HFP and A2DP.
// It would show in Available Devices group.
if (cachedDevice.isConnectedAshaHearingAidDevice()) {
@@ -82,20 +108,7 @@
+ ", the Hearing Aid profile is connected.");
return true;
}
- // If device is LE Audio, it is compatible with HFP and A2DP.
- // It would show in Available Devices group if the audio sharing flag is disabled or
- // the device is not in the audio sharing session.
- if (cachedDevice.isConnectedLeAudioDevice()) {
- if (!AudioSharingUtils.isFeatureEnabled()
- || !AudioSharingUtils.hasBroadcastSource(cachedDevice, mLocalManager)) {
- Log.d(
- TAG,
- "isFilterMatched() device : "
- + cachedDevice.getName()
- + ", the LE Audio profile is connected and not in sharing.");
- return true;
- }
- }
+
// According to the current audio profile type,
// this page will show the bluetooth device that have corresponding profile.
// For example:
@@ -125,13 +138,9 @@
mMetricsFeatureProvider.logClickedPreference(preference, mMetricsCategory);
final CachedBluetoothDevice device =
((BluetoothDevicePreference) preference).getBluetoothDevice();
- if (AudioSharingUtils.isFeatureEnabled()
- && AudioSharingUtils.isBroadcasting(mLocalBtManager)) {
- if (DBG) {
- Log.d(TAG, "onPreferenceClick stop broadcasting.");
- }
- AudioSharingUtils.stopBroadcasting(mLocalBtManager);
- }
+ FeatureFactory.getFeatureFactory()
+ .getAudioSharingFeatureProvider()
+ .handleMediaDeviceOnClick(mLocalManager);
return device.setActive();
}
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt
index 77a80b8..3224f94 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.kt
@@ -34,8 +34,10 @@
import androidx.preference.PreferenceGroup
import com.android.settings.R
import com.android.settings.dashboard.RestrictedDashboardFragment
+import com.android.settings.flags.Flags
import com.android.settingslib.bluetooth.BluetoothCallback
import com.android.settingslib.bluetooth.BluetoothDeviceFilter
+import com.android.settingslib.bluetooth.BluetoothUtils
import com.android.settingslib.bluetooth.CachedBluetoothDevice
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager
import com.android.settingslib.bluetooth.LocalBluetoothManager
@@ -217,6 +219,14 @@
)
return
}
+ if (Flags.enableHideExclusivelyManagedBluetoothDevice()) {
+ if (cachedDevice.device.bondState == BluetoothDevice.BOND_BONDED
+ && BluetoothUtils.isExclusivelyManagedBluetoothDevice(
+ prefContext, cachedDevice.device)) {
+ Log.d(TAG, "Trying to create preference for a exclusively managed device")
+ return
+ }
+ }
// Only add device preference when it's not found in the map and there's no other state
// message showing in the list
val preference = devicePreferenceMap.computeIfAbsent(cachedDevice) {
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index 27001d6..2798be4 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -22,12 +22,13 @@
import android.text.TextUtils;
import android.util.Log;
+import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.Lifecycle;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
-import com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController;
import com.android.settings.connecteddevice.audiosharing.AudioSharingUtils;
import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.dashboard.DashboardFragment;
@@ -36,8 +37,12 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.slices.SlicePreferenceController;
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
+import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
+import java.util.ArrayList;
+import java.util.List;
+
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class ConnectedDeviceDashboardFragment extends DashboardFragment {
@@ -87,9 +92,6 @@
+ ", action : "
+ action);
}
- if (AudioSharingUtils.isFeatureEnabled()) {
- use(AudioSharingDevicePreferenceController.class).init(this);
- }
use(AvailableMediaDeviceGroupController.class).init(this);
use(ConnectedDeviceGroupController.class).init(this);
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
@@ -112,6 +114,29 @@
}
}
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, /* fragment= */ this, getSettingsLifecycle());
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(
+ Context context,
+ @Nullable ConnectedDeviceDashboardFragment fragment,
+ @Nullable Lifecycle lifecycle) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ if (AudioSharingUtils.isFeatureEnabled()) {
+ AbstractPreferenceController audioSharingController =
+ FeatureFactory.getFeatureFactory()
+ .getAudioSharingFeatureProvider()
+ .createAudioSharingDevicePreferenceController(
+ context, fragment, lifecycle);
+ if (audioSharingController != null) {
+ controllers.add(audioSharingController);
+ }
+ }
+ return controllers;
+ }
+
@VisibleForTesting
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
return TextUtils.equals(SLICE_ACTION, action)
@@ -122,5 +147,12 @@
/** For Search. */
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.connected_devices);
+ new BaseSearchIndexProvider(R.xml.connected_devices) {
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(
+ Context context) {
+ return buildPreferenceControllers(
+ context, /* fragment= */ null, /* lifecycle= */ null);
+ }
+ };
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProvider.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProvider.java
new file mode 100644
index 0000000..c71a368
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProvider.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 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.connecteddevice.audiosharing;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.Lifecycle;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+/** Feature provider for the audio sharing related features, */
+public interface AudioSharingFeatureProvider {
+
+ /** Create audio sharing device preference controller. */
+ @Nullable
+ AbstractPreferenceController createAudioSharingDevicePreferenceController(
+ @NonNull Context context,
+ @Nullable DashboardFragment fragment,
+ @Nullable Lifecycle lifecycle);
+
+ /**
+ * Check if the device match the audio sharing filter.
+ *
+ * <p>The filter is used to filter device in "Media devices" section.
+ */
+ boolean isAudioSharingFilterMatched(
+ @NonNull CachedBluetoothDevice cachedDevice, LocalBluetoothManager localBtManager);
+
+ /** Handle preference onClick in "Media devices" section. */
+ void handleMediaDeviceOnClick(LocalBluetoothManager localBtManager);
+}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImpl.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImpl.java
new file mode 100644
index 0000000..05a6a63
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImpl.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 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.connecteddevice.audiosharing;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.Lifecycle;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+public class AudioSharingFeatureProviderImpl implements AudioSharingFeatureProvider {
+
+ @Nullable
+ @Override
+ public AbstractPreferenceController createAudioSharingDevicePreferenceController(
+ @NonNull Context context,
+ @Nullable DashboardFragment fragment,
+ @Nullable Lifecycle lifecycle) {
+ return null;
+ }
+
+ @Override
+ public boolean isAudioSharingFilterMatched(
+ @NonNull CachedBluetoothDevice cachedDevice, LocalBluetoothManager localBtManager) {
+ return false;
+ }
+
+ @Override
+ public void handleMediaDeviceOnClick(LocalBluetoothManager localBtManager) {}
+}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index b1ffcf1..887fc32 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -26,6 +26,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.content.pm.UserProperties;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.VpnManager;
@@ -220,6 +221,9 @@
public int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile() {
int activeAdmins = 0;
for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) {
+ if (shouldSkipProfile(userInfo)) {
+ continue;
+ }
final List<ComponentName> activeAdminsForUser
= mDpm.getActiveAdminsAsUser(userInfo.id);
if (activeAdminsForUser != null) {
@@ -250,6 +254,14 @@
return false;
}
+ private boolean shouldSkipProfile(UserInfo userInfo) {
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
+ && userInfo.isQuietModeEnabled()
+ && mUm.getUserProperties(userInfo.getUserHandle()).getShowInQuietMode()
+ == UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
+ }
+
private Intent getParentalControlsIntent() {
final ComponentName componentName =
mDpm.getProfileOwnerOrDeviceOwnerSupervisionComponent(new UserHandle(MY_USER_ID));
diff --git a/src/com/android/settings/network/SimOnboardingActivity.kt b/src/com/android/settings/network/SimOnboardingActivity.kt
index f5dc886..abeeb6c 100644
--- a/src/com/android/settings/network/SimOnboardingActivity.kt
+++ b/src/com/android/settings/network/SimOnboardingActivity.kt
@@ -22,19 +22,25 @@
import android.os.Bundle
import android.telephony.SubscriptionManager
import android.util.Log
-import android.view.MotionEvent
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SignalCellularAlt
+import androidx.compose.material3.AlertDialogDefaults
+import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.Button
+import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
+import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
@@ -58,6 +64,7 @@
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.getDialogWidth
import com.android.settingslib.spa.widget.ui.SettingsTitle
import com.android.settingslib.spaprivileged.framework.common.userManager
import kotlinx.coroutines.CoroutineScope
@@ -193,26 +200,43 @@
}
}
+ @OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProgressDialogImpl() {
- // TODO: 1. Create the SPA's ProgressDialog and using SPA's widget
- val dialog: ProgressDialog = object : ProgressDialog(this) {
- override fun onTouchEvent(event: MotionEvent): Boolean {
- return true
+ if(showDialog.value) {
+ // TODO: Create the SPA's ProgressDialog and using SPA's widget
+ BasicAlertDialog(
+ onDismissRequest = {},
+ modifier = Modifier.width(
+ getDialogWidth()
+ ),
+ ) {
+ Surface(
+ color = AlertDialogDefaults.containerColor,
+ shape = AlertDialogDefaults.shape
+ ) {
+ Row(
+ modifier = Modifier
+ .fillMaxWidth()
+ .padding(SettingsDimension.itemPaddingStart),
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ CircularProgressIndicator()
+ Column(modifier = Modifier
+ .padding(start = SettingsDimension.itemPaddingStart)) {
+ SettingsTitle(
+ stringResource(
+ R.string.sim_onboarding_progressbar_turning_sim_on,
+ onboardingService.targetSubInfo?.displayName ?: ""
+ )
+ )
+ }
+ }
+ }
}
}
- dialog.setMessage(
- stringResource(
- R.string.sim_onboarding_progressbar_turning_sim_on,
- onboardingService.targetSubInfo?.displayName ?: ""
- )
- )
- dialog.setCancelable(false)
-
- if(showDialog.value) {
- dialog.show()
- }
}
+
@Composable
fun registerSidecarReceiverFlow(){
switchToEuiccSubscriptionSidecar?.sidecarReceiverFlow()
diff --git a/src/com/android/settings/network/SimOnboardingService.kt b/src/com/android/settings/network/SimOnboardingService.kt
index 8679385..f33abf6 100644
--- a/src/com/android/settings/network/SimOnboardingService.kt
+++ b/src/com/android/settings/network/SimOnboardingService.kt
@@ -45,7 +45,6 @@
var activeSubInfoList: List<SubscriptionInfo> = listOf()
var slotInfoList: List<UiccSlotInfo> = listOf()
var uiccCardInfoList: List<UiccCardInfo> = listOf()
- var selectedSubInfoList: MutableList<SubscriptionInfo> = mutableListOf()
var targetPrimarySimCalls: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID
var targetPrimarySimTexts: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID
var targetPrimarySimMobileData: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID
@@ -56,10 +55,8 @@
Log.w(TAG, "No DDS")
return SubscriptionManager.INVALID_SUBSCRIPTION_ID
}
- return selectedSubInfoList
- .filter { info ->
- (info.simSlotIndex != -1) && (info.subscriptionId != targetPrimarySimMobileData)
- }
+ return userSelectedSubInfoList
+ .filter { info -> info.subscriptionId != targetPrimarySimMobileData }
.map { it.subscriptionId }
.firstOrNull() ?: SubscriptionManager.INVALID_SUBSCRIPTION_ID
}
@@ -118,7 +115,6 @@
&& targetSubInfo != null
&& activeSubInfoList.isNotEmpty()
&& slotInfoList.isNotEmpty()
- && selectedSubInfoList.isNotEmpty()
}
fun clear() {
@@ -128,7 +124,6 @@
activeSubInfoList = listOf()
slotInfoList = listOf()
uiccCardInfoList = listOf()
- selectedSubInfoList = mutableListOf()
targetPrimarySimCalls = -1
targetPrimarySimTexts = -1
targetPrimarySimMobileData = -1
@@ -151,7 +146,8 @@
ThreadUtils.postOnBackgroundThread {
activeSubInfoList = SubscriptionUtil.getActiveSubscriptions(subscriptionManager)
availableSubInfoList = SubscriptionUtil.getAvailableSubscriptions(context)
- targetSubInfo = availableSubInfoList.find { subInfo -> subInfo.subscriptionId == targetSubId }
+ targetSubInfo =
+ availableSubInfoList.find { subInfo -> subInfo.subscriptionId == targetSubId }
targetSubInfo?.let { userSelectedSubInfoList.add(it) }
Log.d(
TAG, "targetSubId: $targetSubId" + ", targetSubInfo: $targetSubInfo" +
@@ -186,7 +182,6 @@
targetSubInfo?.let { list.add(it) }
}
- Log.d(TAG, "list: $list")
return list.toList()
}
@@ -206,7 +201,10 @@
return
}
renameMutableMap[subInfo.subscriptionId] = newName
- Log.d(TAG, "renameMutableMap add ${subInfo.subscriptionId} & $newName into: $renameMutableMap")
+ Log.d(
+ TAG,
+ "renameMutableMap add ${subInfo.subscriptionId} & $newName into: $renameMutableMap"
+ )
}
fun getSubscriptionInfoDisplayName(subInfo: SubscriptionInfo): String {
@@ -278,11 +276,18 @@
targetPrimarySimMobileData
)
-
- val telephonyManagerForNonDds: TelephonyManager? =
- context.getSystemService(TelephonyManager::class.java)
- ?.createForSubscriptionId(targetNonDds)
- setAutomaticData(telephonyManagerForNonDds, targetPrimarySimAutoDataSwitch)
+ var nonDds = targetNonDds
+ Log.d(
+ TAG,
+ "setAutomaticData: targetNonDds: $nonDds," +
+ " targetPrimarySimAutoDataSwitch: $targetPrimarySimAutoDataSwitch"
+ )
+ if (nonDds != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ val telephonyManagerForNonDds: TelephonyManager? =
+ context.getSystemService(TelephonyManager::class.java)
+ ?.createForSubscriptionId(nonDds)
+ setAutomaticData(telephonyManagerForNonDds, targetPrimarySimAutoDataSwitch)
+ }
// no next action, send finish
callback(SimOnboardingActivity.CALLBACK_FINISH)
diff --git a/src/com/android/settings/overlay/FeatureFactory.kt b/src/com/android/settings/overlay/FeatureFactory.kt
index 37507a8..2c4a295 100644
--- a/src/com/android/settings/overlay/FeatureFactory.kt
+++ b/src/com/android/settings/overlay/FeatureFactory.kt
@@ -24,6 +24,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
import com.android.settings.dashboard.DashboardFeatureProvider
@@ -182,6 +183,11 @@
*/
abstract val displayFeatureProvider: DisplayFeatureProvider
+ /**
+ * Gets implementation for audio sharing related feature.
+ */
+ abstract val audioSharingFeatureProvider: AudioSharingFeatureProvider
+
companion object {
private var _factory: FeatureFactory? = null
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.kt b/src/com/android/settings/overlay/FeatureFactoryImpl.kt
index e0313b7..e1519b3 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.kt
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.kt
@@ -34,6 +34,8 @@
import com.android.settings.biometrics2.factory.BiometricsRepositoryProviderImpl
import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProviderImpl
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProviderImpl
@@ -192,7 +194,12 @@
override val privateSpaceLoginFeatureProvider: PrivateSpaceLoginFeatureProvider by lazy {
PrivateSpaceLoginFeatureProviderImpl()
}
+
override val displayFeatureProvider: DisplayFeatureProvider by lazy {
DisplayFeatureProviderImpl()
}
+
+ override val audioSharingFeatureProvider: AudioSharingFeatureProvider by lazy {
+ AudioSharingFeatureProviderImpl()
+ }
}
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index 0741ce4..b1d04d4 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -56,7 +56,7 @@
* @throws IllegalArgumentException when caller is null
* @throws SecurityException when caller is not allowed to launch search result page
*/
- void verifyLaunchSearchResultPageCaller(Context context, @NonNull ComponentName caller)
+ void verifyLaunchSearchResultPageCaller(@NonNull Context context, @NonNull String callerPackage)
throws SecurityException, IllegalArgumentException;
/**
diff --git a/src/com/android/settings/search/SearchFeatureProviderImpl.java b/src/com/android/settings/search/SearchFeatureProviderImpl.java
index 6f90970..3a62ddf 100644
--- a/src/com/android/settings/search/SearchFeatureProviderImpl.java
+++ b/src/com/android/settings/search/SearchFeatureProviderImpl.java
@@ -17,13 +17,14 @@
package com.android.settings.search;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+
import com.android.settingslib.search.SearchIndexableResources;
import com.android.settingslib.search.SearchIndexableResourcesMobile;
@@ -32,21 +33,18 @@
*/
public class SearchFeatureProviderImpl implements SearchFeatureProvider {
- private static final String TAG = "SearchFeatureProvider";
-
private SearchIndexableResources mSearchIndexableResources;
@Override
- public void verifyLaunchSearchResultPageCaller(Context context, ComponentName caller) {
- if (caller == null) {
+ public void verifyLaunchSearchResultPageCaller(@NonNull Context context,
+ @NonNull String callerPackage) {
+ if (TextUtils.isEmpty(callerPackage)) {
throw new IllegalArgumentException("ExternalSettingsTrampoline intents "
+ "must be called with startActivityForResult");
}
- final String packageName = caller.getPackageName();
- final boolean isSettingsPackage = TextUtils.equals(packageName, context.getPackageName())
- || TextUtils.equals(getSettingsIntelligencePkgName(context), packageName);
- final boolean isAllowlistedPackage =
- isSignatureAllowlisted(context, caller.getPackageName());
+ final boolean isSettingsPackage = TextUtils.equals(callerPackage, context.getPackageName())
+ || TextUtils.equals(getSettingsIntelligencePkgName(context), callerPackage);
+ final boolean isAllowlistedPackage = isSignatureAllowlisted(context, callerPackage);
if (isSettingsPackage || isAllowlistedPackage) {
return;
}
diff --git a/src/com/android/settings/search/SearchResultTrampoline.java b/src/com/android/settings/search/SearchResultTrampoline.java
index 5d897af..04d9db5 100644
--- a/src/com/android/settings/search/SearchResultTrampoline.java
+++ b/src/com/android/settings/search/SearchResultTrampoline.java
@@ -21,7 +21,6 @@
import static com.android.settings.activityembedding.EmbeddedDeepLinkUtils.getTrampolineIntent;
import android.app.Activity;
-import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -53,11 +52,11 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- final ComponentName callingActivity = getCallingActivity();
+ final String callerPackage = getLaunchedFromPackage();
// First make sure caller has privilege to launch a search result page.
FeatureFactory.getFeatureFactory()
.getSearchFeatureProvider()
- .verifyLaunchSearchResultPageCaller(this, callingActivity);
+ .verifyLaunchSearchResultPageCaller(this, callerPackage);
// Didn't crash, proceed and launch the result as a subsetting.
Intent intent = getIntent();
final String highlightMenuKey = intent.getStringExtra(
@@ -106,7 +105,7 @@
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)
|| ActivityEmbeddingUtils.isAlreadyEmbedded(this)) {
startActivity(intent);
- } else if (isSettingsIntelligence(callingActivity)) {
+ } else if (isSettingsIntelligence(callerPackage)) {
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
startActivity(getTrampolineIntent(intent, highlightMenuKey)
.setClass(this, DeepLinkHomepageActivityInternal.class)
@@ -139,9 +138,9 @@
finish();
}
- private boolean isSettingsIntelligence(ComponentName callingActivity) {
- return callingActivity != null && TextUtils.equals(
- callingActivity.getPackageName(),
+ private boolean isSettingsIntelligence(String callerPackage) {
+ return TextUtils.equals(
+ callerPackage,
FeatureFactory.getFeatureFactory().getSearchFeatureProvider()
.getSettingsIntelligencePkgName(this));
}
diff --git a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
index b6d83f2..351ac77 100644
--- a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
+++ b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
@@ -219,24 +219,24 @@
mutableStateOf(false)
}
//TODO: Add the Restricted TwoTargetSwitchPreference in SPA
- TwoTargetSwitchPreference(remember {
- object : SwitchPreferenceModel {
- override val title = subInfo.displayName.toString()
- override val summary = { subInfo.number }
- override val checked = {
- coroutineScope.launch {
- withContext(Dispatchers.Default) {
- checked.value = subscriptionManager?.isSubscriptionEnabled(
+ TwoTargetSwitchPreference(
+ object : SwitchPreferenceModel {
+ override val title = subInfo.displayName.toString()
+ override val summary = { subInfo.number }
+ override val checked = {
+ coroutineScope.launch {
+ withContext(Dispatchers.Default) {
+ checked.value = subscriptionManager?.isSubscriptionEnabled(
subInfo.subscriptionId)?:false
+ }
}
+ checked.value
}
- checked.value
+ override val onCheckedChange = { newChecked: Boolean ->
+ startToggleSubscriptionDialog(context, subInfo, newChecked)
+ }
}
- override val onCheckedChange = { newChecked: Boolean ->
- startToggleSubscriptionDialog(context, subInfo, newChecked)
- }
- }
- }) {
+ ) {
startMobileNetworkSettings(context, subInfo)
}
}
@@ -258,7 +258,7 @@
}
@Composable
-fun PrimarySimSectionImpl(
+fun PrimarySimImpl(
subscriptionInfoList: List<SubscriptionInfo>,
callsSelectedId: MutableIntState,
textsSelectedId: MutableIntState,
@@ -318,15 +318,18 @@
for (info in subscriptionInfoList) {
var item = ListPreferenceOption(
id = info.subscriptionId,
- text = "${info.displayName}"
+ text = "${info.displayName}",
+ summary = "${info.number}"
)
callsAndSmsList.add(item)
dataList.add(item)
}
- callsAndSmsList.add(ListPreferenceOption(
+ callsAndSmsList.add(
+ ListPreferenceOption(
id = SubscriptionManager.INVALID_SUBSCRIPTION_ID,
text = stringResource(id = R.string.sim_calls_ask_first_prefs_title)
- ))
+ )
+ )
} else {
// hide the primary sim
state.value = false
@@ -341,33 +344,31 @@
mutableStateOf(false)
}
- Category(title = stringResource(id = R.string.primary_sim_title)) {
- CreatePrimarySimListPreference(
- stringResource(id = R.string.primary_sim_calls_title),
- callsAndSmsList,
- callsSelectedId,
- ImageVector.vectorResource(R.drawable.ic_phone),
- actionSetCalls
- )
- CreatePrimarySimListPreference(
- stringResource(id = R.string.primary_sim_texts_title),
- callsAndSmsList,
- textsSelectedId,
- Icons.AutoMirrored.Outlined.Message,
- actionSetTexts
- )
- CreatePrimarySimListPreference(
- stringResource(id = R.string.mobile_data_settings_title),
- dataList,
- mobileDataSelectedId,
- Icons.Outlined.DataUsage,
- actionSetMobileData
- )
- }
+ CreatePrimarySimListPreference(
+ stringResource(id = R.string.primary_sim_calls_title),
+ callsAndSmsList,
+ callsSelectedId,
+ ImageVector.vectorResource(R.drawable.ic_phone),
+ actionSetCalls
+ )
+ CreatePrimarySimListPreference(
+ stringResource(id = R.string.primary_sim_texts_title),
+ callsAndSmsList,
+ textsSelectedId,
+ Icons.AutoMirrored.Outlined.Message,
+ actionSetTexts
+ )
+ CreatePrimarySimListPreference(
+ stringResource(id = R.string.mobile_data_settings_title),
+ dataList,
+ mobileDataSelectedId,
+ Icons.Outlined.DataUsage,
+ actionSetMobileData
+ )
val autoDataTitle = stringResource(id = R.string.primary_sim_automatic_data_title)
val autoDataSummary = stringResource(id = R.string.primary_sim_automatic_data_msg)
- SwitchPreference(remember {
+ SwitchPreference(
object : SwitchPreferenceModel {
override val title = autoDataTitle
override val summary = { autoDataSummary }
@@ -375,6 +376,11 @@
if (nonDds.intValue != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
coroutineScope.launch {
automaticDataChecked.value = getAutomaticData(telephonyManagerForNonDds)
+ Log.d(
+ NetworkCellularGroupProvider.name,
+ "NonDds:${nonDds.intValue}" +
+ "getAutomaticData:${automaticDataChecked.value}"
+ )
}
}
automaticDataChecked.value
@@ -384,7 +390,26 @@
actionSetAutoDataSwitch(it)
}
}
- })
+ )
+ }
+}
+
+@Composable
+fun PrimarySimSectionImpl(
+ subscriptionInfoList: List<SubscriptionInfo>,
+ callsSelectedId: MutableIntState,
+ textsSelectedId: MutableIntState,
+ mobileDataSelectedId: MutableIntState,
+ nonDds: MutableIntState,
+) {
+ Category(title = stringResource(id = R.string.primary_sim_title)) {
+ PrimarySimImpl(
+ subscriptionInfoList,
+ callsSelectedId,
+ textsSelectedId,
+ mobileDataSelectedId,
+ nonDds
+ )
}
}
@@ -442,32 +467,42 @@
}
suspend fun setDefaultVoice(
- subscriptionManager: SubscriptionManager?,
- subId: Int): Unit = withContext(Dispatchers.Default) {
- subscriptionManager?.setDefaultVoiceSubscriptionId(subId)
-}
+ subscriptionManager: SubscriptionManager?,
+ subId: Int
+): Unit =
+ withContext(Dispatchers.Default) {
+ subscriptionManager?.setDefaultVoiceSubscriptionId(subId)
+ }
suspend fun setDefaultSms(
- subscriptionManager: SubscriptionManager?,
- subId: Int): Unit = withContext(Dispatchers.Default) {
- subscriptionManager?.setDefaultSmsSubId(subId)
-}
+ subscriptionManager: SubscriptionManager?,
+ subId: Int
+): Unit =
+ withContext(Dispatchers.Default) {
+ subscriptionManager?.setDefaultSmsSubId(subId)
+ }
-suspend fun setDefaultData(context: Context,
- subscriptionManager: SubscriptionManager?,
- wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
- subId: Int): Unit = withContext(Dispatchers.Default) {
- subscriptionManager?.setDefaultDataSubId(subId)
- MobileNetworkUtils.setMobileDataEnabled(
+suspend fun setDefaultData(
+ context: Context,
+ subscriptionManager: SubscriptionManager?,
+ wifiPickerTrackerHelper: WifiPickerTrackerHelper?,
+ subId: Int
+): Unit =
+ withContext(Dispatchers.Default) {
+ subscriptionManager?.setDefaultDataSubId(subId)
+ MobileNetworkUtils.setMobileDataEnabled(
context,
subId,
true /* enabled */,
- true /* disableOtherSubscriptions */)
- if (wifiPickerTrackerHelper != null
- && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)) {
- wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
+ true /* disableOtherSubscriptions */
+ )
+ if (wifiPickerTrackerHelper != null
+ && !wifiPickerTrackerHelper.isCarrierNetworkProvisionEnabled(subId)
+ ) {
+ wifiPickerTrackerHelper.setCarrierNetworkEnabled(true)
+ }
}
-}
+
suspend fun getAutomaticData(telephonyManagerForNonDds: TelephonyManager?): Boolean =
withContext(Dispatchers.Default) {
telephonyManagerForNonDds != null
@@ -478,7 +513,7 @@
suspend fun setAutomaticData(telephonyManager: TelephonyManager?, newState: Boolean): Unit =
withContext(Dispatchers.Default) {
Log.d(
- "NetworkCellularGroupProvider",
+ NetworkCellularGroupProvider.name,
"setAutomaticData: MOBILE_DATA_POLICY_AUTO_DATA_SWITCH as $newState"
)
telephonyManager?.setMobileDataPolicyEnabled(
diff --git a/src/com/android/settings/spa/network/SimOnboardingLabelSim.kt b/src/com/android/settings/spa/network/SimOnboardingLabelSim.kt
index e88c5c7..3b2d5ec 100644
--- a/src/com/android/settings/spa/network/SimOnboardingLabelSim.kt
+++ b/src/com/android/settings/spa/network/SimOnboardingLabelSim.kt
@@ -20,6 +20,7 @@
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SignalCellularAlt
+import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -91,11 +92,13 @@
},
title = stringResource(R.string.sim_onboarding_label_sim_dialog_title),
text = {
- Text(summaryNumber)
+ Text(summaryNumber,
+ modifier = Modifier.padding(bottom = SettingsDimension.itemPaddingVertical))
SettingsOutlinedTextField(
value = titleSimName,
label = stringResource(R.string.sim_onboarding_label_sim_dialog_label),
- enabled = true
+ enabled = true,
+ shape = MaterialTheme.shapes.extraLarge
) {
titleSimName = it
}
diff --git a/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt b/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
index 999abb4..a5f55d0 100644
--- a/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
+++ b/src/com/android/settings/spa/network/SimOnboardingPrimarySim.kt
@@ -24,7 +24,6 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableIntState
import androidx.compose.runtime.mutableIntStateOf
-import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
@@ -82,7 +81,7 @@
callsSelectedId.intValue = onboardingService.targetPrimarySimCalls
textsSelectedId.intValue = onboardingService.targetPrimarySimTexts
mobileDataSelectedId.intValue = onboardingService.targetPrimarySimMobileData
- PrimarySimSectionImpl(
+ PrimarySimImpl(
subscriptionInfoList = selectedSubscriptionInfoList,
callsSelectedId = callsSelectedId,
textsSelectedId = textsSelectedId,
@@ -110,7 +109,7 @@
selectedId: MutableIntState,
icon: ImageVector,
onIdSelected: (id: Int) -> Unit
-) = ListPreference(remember {
+) = ListPreference(
object : ListPreferenceModel {
override val title = title
override val options = list
@@ -119,5 +118,4 @@
override val icon = @Composable {
SettingsIcon(icon)
}
- }
})
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index dceadeb..5a7e247 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -16,7 +16,6 @@
package com.android.settings.bluetooth;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -25,36 +24,26 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothLeBroadcastReceiveState;
import android.bluetooth.BluetoothProfile;
-import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
-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 android.util.Pair;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider;
import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.flags.Flags;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowAudioManager;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
-import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
-import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -75,9 +64,6 @@
ShadowBluetoothUtils.class
})
public class AvailableMediaBluetoothDeviceUpdaterTest {
- @Rule
- public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
-
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
@Mock private DashboardFragment mDashboardFragment;
@@ -86,11 +72,7 @@
@Mock private BluetoothDevice mBluetoothDevice;
@Mock private Drawable mDrawable;
@Mock private LocalBluetoothManager mLocalBtManager;
- @Mock private LocalBluetoothProfileManager mLocalBtProfileManager;
@Mock private CachedBluetoothDeviceManager mCachedDeviceManager;
- @Mock private LocalBluetoothLeBroadcast mBroadcast;
- @Mock private LocalBluetoothLeBroadcastAssistant mAssistant;
- @Mock private BluetoothLeBroadcastReceiveState mBroadcastReceiveState;
private Context mContext;
private AvailableMediaBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -98,12 +80,14 @@
private AudioManager mAudioManager;
private BluetoothDevicePreference mPreference;
private ShadowBluetoothAdapter mShadowBluetoothAdapter;
+ private AudioSharingFeatureProvider mFeatureProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
+ mFeatureProvider = FakeFeatureFactory.setupForTest().getAudioSharingFeatureProvider();
mAudioManager = mContext.getSystemService(AudioManager.class);
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager;
mLocalBtManager = Utils.getLocalBtManager(mContext);
@@ -267,13 +251,15 @@
}
@Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_addsPreference() {
- setUpBroadcast(/* isSupported= */ false, /* isBroadcasting= */ false);
+ public void
+ onProfileConnectionStateChanged_leaDeviceConnected_notInCallNoSharing_addsPreference() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
.thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+ when(mFeatureProvider.isAudioSharingFilterMatched(
+ any(CachedBluetoothDevice.class), any(LocalBluetoothManager.class)))
+ .thenReturn(false);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
mCachedBluetoothDevice,
@@ -284,13 +270,15 @@
}
@Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void onProfileConnectionStateChanged_leAudioDeviceConnected_inCall_addsPreference() {
- setUpBroadcast(/* isSupported= */ false, /* isBroadcasting= */ false);
+ public void
+ onProfileConnectionStateChanged_leaDeviceConnected_inCallNoSharing_addsPreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
.thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+ when(mFeatureProvider.isAudioSharingFilterMatched(
+ any(CachedBluetoothDevice.class), any(LocalBluetoothManager.class)))
+ .thenReturn(false);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
mCachedBluetoothDevice,
@@ -301,50 +289,16 @@
}
@Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
public void
- onProfileConnectionStateChanged_leaDeviceConnected_notInCall_notInBroadcast_addsPref() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ false);
+ onProfileConnectionStateChanged_leaDeviceConnected_notInCallInSharing_removesPref() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
.thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
-
- mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
- mCachedBluetoothDevice,
- BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.LE_AUDIO);
-
- verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
- }
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void
- onProfileConnectionStateChanged_leaDeviceConnected_inCall_notInBroadcast_addsPref() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ false);
- mAudioManager.setMode(AudioManager.MODE_IN_CALL);
- when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
+ when(mCachedBluetoothDevice.isConnectedA2dpDevice()).thenReturn(true);
+ when(mFeatureProvider.isAudioSharingFilterMatched(
+ any(CachedBluetoothDevice.class), any(LocalBluetoothManager.class)))
.thenReturn(true);
- when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
-
- mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
- mCachedBluetoothDevice,
- BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.LE_AUDIO);
-
- verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
- }
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void
- onProfileConnectionStateChanged_leaDeviceConnected_notInCall_inBroadcast_removesPref() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ true);
- mAudioManager.setMode(AudioManager.MODE_NORMAL);
- when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
- .thenReturn(true);
- when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
mCachedBluetoothDevice,
@@ -355,14 +309,15 @@
}
@Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void
- onProfileConnectionStateChanged_leaDeviceConnected_inCall_inBroadcast_removesPref() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ true);
- mAudioManager.setMode(AudioManager.MODE_IN_CALL);
+ public void onProfileConnectionStateChanged_leaDeviceConnected_inCallInSharing_removesPref() {
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
.thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
+ when(mFeatureProvider.isAudioSharingFilterMatched(
+ any(CachedBluetoothDevice.class), any(LocalBluetoothManager.class)))
+ .thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
mCachedBluetoothDevice,
@@ -414,56 +369,9 @@
}
@Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
public void onClick_Preference_setActive() {
- setUpBroadcast(/* isSupported= */ false, /* isBroadcasting= */ false);
mBluetoothDeviceUpdater.onPreferenceClick(mPreference);
verify(mCachedBluetoothDevice).setActive();
}
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void onClick_Preference_isNotBroadcasting_setActive() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ false);
- mBluetoothDeviceUpdater.onPreferenceClick(mPreference);
-
- verify(mCachedBluetoothDevice).setActive();
- }
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void onClick_Preference_isBroadcasting_stopBroadcastingAndSetActive() {
- setUpBroadcast(/* isSupported= */ true, /* isBroadcasting= */ true);
- doNothing().when(mBroadcast).stopBroadcast(anyInt());
- mBluetoothDeviceUpdater.onPreferenceClick(mPreference);
-
- verify(mBroadcast).stopBroadcast(anyInt());
- verify(mCachedBluetoothDevice).setActive();
- }
-
- private void setUpBroadcast(boolean isSupported, boolean isBroadcasting) {
- if (isSupported) {
- mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
- mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
- when(mLocalBtManager.getProfileManager()).thenReturn(mLocalBtProfileManager);
- when(mLocalBtProfileManager.getLeAudioBroadcastProfile()).thenReturn(mBroadcast);
- when(mBroadcast.isEnabled(null)).thenReturn(isBroadcasting);
- when(mLocalBtProfileManager.getLeAudioBroadcastAssistantProfile())
- .thenReturn(mAssistant);
- if (isBroadcasting) {
- when(mAssistant.getAllSources(any()))
- .thenReturn(ImmutableList.of(mBroadcastReceiveState));
- } else {
- when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
- }
- } else {
- mShadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
- BluetoothStatusCodes.FEATURE_NOT_SUPPORTED);
- mShadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
- BluetoothStatusCodes.FEATURE_NOT_SUPPORTED);
- }
- }
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImplTest.java
new file mode 100644
index 0000000..0edbc77
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingFeatureProviderImplTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 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.connecteddevice.audiosharing;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class AudioSharingFeatureProviderImplTest {
+ @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock private CachedBluetoothDevice mCachedDevice;
+ @Mock private LocalBluetoothManager mLocalBtManager;
+ @Mock private DashboardFragment mFragment;
+ private Context mContext;
+ private AudioSharingFeatureProviderImpl mFeatureProvider;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mFeatureProvider = new AudioSharingFeatureProviderImpl();
+ }
+
+ @Test
+ public void createAudioSharingDevicePreferenceController_returnsNull() {
+ assertThat(
+ mFeatureProvider.createAudioSharingDevicePreferenceController(
+ mContext, mFragment, /* lifecycle= */ null))
+ .isNull();
+ }
+
+ @Test
+ public void isAudioSharingFilterMatched_returnsFalse() {
+ assertThat(mFeatureProvider.isAudioSharingFilterMatched(mCachedDevice, mLocalBtManager))
+ .isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
index f349600..8a7419b 100644
--- a/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchFeatureProviderImplTest.java
@@ -20,7 +20,6 @@
import static com.google.common.truth.Truth.assertThat;
import android.app.settings.SettingsEnums;
-import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
@@ -131,20 +130,22 @@
@Test(expected = SecurityException.class)
public void verifyLaunchSearchResultPageCaller_badCaller_shouldCrash() {
- final ComponentName cn = new ComponentName("pkg", "class");
- mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+ final String packageName = "pkg";
+
+ mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
}
@Test
public void verifyLaunchSearchResultPageCaller_settingsCaller_shouldNotCrash() {
- final ComponentName cn = new ComponentName(mActivity.getPackageName(), "class");
- mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+ final String packageName = mActivity.getPackageName();
+
+ mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
}
@Test
public void verifyLaunchSearchResultPageCaller_settingsIntelligenceCaller_shouldNotCrash() {
final String packageName = mProvider.getSettingsIntelligencePkgName(mActivity);
- final ComponentName cn = new ComponentName(packageName, "class");
- mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
+
+ mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
}
}
diff --git a/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
index a11b226..f49cc68 100644
--- a/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
@@ -27,6 +27,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider;
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
@@ -103,6 +104,7 @@
public FastPairFeatureProvider mFastPairFeatureProvider;
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
public DisplayFeatureProvider mDisplayFeatureProvider;
+ public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
/**
* Call this in {@code @Before} method of the test class to use fake factory.
@@ -152,6 +154,7 @@
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
+ mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
}
@Override
@@ -339,5 +342,10 @@
public DisplayFeatureProvider getDisplayFeatureProvider() {
return mDisplayFeatureProvider;
}
+
+ @Override
+ public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
+ return mAudioSharingFeatureProvider;
+ }
}
diff --git a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingLabelSimTest.kt b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingLabelSimTest.kt
index 8e12b20..44a5037 100644
--- a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingLabelSimTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingLabelSimTest.kt
@@ -47,7 +47,6 @@
on { activeSubInfoList }.doReturn(listOf())
on { slotInfoList }.doReturn(listOf())
on { uiccCardInfoList }.doReturn(listOf())
- on { selectedSubInfoList }.doReturn(mutableListOf())
on { targetPrimarySimCalls }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
on { targetPrimarySimTexts }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
diff --git a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt
index 82dba76..d1847c8 100644
--- a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt
@@ -47,7 +47,6 @@
on { activeSubInfoList }.doReturn(listOf())
on { slotInfoList }.doReturn(listOf())
on { uiccCardInfoList }.doReturn(listOf())
- on { selectedSubInfoList }.doReturn(mutableListOf())
on { targetPrimarySimCalls }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
on { targetPrimarySimTexts }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
diff --git a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPrimarySimTest.kt b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPrimarySimTest.kt
index 9cb8909..d9c762d 100644
--- a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPrimarySimTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPrimarySimTest.kt
@@ -48,7 +48,6 @@
on { activeSubInfoList }.doReturn(listOf())
on { slotInfoList }.doReturn(listOf())
on { uiccCardInfoList }.doReturn(listOf())
- on { selectedSubInfoList }.doReturn(mutableListOf())
on { targetPrimarySimCalls }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
on { targetPrimarySimTexts }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
diff --git a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingSelectSimTest.kt b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingSelectSimTest.kt
index 45667ef..e063f69 100644
--- a/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingSelectSimTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingSelectSimTest.kt
@@ -47,7 +47,6 @@
on { activeSubInfoList }.doReturn(listOf())
on { slotInfoList }.doReturn(listOf())
on { uiccCardInfoList }.doReturn(listOf())
- on { selectedSubInfoList }.doReturn(mutableListOf())
on { targetPrimarySimCalls }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
on { targetPrimarySimTexts }.doReturn(PRIMARY_SIM_ASK_EVERY_TIME)
diff --git a/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt b/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
index 4048c24..606db8e 100644
--- a/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
+++ b/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
@@ -25,6 +25,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider
import com.android.settings.dashboard.DashboardFeatureProvider
@@ -149,4 +150,6 @@
get() = TODO("Not yet implemented")
override val displayFeatureProvider: DisplayFeatureProvider
get() = TODO("Not yet implemented")
+ override val audioSharingFeatureProvider: AudioSharingFeatureProvider
+ get() = TODO("Not yet implemented")
}
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index 9e7948c..4f17a3a 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -27,6 +27,7 @@
import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
+import com.android.settings.connecteddevice.audiosharing.AudioSharingFeatureProvider;
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
import com.android.settings.connecteddevice.stylus.StylusFeatureProvider;
import com.android.settings.dashboard.DashboardFeatureProvider;
@@ -102,6 +103,7 @@
public FastPairFeatureProvider mFastPairFeatureProvider;
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
public DisplayFeatureProvider mDisplayFeatureProvider;
+ public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
/** Call this in {@code @Before} method of the test class to use fake factory. */
public static FakeFeatureFactory setupForTest() {
@@ -153,6 +155,7 @@
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
+ mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
}
@Override
@@ -340,4 +343,9 @@
public DisplayFeatureProvider getDisplayFeatureProvider() {
return mDisplayFeatureProvider;
}
+
+ @Override
+ public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
+ return mAudioSharingFeatureProvider;
+ }
}