Merge "Fix "show system apps" status lost when switching on/off dark theme" am: df8e9c630a am: c0904055f4
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2253577
Change-Id: If5a0b0e899b0eea3110319c7df89bb23f932e77e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/res/drawable/ic_ring_volume.xml b/res/drawable/ic_ring_volume.xml
new file mode 100644
index 0000000..343fe5d
--- /dev/null
+++ b/res/drawable/ic_ring_volume.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M11,7V2H13V7ZM17.6,9.85 L16.2,8.4 19.75,4.85 21.15,6.3ZM6.4,9.85 L2.85,6.3 4.25,4.85 7.8,8.4ZM12,12Q14.95,12 17.812,13.188Q20.675,14.375 22.9,16.75Q23.2,17.05 23.2,17.45Q23.2,17.85 22.9,18.15L20.6,20.4Q20.325,20.675 19.963,20.7Q19.6,20.725 19.3,20.5L16.4,18.3Q16.2,18.15 16.1,17.95Q16,17.75 16,17.5V14.65Q15.05,14.35 14.05,14.175Q13.05,14 12,14Q10.95,14 9.95,14.175Q8.95,14.35 8,14.65V17.5Q8,17.75 7.9,17.95Q7.8,18.15 7.6,18.3L4.7,20.5Q4.4,20.725 4.038,20.7Q3.675,20.675 3.4,20.4L1.1,18.15Q0.8,17.85 0.8,17.45Q0.8,17.05 1.1,16.75Q3.3,14.375 6.175,13.188Q9.05,12 12,12ZM6,15.35Q5.275,15.725 4.6,16.212Q3.925,16.7 3.2,17.3L4.2,18.3L6,16.9ZM18,15.4V16.9L19.8,18.3L20.8,17.35Q20.075,16.7 19.4,16.225Q18.725,15.75 18,15.4ZM6,15.35Q6,15.35 6,15.35Q6,15.35 6,15.35ZM18,15.4Q18,15.4 18,15.4Q18,15.4 18,15.4Z"
+ android:fillColor="?android:attr/colorPrimary"/>
+
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_ring_volume_off.xml b/res/drawable/ic_ring_volume_off.xml
new file mode 100644
index 0000000..74f30d1
--- /dev/null
+++ b/res/drawable/ic_ring_volume_off.xml
@@ -0,0 +1,34 @@
+<!--
+ Copyright (C) 2022 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+<path
+ android:pathData="M0.8,4.2l8.1,8.1c-2.2,0.5 -5.2,1.6 -7.8,4.4c-0.4,0.4 -0.4,1 0,1.4l2.3,2.3c0.3,0.3 0.9,0.4 1.3,0.1l2.9,-2.2C7.8,18.1 8,17.8 8,17.5v-2.9c0.9,-0.3 1.7,-0.5 2.7,-0.6l8.5,8.5l1.4,-1.4L2.2,2.8L0.8,4.2z"
+ android:fillColor="?android:attr/colorPrimary"/>
+ <path
+ android:pathData="M11,2h2v5h-2z"
+ android:fillColor="?android:attr/colorPrimary"/>
+ <path
+ android:pathData="M21.2,6.3l-1.4,-1.4l-3.6,3.6l1.4,1.4C17.6,9.8 21,6.3 21.2,6.3z"
+ android:fillColor="?android:attr/colorPrimary"/>
+ <path
+ android:pathData="M22.9,16.7c-2.8,-3 -6.2,-4.1 -8.4,-4.5l7.2,7.2l1.3,-1.3C23.3,17.7 23.3,17.1 22.9,16.7z"
+ android:fillColor="?android:attr/colorPrimary"/>
+</vector>
diff --git a/res/values/config.xml b/res/values/config.xml
index f5ad38b..8d4e63c 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -628,9 +628,6 @@
<!-- The extra value for battery tip -->
<integer name="config_battery_extra_tip_value">12</integer>
- <!-- Whether to enable the advanced vpn feature. The default is not to. -->
- <bool name="config_advanced_vpn_enabled">false</bool>
-
<!-- An array of uid name for which packages exempt from Wi-Fi permission check. -->
<string-array name="config_exempt_wifi_permission_uid_name" translatable="false">
<item>@string/config_settingsintelligence_package_name</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 694fa6d..8db8ef9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8733,9 +8733,12 @@
<!-- Sound: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
<string name="alarm_volume_option_title">Alarm volume</string>
- <!-- Sound: Title for the option managing ring volume. [CHAR LIMIT=30] -->
+ <!-- Sound: Title for the option managing ring & notification volume. [CHAR LIMIT=30] -->
<string name="ring_volume_option_title">Ring & notification volume</string>
+ <!-- Sound: Title for the option managing ring volume. [CHAR LIMIT=30] -->
+ <string name="separate_ring_volume_option_title">Ring volume</string>
+
<!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] -->
<string name="notification_volume_option_title">Notification volume</string>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index f25b6ec..914ce72 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -72,23 +72,23 @@
android:order="-160"
settings:controller="com.android.settings.notification.RingVolumePreferenceController"/>
+ <!-- Notification volume -->
+ <com.android.settings.notification.VolumeSeekBarPreference
+ android:key="notification_volume"
+ android:icon="@drawable/ic_notifications"
+ android:title="@string/notification_volume_option_title"
+ android:order="-150"
+ settings:controller=
+ "com.android.settings.notification.NotificationVolumePreferenceController"/>
<!-- Alarm volume -->
<com.android.settings.notification.VolumeSeekBarPreference
android:key="alarm_volume"
android:icon="@*android:drawable/ic_audio_alarm"
android:title="@string/alarm_volume_option_title"
- android:order="-150"
- settings:controller="com.android.settings.notification.AlarmVolumePreferenceController"/>
-
- <!-- Notification volume -->
- <com.android.settings.notification.VolumeSeekBarPreference
- android:key="notification_volume"
- android:icon="@drawable/ic_notifications"
- android:title="@string/notification_volume_option_title"
android:order="-140"
- settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
-
+ settings:controller="com.android.settings.notification.AlarmVolumePreferenceController"/>
+x
<!-- TODO(b/174964721): make this a PrimarySwitchPreference -->
<!-- Interruptions -->
<com.android.settingslib.RestrictedPreference
diff --git a/res/xml/vpn_settings2.xml b/res/xml/vpn_settings2.xml
index 0d374c7..08075a6 100644
--- a/res/xml/vpn_settings2.xml
+++ b/res/xml/vpn_settings2.xml
@@ -16,9 +16,4 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/vpn_title">
- <PreferenceCategory
- android:key="advanced_vpn_group"/>
-
- <PreferenceCategory
- android:key="vpn_group"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/applications/AppStateLocaleBridge.java b/src/com/android/settings/applications/AppStateLocaleBridge.java
index 5600766..8262ce7 100644
--- a/src/com/android/settings/applications/AppStateLocaleBridge.java
+++ b/src/com/android/settings/applications/AppStateLocaleBridge.java
@@ -18,13 +18,19 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.ArrayMap;
import android.util.Log;
+import com.android.settings.Utils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* Creates a application filter to restrict UI display of applications.
@@ -35,20 +41,22 @@
private static final String TAG = AppStateLocaleBridge.class.getSimpleName();
private final Context mContext;
- private final List<ResolveInfo> mListInfos;
+ private final Map<Integer, AppInfoByProfiles> mUserIdToAppInfoByProfiles = new ArrayMap<>();
public AppStateLocaleBridge(Context context, ApplicationsState appState,
- Callback callback) {
+ Callback callback, UserManager userManager) {
super(appState, callback);
mContext = context;
- mListInfos = context.getPackageManager().queryIntentActivities(
- AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA);
+ collectLocaleBridgeInfo(userManager);
}
@Override
protected void updateExtraInfo(AppEntry app, String packageName, int uid) {
- app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos)
- ? Boolean.TRUE : Boolean.FALSE;
+ AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(uid));
+
+ app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser,
+ app.info.packageName,
+ appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE;
}
@Override
@@ -56,9 +64,11 @@
final List<AppEntry> allApps = mAppSession.getAllApps();
for (int i = 0; i < allApps.size(); i++) {
AppEntry app = allApps.get(i);
- app.extraInfo =
- AppLocaleUtil.canDisplayLocaleUi(mContext, app.info.packageName, mListInfos)
- ? Boolean.TRUE : Boolean.FALSE;
+ AppInfoByProfiles appInfoByProfiles = getAppInfo(UserHandle.getUserId(app.info.uid));
+
+ app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(appInfoByProfiles.mContextAsUser,
+ app.info.packageName,
+ appInfoByProfiles.mListInfos) ? Boolean.TRUE : Boolean.FALSE;
}
}
@@ -78,4 +88,47 @@
return (Boolean) entry.extraInfo;
}
};
+
+ private void collectLocaleBridgeInfo(UserManager userManager) {
+ List<Integer> userIds = new ArrayList<>();
+
+ userIds.add(mContext.getUserId());
+ int workUserId = Utils.getManagedProfileId(userManager, mContext.getUserId());
+ if (workUserId != UserHandle.USER_NULL) {
+ userIds.add(workUserId);
+ }
+
+ // Separate the app information by profiles.
+ for (int userId : userIds) {
+ if (!mUserIdToAppInfoByProfiles.containsKey(userId)) {
+ mUserIdToAppInfoByProfiles.put(userId, new AppInfoByProfiles(mContext, userId));
+ }
+ }
+ }
+
+ private AppInfoByProfiles getAppInfo(int userId) {
+ AppInfoByProfiles info;
+ if (mUserIdToAppInfoByProfiles.containsKey(userId)) {
+ info = mUserIdToAppInfoByProfiles.get(userId);
+ } else {
+ info = new AppInfoByProfiles(mContext, userId);
+ mUserIdToAppInfoByProfiles.put(userId, info);
+ }
+
+ return info;
+ }
+
+ /**
+ * The app information by profiles.
+ */
+ private static class AppInfoByProfiles {
+ public final Context mContextAsUser;
+ public final List<ResolveInfo> mListInfos;
+
+ private AppInfoByProfiles(Context context, int userId) {
+ mContextAsUser = context.createContextAsUser(UserHandle.of(userId), 0);
+ mListInfos = mContextAsUser.getPackageManager().queryIntentActivities(
+ AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA);
+ }
+ }
}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 9a4d13c..5ee059e 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -1148,7 +1148,8 @@
} else if (mManageApplications.mListType == LIST_TYPE_MEDIA_MANAGEMENT_APPS) {
mExtraInfoBridge = new AppStateMediaManagementAppsBridge(mContext, mState, this);
} else if (mManageApplications.mListType == LIST_TYPE_APPS_LOCALE) {
- mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this);
+ mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this,
+ mManageApplications.mUserManager);
} else if (mManageApplications.mListType == LIST_TYPE_BATTERY_OPTIMIZATION) {
mExtraInfoBridge = new AppStateAppBatteryUsageBridge(mContext, mState, this);
} else {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index d65c8c7..9598019 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -168,7 +168,8 @@
private Vibrator mVibrator;
private boolean mIsSetupWizard;
private boolean mIsOrientationChanged;
- private boolean mIsCanceled;
+ @VisibleForTesting
+ boolean mIsCanceled;
private AccessibilityManager mAccessibilityManager;
private boolean mIsAccessibilityEnabled;
private LottieAnimationView mIllustrationLottie;
@@ -196,7 +197,7 @@
@Override
public void onWindowFocusChanged(boolean hasFocus) {
- if (hasFocus) {
+ if (hasFocus || mIsCanceled) {
return;
}
@@ -411,8 +412,10 @@
@VisibleForTesting
void onCancelEnrollment(@IdRes int errorMsgId) {
- FingerprintErrorDialog.showErrorDialog(this, errorMsgId);
+ // showErrorDialog() will cause onWindowFocusChanged(false), set mIsCanceled to false
+ // before showErrorDialog() to prevent that another error dialog is triggered again.
mIsCanceled = true;
+ FingerprintErrorDialog.showErrorDialog(this, errorMsgId);
mIsOrientationChanged = false;
cancelEnrollment();
stopIconAnimation();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintErrorDialog.java b/src/com/android/settings/biometrics/fingerprint/FingerprintErrorDialog.java
index 9f9efdc..39d35dc 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintErrorDialog.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintErrorDialog.java
@@ -72,6 +72,7 @@
dialog.dismiss();
Activity activity = getActivity();
Intent intent = activity.getIntent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
intent.putExtra(KEY_STATE_CANCELED, false);
activity.startActivity(intent);
activity.finish();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 44b3a40..c031fe6 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -669,6 +669,14 @@
mLaunchedConfirm = false;
if (resultCode == RESULT_FINISHED || resultCode == RESULT_OK) {
if (data != null && BiometricUtils.containsGatekeeperPasswordHandle(data)) {
+ if (!mHasFirstEnrolled && !mIsEnrolling) {
+ final Activity activity = getActivity();
+ if (activity != null) {
+ // Apply pending transition for auto adding first fingerprint case
+ activity.overridePendingTransition(R.anim.sud_slide_next_in,
+ R.anim.sud_slide_next_out);
+ }
+ }
mFingerprintManager.generateChallenge(mUserId,
(sensorId, userId, challenge) -> {
mToken = BiometricUtils.requestGatekeeperHat(getActivity(),
diff --git a/src/com/android/settings/network/CarrierConfigChangedReceiver.java b/src/com/android/settings/network/CarrierConfigChangedReceiver.java
index 8a6d47d..d9ff03e 100644
--- a/src/com/android/settings/network/CarrierConfigChangedReceiver.java
+++ b/src/com/android/settings/network/CarrierConfigChangedReceiver.java
@@ -32,9 +32,20 @@
CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED;
private final CountDownLatch mLatch;
+ private final boolean mIsWaitingForValidSubId;
- public CarrierConfigChangedReceiver(CountDownLatch latch) {
+ /**
+ * This is the CarrierConfigChanged receiver. If it receives the carrier config changed, then it
+ * call the CountDownLatch.countDown().
+ * If the "isWaitingForValidSubId" is true, then the receiver skip the carrier config changed
+ * with the subId = -1. The receiver executes the countDown when the CarrierConfigChanged
+ * with valid subId.
+ * If the "isWaitingForValidSubId" is false, then the receiver executes the countDown when
+ * receiving any CarrierConfigChanged.
+ */
+ public CarrierConfigChangedReceiver(CountDownLatch latch, boolean isWaitingForValidSubId) {
mLatch = latch;
+ mIsWaitingForValidSubId = isWaitingForValidSubId;
}
public void registerOn(Context context) {
@@ -53,7 +64,8 @@
}
private void checkSubscriptionIndex(Intent intent) {
- if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX)) {
+ if (intent.hasExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX)
+ || !mIsWaitingForValidSubId) {
int subId = intent.getIntExtra(CarrierConfigManager.EXTRA_SUBSCRIPTION_INDEX, -1);
Log.i(TAG, "subId from config changed: " + subId);
mLatch.countDown();
diff --git a/src/com/android/settings/network/UiccSlotUtil.java b/src/com/android/settings/network/UiccSlotUtil.java
index e5323d1..7b8d330 100644
--- a/src/com/android/settings/network/UiccSlotUtil.java
+++ b/src/com/android/settings/network/UiccSlotUtil.java
@@ -141,7 +141,8 @@
inactiveRemovableSlot,
/*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX,
excludedLogicalSlotIndex),
- context);
+ context,
+ /*isWaitingForValidSubId=*/ true);
}
/**
@@ -179,7 +180,8 @@
performSwitchToSlot(telMgr,
prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false,
physicalSlotId, port, excludedLogicalSlotIndex),
- context);
+ context,
+ /*isWaitingForValidSubId=*/ false);
}
/**
@@ -231,7 +233,8 @@
}
private static void performSwitchToSlot(TelephonyManager telMgr,
- Collection<UiccSlotMapping> uiccSlotMappings, Context context)
+ Collection<UiccSlotMapping> uiccSlotMappings, Context context,
+ boolean isWaitingForValidSubId)
throws UiccSlotsException {
CarrierConfigChangedReceiver receiver = null;
long waitingTimeMillis =
@@ -241,7 +244,7 @@
DEFAULT_WAIT_AFTER_SWITCH_TIMEOUT_MILLIS);
try {
CountDownLatch latch = new CountDownLatch(1);
- receiver = new CarrierConfigChangedReceiver(latch);
+ receiver = new CarrierConfigChangedReceiver(latch, isWaitingForValidSubId);
receiver.registerOn(context);
telMgr.setSimSlotMapping(uiccSlotMappings);
latch.await(waitingTimeMillis, TimeUnit.MILLISECONDS);
diff --git a/src/com/android/settings/notification/NotificationVolumePreferenceController.java b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
index 0fe0d62..322bb6c 100644
--- a/src/com/android/settings/notification/NotificationVolumePreferenceController.java
+++ b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
@@ -16,26 +16,96 @@
package com.android.settings.notification;
+import android.app.INotificationManager;
+import android.app.NotificationManager;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.media.AudioManager;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.os.ServiceManager;
+import android.os.Vibrator;
+import android.service.notification.NotificationListenerService;
import android.text.TextUtils;
+import android.util.Log;
+import androidx.lifecycle.OnLifecycleEvent;
+
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
+import com.android.settingslib.core.lifecycle.Lifecycle;
-public class NotificationVolumePreferenceController extends
- RingVolumePreferenceController {
+import java.util.Objects;
+/**
+ * Update notification volume icon in Settings in response to user adjusting volume
+ */
+public class NotificationVolumePreferenceController extends VolumeSeekBarPreferenceController {
+
+ private static final String TAG = "NotificationVolumePreferenceController";
private static final String KEY_NOTIFICATION_VOLUME = "notification_volume";
+ private Vibrator mVibrator;
+ private int mRingerMode = AudioManager.RINGER_MODE_NORMAL;
+ private ComponentName mSuppressor;
+ private final RingReceiver mReceiver = new RingReceiver();
+ private final H mHandler = new H();
+ private INotificationManager mNoMan;
+
+
+ private int mMuteIcon;
+ private final int mNormalIconId = R.drawable.ic_notifications;
+ private final int mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
+ private final int mSilentIconId = R.drawable.ic_notifications_off_24dp;
+
+ private final boolean mRingNotificationAliased;
+
+
public NotificationVolumePreferenceController(Context context) {
- super(context, KEY_NOTIFICATION_VOLUME);
+ this(context, KEY_NOTIFICATION_VOLUME);
+ }
+
+ public NotificationVolumePreferenceController(Context context, String key) {
+ super(context, key);
+ mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
+ if (mVibrator != null && !mVibrator.hasVibrator()) {
+ mVibrator = null;
+ }
+
+ mRingNotificationAliased = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_alias_ring_notif_stream_types);
+ updateRingerMode();
+ }
+
+ @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
+ @Override
+ public void onResume() {
+ super.onResume();
+ mReceiver.register(true);
+ updateEffectsSuppressor();
+ updatePreferenceIconAndSliderState();
+ }
+
+ @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
+ @Override
+ public void onPause() {
+ super.onPause();
+ mReceiver.register(false);
}
@Override
public int getAvailabilityStatus() {
+
+ // Show separate notification slider if ring/notification are not aliased by AudioManager --
+ // if they are, notification volume is controlled by RingVolumePreferenceController.
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
- && !Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
+ && (!mRingNotificationAliased || !Utils.isVoiceCapable(mContext))
+ && !mHelper.isSingleVolume()
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@@ -55,13 +125,152 @@
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public int getAudioStream() {
return AudioManager.STREAM_NOTIFICATION;
}
@Override
public int getMuteIcon() {
- return R.drawable.ic_notifications_off_24dp;
+ return mMuteIcon;
+ }
+
+ private void updateRingerMode() {
+ final int ringerMode = mHelper.getRingerModeInternal();
+ if (mRingerMode == ringerMode) return;
+ mRingerMode = ringerMode;
+ updatePreferenceIconAndSliderState();
+ }
+
+ private void updateEffectsSuppressor() {
+ final ComponentName suppressor = NotificationManager.from(mContext).getEffectsSuppressor();
+ if (Objects.equals(suppressor, mSuppressor)) return;
+
+ if (mNoMan == null) {
+ mNoMan = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ }
+
+ final int hints;
+ try {
+ hints = mNoMan.getHintsFromListenerNoToken();
+ } catch (android.os.RemoteException exception) {
+ Log.w(TAG, "updateEffectsSuppressor: " + exception.getLocalizedMessage());
+ return;
+ }
+
+ if (hintsMatch(hints)) {
+
+ mSuppressor = suppressor;
+ if (mPreference != null) {
+ final String text = SuppressorHelper.getSuppressionText(mContext, suppressor);
+ mPreference.setSuppressionText(text);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ boolean hintsMatch(int hints) {
+ boolean allEffectsDisabled =
+ (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0;
+ boolean notificationEffectsDisabled =
+ (hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0;
+
+ return allEffectsDisabled || notificationEffectsDisabled;
+ }
+
+ private void updatePreferenceIconAndSliderState() {
+ if (mPreference != null) {
+ if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
+ mMuteIcon = mVibrateIconId;
+ mPreference.showIcon(mVibrateIconId);
+ mPreference.setEnabled(false);
+
+ } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT
+ || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
+ mMuteIcon = mSilentIconId;
+ mPreference.showIcon(mSilentIconId);
+ mPreference.setEnabled(false);
+ } else { // ringmode normal: could be that we are still silent
+ mPreference.setEnabled(true);
+ if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
+ // ring is in normal, but notification is in silent
+ mMuteIcon = mSilentIconId;
+ mPreference.showIcon(mSilentIconId);
+ } else {
+ mPreference.showIcon(mNormalIconId);
+ }
+ }
+ }
+ }
+
+ private final class H extends Handler {
+ private static final int UPDATE_EFFECTS_SUPPRESSOR = 1;
+ private static final int UPDATE_RINGER_MODE = 2;
+ private static final int NOTIFICATION_VOLUME_CHANGED = 3;
+
+ private H() {
+ super(Looper.getMainLooper());
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case UPDATE_EFFECTS_SUPPRESSOR:
+ updateEffectsSuppressor();
+ break;
+ case UPDATE_RINGER_MODE:
+ updateRingerMode();
+ break;
+ case NOTIFICATION_VOLUME_CHANGED:
+ updatePreferenceIconAndSliderState();
+ break;
+ }
+ }
+ }
+
+ /**
+ * For notification volume icon to be accurate, we need to listen to volume change as well.
+ * That is because the icon can change from mute/vibrate to normal without ringer mode changing.
+ */
+ private class RingReceiver extends BroadcastReceiver {
+ private boolean mRegistered;
+
+ public void register(boolean register) {
+ if (mRegistered == register) return;
+ if (register) {
+ final IntentFilter filter = new IntentFilter();
+ filter.addAction(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED);
+ filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
+ filter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
+ mContext.registerReceiver(this, filter);
+ } else {
+ mContext.unregisterReceiver(this);
+ }
+ mRegistered = register;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+ if (NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED.equals(action)) {
+ mHandler.sendEmptyMessage(H.UPDATE_EFFECTS_SUPPRESSOR);
+ } else if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) {
+ mHandler.sendEmptyMessage(H.UPDATE_RINGER_MODE);
+ } else if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
+ int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
+ if (streamType == AudioManager.STREAM_NOTIFICATION) {
+ int streamValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE,
+ -1);
+ mHandler.obtainMessage(H.NOTIFICATION_VOLUME_CHANGED, streamValue, 0)
+ .sendToTarget();
+ }
+ }
+ }
}
}
diff --git a/src/com/android/settings/notification/RingVolumePreferenceController.java b/src/com/android/settings/notification/RingVolumePreferenceController.java
index 5e7d067..a78689f 100644
--- a/src/com/android/settings/notification/RingVolumePreferenceController.java
+++ b/src/com/android/settings/notification/RingVolumePreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.notification;
+import android.app.INotificationManager;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -26,30 +27,56 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.os.ServiceManager;
import android.os.Vibrator;
+import android.service.notification.NotificationListenerService;
import android.text.TextUtils;
+import android.util.Log;
import androidx.lifecycle.OnLifecycleEvent;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.Objects;
+/**
+ * This slider can represent both ring and notification, if the corresponding streams are aliased,
+ * and only ring if the streams are not aliased.
+ */
public class RingVolumePreferenceController extends VolumeSeekBarPreferenceController {
- private static final String TAG = "RingVolumeController";
+ private static final String TAG = "RingVolumePreferenceController";
private static final String KEY_RING_VOLUME = "ring_volume";
private Vibrator mVibrator;
- private int mRingerMode = -1;
+ private int mRingerMode = AudioManager.RINGER_MODE_NORMAL;
private ComponentName mSuppressor;
private final RingReceiver mReceiver = new RingReceiver();
private final H mHandler = new H();
private int mMuteIcon;
+ /*
+ * Whether ring and notification streams are aliased together by AudioManager.
+ * If they are, we'll present one volume control for both.
+ * If not, we'll present separate volume controls.
+ */
+ private final boolean mRingAliasNotif;
+
+ private final int mNormalIconId;
+ @VisibleForTesting
+ final int mVibrateIconId;
+ @VisibleForTesting
+ final int mSilentIconId;
+
+ @VisibleForTesting
+ final int mTitleId;
+
+ private INotificationManager mNoMan;
+
public RingVolumePreferenceController(Context context) {
this(context, KEY_RING_VOLUME);
}
@@ -60,9 +87,31 @@
if (mVibrator != null && !mVibrator.hasVibrator()) {
mVibrator = null;
}
+
+ mRingAliasNotif = isRingAliasNotification();
+ if (mRingAliasNotif) {
+ mTitleId = R.string.ring_volume_option_title;
+
+ mNormalIconId = R.drawable.ic_notifications;
+ mSilentIconId = R.drawable.ic_notifications_off_24dp;
+ } else {
+ mTitleId = R.string.separate_ring_volume_option_title;
+
+ mNormalIconId = R.drawable.ic_ring_volume;
+ mSilentIconId = R.drawable.ic_ring_volume_off;
+ }
+ // todo: set a distinct vibrate icon for ring vs notification
+ mVibrateIconId = R.drawable.ic_volume_ringer_vibrate;
+
updateRingerMode();
}
+ @VisibleForTesting
+ boolean isRingAliasNotification() {
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_alias_ring_notif_stream_types);
+ }
+
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@Override
public void onResume() {
@@ -70,6 +119,7 @@
mReceiver.register(true);
updateEffectsSuppressor();
updatePreferenceIcon();
+ setPreferenceTitle();
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
@@ -115,7 +165,8 @@
return mMuteIcon;
}
- private void updateRingerMode() {
+ @VisibleForTesting
+ void updateRingerMode() {
final int ringerMode = mHelper.getRingerModeInternal();
if (mRingerMode == ringerMode) return;
mRingerMode = ringerMode;
@@ -125,28 +176,73 @@
private void updateEffectsSuppressor() {
final ComponentName suppressor = NotificationManager.from(mContext).getEffectsSuppressor();
if (Objects.equals(suppressor, mSuppressor)) return;
- mSuppressor = suppressor;
- if (mPreference != null) {
- final String text = SuppressorHelper.getSuppressionText(mContext, suppressor);
- mPreference.setSuppressionText(text);
+
+ if (mNoMan == null) {
+ mNoMan = INotificationManager.Stub.asInterface(
+ ServiceManager.getService(Context.NOTIFICATION_SERVICE));
}
- updatePreferenceIcon();
+
+ final int hints;
+ try {
+ hints = mNoMan.getHintsFromListenerNoToken();
+ } catch (android.os.RemoteException ex) {
+ Log.w(TAG, "updateEffectsSuppressor: " + ex.getMessage());
+ return;
+ }
+
+ if (hintsMatch(hints, mRingAliasNotif)) {
+ mSuppressor = suppressor;
+ if (mPreference != null) {
+ final String text = SuppressorHelper.getSuppressionText(mContext, suppressor);
+ mPreference.setSuppressionText(text);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ boolean hintsMatch(int hints, boolean ringNotificationAliased) {
+ return (hints & NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS) != 0
+ || (hints & NotificationListenerService.HINT_HOST_DISABLE_EFFECTS) != 0
+ || ((hints & NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS)
+ != 0 && ringNotificationAliased);
+ }
+
+ @VisibleForTesting
+ void setPreference(VolumeSeekBarPreference volumeSeekBarPreference) {
+ mPreference = volumeSeekBarPreference;
+ }
+
+ @VisibleForTesting
+ void setVibrator(Vibrator vibrator) {
+ mVibrator = vibrator;
}
private void updatePreferenceIcon() {
if (mPreference != null) {
- if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
- mMuteIcon = R.drawable.ic_volume_ringer_vibrate;
- mPreference.showIcon(R.drawable.ic_volume_ringer_vibrate);
- } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT) {
- mMuteIcon = R.drawable.ic_notifications_off_24dp;
- mPreference.showIcon(R.drawable.ic_notifications_off_24dp);
+ if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
+ mPreference.showIcon(mNormalIconId);
} else {
- mPreference.showIcon(R.drawable.ic_notifications);
+ if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE && mVibrator != null) {
+ mMuteIcon = mVibrateIconId;
+ } else {
+ mMuteIcon = mSilentIconId;
+ }
+ mPreference.showIcon(mMuteIcon);
}
}
}
+ /**
+ * This slider can represent both ring and notification, or only ring.
+ * Note: This cannot be used in the constructor, as the reference to preference object would
+ * still be null.
+ */
+ private void setPreferenceTitle() {
+ if (mPreference != null) {
+ mPreference.setTitle(mTitleId);
+ }
+ }
+
private final class H extends Handler {
private static final int UPDATE_EFFECTS_SUPPRESSOR = 1;
private static final int UPDATE_RINGER_MODE = 2;
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index c59b385..aff7197 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -45,7 +45,6 @@
import com.android.settings.security.SecuritySettingsFeatureProvider;
import com.android.settings.slices.SlicesFeatureProvider;
import com.android.settings.users.UserFeatureProvider;
-import com.android.settings.vpn2.AdvancedVpnFeatureProvider;
import com.android.settings.wifi.WifiTrackerLibProvider;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -178,11 +177,6 @@
*/
public abstract AccessibilityMetricsFeatureProvider getAccessibilityMetricsFeatureProvider();
- /**
- * Retrieves implementation for advanced vpn feature.
- */
- public abstract AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider();
-
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 593b866..89f74de 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -71,8 +71,6 @@
import com.android.settings.slices.SlicesFeatureProviderImpl;
import com.android.settings.users.UserFeatureProvider;
import com.android.settings.users.UserFeatureProviderImpl;
-import com.android.settings.vpn2.AdvancedVpnFeatureProvider;
-import com.android.settings.vpn2.AdvancedVpnFeatureProviderImpl;
import com.android.settings.wifi.WifiTrackerLibProvider;
import com.android.settings.wifi.WifiTrackerLibProviderImpl;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -108,7 +106,6 @@
private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
private AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
private AccessibilityMetricsFeatureProvider mAccessibilityMetricsFeatureProvider;
- private AdvancedVpnFeatureProvider mAdvancedVpnFeatureProvider;
@Override
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
@@ -337,12 +334,4 @@
}
return mAccessibilityMetricsFeatureProvider;
}
-
- @Override
- public AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider() {
- if (mAdvancedVpnFeatureProvider == null) {
- mAdvancedVpnFeatureProvider = new AdvancedVpnFeatureProviderImpl();
- }
- return mAdvancedVpnFeatureProvider;
- }
}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index 9f5ffe9..afccc78 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -54,7 +54,7 @@
* Maximum number of slices allowed on the panel view.
*/
@VisibleForTesting
- static final int MAX_NUM_OF_SLICES = 6;
+ static final int MAX_NUM_OF_SLICES = 7;
private final List<LiveData<Slice>> mSliceLiveData;
private final int mMetricsCategory;
diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java
index d1b169c..569a0ea 100644
--- a/src/com/android/settings/slices/CustomSliceRegistry.java
+++ b/src/com/android/settings/slices/CustomSliceRegistry.java
@@ -218,6 +218,16 @@
.build();
/**
+ * Full {@link Uri} for the Notification volume Slice.
+ */
+ public static final Uri VOLUME_NOTIFICATION_URI = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_CONTENT)
+ .authority(SettingsSliceProvider.SLICE_AUTHORITY)
+ .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
+ .appendPath("notification_volume")
+ .build();
+
+ /**
* Full {@link Uri} for the all volume Slices.
*/
public static final Uri VOLUME_SLICES_URI = new Uri.Builder()
diff --git a/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java b/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java
deleted file mode 100644
index 962b6c2..0000000
--- a/src/com/android/settings/vpn2/AdvancedVpnFeatureProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.vpn2;
-
-import android.content.Context;
-
-/**
- * Feature Provider used in vpn usage
- */
-public interface AdvancedVpnFeatureProvider {
-
- /**
- * Returns package name of advanced vpn.
- */
- String getAdvancedVpnPackageName();
-
- /**
- * Returns {@code true} advanced vpn is supported.
- */
- boolean isAdvancedVpnSupported(Context context);
-
- /**
- * Returns the title of advanced vpn preference group.
- */
- String getAdvancedVpnPreferenceGroupTitle(Context context);
-
- /**
- * Returns the title of vpn preference group.
- */
- String getVpnPreferenceGroupTitle(Context context);
-
- /**
- * Returns {@code true} advanced vpn is removable.
- */
- boolean isAdvancedVpnRemovable();
-
- /**
- * Returns {@code true} if the disconnect dialog is enabled when advanced vpn is connected.
- */
- boolean isDisconnectDialogEnabled();
-}
diff --git a/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java b/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java
deleted file mode 100644
index b8f58a9..0000000
--- a/src/com/android/settings/vpn2/AdvancedVpnFeatureProviderImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.vpn2;
-
-import android.content.Context;
-
-/**
- * Feature provider implementation for advanced vpn.
- */
-public class AdvancedVpnFeatureProviderImpl implements AdvancedVpnFeatureProvider {
- @Override
- public String getAdvancedVpnPackageName() {
- return null;
- }
-
- @Override
- public boolean isAdvancedVpnSupported(Context context) {
- return false;
- }
-
- @Override
- public String getAdvancedVpnPreferenceGroupTitle(Context context) {
- return null;
- }
-
- @Override
- public String getVpnPreferenceGroupTitle(Context context) {
- return null;
- }
-
- @Override
- public boolean isAdvancedVpnRemovable() {
- return true;
- }
-
- @Override
- public boolean isDisconnectDialogEnabled() {
- return true;
- }
-}
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index d2fa5fc..d4ee5b9 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -48,7 +48,6 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedPreference;
@@ -72,7 +71,6 @@
private PackageManager mPackageManager;
private DevicePolicyManager mDevicePolicyManager;
private VpnManager mVpnManager;
- private AdvancedVpnFeatureProvider mFeatureProvider;
// VPN app info
private final int mUserId = UserHandle.myUserId();
@@ -124,7 +122,6 @@
mPackageManager = getContext().getPackageManager();
mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
mVpnManager = getContext().getSystemService(VpnManager.class);
- mFeatureProvider = FeatureFactory.getFactory(getContext()).getAdvancedVpnFeatureProvider();
mPreferenceAlwaysOn = (RestrictedSwitchPreference) findPreference(KEY_ALWAYS_ON_VPN);
mPreferenceLockdown = (RestrictedSwitchPreference) findPreference(KEY_LOCKDOWN_VPN);
@@ -286,16 +283,7 @@
}
}
- @VisibleForTesting
- void updateRestrictedViews() {
- if (mFeatureProvider.isAdvancedVpnSupported(getContext())
- && !mFeatureProvider.isAdvancedVpnRemovable()
- && TextUtils.equals(mPackageName, mFeatureProvider.getAdvancedVpnPackageName())) {
- mPreferenceForget.setVisible(false);
- } else {
- mPreferenceForget.setVisible(true);
- }
-
+ private void updateRestrictedViews() {
if (isAdded()) {
mPreferenceAlwaysOn.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_VPN,
mUserId);
@@ -326,14 +314,6 @@
}
}
- @VisibleForTesting
- void init(String packageName, AdvancedVpnFeatureProvider featureProvider,
- RestrictedPreference preference) {
- mPackageName = packageName;
- mFeatureProvider = featureProvider;
- mPreferenceForget = preference;
- }
-
private String getAlwaysOnVpnPackage() {
return mVpnManager.getAlwaysOnVpnPackageForUser(mUserId);
}
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index a91bb6c..e89785f 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -26,7 +26,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
@@ -43,7 +42,6 @@
import android.os.UserManager;
import android.security.Credentials;
import android.security.LegacyVpnProfileStore;
-import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
@@ -54,7 +52,6 @@
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.net.LegacyVpnInfo;
@@ -62,7 +59,6 @@
import com.android.internal.net.VpnProfile;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.GearPreference;
import com.android.settings.widget.GearPreference.OnGearClickListener;
import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -83,12 +79,9 @@
public class VpnSettings extends RestrictedSettingsFragment implements
Handler.Callback, Preference.OnPreferenceClickListener {
private static final String LOG_TAG = "VpnSettings";
- private static final boolean DEBUG = Log.isLoggable(LOG_TAG, Log.DEBUG);
private static final int RESCAN_MESSAGE = 0;
private static final int RESCAN_INTERVAL_MS = 1000;
- private static final String ADVANCED_VPN_GROUP_KEY = "advanced_vpn_group";
- private static final String VPN_GROUP_KEY = "vpn_group";
private static final NetworkRequest VPN_REQUEST = new NetworkRequest.Builder()
.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
@@ -109,9 +102,6 @@
private LegacyVpnInfo mConnectedLegacyVpn;
private boolean mUnavailable;
- private AdvancedVpnFeatureProvider mFeatureProvider;
- private PreferenceScreen mPreferenceScreen;
- private boolean mIsAdvancedVpnSupported;
public VpnSettings() {
super(UserManager.DISALLOW_CONFIG_VPN);
@@ -129,14 +119,11 @@
mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mVpnManager = (VpnManager) getSystemService(Context.VPN_MANAGEMENT_SERVICE);
- mFeatureProvider = FeatureFactory.getFactory(getContext()).getAdvancedVpnFeatureProvider();
- mIsAdvancedVpnSupported = mFeatureProvider.isAdvancedVpnSupported(getContext());
mUnavailable = isUiRestricted();
setHasOptionsMenu(!mUnavailable);
addPreferencesFromResource(R.xml.vpn_settings2);
- mPreferenceScreen = getPreferenceScreen();
}
@Override
@@ -242,8 +229,7 @@
// Run heavy RPCs before switching to UI thread
final List<VpnProfile> vpnProfiles = loadVpnProfiles();
- final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */ true,
- mFeatureProvider);
+ final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */ true);
final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
final Set<AppVpnInfo> connectedAppVpns = getConnectedAppVpns();
@@ -279,7 +265,7 @@
private final VpnSettings mSettings;
- UpdatePreferences(VpnSettings settings) {
+ public UpdatePreferences(VpnSettings settings) {
mSettings = settings;
}
@@ -346,14 +332,7 @@
}
// Trim out deleted VPN preferences
- if (DEBUG) {
- Log.d(LOG_TAG, "isAdvancedVpnSupported() : " + mSettings.mIsAdvancedVpnSupported);
- }
- if (mSettings.mIsAdvancedVpnSupported) {
- mSettings.setShownAdvancedPreferences(updates);
- } else {
- mSettings.setShownPreferences(updates);
- }
+ mSettings.setShownPreferences(updates);
}
}
@@ -364,61 +343,12 @@
@VisibleForTesting @UiThread
public void setShownPreferences(final Collection<Preference> updates) {
- retainAllPreference(updates);
-
- final PreferenceGroup vpnGroup = mPreferenceScreen;
- updatePreferenceGroup(vpnGroup, updates);
-
- // Show all new preferences on the screen
- for (Preference pref : updates) {
- vpnGroup.addPreference(pref);
- }
- }
-
- @VisibleForTesting @UiThread
- void setShownAdvancedPreferences(final Collection<Preference> updates) {
- retainAllPreference(updates);
-
- PreferenceGroup advancedVpnGroup = mPreferenceScreen.findPreference(ADVANCED_VPN_GROUP_KEY);
- PreferenceGroup vpnGroup = mPreferenceScreen.findPreference(VPN_GROUP_KEY);
- advancedVpnGroup.setTitle(
- mFeatureProvider.getAdvancedVpnPreferenceGroupTitle(getContext()));
- vpnGroup.setTitle(mFeatureProvider.getVpnPreferenceGroupTitle(getContext()));
- updatePreferenceGroup(advancedVpnGroup, updates);
- updatePreferenceGroup(vpnGroup, updates);
-
- // Show all new preferences on the screen
- for (Preference pref : updates) {
- String packageName = "";
- if (pref instanceof LegacyVpnPreference) {
- LegacyVpnPreference legacyPref = (LegacyVpnPreference) pref;
- packageName = legacyPref.getPackageName();
- } else if (pref instanceof AppPreference) {
- AppPreference appPref = (AppPreference) pref;
- packageName = appPref.getPackageName();
- }
- if (DEBUG) {
- Log.d(LOG_TAG, "setShownAdvancedPreferences() package name : " + packageName);
- }
- if (TextUtils.equals(packageName, mFeatureProvider.getAdvancedVpnPackageName())) {
- advancedVpnGroup.addPreference(pref);
- } else {
- vpnGroup.addPreference(pref);
- }
- }
-
- advancedVpnGroup.setVisible(advancedVpnGroup.getPreferenceCount() > 0);
- vpnGroup.setVisible(vpnGroup.getPreferenceCount() > 0);
- }
-
- private void retainAllPreference(Collection<Preference> updates) {
mLegacyVpnPreferences.values().retainAll(updates);
mAppPreferences.values().retainAll(updates);
- }
- private void updatePreferenceGroup(PreferenceGroup vpnGroup, Collection<Preference> updates) {
// Change {@param updates} in-place to only contain new preferences that were not already
// added to the preference screen.
+ final PreferenceGroup vpnGroup = getPreferenceScreen();
for (int i = vpnGroup.getPreferenceCount() - 1; i >= 0; i--) {
Preference p = vpnGroup.getPreference(i);
if (updates.contains(p)) {
@@ -427,6 +357,11 @@
vpnGroup.removePreference(p);
}
}
+
+ // Show any new preferences on the screen
+ for (Preference pref : updates) {
+ vpnGroup.addPreference(pref);
+ }
}
@Override
@@ -448,16 +383,14 @@
} else if (preference instanceof AppPreference) {
AppPreference pref = (AppPreference) preference;
boolean connected = (pref.getState() == AppPreference.STATE_CONNECTED);
- String vpnPackageName = pref.getPackageName();
- if ((!connected) || (isAdvancedVpn(mFeatureProvider, vpnPackageName, getContext())
- && !mFeatureProvider.isDisconnectDialogEnabled())) {
+ if (!connected) {
try {
UserHandle user = UserHandle.of(pref.getUserId());
- Context userContext = getContext().createPackageContextAsUser(
- getContext().getPackageName(), 0 /* flags */, user);
+ Context userContext = getActivity().createPackageContextAsUser(
+ getActivity().getPackageName(), 0 /* flags */, user);
PackageManager pm = userContext.getPackageManager();
- Intent appIntent = pm.getLaunchIntentForPackage(vpnPackageName);
+ Intent appIntent = pm.getLaunchIntentForPackage(pref.getPackageName());
if (appIntent != null) {
userContext.startActivityAsUser(appIntent, user);
return true;
@@ -537,32 +470,9 @@
pref.setOnPreferenceClickListener(this);
mAppPreferences.put(app, pref);
}
- enableAdvancedVpnGearIconIfNecessary(pref);
return pref;
}
- private void enableAdvancedVpnGearIconIfNecessary(AppPreference pref) {
- Context context = getContext();
- if (!isAdvancedVpn(mFeatureProvider, pref.getPackageName(), context)) {
- return;
- }
-
- boolean isEnabled = false;
- AppOpsManager appOpsManager = getContext().getSystemService(AppOpsManager.class);
- List<AppOpsManager.PackageOps> apps =
- appOpsManager.getPackagesForOps(
- new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
- if (apps != null) {
- for (AppOpsManager.PackageOps pkg : apps) {
- if (isAdvancedVpn(mFeatureProvider, pkg.getPackageName(), context)) {
- isEnabled = true;
- break;
- }
- }
- }
- pref.setOnGearClickListener(isEnabled ? mGearListener : null);
- }
-
@WorkerThread
private Map<String, LegacyVpnInfo> getConnectedLegacyVpns() {
mConnectedLegacyVpn = mVpnManager.getLegacyVpnInfo(UserHandle.myUserId());
@@ -598,15 +508,7 @@
return result;
}
- static List<AppVpnInfo> getVpnApps(Context context, boolean includeProfiles,
- AdvancedVpnFeatureProvider featureProvider) {
- return getVpnApps(context, includeProfiles, featureProvider,
- context.getSystemService(AppOpsManager.class));
- }
-
- @VisibleForTesting
- static List<AppVpnInfo> getVpnApps(Context context, boolean includeProfiles,
- AdvancedVpnFeatureProvider featureProvider, AppOpsManager aom) {
+ static List<AppVpnInfo> getVpnApps(Context context, boolean includeProfiles) {
List<AppVpnInfo> result = Lists.newArrayList();
final Set<Integer> profileIds;
@@ -619,19 +521,8 @@
profileIds = Collections.singleton(UserHandle.myUserId());
}
- if (featureProvider.isAdvancedVpnSupported(context)) {
- PackageManager pm = context.getPackageManager();
- try {
- ApplicationInfo appInfo =
- pm.getApplicationInfo(
- featureProvider.getAdvancedVpnPackageName(), /* flags= */ 0);
- int userId = UserHandle.getUserId(appInfo.uid);
- result.add(new AppVpnInfo(userId, featureProvider.getAdvancedVpnPackageName()));
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(LOG_TAG, "Advanced VPN package name not found.", e);
- }
- }
-
+ // Fetch VPN-enabled apps from AppOps.
+ AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
List<AppOpsManager.PackageOps> apps =
aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
if (apps != null) {
@@ -641,9 +532,6 @@
// Skip packages for users outside of our profile group.
continue;
}
- if (isAdvancedVpn(featureProvider, pkg.getPackageName(), context)) {
- continue;
- }
// Look for a MODE_ALLOWED permission to activate VPN.
boolean allowed = false;
for (AppOpsManager.OpEntry op : pkg.getOps()) {
@@ -662,12 +550,6 @@
return result;
}
- private static boolean isAdvancedVpn(AdvancedVpnFeatureProvider featureProvider,
- String packageName, Context context) {
- return featureProvider.isAdvancedVpnSupported(context)
- && TextUtils.equals(packageName, featureProvider.getAdvancedVpnPackageName());
- }
-
private static List<VpnProfile> loadVpnProfiles() {
final ArrayList<VpnProfile> result = Lists.newArrayList();
@@ -680,10 +562,4 @@
}
return result;
}
-
- @VisibleForTesting
- void init(PreferenceScreen preferenceScreen, AdvancedVpnFeatureProvider featureProvider) {
- mPreferenceScreen = preferenceScreen;
- mFeatureProvider = featureProvider;
- }
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index b808319..a7b7501 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -151,6 +151,16 @@
}
@Test
+ public void fingerprintUdfpsOverlayEnrollment_loseFocusWithCancelFlag_shouldNotCancelAgain() {
+ initializeActivityFor(TYPE_UDFPS_OPTICAL);
+
+ mActivity.mIsCanceled = true;
+ mActivity.onWindowFocusChanged(true);
+
+ verify(mActivity, never()).onCancelEnrollment(anyInt());
+ }
+
+ @Test
public void fingerprintSfpsEnroll_PlaysAllAnimationsAssetsCorrectly() {
initializeActivityFor(TYPE_POWER_BUTTON);
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
index fe4744f..96b9e62 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
@@ -22,10 +22,14 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Vibrator;
+import android.service.notification.NotificationListenerService;
import android.telephony.TelephonyManager;
+import com.android.internal.R;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,6 +50,8 @@
private AudioManager mAudioManager;
@Mock
private Vibrator mVibrator;
+ @Mock
+ private Resources mResources;
private Context mContext;
private NotificationVolumePreferenceController mController;
@@ -57,6 +63,8 @@
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
when(mContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
+ when(mContext.getResources()).thenReturn(mResources);
+
mController = new NotificationVolumePreferenceController(mContext);
mController.setAudioHelper(mHelper);
}
@@ -76,15 +84,50 @@
}
@Test
- public void isAvailable_voiceCapable_shouldReturnFalse() {
+ public void isAvailable_voiceCapable_aliasedWithRing_shouldReturnFalse() {
+ when(mResources.getBoolean(
+ com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
+ when(mResources.getBoolean(R.bool.config_alias_ring_notif_stream_types)).thenReturn(true);
+
+ NotificationVolumePreferenceController controller =
+ new NotificationVolumePreferenceController(mContext);
when(mHelper.isSingleVolume()).thenReturn(false);
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ assertThat(controller.isAvailable()).isFalse();
+ }
+
+ /**
+ * With the introduction of ring-notification volume separation, voice-capable devices could now
+ * display the notification volume slider.
+ */
+ @Test
+ public void isAvailable_voiceCapable_separatedFromRing_shouldReturnTrue() {
+ when(mResources.getBoolean(
+ com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
+ when(mResources.getBoolean(R.bool.config_alias_ring_notif_stream_types)).thenReturn(false);
+
+ NotificationVolumePreferenceController controller =
+ new NotificationVolumePreferenceController(mContext);
+
+ when(mHelper.isSingleVolume()).thenReturn(false);
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+
+ assertThat(controller.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_notShowNotificationVolume_shouldReturnFalse() {
+ when(mResources.getBoolean(
+ com.android.settings.R.bool.config_show_notification_volume)).thenReturn(false);
+
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_notSingleVolume_notVoiceCapable_shouldReturnTrue() {
+ when(mResources.getBoolean(
+ com.android.settings.R.bool.config_show_notification_volume)).thenReturn(true);
when(mHelper.isSingleVolume()).thenReturn(false);
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
@@ -107,4 +150,24 @@
public void isPublicSlice_returnTrue() {
assertThat(mController.isPublicSlice()).isTrue();
}
+
+ @Test
+ public void setHintsRing_DoesNotMatch() {
+ assertThat(mController.hintsMatch(
+ NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS)).isFalse();
+ }
+
+ @Test
+ public void setHintsAll_Matches() {
+ assertThat(mController.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_EFFECTS))
+ .isTrue();
+ }
+
+ @Test
+ public void setHintNotification_Matches() {
+ assertThat(mController
+ .hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS))
+ .isTrue();
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
index 5e484a3..02757d5 100644
--- a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
@@ -18,15 +18,20 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
+import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Vibrator;
+import android.service.notification.NotificationListenerService;
import android.telephony.TelephonyManager;
+import com.android.settings.R;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,8 +56,13 @@
private NotificationManager mNotificationManager;
@Mock
private ComponentName mSuppressor;
+ @Mock
+ private Resources mResources;
+ @Mock
+ private VolumeSeekBarPreference mPreference;
private Context mContext;
+
private RingVolumePreferenceController mController;
@Before
@@ -63,8 +73,9 @@
shadowContext.setSystemService(Context.AUDIO_SERVICE, mAudioManager);
shadowContext.setSystemService(Context.VIBRATOR_SERVICE, mVibrator);
shadowContext.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
- mContext = RuntimeEnvironment.application;
+ mContext = spy(RuntimeEnvironment.application);
when(mNotificationManager.getEffectsSuppressor()).thenReturn(mSuppressor);
+ when(mContext.getResources()).thenReturn(mResources);
mController = new RingVolumePreferenceController(mContext);
mController.setAudioHelper(mHelper);
}
@@ -109,4 +120,92 @@
public void isPublicSlice_returnTrue() {
assertThat(mController.isPublicSlice()).isTrue();
}
+
+ // todo: verify that the title change is displayed, by examining the underlying preference
+ @Test
+ public void ringNotificationStreamsNotAliased_sliderTitleSetToRingOnly() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_alias_ring_notif_stream_types))
+ .thenReturn(false);
+ final RingVolumePreferenceController controller =
+ new RingVolumePreferenceController(mContext);
+
+ int expectedTitleId = R.string.separate_ring_volume_option_title;
+
+ assertThat(controller.mTitleId).isEqualTo(expectedTitleId);
+ }
+
+ @Test
+ public void ringNotificationStreamsAliased_sliderTitleIncludesBothRingNotification() {
+
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_alias_ring_notif_stream_types)).thenReturn(true);
+ final RingVolumePreferenceController control = new RingVolumePreferenceController(mContext);
+
+ int expectedTitleId = R.string.ring_volume_option_title;
+
+ assertThat(control.mTitleId).isEqualTo(expectedTitleId);
+ }
+
+ @Test
+ public void setHintsRing_aliased_Matches() {
+ assertThat(mController.hintsMatch(
+ NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, true)).isTrue();
+ }
+
+ @Test
+ public void setHintsRingNotification_aliased_Matches() {
+ assertThat(mController.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_EFFECTS,
+ true)).isTrue();
+ }
+
+ @Test
+ public void setHintNotification_aliased_Matches() {
+ assertThat(mController
+ .hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS,
+ true)).isTrue();
+ }
+
+ @Test
+ public void setHintsRing_unaliased_Matches() {
+ assertThat(mController.hintsMatch(
+ NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, false)).isTrue();
+ }
+
+ @Test
+ public void setHintsRingNotification_unaliased_Matches() {
+ assertThat(mController.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_EFFECTS,
+ false)).isTrue();
+ }
+
+ @Test
+ public void setHintNotification_unaliased_doesNotMatch() {
+ assertThat(mController
+ .hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS,
+ false)).isFalse();
+ }
+
+ @Test
+ public void setRingerModeToVibrate_butNoVibratorAvailable_iconIsSilent() {
+ when(mHelper.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+
+ mController.setPreference(mPreference);
+ mController.setVibrator(null);
+ mController.updateRingerMode();
+
+ assertThat(mController.getMuteIcon()).isEqualTo(mController.mSilentIconId);
+ }
+
+ @Test
+ public void setRingerModeToVibrate_VibratorAvailable_iconIsVibrate() {
+ when(mHelper.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+ when(mVibrator.hasVibrator()).thenReturn(true);
+
+ mController.setPreference(mPreference);
+ mController.setVibrator(mVibrator);
+ mController.updateRingerMode();
+
+ assertThat(mController.getMuteIcon()).isEqualTo(mController.mVibrateIconId);
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java b/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
index c2ea6e7..9e84883 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundSettingsTest.java
@@ -35,6 +35,7 @@
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowUserManager;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -44,8 +45,6 @@
import java.util.List;
-import org.junit.Ignore;
-
@RunWith(RobolectricTestRunner.class)
public class SoundSettingsTest {
@@ -86,4 +85,19 @@
assertThat(settings.mHandler.hasMessages(SoundSettings.STOP_SAMPLE)).isTrue();
}
+
+ @Test
+ public void notificationVolume_isBetweenRingAndAlarm() {
+ final Context context = spy(RuntimeEnvironment.application);
+ final SoundSettings settings = new SoundSettings();
+ final int xmlId = settings.getPreferenceScreenResId();
+ final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
+
+ int ring = keys.indexOf("ring_volume");
+ int notification = keys.indexOf("notification_volume");
+ int alarm = keys.indexOf("alarm_volume");
+
+ assertThat(ring < notification).isTrue();
+ assertThat(notification < alarm).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index 2f24832..518aee9 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -47,7 +47,6 @@
import com.android.settings.security.SecuritySettingsFeatureProvider;
import com.android.settings.slices.SlicesFeatureProvider;
import com.android.settings.users.UserFeatureProvider;
-import com.android.settings.vpn2.AdvancedVpnFeatureProvider;
import com.android.settings.wifi.WifiTrackerLibProvider;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -88,7 +87,6 @@
public SecuritySettingsFeatureProvider securitySettingsFeatureProvider;
public AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
public AccessibilityMetricsFeatureProvider mAccessibilityMetricsFeatureProvider;
- public AdvancedVpnFeatureProvider mAdvancedVpnFeatureProvider;
/**
* Call this in {@code @Before} method of the test class to use fake factory.
@@ -138,7 +136,6 @@
securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class);
mAccessibilitySearchFeatureProvider = mock(AccessibilitySearchFeatureProvider.class);
mAccessibilityMetricsFeatureProvider = mock(AccessibilityMetricsFeatureProvider.class);
- mAdvancedVpnFeatureProvider = mock(AdvancedVpnFeatureProvider.class);
}
@Override
@@ -275,9 +272,4 @@
public AccessibilityMetricsFeatureProvider getAccessibilityMetricsFeatureProvider() {
return mAccessibilityMetricsFeatureProvider;
}
-
- @Override
- public AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider() {
- return mAdvancedVpnFeatureProvider;
- }
}
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index f565075..717de79 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -45,7 +45,6 @@
import com.android.settings.security.SecuritySettingsFeatureProvider;
import com.android.settings.slices.SlicesFeatureProvider;
import com.android.settings.users.UserFeatureProvider;
-import com.android.settings.vpn2.AdvancedVpnFeatureProvider;
import com.android.settings.wifi.WifiTrackerLibProvider;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -83,7 +82,6 @@
public SecuritySettingsFeatureProvider securitySettingsFeatureProvider;
public AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
public AccessibilityMetricsFeatureProvider mAccessibilityMetricsFeatureProvider;
- public AdvancedVpnFeatureProvider mAdvancedVpnFeatureProvider;
/**
* Call this in {@code @Before} method of the test class to use fake factory.
@@ -124,7 +122,6 @@
securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class);
mAccessibilitySearchFeatureProvider = mock(AccessibilitySearchFeatureProvider.class);
mAccessibilityMetricsFeatureProvider = mock(AccessibilityMetricsFeatureProvider.class);
- mAdvancedVpnFeatureProvider = mock(AdvancedVpnFeatureProvider.class);
}
@Override
@@ -261,9 +258,4 @@
public AccessibilityMetricsFeatureProvider getAccessibilityMetricsFeatureProvider() {
return mAccessibilityMetricsFeatureProvider;
}
-
- @Override
- public AdvancedVpnFeatureProvider getAdvancedVpnFeatureProvider() {
- return mAdvancedVpnFeatureProvider;
- }
}
diff --git a/tests/unit/src/com/android/settings/vpn2/AppManagementFragmentTest.java b/tests/unit/src/com/android/settings/vpn2/AppManagementFragmentTest.java
deleted file mode 100644
index 80bb393..0000000
--- a/tests/unit/src/com/android/settings/vpn2/AppManagementFragmentTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.vpn2;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.os.Looper;
-
-import androidx.test.annotation.UiThreadTest;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settingslib.RestrictedPreference;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-@RunWith(AndroidJUnit4.class)
-public class AppManagementFragmentTest {
- private static final String FAKE_PACKAGE_NAME = "com.fake.package.name";
- private static final String ADVANCED_VPN_GROUP_PACKAGE_NAME = "com.advanced.package.name";
-
- @Rule
- public final MockitoRule mMockitoRule = MockitoJUnit.rule();
-
- private AppManagementFragment mFragment;
- private Context mContext;
- private FakeFeatureFactory mFakeFeatureFactory;
- private RestrictedPreference mPreferenceForget;
-
- @Before
- @UiThreadTest
- public void setUp() {
- if (Looper.myLooper() == null) {
- Looper.prepare();
- }
-
- mFragment = spy(new AppManagementFragment());
- mContext = spy(ApplicationProvider.getApplicationContext());
- mPreferenceForget = new RestrictedPreference(mContext);
-
- mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
- mFragment.init(ADVANCED_VPN_GROUP_PACKAGE_NAME,
- mFakeFeatureFactory.getAdvancedVpnFeatureProvider(), mPreferenceForget);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.getAdvancedVpnPackageName())
- .thenReturn(ADVANCED_VPN_GROUP_PACKAGE_NAME);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnSupported(any()))
- .thenReturn(true);
- }
-
- @Test
- public void updateRestrictedViews_isAdvancedVpn_hidesForgetPreference() {
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnRemovable())
- .thenReturn(false);
- mFragment.updateRestrictedViews();
- assertThat(mPreferenceForget.isVisible()).isFalse();
- }
-
- @Test
- public void updateRestrictedViews_isNotAdvancedVpn_showsForgetPreference() {
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnRemovable())
- .thenReturn(false);
- mFragment.init(FAKE_PACKAGE_NAME,
- mFakeFeatureFactory.getAdvancedVpnFeatureProvider(), mPreferenceForget);
- mFragment.updateRestrictedViews();
- assertThat(mPreferenceForget.isVisible()).isTrue();
- }
-
- @Test
- public void updateRestrictedViews_isAdvancedVpnRemovable_showsForgetPreference() {
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnRemovable())
- .thenReturn(true);
- mFragment.init(FAKE_PACKAGE_NAME,
- mFakeFeatureFactory.getAdvancedVpnFeatureProvider(), mPreferenceForget);
- mFragment.updateRestrictedViews();
- assertThat(mPreferenceForget.isVisible()).isTrue();
- }
-}
diff --git a/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java b/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java
deleted file mode 100644
index 953a524..0000000
--- a/tests/unit/src/com/android/settings/vpn2/VpnSettingsTest.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.vpn2;
-
-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.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.AppOpsManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.Looper;
-import android.os.UserHandle;
-import android.text.TextUtils;
-import android.util.ArraySet;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.annotation.UiThreadTest;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(AndroidJUnit4.class)
-public class VpnSettingsTest {
- private static final int USER_ID_1 = UserHandle.USER_NULL;
- private static final String VPN_GROUP_KEY = "vpn_group";
- private static final String VPN_GROUP_TITLE = "vpn_group_title";
- private static final String VPN_PACKAGE_NAME = "vpn.package.name";
- private static final String VPN_LAUNCH_INTENT = "vpn.action";
- private static final String ADVANCED_VPN_GROUP_KEY = "advanced_vpn_group";
- private static final String ADVANCED_VPN_GROUP_TITLE = "advanced_vpn_group_title";
- private static final String ADVANCED_VPN_PACKAGE_NAME = "advanced.vpn.package.name";
- private static final String ADVANCED_VPN_LAUNCH_INTENT = "advanced.vpn.action";
-
- private final Intent mVpnIntent = new Intent().setAction(VPN_LAUNCH_INTENT);
- private final Intent mAdvancedVpnIntent = new Intent().setAction(ADVANCED_VPN_LAUNCH_INTENT);
-
- @Rule
- public final MockitoRule mMockitoRule = MockitoJUnit.rule();
-
- @Mock
- private AppOpsManager mAppOpsManager;
- @Mock
- private PackageManager mPackageManager;
-
- private VpnSettings mVpnSettings;
- private Context mContext;
- private PreferenceManager mPreferenceManager;
- private PreferenceScreen mPreferenceScreen;
- private PreferenceGroup mAdvancedVpnGroup;
- private PreferenceGroup mVpnGroup;
- private FakeFeatureFactory mFakeFeatureFactory;
-
- @Before
- @UiThreadTest
- public void setUp() throws PackageManager.NameNotFoundException {
- if (Looper.myLooper() == null) {
- Looper.prepare();
- }
-
- mVpnSettings = spy(new VpnSettings());
- mContext = spy(ApplicationProvider.getApplicationContext());
- mAdvancedVpnGroup = spy(new PreferenceCategory(mContext));
- mVpnGroup = spy(new PreferenceCategory(mContext));
- mAdvancedVpnGroup.setKey(ADVANCED_VPN_GROUP_KEY);
- mVpnGroup.setKey(VPN_GROUP_KEY);
- mPreferenceManager = new PreferenceManager(mContext);
- mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
- mPreferenceScreen.addPreference(mAdvancedVpnGroup);
- mPreferenceScreen.addPreference(mVpnGroup);
- mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
- mVpnSettings.init(mPreferenceScreen, mFakeFeatureFactory.getAdvancedVpnFeatureProvider());
-
- when(mVpnSettings.getContext()).thenReturn(mContext);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider
- .getAdvancedVpnPreferenceGroupTitle(mContext)).thenReturn(ADVANCED_VPN_GROUP_TITLE);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.getVpnPreferenceGroupTitle(mContext))
- .thenReturn(VPN_GROUP_TITLE);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.getAdvancedVpnPackageName())
- .thenReturn(ADVANCED_VPN_PACKAGE_NAME);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnSupported(any()))
- .thenReturn(true);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- doReturn(mContext).when(mContext).createContextAsUser(any(), anyInt());
- doReturn(mContext).when(mContext).createPackageContextAsUser(any(), anyInt(), any());
- doReturn(mPreferenceManager).when(mVpnGroup).getPreferenceManager();
- doReturn(mPreferenceManager).when(mAdvancedVpnGroup).getPreferenceManager();
- }
-
- @Test
- public void setShownAdvancedPreferences_hasGeneralVpn_returnsVpnCountAs1() {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref =
- spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
- updates.add(pref);
-
- mVpnSettings.setShownAdvancedPreferences(updates);
-
- assertThat(mVpnGroup.getPreferenceCount()).isEqualTo(1);
- assertThat(mVpnGroup.isVisible()).isTrue();
- assertThat(mAdvancedVpnGroup.isVisible()).isFalse();
- }
-
- @Test
- public void setShownAdvancedPreferences_hasAdvancedVpn_returnsAdvancedVpnCountAs1() {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref =
- spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
- updates.add(pref);
-
- mVpnSettings.setShownAdvancedPreferences(updates);
-
- assertThat(mAdvancedVpnGroup.getPreferenceCount()).isEqualTo(1);
- assertThat(mAdvancedVpnGroup.isVisible()).isTrue();
- assertThat(mVpnGroup.isVisible()).isFalse();
- }
-
- @Test
- public void setShownAdvancedPreferences_noVpn_returnsEmpty() {
- Set<Preference> updates = new ArraySet<>();
-
- mVpnSettings.setShownAdvancedPreferences(updates);
-
- assertThat(mAdvancedVpnGroup.getPreferenceCount()).isEqualTo(0);
- assertThat(mVpnGroup.getPreferenceCount()).isEqualTo(0);
- assertThat(mAdvancedVpnGroup.isVisible()).isFalse();
- assertThat(mVpnGroup.isVisible()).isFalse();
- }
-
- @Test
- public void getVpnApps_isAdvancedVpn_returnsOne() throws Exception {
- ApplicationInfo info = new ApplicationInfo();
- info.uid = 1111;
- when(mPackageManager.getApplicationInfo(anyString(), anyInt())).thenReturn(info);
-
- assertThat(VpnSettings.getVpnApps(mContext, /* includeProfiles= */ false,
- mFakeFeatureFactory.getAdvancedVpnFeatureProvider(),
- mAppOpsManager).size()).isEqualTo(1);
- }
-
- @Test
- public void getVpnApps_isNotAdvancedVpn_returnsEmpty() {
- int uid = 1111;
- List<AppOpsManager.OpEntry> opEntries = new ArrayList<>();
- List<AppOpsManager.PackageOps> apps = new ArrayList<>();
- AppOpsManager.PackageOps packageOps =
- new AppOpsManager.PackageOps(VPN_PACKAGE_NAME, uid, opEntries);
- apps.add(packageOps);
- when(mAppOpsManager.getPackagesForOps((int[]) any())).thenReturn(apps);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isAdvancedVpnSupported(any()))
- .thenReturn(false);
-
- assertThat(VpnSettings.getVpnApps(mContext, /* includeProfiles= */ false,
- mFakeFeatureFactory.getAdvancedVpnFeatureProvider(),
- mAppOpsManager)).isEmpty();
- }
-
- @Test
- public void clickVpn_VpnConnected_doesNotStartVpnLaunchIntent()
- throws PackageManager.NameNotFoundException {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref = spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
- pref.setState(AppPreference.STATE_CONNECTED);
- updates.add(pref);
- when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mVpnIntent);
- ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
- mVpnSettings.setShownPreferences(updates);
-
- mVpnSettings.onPreferenceClick(pref);
-
- verify(mContext, never()).startActivityAsUser(any(), any());
- }
-
- @Test
- public void clickVpn_VpnDisconnected_startsVpnLaunchIntent()
- throws PackageManager.NameNotFoundException {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref = spy(new AppPreference(mContext, USER_ID_1, VPN_PACKAGE_NAME));
- pref.setState(AppPreference.STATE_DISCONNECTED);
- updates.add(pref);
- when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mVpnIntent);
- ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
- mVpnSettings.setShownPreferences(updates);
-
- mVpnSettings.onPreferenceClick(pref);
-
- verify(mContext).startActivityAsUser(captor.capture(), any());
- assertThat(TextUtils.equals(captor.getValue().getAction(),
- VPN_LAUNCH_INTENT)).isTrue();
- }
-
- @Test
- public void clickAdvancedVpn_VpnConnectedDisconnectDialogDisabled_startsAppLaunchIntent()
- throws PackageManager.NameNotFoundException {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref =
- spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
- pref.setState(AppPreference.STATE_CONNECTED);
- updates.add(pref);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isDisconnectDialogEnabled())
- .thenReturn(false);
- when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mAdvancedVpnIntent);
- ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
- mVpnSettings.setShownAdvancedPreferences(updates);
-
- mVpnSettings.onPreferenceClick(pref);
-
- verify(mContext).startActivityAsUser(captor.capture(), any());
- assertThat(TextUtils.equals(captor.getValue().getAction(),
- ADVANCED_VPN_LAUNCH_INTENT)).isTrue();
- }
-
- @Test
- public void clickAdvancedVpn_VpnConnectedDisconnectDialogEnabled_doesNotStartAppLaunchIntent()
- throws PackageManager.NameNotFoundException {
- Set<Preference> updates = new ArraySet<>();
- AppPreference pref =
- spy(new AppPreference(mContext, USER_ID_1, ADVANCED_VPN_PACKAGE_NAME));
- pref.setState(AppPreference.STATE_CONNECTED);
- updates.add(pref);
- when(mFakeFeatureFactory.mAdvancedVpnFeatureProvider.isDisconnectDialogEnabled())
- .thenReturn(true);
- when(mContext.createPackageContextAsUser(any(), anyInt(), any())).thenReturn(mContext);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getLaunchIntentForPackage(any())).thenReturn(mAdvancedVpnIntent);
- ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivityAsUser(captor.capture(), any());
- mVpnSettings.setShownAdvancedPreferences(updates);
-
- mVpnSettings.onPreferenceClick(pref);
-
- verify(mContext, never()).startActivityAsUser(any(), any());
- }
-}