Merge "Split Documents&Other" into main
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9401ee0..48e9811 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1380,12 +1380,6 @@
<string name="private_space_choose_your_password_header">Set a password for your private space</string>
<!-- Header for private space choose your pattern screen [CHAR LIMIT=40] -->
<string name="private_space_choose_your_pattern_header">Set a pattern for your private space</string>
- <!-- Header for private space apps and notifications section [CHAR LIMIT=40] -->
- <string name="private_space_apps_and_notifications_header">Apps and notifications</string>
- <!-- Title for private space sensitive notifications toggle [CHAR LIMIT=80] -->
- <string name="private_space_notifications_title">Sensitive notifications on lock screen</string>
- <!-- Summary description for private space sensitive notifications toggle [CHAR LIMIT=200] -->
- <string name="private_space_sensitive_notifications_description">Show sensitive content when private space is unlocked</string>
<!-- Title for private space GAIA education screen [CHAR LIMIT=90] -->
<string name="private_space_gaia_education_title">Create a Google Account to help keep your data private</string>
<!-- Description for private space GAIA education screen [CHAR LIMIT=120] -->
@@ -5733,7 +5727,9 @@
<!-- Category title for battery background settings in power usage detail page [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_category_title">Manage battery usage</string>
- <!-- Title for allow background usage [CHAR LIMIT=NONE] -->
+ <!-- Title for allow background usage settings page [CHAR LIMIT=NONE] -->
+ <string name="manager_battery_usage_allow_background_usage_settings_title">Allow background usage</string>
+ <!-- Title for the allow background usage toggle [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_allow_background_usage_title">Allow background usage</string>
<!-- Summary for allow background usage [CHAR LIMIT=NONE] -->
<string name="manager_battery_usage_allow_background_usage_summary">Enable for real-time updates, disable to save battery</string>
@@ -9840,13 +9836,6 @@
<!-- Label for showing apps that can manage external storage[CHAR LIMIT=45] -->
<string name="filter_manage_external_storage">Can access all files</string>
- <!-- Voice Activation apps settings title [CHAR LIMIT=40] -->
- <string name="voice_activation_apps_title">Voice activation apps</string>
- <!-- Label for a setting which controls whether an app can be voice activated [CHAR LIMIT=NONE] -->
- <string name="permit_voice_activation_apps">Allow voice activation</string>
- <!-- Description for a setting which controls whether an app can be voice activated [CHAR LIMIT=NONE] -->
- <string name ="allow_voice_activation_apps_description">Voice activation turns-on approved apps, hands-free, using voice command. Built-in adaptive sensing ensures data stays private only to you.\n\n<a href="">More about protected adaptive sensing</a></string>
-
<!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
<string name="full_screen_intent_title">Full screen notifications</string>
diff --git a/res/xml/power_background_usage_detail.xml b/res/xml/power_background_usage_detail.xml
index fb089fd..5c7b6a5 100644
--- a/res/xml/power_background_usage_detail.xml
+++ b/res/xml/power_background_usage_detail.xml
@@ -18,7 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/manager_battery_usage_allow_background_usage_title">
+ android:title="@string/manager_battery_usage_allow_background_usage_settings_title">
<com.android.settingslib.widget.LayoutPreference
android:key="header_view"
diff --git a/res/xml/private_space_settings.xml b/res/xml/private_space_settings.xml
index f979599..b1233b9 100644
--- a/res/xml/private_space_settings.xml
+++ b/res/xml/private_space_settings.xml
@@ -60,17 +60,6 @@
</PreferenceCategory>
<PreferenceCategory
- android:title="@string/private_space_apps_and_notifications_header">
-
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="private_space_sensitive_notifications"
- android:title="@string/private_space_notifications_title"
- android:summary="@string/private_space_sensitive_notifications_description"
- settings:controller="com.android.settings.privatespace.HidePrivateSpaceSensitiveNotificationsController" />
-
- </PreferenceCategory>
-
- <PreferenceCategory
android:title="@string/private_space_category_system">
<Preference
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 572345c..4caf7ac 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -117,11 +117,6 @@
settings:controller="com.android.settings.spa.app.specialaccess.UseFullScreenIntentPreferenceController" />
<Preference
- android:key="voice_activation_apps"
- android:title="@string/voice_activation_apps_title"
- settings:controller="com.android.settings.spa.app.specialaccess.VoiceActivationAppsPreferenceController" />
-
- <Preference
android:key="picture_in_picture"
android:title="@string/picture_in_picture_title"
android:order="-1100"
diff --git a/src/com/android/settings/SettingsActivityUtil.kt b/src/com/android/settings/SettingsActivityUtil.kt
index b1927f1..3cbd4b4 100644
--- a/src/com/android/settings/SettingsActivityUtil.kt
+++ b/src/com/android/settings/SettingsActivityUtil.kt
@@ -38,7 +38,6 @@
import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider
import com.android.settings.spa.app.specialaccess.NfcTagAppsSettingsProvider
import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
-import com.android.settings.spa.app.specialaccess.VoiceActivationAppsListProvider
import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider
import com.android.settings.wifi.ChangeWifiStateDetails
@@ -67,8 +66,6 @@
WifiControlAppListProvider.getAppInfoRoutePrefix(),
NfcTagAppsSettingsProvider::class.qualifiedName to
NfcTagAppsSettingsProvider.getAppInfoRoutePrefix(),
- VoiceActivationAppsListProvider::class.qualifiedName to
- VoiceActivationAppsListProvider.getAppInfoRoutePrefix(),
BackupTasksAppsListProvider::class.qualifiedName to
BackupTasksAppsListProvider.getAppInfoRoutePrefix(),
)
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 1b9a70f..5ebe9c7 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -229,13 +229,15 @@
}
// Show secondary button once scroll is completed.
- if (!scrollNeeded) {
- if (!enrollmentCompleted) {
- getSecondaryFooterButton().setVisibility(View.VISIBLE);
- }
- mHasScrolledToBottom = true;
- }
+ getSecondaryFooterButton().setVisibility(
+ !scrollNeeded && !enrollmentCompleted ? View.VISIBLE : View.INVISIBLE);
+ mHasScrolledToBottom = !scrollNeeded;
});
+
+ final boolean isScrollNeeded = requireScrollMixin.isScrollingRequired();
+ final boolean enrollmentCompleted = checkMaxEnrolled() != 0;
+ getSecondaryFooterButton().setVisibility(
+ !isScrollNeeded && !enrollmentCompleted ? View.VISIBLE : View.INVISIBLE);
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
index 7dd29da..51d3a3a 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroductionInternal.java
@@ -16,8 +16,34 @@
package com.android.settings.biometrics.face;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import androidx.fragment.app.FragmentActivity;
+
/**
* Wrapper of {@link FaceEnrollIntroduction} to use with a pre-defined task affinity.
+ *
+ * <p>Trampolines over to FaceEnrollIntroduction - doing this as a trampoline rather than having
+ * this activity extend FaceEnrollIntroduction works around b/331157120.
*/
-public class FaceEnrollIntroductionInternal extends FaceEnrollIntroduction {
+public class FaceEnrollIntroductionInternal extends FragmentActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (isFinishing()) {
+ return;
+ }
+
+ // Copy our intent to grab all extras. Drop flags so we don't start new tasks twice.
+ Intent trampoline = new Intent(getIntent());
+ trampoline.setFlags(0);
+
+ // Trampoline to the intended activity, and finish
+ trampoline.setClassName(SETTINGS_PACKAGE_NAME, FaceEnrollIntroduction.class.getName());
+ startActivity(trampoline);
+ finish();
+ }
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 197aca0..3398c20 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -201,8 +201,9 @@
}
mRemoveController.setUserId(mUserId);
- // Don't show keyguard controller for work profile settings.
- if (mUserManager.isManagedProfile(mUserId)) {
+ // Don't show keyguard controller for work and private profile settings.
+ if (mUserManager.isManagedProfile(mUserId)
+ || mUserManager.getUserInfo(mUserId).isPrivateProfile()) {
removePreference(FaceSettingsKeyguardPreferenceController.KEY);
removePreference(mLockscreenController.getPreferenceKey());
}
diff --git a/src/com/android/settings/datausage/ChartDataUsagePreference.java b/src/com/android/settings/datausage/ChartDataUsagePreference.java
index e8e2109..0c7db71 100644
--- a/src/com/android/settings/datausage/ChartDataUsagePreference.java
+++ b/src/com/android/settings/datausage/ChartDataUsagePreference.java
@@ -124,7 +124,7 @@
UsageView chart, @NonNull List<NetworkUsageData> usageSummary) {
final Context context = getContext();
final StringBuilder contentDescription = new StringBuilder();
- final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH;
+ final int flags = DateUtils.FORMAT_SHOW_DATE;
// Setup a brief content description.
final String startDate = DateUtils.formatDateTime(context, mStart, flags);
@@ -153,7 +153,7 @@
nodeDate = DateUtils.formatDateRange(context, data.getStartTime(),
data.getEndTime(), flags);
}
- nodeContentDescription = String.format(";%s %d%%", nodeDate, dataUsagePercentage);
+ nodeContentDescription = String.format("; %s, %d%%", nodeDate, dataUsagePercentage);
contentDescription.append(nodeContentDescription);
}
diff --git a/src/com/android/settings/network/apn/ApnEditPageProvider.kt b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
index a287b84..71fe4d6 100644
--- a/src/com/android/settings/network/apn/ApnEditPageProvider.kt
+++ b/src/com/android/settings/network/apn/ApnEditPageProvider.kt
@@ -27,6 +27,7 @@
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -39,6 +40,7 @@
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.android.settings.R
+import com.android.settings.network.telephony.SubscriptionRepository
import com.android.settingslib.spa.framework.common.SettingsPageProvider
import com.android.settingslib.spa.framework.compose.LocalNavController
import com.android.settingslib.spa.framework.theme.SettingsDimension
@@ -78,6 +80,18 @@
mutableStateOf(apnDataInit)
}
ApnPage(apnDataInit, apnDataCur, uriInit)
+ SubscriptionNotEnabledEffect(subId)
+ }
+
+ @Composable
+ private fun SubscriptionNotEnabledEffect(subId: Int) {
+ val context = LocalContext.current
+ val navController = LocalNavController.current
+ LaunchedEffect(subId) {
+ SubscriptionRepository(context).isSubscriptionEnabledFlow(subId).collect { isEnabled ->
+ if (!isEnabled) navController.navigateBack()
+ }
+ }
}
fun getRoute(
diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java
index be90653..80239cb 100644
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -52,8 +52,11 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
+import android.view.View;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
@@ -61,9 +64,12 @@
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.flags.Flags;
import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.SubscriptionRepository;
import com.android.settings.spa.SpaActivity;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import kotlin.Unit;
+
import java.util.ArrayList;
/** Handle each different apn setting. */
@@ -92,13 +98,6 @@
Telephony.Carriers.EDITED_STATUS,
};
- /** Copied from {@code com.android.internal.telephony.TelephonyIntents} */
- private static final String ACTION_SIM_STATE_CHANGED =
- "android.intent.action.SIM_STATE_CHANGED";
- /** Copied from {@code com.android.internal.telephony.IccCardConstants} */
- public static final String INTENT_KEY_ICC_STATE = "ss";
- public static final String INTENT_VALUE_ICC_ABSENT = "ABSENT";
-
private static final int ID_INDEX = 0;
private static final int NAME_INDEX = 1;
private static final int APN_INDEX = 2;
@@ -162,16 +161,7 @@
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ACTION_SIM_STATE_CHANGED.equals(action)
- && intent.getStringExtra(INTENT_KEY_ICC_STATE)
- .equals(INTENT_VALUE_ICC_ABSENT)) {
- final SubscriptionManager sm = context.getSystemService(SubscriptionManager.class);
- if (sm != null && !sm.isActiveSubscriptionId(mSubId)) {
- Log.d(TAG, "Due to SIM absent, closes APN settings page");
- finish();
- }
- } else if (intent.getAction().equals(
+ if (intent.getAction().equals(
TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) {
if (mRestoreDefaultApnMode) {
return;
@@ -223,7 +213,6 @@
mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED);
- mIntentFilter.addAction(ACTION_SIM_STATE_CHANGED);
setIfOnlyAvailableForAdmins(true);
@@ -264,6 +253,20 @@
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ new SubscriptionRepository(requireContext())
+ .collectSubscriptionEnabled(mSubId, getViewLifecycleOwner(), (isEnabled) -> {
+ if (!isEnabled) {
+ Log.d(TAG, "Due to subscription not enabled, closes APN settings page");
+ finish();
+ }
+ return Unit.INSTANCE;
+ });
+ }
+
+ @Override
public void onResume() {
super.onResume();
diff --git a/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java b/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java
index d439d4f..aaf98f1 100644
--- a/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java
+++ b/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java
@@ -16,6 +16,7 @@
package com.android.settings.network.telephony;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -28,20 +29,21 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/** This dialog activity advise the user to have connectivity if the eSIM uses a RAC. */
public class EuiccRacConnectivityDialogActivity extends FragmentActivity
implements WarningDialogFragment.OnConfirmListener {
private static final String TAG = "EuiccRacConnectivityDialogActivity";
- // Dialog tags
- private static final int DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION = 1;
private static final String ARG_SUB_ID = "sub_id";
private static final String ARG_RESET_MOBILE_NETWORK_ID = "reset_mobile_netword_id";
private int mSubId;
@Nullable
private Intent mResetMobileNetworkIntent;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
/**
* Returns an intent of EuiccRacConnectivityDialogActivity for Settings: erase eSIM.
@@ -80,6 +82,7 @@
mSubId = intent.getIntExtra(ARG_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mResetMobileNetworkIntent =
intent.getParcelableExtra(ARG_RESET_MOBILE_NETWORK_ID, Intent.class);
+ mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
if (savedInstanceState == null) {
showConnectivityWarningDialog();
@@ -88,20 +91,26 @@
@Override
public void onConfirm(int tag, boolean confirmed) {
+ if (tag == SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING
+ || tag == SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING) {
+ mMetricsFeatureProvider.action(this, tag, confirmed ? 1 : 0);
+ }
+
if (!confirmed) {
finish();
return;
}
+ finish();
switch (tag) {
- case DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION:
- finish();
+ case SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING:
+ Log.i(TAG, "Show dialogue activity that handles deleting eSIM profile");
+ startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(this, mSubId));
+ break;
+ case SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING:
if (mResetMobileNetworkIntent != null) {
Log.i(TAG, "Show fragment activity that handles mobile network settings reset");
new SubSettingLauncher(this).launchWithIntent(mResetMobileNetworkIntent);
- } else {
- Log.i(TAG, "Show dialogue activity that handles deleting eSIM profiles");
- startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(this, mSubId));
}
break;
default:
@@ -115,10 +124,19 @@
WarningDialogFragment.show(
this,
WarningDialogFragment.OnConfirmListener.class,
- DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION,
+ getMetricsTag(),
getString(R.string.wifi_warning_dialog_title),
getString(R.string.wifi_warning_dialog_text),
getString(R.string.wifi_warning_continue_button),
getString(R.string.wifi_warning_return_button));
}
+
+ /* Get the metrics tag depending on the intent. */
+ private int getMetricsTag() {
+ if (mResetMobileNetworkIntent != null) {
+ return SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING;
+ } else {
+ return SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING;
+ }
+ }
}
diff --git a/src/com/android/settings/network/telephony/SubscriptionRepository.kt b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
index b0a39ec..938f4d8 100644
--- a/src/com/android/settings/network/telephony/SubscriptionRepository.kt
+++ b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
@@ -20,7 +20,9 @@
import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager
import android.util.Log
+import androidx.lifecycle.LifecycleOwner
import com.android.settings.network.SubscriptionUtil
+import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
import kotlinx.coroutines.channels.awaitClose
@@ -43,6 +45,16 @@
context.getSelectableSubscriptionInfoList()
fun isSubscriptionEnabledFlow(subId: Int) = context.isSubscriptionEnabledFlow(subId)
+
+ /** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
+ fun collectSubscriptionEnabled(
+ subId: Int,
+ lifecycleOwner: LifecycleOwner,
+ action: (Boolean) -> Unit,
+ ) {
+ isSubscriptionEnabledFlow(subId).collectLatestWithLifecycle(lifecycleOwner, action = action)
+ }
+
}
val Context.subscriptionManager: SubscriptionManager?
@@ -52,7 +64,8 @@
fun Context.isSubscriptionEnabledFlow(subId: Int) = subscriptionsChangedFlow().map {
subscriptionManager?.isSubscriptionEnabled(subId) ?: false
-}.flowOn(Dispatchers.Default)
+}.conflate().onEach { Log.d(TAG, "[$subId] isSubscriptionEnabledFlow: $it") }
+ .flowOn(Dispatchers.Default)
fun Context.phoneNumberFlow(subscriptionInfo: SubscriptionInfo) = subscriptionsChangedFlow().map {
SubscriptionUtil.getFormattedPhoneNumber(this, subscriptionInfo)
diff --git a/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java b/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java
deleted file mode 100644
index 6cb54a1..0000000
--- a/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.privatespace;
-
-import static android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
-
-import android.content.Context;
-import android.os.UserHandle;
-import android.provider.Settings;
-
-import androidx.annotation.NonNull;
-
-import com.android.settings.core.TogglePreferenceController;
-
-import java.util.Objects;
-
-/**
- * A controller object for sensitive notifications in Private Space settings page.
- */
-public class HidePrivateSpaceSensitiveNotificationsController extends TogglePreferenceController {
- private final PrivateSpaceMaintainer mPrivateSpaceMaintainer;
- private final UserHandle mPrivateProfileId;
- public static final int ENABLED = 1;
- public static final int DISABLED = 0;
- private static final int DEVICE_SENSITIVE_NOTIFICATIONS_DEFAULT = ENABLED;
- private static final int DEVICE_LOCK_SCREEN_NOTIFICATIONS_DEFAULT = ENABLED;
- private static final int PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DEFAULT = DISABLED;
-
- public HidePrivateSpaceSensitiveNotificationsController(@NonNull Context context,
- @NonNull String preferenceKey) {
- super(context, preferenceKey);
- mPrivateSpaceMaintainer = PrivateSpaceMaintainer.getInstance(context);
- mPrivateProfileId = Objects.requireNonNull(
- mPrivateSpaceMaintainer.getPrivateProfileHandle());
- }
-
- @Override
- public int getAvailabilityStatus() {
- if (!android.os.Flags.allowPrivateProfile()
- || !android.multiuser.Flags.enablePsSensitiveNotificationsToggle()
- || !android.multiuser.Flags.enablePrivateSpaceFeatures()
- || !mPrivateSpaceMaintainer.doesPrivateSpaceExist()) {
- return UNSUPPORTED_ON_DEVICE;
- }
- if (!getLockscreenNotificationsEnabled(mContext)
- || !getLockscreenSensitiveNotificationsEnabledOnDevice(mContext)) {
- return DISABLED_DEPENDENT_SETTING;
- }
- return AVAILABLE;
- }
-
- @Override
- public boolean isChecked() {
- return Settings.Secure.getIntForUser(mContext.getContentResolver(),
- LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DEFAULT, mPrivateProfileId.getIdentifier())
- != DISABLED;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- isChecked ? ENABLED : DISABLED, mPrivateProfileId.getIdentifier());
- return true;
- }
-
- @Override
- public int getSliceHighlightMenuRes() {
- return 0;
- }
-
- /**
- * If notifications are disabled on the device, the toggle for private space sensitive
- * notifications should be unavailable.
- */
- private static boolean getLockscreenNotificationsEnabled(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
- DEVICE_LOCK_SCREEN_NOTIFICATIONS_DEFAULT) != DISABLED;
- }
-
- /**
- * If sensitive notifications are hidden on the device, they should be hidden for private space
- * also.
- */
- private static boolean getLockscreenSensitiveNotificationsEnabledOnDevice(Context context) {
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- DEVICE_SENSITIVE_NOTIFICATIONS_DEFAULT) != DISABLED;
- }
-}
diff --git a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
index 6a9ea9d..2ca22d1 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
@@ -23,20 +23,21 @@
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import android.app.ActivityManager;
-import android.app.IActivityManager;
import android.app.KeyguardManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.UserInfo;
import android.os.Flags;
-import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.util.ArraySet;
import android.util.Log;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -54,9 +55,12 @@
private final Context mContext;
private final UserManager mUserManager;
+ private final ActivityManager mActivityManager;
@GuardedBy("this")
private UserHandle mUserHandle;
private final KeyguardManager mKeyguardManager;
+ /** This variable should be accessed via {@link #getBroadcastReceiver()} only. */
+ @Nullable private ProfileAvailabilityBroadcastReceiver mProfileAvailabilityBroadcastReceiver;
/** This is the default value for the hide private space entry point settings. */
public static final int HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL = 0;
@@ -65,6 +69,8 @@
@Settings.Secure.PrivateSpaceAutoLockOption
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
+ /** Default value for the hide private space sensitive notifications on lockscreen. */
+ public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;
public enum ErrorDeletingPrivateSpace {
DELETE_PS_ERROR_NONE,
@@ -104,12 +110,13 @@
return false;
}
- IActivityManager am = ActivityManager.getService();
+ registerBroadcastReceiver();
+
try {
//TODO(b/313926659): To check and handle failure of startProfile
- am.startProfile(mUserHandle.getIdentifier());
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to start private profile");
+ mActivityManager.startProfile(mUserHandle);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Unexpected that " + mUserHandle.getIdentifier() + " is not a profile");
return false;
}
@@ -134,6 +141,7 @@
Log.i(TAG, "Deleting Private space with id: " + mUserHandle.getIdentifier());
if (mUserManager.removeUser(mUserHandle)) {
Log.i(TAG, "Private space deleted");
+ unregisterBroadcastReceiver();
mUserHandle = null;
return ErrorDeletingPrivateSpace.DELETE_PS_ERROR_NONE;
@@ -160,6 +168,7 @@
for (UserInfo user : users) {
if (user.isPrivateProfile()) {
mUserHandle = user.getUserHandle();
+ registerBroadcastReceiver();
return true;
}
}
@@ -213,6 +222,7 @@
mContext = context.getApplicationContext();
mUserManager = mContext.getSystemService(UserManager.class);
mKeyguardManager = mContext.getSystemService(KeyguardManager.class);
+ mActivityManager = mContext.getSystemService(ActivityManager.class);
}
@@ -316,7 +326,7 @@
private void setPrivateSpaceSensitiveNotificationsDefaultValue() {
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- HidePrivateSpaceSensitiveNotificationsController.DISABLED,
+ HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL,
mUserHandle.getIdentifier());
}
@@ -336,4 +346,91 @@
&& android.multiuser.Flags.supportAutolockForPrivateSpace()
&& android.multiuser.Flags.enablePrivateSpaceFeatures();
}
+
+ /** {@link BroadcastReceiver} which handles the private profile's availability related
+ * broadcasts.
+ */
+ private final class ProfileAvailabilityBroadcastReceiver extends BroadcastReceiver {
+ void register() {
+ Log.d(TAG, "Registering the receiver");
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_PROFILE_UNAVAILABLE);
+ mContext.registerReceiver(/* receiver= */ this, filter, Context.RECEIVER_NOT_EXPORTED);
+ }
+
+ void unregister() {
+ Log.d(TAG, "Unregistering the receiver");
+ mContext.unregisterReceiver(/* receiver= */ this);
+ }
+
+ @Override
+ public void onReceive(@NonNull Context context, @NonNull Intent intent) {
+ UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER, UserHandle.class);
+ if (!userHandle.equals(getPrivateProfileHandle())) {
+ Log.d(TAG, "Ignoring intent for non-private profile with user id "
+ + userHandle.getIdentifier());
+ return;
+ }
+
+ Log.i(TAG, "Removing all Settings tasks.");
+ removeSettingsAllTasks();
+ }
+ }
+
+ private synchronized void registerBroadcastReceiver() {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
+ return;
+ }
+ var broadcastReceiver = getBroadcastReceiver();
+ if (broadcastReceiver == null) {
+ return;
+ }
+ broadcastReceiver.register();
+ }
+
+ private synchronized void unregisterBroadcastReceiver() {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
+ return;
+ }
+ if (mProfileAvailabilityBroadcastReceiver == null) {
+ Log.w(TAG, "Requested to unregister when there is no receiver.");
+ return;
+ }
+ mProfileAvailabilityBroadcastReceiver.unregister();
+ mProfileAvailabilityBroadcastReceiver = null;
+ }
+
+ /** Always use this getter to access {@link #mProfileAvailabilityBroadcastReceiver}. */
+ @VisibleForTesting
+ @Nullable synchronized ProfileAvailabilityBroadcastReceiver getBroadcastReceiver() {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
+ return null;
+ }
+ if (!doesPrivateSpaceExist()) {
+ Log.e(TAG, "Cannot return a broadcast receiver when private space doesn't exist");
+ return null;
+ }
+ if (mProfileAvailabilityBroadcastReceiver == null) {
+ mProfileAvailabilityBroadcastReceiver = new ProfileAvailabilityBroadcastReceiver();
+ }
+ return mProfileAvailabilityBroadcastReceiver;
+ }
+
+ /** This is purely for testing purpose only, and should not be used elsewhere. */
+ @VisibleForTesting
+ synchronized void resetBroadcastReceiver() {
+ mProfileAvailabilityBroadcastReceiver = null;
+ }
+
+ private void removeSettingsAllTasks() {
+ List<ActivityManager.AppTask> appTasks = mActivityManager.getAppTasks();
+ for (var appTask : appTasks) {
+ if (!appTask.getTaskInfo().isVisible()) {
+ appTask.finishAndRemoveTask();
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/spa/SettingsSpaEnvironment.kt b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
index f701323..b844d44 100644
--- a/src/com/android/settings/spa/SettingsSpaEnvironment.kt
+++ b/src/com/android/settings/spa/SettingsSpaEnvironment.kt
@@ -41,7 +41,6 @@
import com.android.settings.spa.app.specialaccess.SpecialAppAccessPageProvider
import com.android.settings.spa.app.specialaccess.TurnScreenOnAppsAppListProvider
import com.android.settings.spa.app.specialaccess.UseFullScreenIntentAppListProvider
-import com.android.settings.spa.app.specialaccess.VoiceActivationAppsListProvider
import com.android.settings.spa.app.specialaccess.WifiControlAppListProvider
import com.android.settings.spa.app.storage.StorageAppListPageProvider
import com.android.settings.spa.core.instrumentation.SpaLogProvider
@@ -76,7 +75,6 @@
PictureInPictureListProvider,
InstallUnknownAppsListProvider,
AlarmsAndRemindersAppListProvider,
- VoiceActivationAppsListProvider,
WifiControlAppListProvider,
NfcTagAppsSettingsProvider,
LongBackgroundTasksAppListProvider,
diff --git a/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt b/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
index c12915c..2fd8fc5 100644
--- a/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppInfoSettings.kt
@@ -43,7 +43,6 @@
import com.android.settings.spa.app.specialaccess.InstallUnknownAppsListProvider
import com.android.settings.spa.app.specialaccess.ModifySystemSettingsAppListProvider
import com.android.settings.spa.app.specialaccess.PictureInPictureListProvider
-import com.android.settings.spa.app.specialaccess.VoiceActivationAppsListProvider
import com.android.settingslib.spa.framework.common.SettingsPageProvider
import com.android.settingslib.spa.framework.compose.navigator
import com.android.settingslib.spa.widget.scaffold.RegularScaffold
@@ -167,9 +166,6 @@
InstallUnknownAppsListProvider.InfoPageEntryItem(app)
InteractAcrossProfilesDetailsPreference(app)
AlarmsAndRemindersAppListProvider.InfoPageEntryItem(app)
- if (Flags.enableVoiceActivationAppsInSettings()) {
- VoiceActivationAppsListProvider.InfoPageEntryItem(app)
- }
if (Flags.enablePerformBackupTasksInSettings()) {
BackupTasksAppsListProvider.InfoPageEntryItem(app)
}
diff --git a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
index 4f79173..aabc9f8 100644
--- a/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
+++ b/src/com/android/settings/spa/app/specialaccess/SpecialAppAccess.kt
@@ -67,7 +67,6 @@
PictureInPictureListProvider,
InstallUnknownAppsListProvider,
AlarmsAndRemindersAppListProvider,
- VoiceActivationAppsListProvider,
WifiControlAppListProvider,
LongBackgroundTasksAppListProvider,
TurnScreenOnAppsAppListProvider,
diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
deleted file mode 100644
index 1225806..0000000
--- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationApps.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2023 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.spa.app.specialaccess
-
-import android.Manifest
-import android.app.AppOpsManager
-import android.app.settings.SettingsEnums
-import android.content.Context
-import com.android.settings.R
-import com.android.settings.overlay.FeatureFactory
-import com.android.settingslib.spaprivileged.model.app.PackageManagers.hasGrantPermission
-import com.android.settingslib.spaprivileged.template.app.AppOpPermissionListModel
-import com.android.settingslib.spaprivileged.template.app.AppOpPermissionRecord
-import com.android.settingslib.spaprivileged.template.app.TogglePermissionAppListProvider
-
-/**
- * This class builds an App List under voice activation apps and the individual page which
- * allows the user to toggle voice activation related permissions on / off for the apps displayed
- * in the list.
- */
-object VoiceActivationAppsListProvider : TogglePermissionAppListProvider {
- override val permissionType = "VoiceActivationApps"
- override fun createModel(context: Context) = VoiceActivationAppsListModel(context)
-}
-
-class VoiceActivationAppsListModel(context: Context) : AppOpPermissionListModel(context) {
- override val pageTitleResId = R.string.voice_activation_apps_title
- override val switchTitleResId = R.string.permit_voice_activation_apps
- override val footerResId = R.string.allow_voice_activation_apps_description
- override val appOp = AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO
- override val permission = Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
- override val setModeByUid = true
-
- override fun setAllowed(record: AppOpPermissionRecord, newAllowed: Boolean) {
- super.setAllowed(record, newAllowed)
- logPermissionChange(newAllowed)
- }
-
- override fun isChangeable(record: AppOpPermissionRecord): Boolean =
- super.isChangeable(record) && record.app.hasGrantPermission(permission)
-
- private fun logPermissionChange(newAllowed: Boolean) {
- val category = when {
- newAllowed -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_ALLOW
- else -> SettingsEnums.APP_SPECIAL_PERMISSION_RECEIVE_SANDBOX_TRIGGER_AUDIO_DENY
- }
- /**
- * Leave the package string empty as we should not log the package names for the collected
- * metrics.
- */
- FeatureFactory.featureFactory.metricsFeatureProvider.action(context, category, "")
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceController.kt b/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceController.kt
deleted file mode 100644
index 27d4b4b..0000000
--- a/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceController.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2023 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.spa.app.specialaccess
-
-import android.content.Context
-import androidx.preference.Preference
-import com.android.settings.core.BasePreferenceController
-import com.android.settings.flags.Flags
-import com.android.settings.spa.SpaActivity.Companion.startSpaActivity
-
-class VoiceActivationAppsPreferenceController(context: Context, preferenceKey: String) :
- BasePreferenceController(context, preferenceKey) {
- override fun getAvailabilityStatus() =
- if (Flags.enableVoiceActivationAppsInSettings()) AVAILABLE
- else CONDITIONALLY_UNAVAILABLE
-
- override fun handlePreferenceTreeClick(preference: Preference): Boolean {
- if (preference.key == mPreferenceKey) {
- mContext.startSpaActivity(VoiceActivationAppsListProvider.getAppListRoute())
- return true
- }
- return false
- }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 675e10f..14ef483 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -17,7 +17,6 @@
package com.android.settings.wallpaper;
import android.app.WallpaperManager;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -81,10 +80,9 @@
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = controller.getTitle();
data.screenTitle = data.title;
- ComponentName component = controller.getComponentName();
- data.intentTargetPackage = component.getPackageName();
- data.intentTargetClass = component.getClassName();
- data.intentAction = controller.getComponentActionName();
+ data.intentTargetPackage = context.getPackageName();
+ data.intentTargetClass = WallpaperSuggestionActivity.class.getName();
+ data.intentAction = Intent.ACTION_MAIN;
data.key = SUPPORT_SEARCH_INDEX_KEY;
data.keywords = controller.getKeywords();
result.add(data);
diff --git a/tests/robotests/src/com/android/settings/biometrics/face/FaceEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/face/FaceEnrollIntroductionTest.java
index a56c34c..81a7269 100644
--- a/tests/robotests/src/com/android/settings/biometrics/face/FaceEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/face/FaceEnrollIntroductionTest.java
@@ -78,6 +78,7 @@
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifLayout;
+import com.google.android.setupdesign.template.RequireScrollMixin;
import com.google.android.setupdesign.view.BottomScrollView;
import org.junit.After;
@@ -138,6 +139,11 @@
}
@Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+ @Override
public void recreate() {
mRecreateCount++;
// Do nothing
@@ -424,11 +430,39 @@
}
@Test
- public void testFaceEnrollIntroduction_notShowFooterSecondaryButton() {
+ public void testFaceEnrollIntroduction_footerSecondaryButtonWhenCanEnroll() {
setupActivity();
FooterBarMixin footer = getGlifLayout(mActivity).getMixin(FooterBarMixin.class);
FooterButton footerButton = footer.getSecondaryButton();
+ final RequireScrollMixin requireScrollMixin = getGlifLayout(mActivity).getMixin(
+ RequireScrollMixin.class);
+ assertThat(footerButton.getVisibility()).isEqualTo(
+ requireScrollMixin.isScrollingRequired() ? View.INVISIBLE : View.VISIBLE);
+
+ requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
+ false);
+ assertThat(footerButton.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void testFaceEnrollIntroduction_footerSecondaryButtonWhenMaxEnroll() {
+ setFaceManagerToHave(1 /* numEnrollments */);
+ final Intent intent = new Intent();
+ intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, new byte[0]);
+ mController = Robolectric.buildActivity(TestFaceEnrollIntroduction.class, intent);
+ mActivity = (TestFaceEnrollIntroduction) mController.get();
+
+ mController.create();
+
+ FooterBarMixin footer = getGlifLayout(mActivity).getMixin(FooterBarMixin.class);
+ FooterButton footerButton = footer.getSecondaryButton();
+ final RequireScrollMixin requireScrollMixin = getGlifLayout(mActivity).getMixin(
+ RequireScrollMixin.class);
+ assertThat(footerButton.getVisibility()).isEqualTo(View.INVISIBLE);
+
+ requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
+ false);
assertThat(footerButton.getVisibility()).isEqualTo(View.INVISIBLE);
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
index 6df8b8e..edd50a6 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
@@ -183,14 +183,6 @@
int result = mFingerprintEnrollIntroduction.checkMaxEnrolled();
assertThat(result).isEqualTo(0);
-
- final RequireScrollMixin requireScrollMixin =
- ((GlifLayout) mFingerprintEnrollIntroduction.findViewById(
- R.id.setup_wizard_layout)).getMixin(RequireScrollMixin.class);
- requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
- false);
- Assert.assertEquals(View.VISIBLE,
- mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
}
@Test
@@ -206,14 +198,6 @@
int result = mFingerprintEnrollIntroduction.checkMaxEnrolled();
assertThat(result).isEqualTo(R.string.fingerprint_intro_error_max);
-
- final RequireScrollMixin requireScrollMixin =
- ((GlifLayout) mFingerprintEnrollIntroduction.findViewById(
- R.id.setup_wizard_layout)).getMixin(RequireScrollMixin.class);
- requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
- false);
- Assert.assertEquals(View.INVISIBLE,
- mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
}
@Test
@@ -321,6 +305,57 @@
.isEqualTo(FingerprintEnrollOptions.ENROLL_REASON_SETTINGS);
}
+ @Test
+ public void intro_CheckNoThanksButtonWhenCanEnroll() {
+ // This code path should depend on suw_max_fingerprints_enrollable versus
+ // FingerprintManager.getSensorProperties...maxEnrollmentsPerUser()
+ Resources resources = mock(Resources.class);
+ when(resources.getInteger(anyInt())).thenReturn(5);
+ when(mContext.getResources()).thenReturn(resources);
+
+ setupFingerprintEnrollIntroWith(newFirstSuwIntent());
+ setFingerprintManagerToHave(0 /* numEnrollments */);
+
+ final RequireScrollMixin requireScrollMixin =
+ ((GlifLayout) mFingerprintEnrollIntroduction.findViewById(
+ R.id.setup_wizard_layout)).getMixin(RequireScrollMixin.class);
+
+ Assert.assertEquals(
+ requireScrollMixin.isScrollingRequired() ? View.INVISIBLE : View.VISIBLE,
+ mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
+
+ requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
+ false);
+ Assert.assertEquals(View.VISIBLE,
+ mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
+ }
+
+ @Test
+ public void intro_CheckNoThanksButtonWhenMaxEnroll() {
+ // This code path should depend on suw_max_fingerprints_enrollable versus
+ // FingerprintManager.getSensorProperties...maxEnrollmentsPerUser()
+ Resources resources = mock(Resources.class);
+ when(mContext.getResources()).thenReturn(resources);
+ when(resources.getInteger(anyInt())).thenReturn(1);
+
+ setupFingerprintEnrollIntroWith(newFirstSuwIntent());
+ setFingerprintManagerToHave(1 /* numEnrollments */);
+
+ final RequireScrollMixin requireScrollMixin =
+ ((GlifLayout) mFingerprintEnrollIntroduction.findViewById(
+ R.id.setup_wizard_layout)).getMixin(RequireScrollMixin.class);
+
+ mFingerprintEnrollIntroduction.onResume();
+ Assert.assertEquals(View.INVISIBLE,
+ mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
+
+ requireScrollMixin.getOnRequireScrollStateChangedListener().onRequireScrollStateChanged(
+ false);
+ Assert.assertEquals(View.INVISIBLE,
+ mFingerprintEnrollIntroduction.getSecondaryFooterButton().getVisibility());
+
+ }
+
private Intent newTokenOnlyIntent() {
return new Intent()
.putExtra(EXTRA_KEY_CHALLENGE_TOKEN, new byte[] { 1 });
@@ -365,6 +400,11 @@
public int mNewSensorId;
public long mNewChallenge;
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
@Nullable
public byte[] getTokenField() {
return mToken;
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivityTest.java
new file mode 100644
index 0000000..29d8f79
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivityTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class EuiccRacConnectivityDialogActivityTest {
+ private static final boolean CONFIRMED = true;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private EuiccRacConnectivityDialogActivity mActivity;
+
+ @Before
+ public void setUp() {
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mActivity = spy(Robolectric.buildActivity(EuiccRacConnectivityDialogActivity.class).get());
+ mActivity.onCreate(null);
+ }
+
+ @Test
+ public void dialogAction_continue_intentResetMobileNetwork_metricsLogged() {
+ mActivity.onConfirm(
+ SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING, CONFIRMED);
+
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mActivity,
+ SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING,
+ getMetricsValue(CONFIRMED));
+ }
+
+ @Test
+ public void dialogAction_back_intentResetMobileNetwork_metricsLogged() {
+ mActivity.onConfirm(
+ SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING, !CONFIRMED);
+
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mActivity,
+ SettingsEnums.ACTION_RESET_MOBILE_NETWORK_RAC_CONNECTIVITY_WARNING,
+ getMetricsValue(!CONFIRMED));
+ }
+
+ @Test
+ public void dialogAction_continue_intentSettingsEsimDelete_metricsLogged() {
+ mActivity.onConfirm(SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING, CONFIRMED);
+
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mActivity,
+ SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING,
+ getMetricsValue(CONFIRMED));
+ }
+
+ @Test
+ public void dialogAction_back_intentSettingsEsimDelete_metricsLogged() {
+ mActivity.onConfirm(
+ SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING, !CONFIRMED);
+
+ verify(mFeatureFactory.metricsFeatureProvider)
+ .action(
+ mActivity,
+ SettingsEnums.ACTION_SETTINGS_ESIM_RAC_CONNECTIVITY_WARNING,
+ getMetricsValue(!CONFIRMED));
+ }
+
+ private int getMetricsValue(boolean confirmed) {
+ return confirmed ? 1 : 0;
+ }
+}
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceControllerTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceControllerTest.kt
deleted file mode 100644
index 2127497..0000000
--- a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsPreferenceControllerTest.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.android.settings.spa.app.specialaccess
-
-import android.content.Context
-import android.platform.test.annotations.RequiresFlagsDisabled
-import android.platform.test.annotations.RequiresFlagsEnabled
-import android.platform.test.flag.junit.CheckFlagsRule
-import android.platform.test.flag.junit.DeviceFlagsValueProvider
-import androidx.preference.Preference
-import androidx.test.core.app.ApplicationProvider
-import androidx.test.ext.junit.runners.AndroidJUnit4
-
-import com.android.settings.flags.Flags
-import com.google.common.truth.Truth.assertThat
-
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.kotlin.any
-import org.mockito.kotlin.doNothing
-import org.mockito.kotlin.spy
-import org.mockito.kotlin.whenever
-
-@RunWith(AndroidJUnit4::class)
-class VoiceActivationAppsPreferenceControllerTest {
-
- @get:Rule
- val checkFlagsRule: CheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()
-
- private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
- doNothing().whenever(mock).startActivity(any())
- }
-
- private val matchedPreference = Preference(context).apply { key = preferenceKey }
-
- private val misMatchedPreference = Preference(context).apply { key = testPreferenceKey }
-
- private val controller = VoiceActivationAppsPreferenceController(context, preferenceKey)
-
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_VOICE_ACTIVATION_APPS_IN_SETTINGS)
- fun getAvailabilityStatus_enableVoiceActivationApps_returnAvailable() {
- assertThat(controller.isAvailable).isTrue()
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_VOICE_ACTIVATION_APPS_IN_SETTINGS)
- fun getAvailableStatus_disableVoiceActivationApps_returnConditionallyUnavailable() {
- assertThat(controller.isAvailable).isFalse()
- }
-
- @Test
- fun handlePreferenceTreeClick_keyMatched_returnTrue() {
- assertThat(controller.handlePreferenceTreeClick(matchedPreference)).isTrue()
- }
-
- @Test
- fun handlePreferenceTreeClick_keyMisMatched_returnFalse() {
- assertThat(controller.handlePreferenceTreeClick(misMatchedPreference)).isFalse()
- }
-
- companion object {
- private const val preferenceKey: String = "voice_activation_apps"
- private const val testPreferenceKey: String = "test_key"
- }
-}
\ No newline at end of file
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsTest.kt
deleted file mode 100644
index a2aa293..0000000
--- a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/VoiceActivationAppsTest.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.android.settings.spa.app.specialaccess
-
-import android.Manifest
-import android.app.AppOpsManager
-import android.content.Context
-import androidx.test.core.app.ApplicationProvider
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.android.settings.R
-import com.google.common.truth.Truth.assertThat
-import org.junit.Test
-import org.junit.runner.RunWith
-
-@RunWith(AndroidJUnit4::class)
-class VoiceActivationAppsTest {
- private val context: Context = ApplicationProvider.getApplicationContext()
-
- private val listModel = VoiceActivationAppsListModel(context)
-
- @Test
- fun modelResourceIdAndProperties() {
- assertThat(listModel.pageTitleResId).isEqualTo(R.string.voice_activation_apps_title)
- assertThat(listModel.switchTitleResId).isEqualTo(R.string.permit_voice_activation_apps)
- assertThat(listModel.footerResId).isEqualTo(R.string.allow_voice_activation_apps_description)
- assertThat(listModel.appOp).isEqualTo(AppOpsManager.OP_RECEIVE_SANDBOX_TRIGGER_AUDIO)
- assertThat(listModel.permission).isEqualTo(
- Manifest.permission.RECEIVE_SANDBOX_TRIGGER_AUDIO
- )
- assertThat(listModel.setModeByUid).isTrue()
- }
-}
\ No newline at end of file
diff --git a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java
deleted file mode 100644
index 88503a5..0000000
--- a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.privatespace;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.junit.Assume.assumeTrue;
-import static org.mockito.Mockito.spy;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.platform.test.flag.junit.SetFlagsRule;
-import android.provider.Settings;
-
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-
-/**
- * Tests for HidePrivateSpaceSensitiveNotificationsController.
- * Run as {@code atest SettingsUnitTests:HidePrivateSpaceSensitiveNotificationsControllerTest}
- */
-@RunWith(AndroidJUnit4.class)
-public class HidePrivateSpaceSensitiveNotificationsControllerTest {
- @Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
- private Context mContext;
- private HidePrivateSpaceSensitiveNotificationsController
- mHidePrivateSpaceSensitiveNotificationsController;
- @Mock
- private ContentResolver mContentResolver;
- private int mOriginalDeviceSensitiveNotifValue;
- private int mOriginalDeviceNotifValue;
- private int mOriginalPsSensitiveNotifValue;
- private int mPrivateProfileId;
-
- @Before
- public void setUp() {
- mContext = spy(ApplicationProvider.getApplicationContext());
- mContentResolver = mContext.getContentResolver();
- assumeTrue(PrivateSpaceMaintainer.getInstance(mContext).doesPrivateSpaceExist());
-
- mSetFlagsRule.enableFlags(
- android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
- mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
-
- mPrivateProfileId = PrivateSpaceMaintainer.getInstance(
- mContext).getPrivateProfileHandle().getIdentifier();
-
- mOriginalDeviceSensitiveNotifValue = Settings.Secure.getInt(mContentResolver,
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1);
- mOriginalDeviceNotifValue = Settings.Secure.getInt(mContentResolver,
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
- mOriginalPsSensitiveNotifValue = Settings.Secure.getIntForUser(mContentResolver,
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mPrivateProfileId);
-
- final String preferenceKey = "private_space_sensitive_notifications";
- mHidePrivateSpaceSensitiveNotificationsController =
- new HidePrivateSpaceSensitiveNotificationsController(mContext, preferenceKey);
- }
-
- @After
- public void tearDown() {
- Settings.Secure.putInt(mContentResolver,
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- mOriginalDeviceSensitiveNotifValue
- );
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, mOriginalDeviceNotifValue);
- Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- mOriginalPsSensitiveNotifValue, mPrivateProfileId);
- }
-
- /**
- * Tests that the controller is unavailable if lockscreen sensitive notifications are disabled
- * on the device.
- */
- @Test
- public void getAvailabilityStatus_lockScreenPrivateNotificationsOff() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.getAvailabilityStatus())
- .isEqualTo(DISABLED_DEPENDENT_SETTING);
- }
-
- /**
- * Tests that the controller is unavailable if lockscreen notifications are disabled on the
- * device.
- */
- @Test
- public void getAvailabilityStatus_lockScreenNotificationsOff() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.getAvailabilityStatus())
- .isEqualTo(DISABLED_DEPENDENT_SETTING);
- }
-
- /**
- * Tests that the controller is available if lockscreen notifications and lockscreen private
- * notifications are enabled on the device.
- */
- @Test
- public void getAvailabilityStatus_returnAvailable() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1);
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.getAvailabilityStatus())
- .isEqualTo(AVAILABLE);
- }
-
-
- /**
- * Tests that toggle is not available if the flag for this feature and MVP flag are disabled.
- */
- @Test
- public void getAvailabilityStatus_flagDisabled() {
- mSetFlagsRule.disableFlags(
- android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
- mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1);
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.getAvailabilityStatus())
- .isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-
- @Test
- public void testSetChecked() {
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.setChecked(true)).isTrue();
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.isChecked()).isEqualTo(true);
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.setChecked(false)).isTrue();
- assertThat(mHidePrivateSpaceSensitiveNotificationsController.isChecked()).isEqualTo(false);
- }
-}
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
index bb1eb22..f75e76f 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
@@ -21,6 +21,7 @@
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_ENTRY_POINT_ENABLED_VAL;
+import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL;
import static com.google.common.truth.Truth.assertThat;
@@ -100,6 +101,7 @@
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
+ privateSpaceMaintainer.deletePrivateSpace();
ErrorDeletingPrivateSpace errorDeletingPrivateSpace =
privateSpaceMaintainer.deletePrivateSpace();
assertThat(errorDeletingPrivateSpace)
@@ -172,7 +174,7 @@
privateSpaceMaintainer.createPrivateSpace();
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isTrue();
assertThat(getPsSensitiveNotificationsValue(privateSpaceMaintainer))
- .isEqualTo(HidePrivateSpaceSensitiveNotificationsController.DISABLED);
+ .isEqualTo(HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL);
}
/**
@@ -196,6 +198,30 @@
.isEqualTo(HIDE_PRIVATE_SPACE_ENTRY_POINT_ENABLED_VAL);
}
+ @Test
+ public void createPrivateSpace_psDoesNotExist_registersTheBroadcastReceiver() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ PrivateSpaceMaintainer privateSpaceMaintainer =
+ PrivateSpaceMaintainer.getInstance(mContext);
+ privateSpaceMaintainer.deletePrivateSpace();
+ privateSpaceMaintainer.createPrivateSpace();
+ // test that no exception is thrown, which would indicate that the receiver was registered.
+ mContext.unregisterReceiver(privateSpaceMaintainer.getBroadcastReceiver());
+ privateSpaceMaintainer.resetBroadcastReceiver();
+ }
+
+ @Test
+ public void deletePrivateSpace_psExists_unregistersTheBroadcastReceiver() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ PrivateSpaceMaintainer privateSpaceMaintainer =
+ PrivateSpaceMaintainer.getInstance(mContext);
+ privateSpaceMaintainer.createPrivateSpace();
+ privateSpaceMaintainer.deletePrivateSpace();
+ assertThat(privateSpaceMaintainer.getBroadcastReceiver()).isNull();
+ }
+
/**
* Tests that {@link PrivateSpaceMaintainer#lockPrivateSpace()} when PS exists and is running
* locks the private profile.
@@ -396,7 +422,7 @@
private int getPsSensitiveNotificationsValue(PrivateSpaceMaintainer privateSpaceMaintainer) {
return Settings.Secure.getIntForUser(mContentResolver,
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
- HidePrivateSpaceSensitiveNotificationsController.ENABLED,
+ /* enabled */ 1,
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
}
}