connectedHADevices = getConnectedHearingAidDevices();
if (mAudioManager.getMode() == AudioManager.MODE_NORMAL
- && ((connectableA2dpDevices != null && !connectableA2dpDevices.isEmpty())
- || (connectableHADevices != null && !connectableHADevices.isEmpty()))) {
- deviceConnectable = true;
+ && ((connectedA2dpDevices != null && !connectedA2dpDevices.isEmpty())
+ || (connectedHADevices != null && !connectedHADevices.isEmpty()))) {
+ deviceConnected = true;
activeDevice = findActiveDevice();
}
- mPreference.setVisible(deviceConnectable);
+ mPreference.setVisible(deviceConnected);
mPreference.setSummary((activeDevice == null) ?
mContext.getText(R.string.media_output_default_summary) :
activeDevice.getAliasName());
diff --git a/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java b/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java
index 341b2279994..5f4e9d0adb1 100644
--- a/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java
@@ -24,19 +24,22 @@ import android.net.wifi.WifiManager;
import androidx.annotation.VisibleForTesting;
import androidx.preference.DropDownPreference;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.wifi.WifiDialog;
import com.android.settingslib.core.AbstractPreferenceController;
/**
* {@link AbstractPreferenceController} that controls whether the wifi network is metered or not
*/
public class WifiMeteredPreferenceController extends BasePreferenceController implements
- Preference.OnPreferenceChangeListener {
+ Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
private static final String KEY_WIFI_METERED = "metered";
private WifiConfiguration mWifiConfiguration;
private WifiManager mWifiManager;
+ private Preference mPreference;
public WifiMeteredPreferenceController(Context context, WifiConfiguration wifiConfiguration) {
super(context, KEY_WIFI_METERED);
@@ -81,4 +84,25 @@ public class WifiMeteredPreferenceController extends BasePreferenceController im
private void updateSummary(DropDownPreference preference, int meteredOverride) {
preference.setSummary(preference.getEntries()[meteredOverride]);
}
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void onSubmit(WifiDialog dialog) {
+ if (dialog.getController() != null) {
+ final WifiConfiguration newConfig = dialog.getController().getConfig();
+ if (newConfig == null || mWifiConfiguration == null) {
+ return;
+ }
+
+ if (newConfig.meteredOverride != mWifiConfiguration.meteredOverride) {
+ mWifiConfiguration = newConfig;
+ onPreferenceChange(mPreference, String.valueOf(newConfig.meteredOverride));
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 10d1d48f4a2..b645d60bbd2 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -47,12 +47,14 @@ import java.util.List;
* The AccessPoint should be saved to the intent Extras when launching this class via
* {@link AccessPoint#saveWifiState(Bundle)} in order to properly render this page.
*/
-public class WifiNetworkDetailsFragment extends DashboardFragment {
+public class WifiNetworkDetailsFragment extends DashboardFragment implements
+ WifiDialog.WifiDialogListener {
private static final String TAG = "WifiNetworkDetailsFrg";
private AccessPoint mAccessPoint;
private WifiDetailPreferenceController mWifiDetailPreferenceController;
+ private List mWifiDialogListeners = new ArrayList<>();
@Override
public void onAttach(Context context) {
@@ -89,7 +91,7 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
|| mAccessPoint == null) {
return null;
}
- return WifiDialog.createModal(getActivity(), mWifiDetailPreferenceController, mAccessPoint,
+ return WifiDialog.createModal(getActivity(), this, mAccessPoint,
WifiConfigUiBase.MODE_MODIFY);
}
@@ -135,15 +137,31 @@ public class WifiNetworkDetailsFragment extends DashboardFragment {
controllers.add(mWifiDetailPreferenceController);
controllers.add(new AddDevicePreferenceController(context).init(mAccessPoint));
- controllers.add(new WifiMeteredPreferenceController(context, mAccessPoint.getConfig()));
- WifiPrivacyPreferenceController privacyController = new WifiPrivacyPreferenceController(
- context);
+
+ final WifiMeteredPreferenceController meteredPreferenceController =
+ new WifiMeteredPreferenceController(context, mAccessPoint.getConfig());
+ controllers.add(meteredPreferenceController);
+
+ final WifiPrivacyPreferenceController privacyController =
+ new WifiPrivacyPreferenceController(context);
privacyController.setWifiConfiguration(mAccessPoint.getConfig());
privacyController.setIsEphemeral(mAccessPoint.isEphemeral());
privacyController.setIsPasspoint(
mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig());
controllers.add(privacyController);
+ // Sets callback listener for wifi dialog.
+ mWifiDialogListeners.add(mWifiDetailPreferenceController);
+ mWifiDialogListeners.add(privacyController);
+ mWifiDialogListeners.add(meteredPreferenceController);
+
return controllers;
}
+
+ @Override
+ public void onSubmit(WifiDialog dialog) {
+ for (WifiDialog.WifiDialogListener listener : mWifiDialogListeners) {
+ listener.onSubmit(dialog);
+ }
+ }
}
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
index 7bec4119f8d..950cc131f4a 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -18,16 +18,17 @@ package com.android.settings.wifi.details;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
-import android.util.FeatureFlagUtils;
import androidx.annotation.VisibleForTesting;
import androidx.preference.DropDownPreference;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.FeatureFlags;
+import com.android.settings.wifi.WifiDialog;
import com.android.settingslib.core.AbstractPreferenceController;
/**
@@ -35,13 +36,14 @@ import com.android.settingslib.core.AbstractPreferenceController;
* or not
*/
public class WifiPrivacyPreferenceController extends BasePreferenceController implements
- Preference.OnPreferenceChangeListener {
+ Preference.OnPreferenceChangeListener, WifiDialog.WifiDialogListener {
private static final String KEY_WIFI_PRIVACY = "privacy";
private WifiConfiguration mWifiConfiguration;
private WifiManager mWifiManager;
private boolean mIsEphemeral = false;
private boolean mIsPasspoint = false;
+ private Preference mPreference;
public WifiPrivacyPreferenceController(Context context) {
super(context, KEY_WIFI_PRIVACY);
@@ -68,6 +70,12 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
@Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
@@ -87,9 +95,13 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
if (mWifiConfiguration != null) {
mWifiConfiguration.macRandomizationSetting = Integer.parseInt((String) newValue);
mWifiManager.updateNetwork(mWifiConfiguration);
- // To activate changing, we need reconnect network. WiFi will auto connect to current
- // network after disconnect().
- mWifiManager.disconnect();
+
+ // To activate changing, we need to reconnect network. WiFi will auto connect to
+ // current network after disconnect(). Only needed when this is connected network.
+ final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
+ if (wifiInfo != null && wifiInfo.getNetworkId() == mWifiConfiguration.networkId) {
+ mWifiManager.disconnect();
+ }
}
updateSummary((DropDownPreference) preference, Integer.parseInt((String) newValue));
return true;
@@ -133,4 +145,19 @@ public class WifiPrivacyPreferenceController extends BasePreferenceController im
final int prefMacRandomized = translateMacRandomizedValueToPrefValue(macRandomized);
preference.setSummary(preference.getEntries()[prefMacRandomized]);
}
+
+ @Override
+ public void onSubmit(WifiDialog dialog) {
+ if (dialog.getController() != null) {
+ final WifiConfiguration newConfig = dialog.getController().getConfig();
+ if (newConfig == null || mWifiConfiguration == null) {
+ return;
+ }
+
+ if (newConfig.macRandomizationSetting != mWifiConfiguration.macRandomizationSetting) {
+ mWifiConfiguration = newConfig;
+ onPreferenceChange(mPreference, String.valueOf(newConfig.macRandomizationSetting));
+ }
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index c6479147e6a..40b955ccd06 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -187,4 +187,9 @@ public class SubscriptionUtilTest {
assertThat(subs).isNotNull();
assertThat(subs).hasSize(2);
}
+
+ @Test
+ public void isInactiveInsertedPSim_nullSubInfo_doesNotCrash() {
+ assertThat(SubscriptionUtil.isInactiveInsertedPSim(null)).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
index 63bc8284255..b4379aadc44 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceTest.java
@@ -29,7 +29,10 @@ import static org.mockito.Mockito.verify;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.settings.R;
@@ -110,8 +113,8 @@ public class ImportancePreferenceTest {
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
assertThat(holder.itemView.findViewById(R.id.silence).getBackground())
.isEqualTo(unselected);
- assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
- mContext.getString(R.string.notification_channel_summary_default));
+ assertThat(((TextView) holder.itemView.findViewById(R.id.alert_summary)).getText())
+ .isEqualTo(mContext.getString(R.string.notification_channel_summary_default));
}
@Test
@@ -129,28 +132,32 @@ public class ImportancePreferenceTest {
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
- Button silenceButton = holder.itemView.findViewById(R.id.silence);
+ View silenceButton = holder.itemView.findViewById(R.id.silence);
silenceButton.callOnClick();
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
- assertThat(((TextView) holder.itemView.findViewById(R.id.description)).getText()).isEqualTo(
- mContext.getString(R.string.notification_channel_summary_low));
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
}
@Test
public void setImportanceSummary_status() {
+ ViewGroup parent = new LinearLayout(mContext);
TextView tv = new TextView(mContext);
+ tv.setId(R.id.silence_summary);
+ parent.addView(tv);
+ TextView other = new TextView(mContext);
+ other.setId(R.id.alert_summary);
+ parent.addView(other);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(false);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_status));
@@ -158,14 +165,20 @@ public class ImportancePreferenceTest {
@Test
public void setImportanceSummary_lock() {
+ ViewGroup parent = new LinearLayout(mContext);
TextView tv = new TextView(mContext);
+ tv.setId(R.id.silence_summary);
+ parent.addView(tv);
+ TextView other = new TextView(mContext);
+ other.setId(R.id.alert_summary);
+ parent.addView(other);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(false);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_lock));
@@ -173,14 +186,20 @@ public class ImportancePreferenceTest {
@Test
public void setImportanceSummary_statusLock() {
+ ViewGroup parent = new LinearLayout(mContext);
TextView tv = new TextView(mContext);
+ tv.setId(R.id.silence_summary);
+ parent.addView(tv);
+ TextView other = new TextView(mContext);
+ other.setId(R.id.alert_summary);
+ parent.addView(other);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_LOW);
+ preference.setImportanceSummary(parent, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_low_status_lock));
@@ -188,14 +207,20 @@ public class ImportancePreferenceTest {
@Test
public void setImportanceSummary_statusLock_default() {
+ ViewGroup parent = new LinearLayout(mContext);
TextView tv = new TextView(mContext);
+ tv.setId(R.id.alert_summary);
+ parent.addView(tv);
+ TextView other = new TextView(mContext);
+ other.setId(R.id.silence_summary);
+ parent.addView(other);
final ImportancePreference preference = spy(new ImportancePreference(mContext));
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
- preference.setImportanceSummary(tv, IMPORTANCE_DEFAULT);
+ preference.setImportanceSummary(parent, IMPORTANCE_DEFAULT, true);
assertThat(tv.getText()).isEqualTo(
mContext.getString(R.string.notification_channel_summary_default));
diff --git a/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
new file mode 100644
index 00000000000..69c0919719f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sim/SimSelectNotificationTest.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2019 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.sim;
+
+
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_MMS;
+import static android.provider.Settings.ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS;
+import static android.provider.Settings.EXTRA_ENABLE_MMS_DATA_REQUEST_REASON;
+import static android.provider.Settings.EXTRA_SUB_ID;
+import static android.telephony.data.ApnSetting.TYPE_MMS;
+
+import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_CHANNEL;
+import static com.android.settings.sim.SimSelectNotification.ENABLE_MMS_NOTIFICATION_ID;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.provider.Settings;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+import com.android.settings.R;
+
+import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowAlertDialogCompat.class)
+public class SimSelectNotificationTest {
+ @Mock
+ private Context mContext;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ @Mock
+ private SubscriptionManager mSubscriptionManager;
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private Resources mResources;
+
+ private String mFakeOperatorName = "fake_operator_name";
+ private CharSequence mFakeNotificationChannelTitle = "fake_notification_channel_title";
+ private CharSequence mFakeNotificationTitle = "fake_notification_title";
+ private String mFakeNotificationSummary = "fake_notification_Summary";
+
+ private int mSubId = 1;
+
+ SimSelectNotification mSimSelectNotification = new SimSelectNotification();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mContext.getSystemService(Context.NOTIFICATION_SERVICE))
+ .thenReturn(mNotificationManager);
+ when(mContext.getSystemService(Context.TELEPHONY_SERVICE))
+ .thenReturn(mTelephonyManager);
+ when(mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE))
+ .thenReturn(mSubscriptionManager);
+ when(mContext.getApplicationInfo()).thenReturn(new ApplicationInfo());
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.checkPermission(any(), any()))
+ .thenReturn(PackageManager.PERMISSION_GRANTED);
+
+ when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
+ when(mTelephonyManager.getSimOperatorName()).thenReturn(mFakeOperatorName);
+ when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(false);
+ when(mSubscriptionManager.isActiveSubId(mSubId)).thenReturn(true);
+ when(mContext.getResources()).thenReturn(mResources);
+
+ when(mResources.getText(R.string.enable_sending_mms_notification_title))
+ .thenReturn(mFakeNotificationTitle);
+ when(mResources.getText(R.string.enable_mms_notification_channel_title))
+ .thenReturn(mFakeNotificationChannelTitle);
+ when(mResources.getString(R.string.enable_mms_notification_summary,
+ mFakeOperatorName)).thenReturn(mFakeNotificationSummary);
+ }
+
+ @Test
+ public void onReceiveEnableMms_notificationShouldSend() {
+ Intent intent = new Intent(Settings.ACTION_ENABLE_MMS_DATA_REQUEST);
+ intent.putExtra(EXTRA_SUB_ID, mSubId);
+ intent.putExtra(EXTRA_ENABLE_MMS_DATA_REQUEST_REASON,
+ ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS);
+
+ mSimSelectNotification.onReceive(mContext, intent);
+
+ // Capture the notification channel created and verify its fields.
+ ArgumentCaptor nc = ArgumentCaptor.forClass(NotificationChannel.class);
+ verify(mNotificationManager).createNotificationChannel(nc.capture());
+
+ assertThat(nc.getValue().getId()).isEqualTo(ENABLE_MMS_NOTIFICATION_CHANNEL);
+ assertThat(nc.getValue().getName()).isEqualTo(mFakeNotificationChannelTitle);
+ assertThat(nc.getValue().getImportance()).isEqualTo(IMPORTANCE_HIGH);
+
+ // Capture the notification it notifies and verify its fields.
+ ArgumentCaptor notification = ArgumentCaptor.forClass(Notification.class);
+ verify(mNotificationManager).notify(
+ eq(ENABLE_MMS_NOTIFICATION_ID), notification.capture());
+ assertThat(notification.getValue().extras.getCharSequence(Notification.EXTRA_TITLE))
+ .isEqualTo(mFakeNotificationTitle);
+ assertThat(notification.getValue().extras.getCharSequence(Notification.EXTRA_BIG_TEXT))
+ .isEqualTo(mFakeNotificationSummary);
+ assertThat(notification.getValue().contentIntent).isNotNull();
+ }
+
+ @Test
+ public void onReceiveEnableMms_NoExtra_notificationShouldNotSend() {
+ Intent intent = new Intent(Settings.ACTION_ENABLE_MMS_DATA_REQUEST);
+
+ // EXTRA_SUB_ID and EXTRA_ENABLE_MMS_DATA_REQUEST_REASON are required.
+ mSimSelectNotification.onReceive(mContext, intent);
+ verify(mNotificationManager, never()).createNotificationChannel(any());
+ }
+
+ @Test
+ public void onReceiveEnableMms_MmsDataAlreadyEnabled_notificationShouldNotSend() {
+ when(mTelephonyManager.isDataEnabledForApn(TYPE_MMS)).thenReturn(true);
+ Intent intent = new Intent(Settings.ACTION_ENABLE_MMS_DATA_REQUEST);
+ intent.putExtra(EXTRA_SUB_ID, mSubId);
+ intent.putExtra(EXTRA_ENABLE_MMS_DATA_REQUEST_REASON,
+ ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_MMS);
+
+ // If MMS data is already enabled, there's no need to trigger the notification.
+ mSimSelectNotification.onReceive(mContext, intent);
+ verify(mNotificationManager, never()).createNotificationChannel(any());
+ }
+}
+
diff --git a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
index 7fcd3d2986d..51264c17f2c 100644
--- a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
@@ -109,7 +109,7 @@ public class MediaOutputPreferenceControllerTest {
private BluetoothDevice mRightBluetoothHapDevice;
private LocalBluetoothManager mLocalBluetoothManager;
private MediaOutputPreferenceController mController;
- private List mProfileConnectableDevices;
+ private List mProfileConnectedDevices;
private List mHearingAidActiveDevices;
@Before
@@ -150,7 +150,7 @@ public class MediaOutputPreferenceControllerTest {
mController = new MediaOutputPreferenceController(mContext, TEST_KEY);
mScreen = spy(new PreferenceScreen(mContext, null));
mPreference = new Preference(mContext);
- mProfileConnectableDevices = new ArrayList<>();
+ mProfileConnectedDevices = new ArrayList<>();
mHearingAidActiveDevices = new ArrayList<>(2);
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
@@ -172,11 +172,11 @@ public class MediaOutputPreferenceControllerTest {
* Preference should be invisible
*/
@Test
- public void updateState_withoutConnectableBtDevice_preferenceInvisible() {
+ public void updateState_withoutConnectedBtDevice_preferenceInvisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_EARPIECE);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
- mProfileConnectableDevices.clear();
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mProfileConnectableDevices);
+ mProfileConnectedDevices.clear();
+ when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
mPreference.setVisible(true);
assertThat(mPreference.isVisible()).isTrue();
@@ -185,16 +185,16 @@ public class MediaOutputPreferenceControllerTest {
}
/**
- * A2DP Bluetooth device(s) are connectable, no matter active or inactive
+ * A2DP Bluetooth device(s) are connected, no matter active or inactive
* Preference should be visible
*/
@Test
- public void updateState_withConnectableBtDevice_preferenceVisible() {
+ public void updateState_withConnectedBtDevice_preferenceVisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLUETOOTH_A2DP);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
- mProfileConnectableDevices.clear();
- mProfileConnectableDevices.add(mBluetoothDevice);
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mProfileConnectableDevices);
+ mProfileConnectedDevices.clear();
+ mProfileConnectedDevices.add(mBluetoothDevice);
+ when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
assertThat(mPreference.isVisible()).isFalse();
// Without Active Bluetooth Device
@@ -208,17 +208,17 @@ public class MediaOutputPreferenceControllerTest {
}
/**
- * A2DP Bluetooth device(s) are connectable, but no device is set as activated
+ * A2DP Bluetooth device(s) are connected, but no device is set as activated
* Preference summary should be "This device"
*/
@Test
- public void updateState_withConnectableBtDevice_withoutActiveBtDevice_setDefaultSummary() {
+ public void updateState_withConnectedBtDevice_withoutActiveBtDevice_setDefaultSummary() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_EARPIECE);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
- mProfileConnectableDevices.clear();
- mProfileConnectableDevices.add(mBluetoothDevice);
- mProfileConnectableDevices.add(mSecondBluetoothDevice);
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mProfileConnectableDevices);
+ mProfileConnectedDevices.clear();
+ mProfileConnectedDevices.add(mBluetoothDevice);
+ mProfileConnectedDevices.add(mSecondBluetoothDevice);
+ when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
when(mA2dpProfile.getActiveDevice()).thenReturn(null);
assertThat(mPreference.getSummary()).isNull();
@@ -235,10 +235,10 @@ public class MediaOutputPreferenceControllerTest {
public void updateState_withActiveBtDevice_setActivatedDeviceName() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLUETOOTH_A2DP);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
- mProfileConnectableDevices.clear();
- mProfileConnectableDevices.add(mBluetoothDevice);
- mProfileConnectableDevices.add(mSecondBluetoothDevice);
- when(mA2dpProfile.getConnectableDevices()).thenReturn(mProfileConnectableDevices);
+ mProfileConnectedDevices.clear();
+ mProfileConnectedDevices.add(mBluetoothDevice);
+ mProfileConnectedDevices.add(mSecondBluetoothDevice);
+ when(mA2dpProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
when(mA2dpProfile.getActiveDevice()).thenReturn(mBluetoothDevice);
assertThat(mPreference.getSummary()).isNull();
@@ -248,16 +248,16 @@ public class MediaOutputPreferenceControllerTest {
/**
- * Hearing Aid device(s) are connectable, no matter active or inactive
+ * Hearing Aid device(s) are connected, no matter active or inactive
* Preference should be visible
*/
@Test
- public void updateState_withConnectableHADevice_preferenceVisible() {
+ public void updateState_withConnectedHADevice_preferenceVisible() {
mShadowAudioManager.setOutputDevice(DEVICE_OUT_HEARING_AID);
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mHearingAidActiveDevices.clear();
mHearingAidActiveDevices.add(mLeftBluetoothHapDevice);
- when(mHearingAidProfile.getConnectableDevices()).thenReturn(mHearingAidActiveDevices);
+ when(mHearingAidProfile.getConnectedDevices()).thenReturn(mHearingAidActiveDevices);
assertThat(mPreference.isVisible()).isFalse();
// Without Active Hearing Aid Device
@@ -280,7 +280,7 @@ public class MediaOutputPreferenceControllerTest {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
mHearingAidActiveDevices.clear();
mHearingAidActiveDevices.add(mLeftBluetoothHapDevice);
- when(mHearingAidProfile.getConnectableDevices()).thenReturn(mHearingAidActiveDevices);
+ when(mHearingAidProfile.getConnectedDevices()).thenReturn(mHearingAidActiveDevices);
when(mHearingAidProfile.getActiveDevices()).thenReturn(mHearingAidActiveDevices);
assertThat(mPreference.getSummary()).isNull();
@@ -332,22 +332,6 @@ public class MediaOutputPreferenceControllerTest {
mContext.getText(R.string.media_out_summary_ongoing_call_state));
}
- /**
- * Media stream is captured by something else (cast device):
- * Preference should be invisible
- * Preference summary should be "unavailable"
- */
- @Test
- public void updateState_mediaStreamIsCapturedByCast_shouldDisableAndSetDefaultSummary() {
- mShadowAudioManager.setOutputDevice(DEVICE_OUT_REMOTE_SUBMIX);
-
- mController.updateState(mPreference);
-
- assertThat(mPreference.isVisible()).isFalse();
- String defaultString = mContext.getString(R.string.media_output_summary_unavailable);
- assertThat(mPreference.getSummary()).isEqualTo(defaultString);
- }
-
@Test
public void findActiveDevice_onlyA2dpDeviceActive_returnA2dpDevice() {
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(null);