Merge "Update Settings owners" into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9a88e98..9dd4732 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -110,7 +110,7 @@
android:hardwareAccelerated="true"
android:requiredForAllUsers="true"
android:supportsRtl="true"
- android:allowBackup="false"
+ android:backupAgent="com.android.settings.backup.SettingsBackupHelper"
android:usesCleartextTraffic="true"
android:defaultToDeviceProtectedStorage="true"
android:directBootAware="true"
@@ -138,6 +138,7 @@
<intent-filter android:priority="1">
<action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
<action android:name="android.settings.DATA_ROAMING_SETTINGS" />
+ <action android:name="android.settings.MMS_MESSAGE_SETTING" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
@@ -2624,6 +2625,7 @@
<receiver android:name=".sim.SimSelectNotification">
<intent-filter>
<action android:name="android.telephony.action.PRIMARY_SUBSCRIPTION_LIST_CHANGED"/>
+ <action android:name="android.settings.ENABLE_MMS_DATA_REQUEST"/>
</intent-filter>
</receiver>
diff --git a/res/drawable/button_border_selected.xml b/res/drawable/button_border_selected.xml
index 2681bf0..9701b38 100644
--- a/res/drawable/button_border_selected.xml
+++ b/res/drawable/button_border_selected.xml
@@ -18,6 +18,6 @@
android:shape="rectangle">
<stroke
android:width="2dp"
- android:color="?android:attr/colorAccent"/>
+ android:color="?android:attr/textColorSecondary"/>
<corners android:radius="@dimen/rect_button_radius" />
-</shape>
\ No newline at end of file
+</shape>
diff --git a/res/drawable/button_border_unselected.xml b/res/drawable/button_border_unselected.xml
index 72e9076..4153303 100644
--- a/res/drawable/button_border_unselected.xml
+++ b/res/drawable/button_border_unselected.xml
@@ -18,7 +18,7 @@
android:shape="rectangle">
<stroke
android:width="2dp"
- android:color="@color/notification_importance_button_unselected"/>
+ android:color="?android:attr/textColorSecondary"/>
<corners android:radius="@dimen/rect_button_radius" />
-</shape>
\ No newline at end of file
+</shape>
diff --git a/res/drawable/ic_settings_gestures.xml b/res/drawable/ic_settings_gestures.xml
index 4fe0bf3..c75e7c3 100644
--- a/res/drawable/ic_settings_gestures.xml
+++ b/res/drawable/ic_settings_gestures.xml
@@ -20,9 +20,6 @@
android:viewportHeight="32.0"
android:tint="?android:attr/colorControlNormal">
<path
- android:fillColor="#FF000000"
- android:pathData="M20,20.2V24H6V5.3h8.7l2.4,-4H7.6c-2.2,0 -4,1.8 -4,4v21.3c0,2.2 1.8,4 4,4h10.7c2.2,0 4,-1.8 4,-4V14.9L20,20.2zM15.6,28h-5.3v-1.3h5.3V28z"/>
- <path
- android:fillColor="#FF000000"
- android:pathData="M28.5,7l1.1,-2.4L32,3.5l-2.4,-1.1L28.5,0l-1.1,2.4L25,3.5l2.4,1.1L28.5,7zM21,7.4l-2.2,-4.8l-2.2,4.8l-4.8,2.2l4.8,2.2l2.2,4.8l2.2,-4.8l4.8,-2.2L21,7.4zM28.5,12.2l-1.1,2.4L25,15.6l2.4,1.1l1.1,2.4l1.1,-2.4l2.4,-1.1l-2.4,-1.1L28.5,12.2z"/>
+ android:fillColor="@android:color/white"
+ android:pathData="M4.59 6.89c0.7-0.71 1.4-1.35 1.71-1.22 0.5 0.2 0 1.03-0.3 1.52-0.25 0.42 -2.86 3.89-2.86 6.31 0 1.28 0.48 2.34 1.34 2.98 0.75 0.56 1.74 0.73 2.64 0.46 1.07-0.31 1.95-1.4 3.06-2.77 1.21-1.49 2.83-3.44 4.08-3.44 1.63 0 1.65 1.01 1.76 1.79-3.78 0.64 -5.38 3.67-5.38 5.37 0 1.7 1.44 3.09 3.21 3.09 1.63 0 4.29-1.33 4.69-6.1H21v-2.5h-2.47c-0.15-1.65-1.09-4.2-4.03-4.2-2.25 0-4.18 1.91-4.94 2.84-0.58 0.73 -2.06 2.48-2.29 2.72-0.25 0.3 -0.68 0.84 -1.11 0.84 -0.45 0-0.72-0.83-0.36-1.92 0.35 -1.09 1.4-2.86 1.85-3.52 0.78 -1.14 1.3-1.92 1.3-3.28C8.95 3.69 7.31 3 6.44 3 5.12 3 3.97 4 3.72 4.25c-0.36 0.36 -0.66 0.66 -0.88 0.93 l1.75 1.71zm9.29 11.66c-0.31 0-0.74-0.26-0.74-0.72 0-0.6 0.73 -2.2 2.87-2.76-0.3 2.69-1.43 3.48-2.13 3.48z" />
</vector>
\ No newline at end of file
diff --git a/res/layout/notif_importance_preference.xml b/res/layout/notif_importance_preference.xml
index bc0d5aa..3507675 100644
--- a/res/layout/notif_importance_preference.xml
+++ b/res/layout/notif_importance_preference.xml
@@ -21,53 +21,92 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
+ android:padding="@dimen/notification_importance_toggle_marginTop"
android:orientation="vertical">
- <LinearLayout
- android:id="@+id/buttons"
+ <RelativeLayout
+ android:id="@+id/alert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/notification_importance_toggle_marginTop"
- android:orientation="horizontal"
- android:gravity="center">
+ android:padding="@dimen/notification_importance_button_padding"
+ android:clickable="true"
+ android:focusable="true">
+ <ImageView
+ android:id="@+id/alert_icon"
+ android:src="@drawable/ic_notification_alert"
+ android:background="@android:color/transparent"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"/>
+ <TextView
+ android:id="@+id/alert_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:clickable="false"
+ android:focusable="false"
+ android:layout_toEndOf="@id/alert_icon"
+ android:layout_marginStart="@dimen/notification_importance_drawable_padding"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
+ android:text="@string/notification_alert_title"/>
+ <TextView
+ android:id="@+id/alert_summary"
+ android:paddingTop="@dimen/notification_importance_button_padding"
+ android:text="@string/notification_channel_summary_default"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:layout_below="@id/alert_icon"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
+ </RelativeLayout>
- <Button
- android:id="@+id/alert"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:minWidth="@dimen/notification_importance_button_width"
- android:paddingStart="@dimen/notification_importance_button_horiz_padding"
- android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
- android:drawablePadding="@dimen/notification_importance_drawable_padding"
- android:foreground="@drawable/button_ripple_radius"
- android:drawableLeft="@drawable/ic_notification_alert"
- android:text="@string/notification_alert_title" />
-
- <Button
- android:id="@+id/silence"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/notification_importance_toggle_size"
- android:minWidth="@dimen/notification_importance_button_width"
- android:paddingStart="@dimen/notification_importance_button_horiz_padding"
- android:paddingEnd="@dimen/notification_importance_button_horiz_padding"
- android:drawablePadding="@dimen/notification_importance_drawable_padding"
- android:foreground="@drawable/button_ripple_radius"
- android:layout_marginStart="@dimen/notification_importance_button_separation"
- android:drawableLeft="@drawable/ic_notification_silence"
- android:text="@string/notification_silence_title" />
-
- </LinearLayout>
-
- <TextView
- android:id="@+id/description"
+ <RelativeLayout
+ android:id="@+id/silence"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/notification_alert_title"
- android:gravity="center"
- android:layout_marginTop="@dimen/notification_importance_text_marginTop"
- android:layout_marginBottom="@dimen/notification_importance_toggle_marginBottom"
- android:paddingStart="@dimen/notification_importance_description_padding"
- android:paddingEnd="@dimen/notification_importance_description_padding"
- android:textAppearance="@style/TextAppearance.NotificationImportanceDetail" />
+ android:padding="@dimen/notification_importance_button_padding"
+ android:layout_marginTop="@dimen/notification_importance_button_separation"
+ android:clickable="true"
+ android:focusable="true">
+ <ImageView
+ android:id="@+id/silence_icon"
+ android:src="@drawable/ic_notification_silence"
+ android:background="@android:color/transparent"
+ android:layout_gravity="center"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"/>
+ <TextView
+ android:id="@+id/silence_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:clickable="false"
+ android:focusable="false"
+ android:layout_toEndOf="@id/silence_icon"
+ android:layout_marginStart="@dimen/notification_importance_drawable_padding"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceButton.Unselected"
+ android:text="@string/notification_silence_title"/>
+ <TextView
+ android:id="@+id/silence_summary"
+ android:paddingTop="@dimen/notification_importance_button_padding"
+ android:text="@string/notification_channel_summary_default"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:layout_below="@id/silence_icon"
+ android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"/>
+ </RelativeLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/panel_slice_row.xml b/res/layout/panel_slice_row.xml
index 4e1184b..74dc412 100644
--- a/res/layout/panel_slice_row.xml
+++ b/res/layout/panel_slice_row.xml
@@ -22,8 +22,9 @@
<androidx.slice.widget.SliceView
android:id="@+id/slice_view"
+ style="@style/SliceViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="20dp"
- android:paddingEnd="20dp"/>
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"/>
</LinearLayout>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c871ac8..a348f8a 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -79,6 +79,7 @@
<dimen name="notification_importance_description_padding">20dp</dimen>
<dimen name="notification_importance_description_text">14sp</dimen>
<dimen name="notification_importance_button_text">16sp</dimen>
+ <dimen name="notification_importance_button_padding">14dp</dimen>
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
<dimen name="zen_schedule_day_margin">17dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5609006..615077c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7330,6 +7330,9 @@
<!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
<string name="keywords_battery_saver_schedule">routine, schedule, battery saver, power saver, battery, automatic, percent</string>
+ <!-- List of synonyms for the Add an account setting [CHAR_LIMIT=NONE] -->
+ <string name="keywords_add_an_account">work profile</string>
+
<!-- Option title for the default sound, context based on screen -->
<string name="default_sound">Default sound</string>
@@ -7802,7 +7805,7 @@
<string name="profile_section_header">Work notifications</string>
<!-- Configure Notifications: section header for prioritizer settings [CHAR LIMIT=80] -->
- <string name="smart_notifications_title">Smart notifications</string>
+ <string name="smart_notifications_title">Adaptive notifications</string>
<!-- Configure Notifications: setting title [CHAR LIMIT=80] -->
<string name="asst_capability_prioritizer_title">Automatic Prioritization</string>
@@ -7973,25 +7976,25 @@
<!-- Channel summaries for the app notification page -->
- <!-- [CHAR LIMIT=100] Notification Importance title: min importance level summary -->
+ <!-- [CHAR LIMIT=150] Notification Importance title: min importance level summary -->
<string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low">Always silent. Displays in pull-down shade.</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low">Helps you focus with notifications only in the pull-down shade. Always silent.</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_status">Always silent. Displays in pull-down shade & status bar.</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_status">Displays below priority notifications. Always silent.</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_lock">Always silent. Displays in pull-down shade & on lock screen.</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_lock">Displays below priority notifications. Always silent.</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: low importance level summary -->
- <string name="notification_channel_summary_low_status_lock">Always silent. Displays in pull-down shade, status bar & on lock screen.</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
+ <string name="notification_channel_summary_low_status_lock">Displays below priority notifications. Always silent.</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: normal importance level summary -->
- <string name="notification_channel_summary_default">Makes sound and displays in pull-down shade, status bar & on lock screen.</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
+ <string name="notification_channel_summary_default">Gets your attention with sound & a status bar icon. Shows on lock screen.</string>
- <!-- [CHAR LIMIT=100] Notification Importance title: high importance level summary -->
+ <!-- [CHAR LIMIT=150] Notification Importance title: high importance level summary -->
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
diff --git a/res/xml/add_account_settings.xml b/res/xml/add_account_settings.xml
index 6b36f8d..01e7674 100644
--- a/res/xml/add_account_settings.xml
+++ b/res/xml/add_account_settings.xml
@@ -19,4 +19,5 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="add_account_screen"
android:title="@string/header_add_an_account"
- settings:controller="com.android.settings.accounts.ChooseAccountPreferenceController" />
+ settings:controller="com.android.settings.accounts.ChooseAccountPreferenceController"
+ settings:keywords="@string/keywords_add_an_account"/>
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index e0ce1c0..fdc930e 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -40,6 +40,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.SystemProperties;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentityCdma;
@@ -130,6 +131,13 @@
private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
private static final int CELL_INFO_LIST_RATE_MAX = 0;
+ private static final String DSDS_MODE_PROPERTY = "ro.boot.hardware.dsds";
+
+ /**
+ * A value indicates the device is always on dsds mode.
+ * @see {@link #DSDS_MODE_PROPERTY}
+ */
+ private static final int ALWAYS_ON_DSDS_MODE = 1;
private static final int IMS_VOLTE_PROVISIONED_CONFIG_ID =
ImsConfig.ConfigConstants.VLT_SETTING_ENABLED;
@@ -497,7 +505,7 @@
cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
dsdsSwitch = findViewById(R.id.dsds_switch);
- if (isDsdsSupported()) {
+ if (isDsdsSupported() && !dsdsModeOnly()) {
dsdsSwitch.setVisibility(View.VISIBLE);
dsdsSwitch.setOnClickListener(v -> {
if (mTelephonyManager.doesSwitchMultiSimConfigTriggerReboot()) {
@@ -1694,6 +1702,14 @@
mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
}
+ /**
+ * @return {@code True} if the device is only supported dsds mode.
+ */
+ private boolean dsdsModeOnly() {
+ String dsdsMode = SystemProperties.get(DSDS_MODE_PROPERTY);
+ return !TextUtils.isEmpty(dsdsMode) && Integer.parseInt(dsdsMode) == ALWAYS_ON_DSDS_MODE;
+ }
+
DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
new DialogInterface.OnClickListener() {
@Override
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 56fa455..f07c66c 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -421,6 +421,10 @@
for (GrantedUriPermission perm : perms) {
String authority = perm.uri.getAuthority();
ProviderInfo provider = pm.resolveContentProvider(authority, 0);
+ if (provider == null) {
+ continue;
+ }
+
CharSequence app = provider.applicationInfo.loadLabel(pm);
MutableInt count = uriCounters.get(app);
if (count == null) {
diff --git a/src/com/android/settings/backup/SettingsBackupHelper.java b/src/com/android/settings/backup/SettingsBackupHelper.java
new file mode 100644
index 0000000..92612b0
--- /dev/null
+++ b/src/com/android/settings/backup/SettingsBackupHelper.java
@@ -0,0 +1,89 @@
+/**
+ * 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.backup;
+
+import android.app.backup.BackupAgentHelper;
+import android.app.backup.BackupDataInputStream;
+import android.app.backup.BackupDataOutput;
+import android.app.backup.BackupHelper;
+import android.os.ParcelFileDescriptor;
+
+import com.android.settings.shortcut.CreateShortcutPreferenceController;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Backup agent for Settings APK
+ */
+public class SettingsBackupHelper extends BackupAgentHelper {
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ addHelper("no-op", new NoOpHelper());
+ }
+
+ @Override
+ public void onRestoreFinished() {
+ super.onRestoreFinished();
+ CreateShortcutPreferenceController.updateRestoredShortcuts(this);
+ }
+
+ /**
+ * Backup helper which does not do anything. Having at least one helper ensures that the
+ * transport is not empty and onRestoreFinished is called eventually.
+ */
+ private static class NoOpHelper implements BackupHelper {
+
+ private final int VERSION_CODE = 1;
+
+ @Override
+ public void performBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+ ParcelFileDescriptor newState) {
+
+ try (FileOutputStream out = new FileOutputStream(newState.getFileDescriptor())) {
+ if (getVersionCode(oldState) != VERSION_CODE) {
+ data.writeEntityHeader("dummy", 1);
+ data.writeEntityData(new byte[1], 1);
+ }
+
+ // Write new version code
+ out.write(VERSION_CODE);
+ out.flush();
+ } catch (IOException e) { }
+ }
+
+ @Override
+ public void restoreEntity(BackupDataInputStream data) { }
+
+ @Override
+ public void writeNewStateDescription(ParcelFileDescriptor newState) { }
+
+ private int getVersionCode(ParcelFileDescriptor state) {
+ if (state == null) {
+ return 0;
+ }
+ try (FileInputStream in = new FileInputStream(state.getFileDescriptor())) {
+ return in.read();
+ } catch (IOException e) {
+ return 0;
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
index 1c75669..d42a1be 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceRenamePreferenceController.java
@@ -66,7 +66,7 @@
if (TextUtils.equals(getPreferenceKey(), preference.getKey()) && mFragment != null) {
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_BLUETOOTH_RENAME);
- LocalDeviceNameDialogFragment.newInstance()
+ new LocalDeviceNameDialogFragment()
.show(mFragment.getFragmentManager(), LocalDeviceNameDialogFragment.TAG);
return true;
}
diff --git a/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java b/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
index 5cf2ccc..c15dd04 100644
--- a/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
+++ b/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragment.java
@@ -31,10 +31,6 @@
public static final String TAG = "LocalAdapterName";
private BluetoothAdapter mBluetoothAdapter;
- public static LocalDeviceNameDialogFragment newInstance() {
- return new LocalDeviceNameDialogFragment();
- }
-
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
index 761755c..d1051fe 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
@@ -30,6 +30,7 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.ArrayMap;
+import android.view.View;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
@@ -112,9 +113,12 @@
continue;
}
final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
- drawable.setColorFilter(new PorterDuffColorFilter(
- mContext.getResources().getColor(batteryTip.getIconTintColorId()),
- PorterDuff.Mode.SRC_IN));
+ final int iconTintColorId = batteryTip.getIconTintColorId();
+ if (iconTintColorId != View.NO_ID) {
+ drawable.setColorFilter(new PorterDuffColorFilter(
+ mContext.getResources().getColor(iconTintColorId),
+ PorterDuff.Mode.SRC_IN));
+ }
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(),
diff --git a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
index c8b5b6d..c37d2b5 100644
--- a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
@@ -16,20 +16,11 @@
package com.android.settings.inputmethod;
-import android.annotation.DrawableRes;
-import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
import android.content.res.Configuration;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.view.inputmethod.InputMethodInfo;
@@ -93,59 +84,12 @@
return SettingsEnums.ENABLE_VIRTUAL_KEYBOARDS;
}
- @Nullable
- private static Drawable loadDrawable(@NonNull final PackageManager packageManager,
- @NonNull final String packageName, @DrawableRes final int resId,
- @NonNull final ApplicationInfo applicationInfo) {
- if (resId == 0) {
- return null;
- }
- try {
- return packageManager.getDrawable(packageName, resId, applicationInfo);
- } catch (Exception e) {
- return null;
- }
- }
-
- @NonNull
- private static Drawable getInputMethodIcon(@NonNull final PackageManager packageManager,
- @NonNull final InputMethodInfo imi) {
- final ServiceInfo si = imi.getServiceInfo();
- final ApplicationInfo ai = si != null ? si.applicationInfo : null;
- final String packageName = imi.getPackageName();
- if (si == null || ai == null || packageName == null) {
- return new ColorDrawable(Color.TRANSPARENT);
- }
- // We do not use ServiceInfo#loadLogo() and ServiceInfo#loadIcon here since those methods
- // internally have some fallback rules, which we want to do manually.
- Drawable drawable = loadDrawable(packageManager, packageName, si.logo, ai);
- if (drawable != null) {
- return drawable;
- }
- drawable = loadDrawable(packageManager, packageName, si.icon, ai);
- if (drawable != null) {
- return drawable;
- }
- // We do not use ApplicationInfo#loadLogo() and ApplicationInfo#loadIcon here since those
- // methods internally have some fallback rules, which we want to do manually.
- drawable = loadDrawable(packageManager, packageName, ai.logo, ai);
- if (drawable != null) {
- return drawable;
- }
- drawable = loadDrawable(packageManager, packageName, ai.icon, ai);
- if (drawable != null) {
- return drawable;
- }
- return new ColorDrawable(Color.TRANSPARENT);
- }
-
private void updateInputMethodPreferenceViews() {
mInputMethodSettingValues.refreshAllInputMethodAndSubtypes();
// Clear existing "InputMethodPreference"s
mInputMethodPreferenceList.clear();
List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
final Context context = getPrefContext();
- final PackageManager packageManager = getActivity().getPackageManager();
final List<InputMethodInfo> imis = mInputMethodSettingValues.getInputMethodList();
final int numImis = (imis == null ? 0 : imis.size());
for (int i = 0; i < numImis; ++i) {
@@ -154,7 +98,7 @@
|| permittedList.contains(imi.getPackageName());
final InputMethodPreference pref = new InputMethodPreference(
context, imi, true, isAllowedByOrganization, this);
- pref.setIcon(getInputMethodIcon(packageManager, imi));
+ pref.setIcon(imi.loadIcon(context.getPackageManager()));
mInputMethodPreferenceList.add(pref);
}
final Collator collator = Collator.getInstance();
diff --git a/src/com/android/settings/inputmethod/VirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/VirtualKeyboardFragment.java
index cb7831e..ef07d11 100644
--- a/src/com/android/settings/inputmethod/VirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/VirtualKeyboardFragment.java
@@ -20,8 +20,6 @@
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
@@ -48,7 +46,6 @@
public final class VirtualKeyboardFragment extends SettingsPreferenceFragment implements Indexable {
private static final String ADD_VIRTUAL_KEYBOARD_SCREEN = "add_virtual_keyboard_screen";
- private static final Drawable NO_ICON = new ColorDrawable(Color.TRANSPARENT);
private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = new ArrayList<>();
private InputMethodManager mImm;
@@ -89,14 +86,7 @@
final InputMethodInfo imi = imis.get(i);
final boolean isAllowedByOrganization = permittedList == null
|| permittedList.contains(imi.getPackageName());
- Drawable icon;
- try {
- // TODO: Consider other ways to retrieve an icon to show here.
- icon = getActivity().getPackageManager().getApplicationIcon(imi.getPackageName());
- } catch (Exception e) {
- // TODO: Consider handling the error differently perhaps by showing default icons.
- icon = NO_ICON;
- }
+ final Drawable icon = imi.loadIcon(context.getPackageManager());
final InputMethodPreference pref = new InputMethodPreference(
context,
imi,
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index e700329..ebac51f 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -59,7 +59,11 @@
return subscriptions;
}
- private static boolean isInactiveInsertedPSim(UiccSlotInfo slotInfo) {
+ @VisibleForTesting
+ static boolean isInactiveInsertedPSim(UiccSlotInfo slotInfo) {
+ if (slotInfo == null) {
+ return false;
+ }
return !slotInfo.getIsEuicc() && !slotInfo.getIsActive() &&
slotInfo.getCardStateInfo() == CARD_STATE_INFO_PRESENT;
}
diff --git a/src/com/android/settings/notification/ImportancePreference.java b/src/com/android/settings/notification/ImportancePreference.java
index 687782b..f48882d 100644
--- a/src/com/android/settings/notification/ImportancePreference.java
+++ b/src/com/android/settings/notification/ImportancePreference.java
@@ -20,10 +20,16 @@
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.transition.AutoTransition;
+import android.transition.TransitionManager;
import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
@@ -38,11 +44,12 @@
private int mImportance;
private boolean mDisplayInStatusBar;
private boolean mDisplayOnLockscreen;
- private Button mSilenceButton;
- private Button mAlertButton;
+ private View mSilenceButton;
+ private View mAlertButton;
private Context mContext;
Drawable selectedBackground;
Drawable unselectedBackground;
+ private static final int BUTTON_ANIM_TIME_MS = 100;
public ImportancePreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
@@ -89,13 +96,12 @@
}
@Override
- public void onBindViewHolder(PreferenceViewHolder holder) {
+ public void onBindViewHolder(final PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.itemView.setClickable(false);
- TextView textView = (TextView) holder.findViewById(R.id.description);
- mSilenceButton = (Button) holder.findViewById(R.id.silence);
- mAlertButton = (Button) holder.findViewById(R.id.alert);
+ mSilenceButton = holder.findViewById(R.id.silence);
+ mAlertButton = holder.findViewById(R.id.alert);
if (!mIsConfigurable) {
mSilenceButton.setEnabled(false);
@@ -114,34 +120,41 @@
mAlertButton.setBackground(selectedBackground);
break;
}
- setImportanceSummary(textView, mImportance);
+ setImportanceSummary((ViewGroup) holder.itemView, mImportance, false);
mSilenceButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_LOW);
mAlertButton.setBackground(unselectedBackground);
+ mAlertButton.setSelected(false);
mSilenceButton.setBackground(selectedBackground);
- mSilenceButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Selected);
- mAlertButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Unselected);
- setImportanceSummary(textView, IMPORTANCE_LOW);
+ mSilenceButton.setSelected(true);
+ setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
});
mAlertButton.setOnClickListener(v -> {
callChangeListener(IMPORTANCE_DEFAULT);
mSilenceButton.setBackground(unselectedBackground);
+ mSilenceButton.setSelected(false);
mAlertButton.setBackground(selectedBackground);
- mAlertButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Selected);
- mSilenceButton.setTextAppearance(
- R.style.TextAppearance_NotificationImportanceButton_Unselected);
- setImportanceSummary(textView, IMPORTANCE_DEFAULT);
+ mAlertButton.setSelected(true);
+ setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_DEFAULT, true);
});
}
- void setImportanceSummary(TextView view, int importance) {
+ void setImportanceSummary(ViewGroup parent, int importance, boolean fromUser) {
+ if (fromUser) {
+ AutoTransition transition = new AutoTransition();
+ transition.setDuration(BUTTON_ANIM_TIME_MS);
+ TransitionManager.beginDelayedTransition(parent, transition);
+ }
if (importance >= IMPORTANCE_DEFAULT) {
+ parent.findViewById(R.id.silence_summary).setVisibility(GONE);
+ TextView view = parent.findViewById(R.id.alert_summary);
view.setText(R.string.notification_channel_summary_default);
+ view.setVisibility(VISIBLE);
} else {
+ parent.findViewById(R.id.alert_summary).setVisibility(GONE);
+ TextView view = parent.findViewById(R.id.silence_summary);
+ view.setVisibility(VISIBLE);
if (mDisplayInStatusBar) {
if (mDisplayOnLockscreen) {
view.setText(R.string.notification_channel_summary_low_status_lock);
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 46b2ec6..dc59275 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -22,6 +22,7 @@
import android.app.NotificationChannel;
import android.content.Context;
import android.media.RingtoneManager;
+import android.provider.Settings;
import com.android.settings.core.PreferenceControllerMixin;
@@ -64,7 +65,8 @@
pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
pref.setImportance(mChannel.getImportance());
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
- // TODO: b/128445911 pass along lock screen setting
+ pref.setDisplayOnLockscreen(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0) == 1);
}
}
diff --git a/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
index 9b9de5f..6b95b92 100644
--- a/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
+++ b/src/com/android/settings/shortcut/CreateShortcutPreferenceController.java
@@ -38,11 +38,6 @@
import android.view.View;
import android.widget.ImageView;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-
import com.android.settings.R;
import com.android.settings.Settings.TetherSettingsActivity;
import com.android.settings.core.BasePreferenceController;
@@ -54,6 +49,11 @@
import java.util.Comparator;
import java.util.List;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceGroup;
+
/**
* {@link BasePreferenceController} that populates a list of widgets that Settings app support.
*/
@@ -143,24 +143,7 @@
@VisibleForTesting
Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
CharSequence label) {
- final ActivityInfo activityInfo = resolveInfo.activityInfo;
-
- final Icon maskableIcon;
- if (activityInfo.icon != 0 && activityInfo.applicationInfo != null) {
- maskableIcon = Icon.createWithAdaptiveBitmap(createIcon(
- activityInfo.applicationInfo, activityInfo.icon,
- R.layout.shortcut_badge_maskable,
- mContext.getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable)));
- } else {
- maskableIcon = Icon.createWithResource(mContext, R.drawable.ic_launcher_settings);
- }
- final String shortcutId = SHORTCUT_ID_PREFIX +
- shortcutIntent.getComponent().flattenToShortString();
- ShortcutInfo info = new ShortcutInfo.Builder(mContext, shortcutId)
- .setShortLabel(label)
- .setIntent(shortcutIntent)
- .setIcon(maskableIcon)
- .build();
+ ShortcutInfo info = createShortcutInfo(mContext, shortcutIntent, resolveInfo, label);
Intent intent = mShortcutManager.createShortcutResultIntent(info);
if (intent == null) {
intent = new Intent();
@@ -170,8 +153,10 @@
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent)
.putExtra(Intent.EXTRA_SHORTCUT_NAME, label);
+ final ActivityInfo activityInfo = resolveInfo.activityInfo;
if (activityInfo.icon != 0) {
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(
+ mContext,
activityInfo.applicationInfo,
activityInfo.icon,
R.layout.shortcut_badge,
@@ -217,15 +202,40 @@
info.activityInfo.name);
}
- private Intent buildShortcutIntent(ResolveInfo info) {
+ private static Intent buildShortcutIntent(ResolveInfo info) {
return new Intent(SHORTCUT_PROBE)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP)
.setClassName(info.activityInfo.packageName, info.activityInfo.name);
}
- private Bitmap createIcon(ApplicationInfo app, int resource, int layoutRes, int size) {
- final Context context = new ContextThemeWrapper(mContext, android.R.style.Theme_Material);
- final View view = LayoutInflater.from(context).inflate(layoutRes, null);
+ private static ShortcutInfo createShortcutInfo(Context context, Intent shortcutIntent,
+ ResolveInfo resolveInfo, CharSequence label) {
+ final ActivityInfo activityInfo = resolveInfo.activityInfo;
+
+ final Icon maskableIcon;
+ if (activityInfo.icon != 0 && activityInfo.applicationInfo != null) {
+ maskableIcon = Icon.createWithAdaptiveBitmap(createIcon(
+ context,
+ activityInfo.applicationInfo, activityInfo.icon,
+ R.layout.shortcut_badge_maskable,
+ context.getResources().getDimensionPixelSize(R.dimen.shortcut_size_maskable)));
+ } else {
+ maskableIcon = Icon.createWithResource(context, R.drawable.ic_launcher_settings);
+ }
+ final String shortcutId = SHORTCUT_ID_PREFIX +
+ shortcutIntent.getComponent().flattenToShortString();
+ return new ShortcutInfo.Builder(context, shortcutId)
+ .setShortLabel(label)
+ .setIntent(shortcutIntent)
+ .setIcon(maskableIcon)
+ .build();
+ }
+
+ private static Bitmap createIcon(Context context, ApplicationInfo app, int resource,
+ int layoutRes, int size) {
+ final Context themedContext = new ContextThemeWrapper(context,
+ android.R.style.Theme_Material);
+ final View view = LayoutInflater.from(themedContext).inflate(layoutRes, null);
final int spec = View.MeasureSpec.makeMeasureSpec(size, View.MeasureSpec.EXACTLY);
view.measure(spec, spec);
final Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
@@ -234,14 +244,15 @@
Drawable iconDrawable;
try {
- iconDrawable = mPackageManager.getResourcesForApplication(app).getDrawable(resource);
+ iconDrawable = context.getPackageManager().getResourcesForApplication(app)
+ .getDrawable(resource);
if (iconDrawable instanceof LayerDrawable) {
iconDrawable = ((LayerDrawable) iconDrawable).getDrawable(1);
}
((ImageView) view.findViewById(android.R.id.icon)).setImageDrawable(iconDrawable);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Cannot load icon from app " + app + ", returning a default icon");
- Icon icon = Icon.createWithResource(mContext, R.drawable.ic_launcher_settings);
+ Icon icon = Icon.createWithResource(context, R.drawable.ic_launcher_settings);
((ImageView) view.findViewById(android.R.id.icon)).setImageIcon(icon);
}
@@ -250,12 +261,24 @@
return bitmap;
}
- private static final Comparator<ResolveInfo> SHORTCUT_COMPARATOR =
- new Comparator<ResolveInfo>() {
+ public static void updateRestoredShortcuts(Context context) {
+ ShortcutManager sm = context.getSystemService(ShortcutManager.class);
+ List<ShortcutInfo> updatedShortcuts = new ArrayList<>();
+ for (ShortcutInfo si : sm.getPinnedShortcuts()) {
+ if (si.getId().startsWith(SHORTCUT_ID_PREFIX)) {
+ ResolveInfo ri = context.getPackageManager().resolveActivity(si.getIntent(), 0);
- @Override
- public int compare(ResolveInfo i1, ResolveInfo i2) {
- return i1.priority - i2.priority;
+ if (ri != null) {
+ updatedShortcuts.add(createShortcutInfo(context, buildShortcutIntent(ri), ri,
+ si.getShortLabel()));
}
- };
+ }
+ }
+ if (!updatedShortcuts.isEmpty()) {
+ sm.updateShortcuts(updatedShortcuts);
+ }
+ }
+
+ private static final Comparator<ResolveInfo> SHORTCUT_COMPARATOR =
+ (i1, i2) -> i1.priority - i2.priority;
}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 3179e6a..911d0e8 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -16,12 +16,18 @@
package com.android.settings.sim;
+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.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_ALL;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_DATA;
import static android.telephony.TelephonyManager.EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE;
import static android.telephony.TelephonyManager.EXTRA_SUBSCRIPTION_ID;
+import static android.telephony.data.ApnSetting.TYPE_MMS;
+import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -32,28 +38,97 @@
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.Settings.SimSettingsActivity;
-
-import androidx.core.app.NotificationCompat;
+import com.android.settings.network.telephony.MobileNetworkActivity;
public class SimSelectNotification extends BroadcastReceiver {
private static final String TAG = "SimSelectNotification";
- private static final int NOTIFICATION_ID = 1;
+ @VisibleForTesting
+ public static final int SIM_SELECT_NOTIFICATION_ID = 1;
+ @VisibleForTesting
+ public static final int ENABLE_MMS_NOTIFICATION_ID = 2;
- private static final String SIM_SELECT_NOTIFICATION_CHANNEL =
+ @VisibleForTesting
+ public static final String SIM_SELECT_NOTIFICATION_CHANNEL =
"sim_select_notification_channel";
+ @VisibleForTesting
+ public static final String ENABLE_MMS_NOTIFICATION_CHANNEL =
+ "enable_mms_notification_channel";
+
@Override
public void onReceive(Context context, Intent intent) {
- if (!TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED.equals(intent.getAction())) {
+ String action = intent.getAction();
+
+ if (action == null) {
+ Log.w(TAG, "Received unexpected intent with null action.");
return;
}
+
+ switch (action) {
+ case TelephonyManager.ACTION_PRIMARY_SUBSCRIPTION_LIST_CHANGED:
+ onPrimarySubscriptionListChanged(context, intent);
+ break;
+ case Settings.ACTION_ENABLE_MMS_DATA_REQUEST:
+ onEnableMmsDataRequest(context, intent);
+ break;
+ default:
+ Log.w(TAG, "Received unexpected intent " + intent.getAction());
+ }
+ }
+
+ private void onEnableMmsDataRequest(Context context, Intent intent) {
+ // Getting subId from extra.
+ int subId = intent.getIntExtra(EXTRA_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
+ subId = SubscriptionManager.getDefaultSmsSubscriptionId();
+ }
+
+ SubscriptionManager subscriptionManager = ((SubscriptionManager) context.getSystemService(
+ Context.TELEPHONY_SUBSCRIPTION_SERVICE));
+ if (!subscriptionManager.isActiveSubId(subId)) {
+ Log.w(TAG, "onEnableMmsDataRequest invalid sub ID " + subId);
+ return;
+ }
+
+ // Getting request reason from extra, which will determine the notification title.
+ CharSequence notificationTitle = null;
+ int requestReason = intent.getIntExtra(EXTRA_ENABLE_MMS_DATA_REQUEST_REASON, -1);
+ if (requestReason == ENABLE_MMS_DATA_REQUEST_REASON_INCOMING_MMS) {
+ notificationTitle = context.getResources().getText(
+ R.string.enable_receiving_mms_notification_title);
+ } else if (requestReason == ENABLE_MMS_DATA_REQUEST_REASON_OUTGOING_MMS) {
+ notificationTitle = context.getResources().getText(
+ R.string.enable_sending_mms_notification_title);
+ } else {
+ Log.w(TAG, "onEnableMmsDataRequest invalid request reason " + requestReason);
+ return;
+ }
+
+ TelephonyManager tm = ((TelephonyManager) context.getSystemService(
+ Context.TELEPHONY_SERVICE)).createForSubscriptionId(subId);
+
+ if (tm.isDataEnabledForApn(TYPE_MMS)) {
+ Log.w(TAG, "onEnableMmsDataRequest MMS data already enabled on sub ID " + subId);
+ return;
+ }
+
+ CharSequence notificationSummary = context.getResources().getString(
+ R.string.enable_mms_notification_summary, tm.getSimOperatorName());
+
+ cancelEnableMmsNotification(context);
+
+ createEnableMmsNotification(context, notificationTitle, notificationSummary, subId);
+ }
+
+ private void onPrimarySubscriptionListChanged(Context context, Intent intent) {
// Cancel any previous notifications
- cancelNotification(context);
+ cancelSimSelectNotification(context);
// Create a notification to tell the user that some defaults are missing
- createNotification(context);
+ createSimSelectNotification(context);
int dialogType = intent.getIntExtra(EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE,
EXTRA_DEFAULT_SUBSCRIPTION_SELECT_TYPE_NONE);
@@ -76,20 +151,20 @@
}
}
- private void createNotification(Context context){
+ private void createSimSelectNotification(Context context){
final Resources resources = context.getResources();
NotificationChannel notificationChannel = new NotificationChannel(
SIM_SELECT_NOTIFICATION_CHANNEL,
- resources.getString(R.string.sim_selection_channel_title),
+ resources.getText(R.string.sim_selection_channel_title),
NotificationManager.IMPORTANCE_LOW);
- NotificationCompat.Builder builder =
- new NotificationCompat.Builder(context, SIM_SELECT_NOTIFICATION_CHANNEL)
+ Notification.Builder builder =
+ new Notification.Builder(context, SIM_SELECT_NOTIFICATION_CHANNEL)
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
.setColor(context.getColor(R.color.sim_noitification))
- .setContentTitle(resources.getString(R.string.sim_notification_title))
- .setContentText(resources.getString(R.string.sim_notification_summary));
+ .setContentTitle(resources.getText(R.string.sim_notification_title))
+ .setContentText(resources.getText(R.string.sim_notification_summary));
Intent resultIntent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
@@ -98,12 +173,51 @@
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
- notificationManager.notify(NOTIFICATION_ID, builder.build());
+ notificationManager.notify(SIM_SELECT_NOTIFICATION_ID, builder.build());
}
- public static void cancelNotification(Context context) {
+ public static void cancelSimSelectNotification(Context context) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancel(NOTIFICATION_ID);
+ notificationManager.cancel(SIM_SELECT_NOTIFICATION_ID);
+ }
+
+ private void createEnableMmsNotification(Context context, CharSequence titleString,
+ CharSequence notificationSummary, int subId) {
+ final Resources resources = context.getResources();
+
+ NotificationChannel notificationChannel = new NotificationChannel(
+ ENABLE_MMS_NOTIFICATION_CHANNEL,
+ resources.getText(R.string.enable_mms_notification_channel_title),
+ NotificationManager.IMPORTANCE_HIGH);
+
+ Notification.Builder builder =
+ new Notification.Builder(context, ENABLE_MMS_NOTIFICATION_CHANNEL)
+ .setSmallIcon(R.drawable.ic_settings_24dp)
+ .setColor(context.getColor(R.color.sim_noitification))
+ .setContentTitle(titleString)
+ .setContentText(notificationSummary)
+ .setStyle(new Notification.BigTextStyle().bigText(notificationSummary));
+
+ // Create the pending intent that will lead to the subscription setting page.
+ Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
+ resultIntent.setClass(context, MobileNetworkActivity.class);
+ resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
+ resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
+ PendingIntent.FLAG_CANCEL_CURRENT);
+ builder.setContentIntent(resultPendingIntent);
+
+ // Notify the notification.
+ NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.createNotificationChannel(notificationChannel);
+ notificationManager.notify(ENABLE_MMS_NOTIFICATION_ID, builder.build());
+ }
+
+ private void cancelEnableMmsNotification(Context context) {
+ NotificationManager notificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(ENABLE_MMS_NOTIFICATION_ID);
}
}
diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java
index e43c6a5..1222913 100644
--- a/src/com/android/settings/sim/SimSettings.java
+++ b/src/com/android/settings/sim/SimSettings.java
@@ -101,7 +101,7 @@
mSimCards = (PreferenceScreen)findPreference(SIM_CARD_CATEGORY);
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(mNumSlots);
mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
- SimSelectNotification.cancelNotification(getActivity());
+ SimSelectNotification.cancelSimSelectNotification(getActivity());
}
private final SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangeListener
diff --git a/src/com/android/settings/sound/AudioSwitchPreferenceController.java b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
index 0da0f21..5b70d16 100644
--- a/src/com/android/settings/sound/AudioSwitchPreferenceController.java
+++ b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.sound;
import static android.media.AudioManager.STREAM_DEVICES_CHANGED_ACTION;
-import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
@@ -29,7 +28,6 @@
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.MediaRouter;
-import android.media.MediaRouter.Callback;
import android.os.Handler;
import android.os.Looper;
import android.util.FeatureFlagUtils;
@@ -76,7 +74,6 @@
protected AudioSwitchCallback mAudioSwitchPreferenceCallback;
private final AudioManagerAudioDeviceCallback mAudioManagerAudioDeviceCallback;
- private final MediaRouterCallback mMediaRouterCallback;
private final WiredHeadsetBroadcastReceiver mReceiver;
private final Handler mHandler;
private LocalBluetoothManager mLocalBluetoothManager;
@@ -92,7 +89,6 @@
mHandler = new Handler(Looper.getMainLooper());
mAudioManagerAudioDeviceCallback = new AudioManagerAudioDeviceCallback();
mReceiver = new WiredHeadsetBroadcastReceiver();
- mMediaRouterCallback = new MediaRouterCallback();
mConnectedDevices = new ArrayList<>();
final FutureTask<LocalBluetoothManager> localBtManagerFutureTask = new FutureTask<>(
// Avoid StrictMode ThreadPolicy violation
@@ -210,12 +206,12 @@
* get A2dp devices on all states
* (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
*/
- protected List<BluetoothDevice> getConnectableA2dpDevices() {
+ protected List<BluetoothDevice> getConnectedA2dpDevices() {
final A2dpProfile a2dpProfile = mProfileManager.getA2dpProfile();
if (a2dpProfile == null) {
return new ArrayList<>();
}
- return a2dpProfile.getConnectableDevices();
+ return a2dpProfile.getConnectedDevices();
}
/**
@@ -242,31 +238,6 @@
}
/**
- * get hearing aid profile devices on all states
- * (STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING)
- * exclude other devices with same hiSyncId.
- */
- protected List<BluetoothDevice> getConnectableHearingAidDevices() {
- final List<BluetoothDevice> connectedDevices = new ArrayList<>();
- final HearingAidProfile hapProfile = mProfileManager.getHearingAidProfile();
- if (hapProfile == null) {
- return connectedDevices;
- }
- final List<Long> devicesHiSyncIds = new ArrayList<>();
- final List<BluetoothDevice> devices = hapProfile.getConnectableDevices();
- for (BluetoothDevice device : devices) {
- final long hiSyncId = hapProfile.getHiSyncId(device);
- // device with same hiSyncId should not be shown in the UI.
- // So do not add it into connectedDevices.
- if (!devicesHiSyncIds.contains(hiSyncId)) {
- devicesHiSyncIds.add(hiSyncId);
- connectedDevices.add(device);
- }
- }
- return connectedDevices;
- }
-
- /**
* Find active hearing aid device
*/
protected BluetoothDevice findActiveHearingAidDevice() {
@@ -299,7 +270,6 @@
private void register() {
mLocalBluetoothManager.getEventManager().registerCallback(this);
mAudioManager.registerAudioDeviceCallback(mAudioManagerAudioDeviceCallback, mHandler);
- mMediaRouter.addCallback(ROUTE_TYPE_REMOTE_DISPLAY, mMediaRouterCallback);
// Register for misc other intent broadcasts.
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
@@ -310,7 +280,6 @@
private void unregister() {
mLocalBluetoothManager.getEventManager().unregisterCallback(this);
mAudioManager.unregisterAudioDeviceCallback(mAudioManagerAudioDeviceCallback);
- mMediaRouter.removeCallback(mMediaRouterCallback);
mContext.unregisterReceiver(mReceiver);
}
@@ -338,49 +307,4 @@
}
}
}
-
- /** Callback for cast device events. */
- private class MediaRouterCallback extends Callback {
- @Override
- public void onRouteSelected(MediaRouter router, int type, MediaRouter.RouteInfo info) {
- }
-
- @Override
- public void onRouteUnselected(MediaRouter router, int type, MediaRouter.RouteInfo info) {
- }
-
- @Override
- public void onRouteAdded(MediaRouter router, MediaRouter.RouteInfo info) {
- if (info != null && !info.isDefault()) {
- // cast mode
- updateState(mPreference);
- }
- }
-
- @Override
- public void onRouteRemoved(MediaRouter router, MediaRouter.RouteInfo info) {
- }
-
- @Override
- public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo info) {
- if (info != null && !info.isDefault()) {
- // cast mode
- updateState(mPreference);
- }
- }
-
- @Override
- public void onRouteGrouped(MediaRouter router, MediaRouter.RouteInfo info,
- MediaRouter.RouteGroup group, int index) {
- }
-
- @Override
- public void onRouteUngrouped(MediaRouter router, MediaRouter.RouteInfo info,
- MediaRouter.RouteGroup group) {
- }
-
- @Override
- public void onRouteVolumeChanged(MediaRouter router, MediaRouter.RouteInfo info) {
- }
- }
}
diff --git a/src/com/android/settings/sound/MediaOutputPreferenceController.java b/src/com/android/settings/sound/MediaOutputPreferenceController.java
index 47810f7..1831ad6 100644
--- a/src/com/android/settings/sound/MediaOutputPreferenceController.java
+++ b/src/com/android/settings/sound/MediaOutputPreferenceController.java
@@ -16,9 +16,6 @@
package com.android.settings.sound;
-import static android.media.AudioManager.STREAM_MUSIC;
-import static android.media.AudioSystem.DEVICE_OUT_REMOTE_SUBMIX;
-
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
@@ -56,13 +53,6 @@
return;
}
- if (isStreamFromOutputDevice(STREAM_MUSIC, DEVICE_OUT_REMOTE_SUBMIX)) {
- // In cast mode, disable switch entry.
- mPreference.setVisible(false);
- preference.setSummary(mContext.getText(R.string.media_output_summary_unavailable));
- return;
- }
-
if (Utils.isAudioModeOngoingCall(mContext)) {
// Ongoing call status, switch entry for media will be disabled.
mPreference.setVisible(false);
@@ -71,19 +61,19 @@
return;
}
- boolean deviceConnectable = false;
+ boolean deviceConnected = false;
BluetoothDevice activeDevice = null;
// Show preference if there is connected or previously connected device
// Find active device and set its name as the preference's summary
- List<BluetoothDevice> connectableA2dpDevices = getConnectableA2dpDevices();
- List<BluetoothDevice> connectableHADevices = getConnectableHearingAidDevices();
+ List<BluetoothDevice> connectedA2dpDevices = getConnectedA2dpDevices();
+ List<BluetoothDevice> 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 341b227..5f4e9d0 100644
--- a/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiMeteredPreferenceController.java
@@ -24,19 +24,22 @@
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 @@
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 10d1d48..b645d60 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -47,12 +47,14 @@
* <p>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<WifiDialog.WifiDialogListener> mWifiDialogListeners = new ArrayList<>();
@Override
public void onAttach(Context context) {
@@ -89,7 +91,7 @@
|| mAccessPoint == null) {
return null;
}
- return WifiDialog.createModal(getActivity(), mWifiDetailPreferenceController, mAccessPoint,
+ return WifiDialog.createModal(getActivity(), this, mAccessPoint,
WifiConfigUiBase.MODE_MODIFY);
}
@@ -135,15 +137,31 @@
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 7bec411..950cc13 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -18,16 +18,17 @@
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 @@
* 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);
@@ -69,6 +71,12 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int randomizationLevel = getRandomizationValue();
@@ -87,9 +95,13 @@
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 @@
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/bluetooth/LocalDeviceNameDialogFragmentTest.java b/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
deleted file mode 100644
index 9a6ad91..0000000
--- a/tests/robotests/src/com/android/settings/bluetooth/LocalDeviceNameDialogFragmentTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2018 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.bluetooth;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-
-import androidx.appcompat.app.AlertDialog;
-import androidx.fragment.app.FragmentActivity;
-
-import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.androidx.fragment.FragmentController;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowAlertDialogCompat.class)
-public class LocalDeviceNameDialogFragmentTest {
-
- @Mock
- private InputMethodManager mInputMethodManager;
-
- private Context mContext;
- private LocalDeviceNameDialogFragment mFragment;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- doReturn(mInputMethodManager).when(mContext).getSystemService(Context.INPUT_METHOD_SERVICE);
-
- mFragment = spy(LocalDeviceNameDialogFragment.newInstance());
- when(mFragment.getContext()).thenReturn(mContext);
- }
-
- @After
- public void tearDown() {
- ReflectionHelpers.setStaticField(LocalBluetoothManager.class, "sInstance", null);
- }
-
- @Test
- @Ignore("b/120505691")
- public void dialogTriggersShowSoftInput() {
- FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId */,
- null /* bundle */);
- AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(dialog).isNotNull();
- View view = dialog.findViewById(R.id.edittext);
- verify(mInputMethodManager).showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index c647914..40b955c 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 @@
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 63bc828..b4379aa 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 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 @@
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 @@
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 @@
@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 @@
@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 @@
@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 0000000..69c0919
--- /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<NotificationChannel> 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> 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 7fcd3d2..51264c1 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 @@
private BluetoothDevice mRightBluetoothHapDevice;
private LocalBluetoothManager mLocalBluetoothManager;
private MediaOutputPreferenceController mController;
- private List<BluetoothDevice> mProfileConnectableDevices;
+ private List<BluetoothDevice> mProfileConnectedDevices;
private List<BluetoothDevice> mHearingAidActiveDevices;
@Before
@@ -150,7 +150,7 @@
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 @@
* 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 @@
}
/**
- * 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 @@
}
/**
- * 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 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 @@
/**
- * 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 @@
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 @@
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);