Merge "Merge Android 12 QPR1"
diff --git a/res/values-v31/strings.xml b/res/values-v31/strings.xml
new file mode 100644
index 0000000..e9c33eb
--- /dev/null
+++ b/res/values-v31/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Name of a font family to use for headlines in SettingsLib. This overrides the default value which points to a private resource. Setting it to an empty value allows it to fallback to the default on the device. -->
+ <string name="settingslib_config_headlineFontFamily" translatable="false"></string>
+</resources>
diff --git a/res/xml/watch_preferences.xml b/res/xml/watch_preferences.xml
index 7296cae..6c8e4ab 100644
--- a/res/xml/watch_preferences.xml
+++ b/res/xml/watch_preferences.xml
@@ -60,9 +60,6 @@
android:defaultValue="@string/alert_reminder_interval_in_min_default"
android:dialogTitle="@string/alert_reminder_interval_title" />
- <SwitchPreference android:key="watch_alert_reminder"
- android:title="@string/alert_reminder_interval_title" />
-
<SwitchPreference android:defaultValue="true"
android:key="enable_alert_vibrate"
android:title="@string/enable_alert_vibrate_title" />
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
index c8eb500..7b15c2d 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastSettings.java
@@ -45,7 +45,6 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragment;
import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
import com.android.internal.annotations.VisibleForTesting;
@@ -149,9 +148,6 @@
// Preference key for emergency alerts history
public static final String KEY_EMERGENCY_ALERT_HISTORY = "emergency_alert_history";
- // For watch layout
- private static final String KEY_WATCH_ALERT_REMINDER = "watch_alert_reminder";
-
// Whether to receive alert in second language code
public static final String KEY_RECEIVE_CMAS_IN_SECOND_LANGUAGE =
"receive_cmas_in_second_language";
@@ -177,9 +173,6 @@
// Key for shared preference which represents whether user has changed any preference
private static final String ANY_PREFERENCE_CHANGED_BY_USER = "any_preference_changed_by_user";
- // Test override for disabling the subId specific resources
- private static boolean sUseResourcesForSubId = true;
-
@Override
public void onCreate(Bundle savedInstanceState) {
// for backward compatibility on R devices
@@ -264,12 +257,9 @@
Log.d(TAG, "In not test harness mode. reset main toggle.");
e.remove(KEY_ENABLE_ALERTS_MASTER_TOGGLE);
}
- PackageManager pm = c.getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
- e.remove(KEY_WATCH_ALERT_REMINDER);
- }
e.commit();
+ PackageManager pm = c.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
PreferenceManager.setDefaultValues(c, R.xml.watch_preferences, true);
} else {
@@ -320,9 +310,6 @@
private PreferenceCategory mAlertPreferencesCategory;
private boolean mDisableSevereWhenExtremeDisabled = true;
- // WATCH
- private TwoStatePreference mAlertReminder;
-
// Show checkbox for Presidential alerts in settings
private TwoStatePreference mPresidentialCheckBox;
@@ -381,27 +368,7 @@
findPreference(KEY_ENABLE_CMAS_PRESIDENTIAL_ALERTS);
PackageManager pm = getActivity().getPackageManager();
- if (pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
- mAlertReminder = (TwoStatePreference)
- findPreference(KEY_WATCH_ALERT_REMINDER);
- if (Integer.valueOf(mReminderInterval.getValue()) == 0) {
- mAlertReminder.setChecked(false);
- } else {
- mAlertReminder.setChecked(true);
- }
- mAlertReminder.setOnPreferenceChangeListener((p, newVal) -> {
- try {
- mReminderInterval.setValueIndex((Boolean) newVal ? 1 : 3);
- } catch (IndexOutOfBoundsException e) {
- mReminderInterval.setValue(String.valueOf(0));
- Log.w(TAG, "Setting default value");
- }
- return true;
- });
- PreferenceScreen watchScreen = (PreferenceScreen)
- findPreference(KEY_CATEGORY_ALERT_PREFERENCES);
- watchScreen.removePreference(mReminderInterval);
- } else {
+ if (!pm.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
mAlertPreferencesCategory = (PreferenceCategory)
findPreference(KEY_CATEGORY_ALERT_PREFERENCES);
mAlertCategory = (PreferenceCategory)
@@ -845,16 +812,6 @@
}
/**
- * Override used by tests so that we don't call
- * SubscriptionManager.getResourcesForSubId, which is a static unmockable
- * method.
- */
- @VisibleForTesting
- public static void setUseResourcesForSubId(boolean useResourcesForSubId) {
- sUseResourcesForSubId = useResourcesForSubId;
- }
-
- /**
* Get the device resource based on SIM
*
* @param context Context
@@ -863,14 +820,12 @@
* @return The resource
*/
public static @NonNull Resources getResources(@NonNull Context context, int subId) {
- // based on the latest design, subId can be valid earlier than mcc mnc is known to telephony
- // check if sim is loaded to avoid caching the wrong resources.
- TelephonyManager tm = context.getSystemService(TelephonyManager.class);
- boolean isSimLoaded = tm.getSimApplicationState(SubscriptionManager.getSlotIndex(subId))
- == TelephonyManager.SIM_STATE_LOADED;
if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID
- || !SubscriptionManager.isValidSubscriptionId(subId) || !sUseResourcesForSubId
- || !isSimLoaded) {
+ || !SubscriptionManager.isValidSubscriptionId(subId)
+ // based on the latest design, subId can be valid earlier than mcc mnc is known to
+ // telephony. check if sim is loaded to avoid caching the wrong resources.
+ || context.getSystemService(TelephonyManager.class).getSimApplicationState(
+ SubscriptionManager.getSlotIndex(subId)) != TelephonyManager.SIM_STATE_LOADED) {
return context.getResources();
}
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertDialogTest.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertDialogTest.java
index a30c9c4..9168d5b 100644
--- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertDialogTest.java
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastAlertDialogTest.java
@@ -35,6 +35,7 @@
import android.os.Message;
import android.os.PowerManager;
import android.telephony.SmsCbMessage;
+import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -68,6 +69,9 @@
@Mock
private IThermalService.Stub mMockedThermalService;
+ @Mock
+ TelephonyManager mTelephonyManager;
+
@Captor
private ArgumentCaptor<Integer> mInt;
@@ -111,7 +115,9 @@
mPowerManager = new PowerManager(mContext, mMockedPowerManagerService,
mMockedThermalService, null);
injectSystemService(PowerManager.class, mPowerManager);
- CellBroadcastSettings.setUseResourcesForSubId(false);
+ doReturn(TelephonyManager.SIM_STATE_UNKNOWN).when(mTelephonyManager)
+ .getSimApplicationState(anyInt());
+ injectSystemService(TelephonyManager.class, mTelephonyManager);
}
@After
diff --git a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastServiceTestCase.java b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastServiceTestCase.java
index 7609829..66ae7b1 100644
--- a/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastServiceTestCase.java
+++ b/tests/unit/src/com/android/cellbroadcastreceiver/unit/CellBroadcastServiceTestCase.java
@@ -165,13 +165,14 @@
doReturn(mMockedTelephonyManager).when(mMockedTelephonyManager)
.createForSubscriptionId(anyInt());
+ doReturn(TelephonyManager.SIM_STATE_UNKNOWN).when(mMockedTelephonyManager)
+ .getSimApplicationState(anyInt());
mMockedServiceManager = new MockedServiceManager();
mMockedServiceManager.replaceService("isub", mSubService);
mContext = new TestContextWrapper(getContext());
setContext(mContext);
- CellBroadcastSettings.setUseResourcesForSubId(false);
}
@After