Merge "[Thread] fix Thread unit test failures" into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2325408..c3c5012 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -231,6 +231,28 @@
</intent-filter>
</receiver>
+ <receiver
+ android:name=".development.Enable16KBootReceiver"
+ android:enabled="true"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
+ <service
+ android:name=".development.PageAgnosticNotificationService"
+ android:enabled="true"
+ android:exported="false"
+ android:permission="android.permission.POST_NOTIFICATIONS"/>
+
+ <activity android:name=".development.PageAgnosticWarningActivity"
+ android:enabled="true"
+ android:launchMode="singleTask"
+ android:taskAffinity=""
+ android:excludeFromRecents="true"
+ android:theme="@*android:style/Theme.DeviceDefault.Dialog.Alert.DayNight"/>
+
<activity android:name=".SubSettings"
android:exported="false"
android:theme="@style/Theme.SubSettings"
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 35b011a..4038f4d 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -577,6 +577,15 @@
if (Utils.isMonkeyRunning()) {
return;
}
+
+ // Disabling developer options in page-agnostic mode isn't supported as device isn't in
+ // production state
+ if (Enable16kUtils.isPageAgnosticModeOn(getContext())) {
+ Enable16kUtils.showPageAgnosticWarning(getContext());
+ onDisableDevelopmentOptionsRejected();
+ return;
+ }
+
DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(getContext(), false);
final SystemPropPoker poker = SystemPropPoker.getInstance();
poker.blockPokes();
diff --git a/src/com/android/settings/development/Enable16KBootReceiver.java b/src/com/android/settings/development/Enable16KBootReceiver.java
new file mode 100644
index 0000000..007a67b
--- /dev/null
+++ b/src/com/android/settings/development/Enable16KBootReceiver.java
@@ -0,0 +1,44 @@
+/*
+ * 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.development;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.UserHandle;
+
+import androidx.annotation.NonNull;
+
+public class Enable16KBootReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(@NonNull Context context, @NonNull Intent intent) {
+ String action = intent.getAction();
+ if (!Intent.ACTION_BOOT_COMPLETED.equals(action)) {
+ return;
+ }
+
+ // Do nothing if device is not in page-agnostic mode
+ if (!Enable16kUtils.isPageAgnosticModeOn(context)) {
+ return;
+ }
+
+ // start a service to post persistent notification
+ Intent startNotificationIntent = new Intent(context, PageAgnosticNotificationService.class);
+ context.startServiceAsUser(startNotificationIntent, UserHandle.SYSTEM);
+ }
+}
diff --git a/src/com/android/settings/development/Enable16KOemUnlockDialog.java b/src/com/android/settings/development/Enable16KOemUnlockDialog.java
index 65690df..8ddded4 100644
--- a/src/com/android/settings/development/Enable16KOemUnlockDialog.java
+++ b/src/com/android/settings/development/Enable16KOemUnlockDialog.java
@@ -16,10 +16,15 @@
package com.android.settings.development;
+import static androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT;
+
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -60,7 +65,10 @@
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.confirm_oem_unlock_for_16k_title)
- .setMessage(R.string.confirm_oem_unlock_for_16k_text)
+ .setMessage(
+ Html.fromHtml(
+ getString(R.string.confirm_oem_unlock_for_16k_text),
+ FROM_HTML_MODE_COMPACT))
.setPositiveButton(android.R.string.ok, this /* onClickListener */)
.create();
}
@@ -74,4 +82,11 @@
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
}
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ ((TextView) getDialog().findViewById(android.R.id.message))
+ .setMovementMethod(LinkMovementMethod.getInstance());
+ }
}
diff --git a/src/com/android/settings/development/Enable16kPagesPreferenceController.java b/src/com/android/settings/development/Enable16kPagesPreferenceController.java
index 7156f0b..23a6a22 100644
--- a/src/com/android/settings/development/Enable16kPagesPreferenceController.java
+++ b/src/com/android/settings/development/Enable16kPagesPreferenceController.java
@@ -23,17 +23,11 @@
import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.RecoverySystem;
-import android.os.SystemProperties;
import android.os.SystemUpdateManager;
import android.os.UpdateEngine;
import android.os.UpdateEngineStable;
import android.os.UpdateEngineStableCallback;
-import android.os.UserHandle;
-import android.os.UserManager;
import android.provider.Settings;
-import android.service.oemlock.OemLockManager;
-import android.system.Os;
-import android.system.OsConstants;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -59,7 +53,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -80,10 +73,6 @@
private static final String TAG = "Enable16kPages";
private static final String REBOOT_REASON = "toggle16k";
private static final String ENABLE_16K_PAGES = "enable_16k_pages";
-
- @VisibleForTesting
- static final String DEV_OPTION_PROPERTY = "ro.product.build.16k_page.enabled";
-
private static final int ENABLE_4K_PAGE_SIZE = 0;
private static final int ENABLE_16K_PAGE_SIZE = 1;
@@ -97,9 +86,6 @@
private static final int OFFSET_TO_FILE_NAME = 30;
public static final String EXPERIMENTAL_UPDATE_TITLE = "Android 16K Kernel Experimental Update";
- private static final long PAGE_SIZE = Os.sysconf(OsConstants._SC_PAGESIZE);
- private static final int PAGE_SIZE_16KB = 16 * 1024;
-
private @NonNull DevelopmentSettingsDashboardFragment mFragment;
private boolean mEnable16k;
@@ -112,12 +98,12 @@
@NonNull Context context, @NonNull DevelopmentSettingsDashboardFragment fragment) {
super(context);
this.mFragment = fragment;
- mEnable16k = (PAGE_SIZE == PAGE_SIZE_16KB);
+ mEnable16k = Enable16kUtils.isUsing16kbPages();
}
@Override
public boolean isAvailable() {
- return SystemProperties.getBoolean(DEV_OPTION_PROPERTY, false);
+ return Enable16kUtils.is16KbToggleAvailable();
}
@Override
@@ -129,12 +115,12 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
mEnable16k = (Boolean) newValue;
// Prompt user to do oem unlock first
- if (!isDeviceOEMUnlocked()) {
+ if (!Enable16kUtils.isDeviceOEMUnlocked(mContext)) {
Enable16KOemUnlockDialog.show(mFragment);
return false;
}
- if (isDataf2fs()) {
+ if (!Enable16kUtils.isDataExt4()) {
EnableExt4WarningDialog.show(mFragment, this);
return false;
}
@@ -145,7 +131,7 @@
@Override
public void updateState(Preference preference) {
int defaultOptionValue =
- PAGE_SIZE == PAGE_SIZE_16KB ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
+ Enable16kUtils.isUsing16kbPages() ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
final int optionValue =
Settings.Global.getInt(
mContext.getContentResolver(),
@@ -169,7 +155,7 @@
@Override
protected void onDeveloperOptionsSwitchEnabled() {
int currentStatus =
- PAGE_SIZE == PAGE_SIZE_16KB ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
+ Enable16kUtils.isUsing16kbPages() ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE;
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.ENABLE_16K_PAGES, currentStatus);
}
@@ -432,51 +418,6 @@
return infoBundle;
}
- private boolean isDataf2fs() {
- try (BufferedReader br = new BufferedReader(new FileReader("/proc/mounts"))) {
- String line;
- while ((line = br.readLine()) != null) {
- final String[] fields = line.split(" ");
- final String partition = fields[1];
- final String fsType = fields[2];
- if (partition.equals("/data") && fsType.equals("f2fs")) {
- return true;
- }
- }
- } catch (IOException e) {
- Log.e(TAG, "Failed to read /proc/mounts");
- displayToast(mContext.getString(R.string.format_ext4_failure_toast));
- }
-
- return false;
- }
-
- private boolean isDeviceOEMUnlocked() {
- // OEM unlock is checked for bootloader, carrier and user. Check all three to ensure
- // that device is unlocked and it is also allowed by user as well as carrier
- final OemLockManager oemLockManager = mContext.getSystemService(OemLockManager.class);
- final UserManager userManager = mContext.getSystemService(UserManager.class);
- if (oemLockManager == null || userManager == null) {
- Log.e(TAG, "Required services not found on device to check for OEM unlock state.");
- return false;
- }
-
- // If either of device or carrier is not allowed to unlock, return false
- if (!oemLockManager.isDeviceOemUnlocked()
- || !oemLockManager.isOemUnlockAllowedByCarrier()) {
- Log.e(TAG, "Device is not OEM unlocked or it is not allowed by carrier");
- return false;
- }
-
- final UserHandle userHandle = UserHandle.of(UserHandle.myUserId());
- if (userManager.hasBaseUserRestriction(UserManager.DISALLOW_FACTORY_RESET, userHandle)) {
- Log.e(TAG, "Factory reset is not allowed for user.");
- return false;
- }
-
- return true;
- }
-
// if BOARD_16K_OTA_MOVE_VENDOR, OTAs will be present on the /vendor partition
private File getOtaFile() throws FileNotFoundException {
String otaPath = mEnable16k ? OTA_16K_PATH : OTA_4K_PATH;
diff --git a/src/com/android/settings/development/Enable16kUtils.java b/src/com/android/settings/development/Enable16kUtils.java
new file mode 100644
index 0000000..00b7ee9
--- /dev/null
+++ b/src/com/android/settings/development/Enable16kUtils.java
@@ -0,0 +1,129 @@
+/*
+ * 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.development;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.SystemProperties;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.service.oemlock.OemLockManager;
+import android.system.Os;
+import android.system.OsConstants;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class Enable16kUtils {
+ private static final long PAGE_SIZE = Os.sysconf(OsConstants._SC_PAGESIZE);
+ private static final int PAGE_SIZE_16KB = 16 * 1024;
+
+ @VisibleForTesting
+ static final String DEV_OPTION_PROPERTY = "ro.product.build.16k_page.enabled";
+
+ private static final String TAG = "Enable16kUtils";
+
+ /**
+ * @param context uses context to retrieve OEM unlock info
+ * @return true if device is OEM unlocked and factory reset is allowed for user.
+ */
+ public static boolean isDeviceOEMUnlocked(@NonNull Context context) {
+ // OEM unlock is checked for bootloader, carrier and user. Check all three to ensure
+ // that device is unlocked and it is also allowed by user as well as carrier
+ final OemLockManager oemLockManager = context.getSystemService(OemLockManager.class);
+ final UserManager userManager = context.getSystemService(UserManager.class);
+ if (oemLockManager == null || userManager == null) {
+ Log.e(TAG, "Required services not found on device to check for OEM unlock state.");
+ return false;
+ }
+
+ // If either of device or carrier is not allowed to unlock, return false
+ if (!oemLockManager.isDeviceOemUnlocked()) {
+ Log.e(TAG, "Device is not OEM unlocked");
+ return false;
+ }
+
+ final UserHandle userHandle = UserHandle.of(UserHandle.myUserId());
+ if (userManager.hasBaseUserRestriction(UserManager.DISALLOW_FACTORY_RESET, userHandle)) {
+ Log.e(TAG, "Factory reset is not allowed for user.");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @return true if /data partition is ext4
+ */
+ public static boolean isDataExt4() {
+ try (BufferedReader br = new BufferedReader(new FileReader("/proc/mounts"))) {
+ String line;
+ while ((line = br.readLine()) != null) {
+ Log.i(TAG, line);
+ final String[] fields = line.split(" ");
+ final String partition = fields[1];
+ final String fsType = fields[2];
+ if (partition.equals("/data") && fsType.equals("ext4")) {
+ return true;
+ }
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to read /proc/mounts");
+ }
+
+ return false;
+ }
+
+ /**
+ * @return returns true if 16KB developer option is available for the device.
+ */
+ public static boolean is16KbToggleAvailable() {
+ return SystemProperties.getBoolean(DEV_OPTION_PROPERTY, false);
+ }
+
+ /**
+ * 16kB page-agnostic mode requires /data to be ext4, ro.product.build.16k_page.enabled for
+ * device and Device OEM unlocked.
+ *
+ * @param context is needed to query OEM unlock state
+ * @return true if device is in page-agnostic mode.
+ */
+ public static boolean isPageAgnosticModeOn(@NonNull Context context) {
+ return is16KbToggleAvailable() && isDeviceOEMUnlocked(context) && isDataExt4();
+ }
+
+ /**
+ * @return returns true if current page size is 16KB
+ */
+ public static boolean isUsing16kbPages() {
+ return PAGE_SIZE == PAGE_SIZE_16KB;
+ }
+
+ /**
+ * show page-agnostic mode warning dialog to user
+ * @param context to start activity
+ */
+ public static void showPageAgnosticWarning(@NonNull Context context) {
+ Intent intent = new Intent(context, PageAgnosticWarningActivity.class);
+ context.startActivityAsUser(intent, UserHandle.SYSTEM);
+ }
+}
diff --git a/src/com/android/settings/development/PageAgnosticNotificationService.java b/src/com/android/settings/development/PageAgnosticNotificationService.java
new file mode 100644
index 0000000..bce1dd9
--- /dev/null
+++ b/src/com/android/settings/development/PageAgnosticNotificationService.java
@@ -0,0 +1,139 @@
+/*
+ * 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.development;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.settings.R;
+
+public class PageAgnosticNotificationService extends Service {
+
+ private static final String NOTIFICATION_CHANNEL_ID =
+ "com.android.settings.development.PageAgnosticNotificationService";
+ private static final int NOTIFICATION_ID = 1;
+
+ static final int DISABLE_UPDATES_SETTING = 1;
+
+ private NotificationManager mNotificationManager;
+
+ @Nullable
+ @Override
+ public IBinder onBind(@NonNull Intent intent) {
+ return null;
+ }
+
+ // create a notification channel to post persistent notification
+ private void createNotificationChannel() {
+ NotificationChannel channel =
+ new NotificationChannel(
+ NOTIFICATION_CHANNEL_ID,
+ getString(R.string.page_agnostic_notification_channel_name),
+ NotificationManager.IMPORTANCE_HIGH);
+ mNotificationManager = getSystemService(NotificationManager.class);
+ if (mNotificationManager != null) {
+ mNotificationManager.createNotificationChannel(channel);
+ }
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ createNotificationChannel();
+ }
+
+ private Notification buildNotification() {
+ // Get the title and text according to page size
+ boolean isIn16kbMode = Enable16kUtils.isUsing16kbPages();
+ String title =
+ isIn16kbMode
+ ? getString(R.string.page_agnostic_16k_pages_title)
+ : getString(R.string.page_agnostic_4k_pages_title);
+ String text =
+ isIn16kbMode
+ ? getString(R.string.page_agnostic_16k_pages_text_short)
+ : getString(R.string.page_agnostic_4k_pages_text_short);
+
+ Intent notifyIntent = new Intent(this, PageAgnosticWarningActivity.class);
+ // Set the Activity to start in a new, empty task.
+ notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+
+ // Create the PendingIntent.
+ PendingIntent notifyPendingIntent =
+ PendingIntent.getActivity(
+ this,
+ 0,
+ notifyIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
+
+ Notification.Action action =
+ new Notification.Action.Builder(
+ R.drawable.empty_icon,
+ getString(R.string.page_agnostic_notification_action),
+ notifyPendingIntent)
+ .build();
+
+ Notification.Builder builder =
+ new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
+ .setContentTitle(title)
+ .setContentText(text)
+ .setOngoing(true)
+ .setSmallIcon(R.drawable.ic_settings_24dp)
+ .setStyle(new Notification.BigTextStyle().bigText(text))
+ .setContentIntent(notifyPendingIntent)
+ .addAction(action);
+
+ return builder.build();
+ }
+
+ private void disableAutomaticUpdates() {
+ final int currentState =
+ Settings.Global.getInt(
+ getApplicationContext().getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ 0 /* default */);
+ // 0 means enabled, 1 means disabled
+ if (currentState == 0) {
+ // automatic updates are enabled, disable them
+ Settings.Global.putInt(
+ getApplicationContext().getContentResolver(),
+ Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
+ DISABLE_UPDATES_SETTING);
+ }
+ }
+
+ @Override
+ public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
+ Notification notification = buildNotification();
+ if (mNotificationManager != null) {
+ mNotificationManager.notify(NOTIFICATION_ID, notification);
+ }
+
+ // No updates should be allowed in page-agnostic mode
+ disableAutomaticUpdates();
+ return Service.START_NOT_STICKY;
+ }
+}
diff --git a/src/com/android/settings/development/PageAgnosticWarningActivity.java b/src/com/android/settings/development/PageAgnosticWarningActivity.java
new file mode 100644
index 0000000..8fd6074
--- /dev/null
+++ b/src/com/android/settings/development/PageAgnosticWarningActivity.java
@@ -0,0 +1,72 @@
+/*
+ * 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.development;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+
+import com.android.settings.R;
+
+public class PageAgnosticWarningActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+
+ String title =
+ Enable16kUtils.isUsing16kbPages()
+ ? getString(R.string.page_agnostic_16k_pages_title)
+ : getString(R.string.page_agnostic_4k_pages_title);
+
+ String warningText =
+ Enable16kUtils.isUsing16kbPages()
+ ? getString(R.string.page_agnostic_16k_pages_text)
+ : getString(R.string.page_agnostic_4k_pages_text);
+ showWarningDialog(title, warningText);
+ }
+
+ // Create warning dialog and make links clickable
+ private void showWarningDialog(String title, String warningText) {
+
+ AlertDialog dialog =
+ new AlertDialog.Builder(this)
+ .setTitle(title)
+ .setMessage(Html.fromHtml(warningText, Html.FROM_HTML_MODE_COMPACT))
+ .setCancelable(false)
+ .setPositiveButton(
+ android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(
+ @NonNull DialogInterface dialog, int which) {
+ dialog.cancel();
+ finish();
+ }
+ })
+ .create();
+ dialog.show();
+
+ ((TextView) dialog.findViewById(android.R.id.message))
+ .setMovementMethod(LinkMovementMethod.getInstance());
+ }
+}
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index 7bc61a4..324b4b7 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -91,7 +91,6 @@
private AirplaneModeObserver mAirplaneModeObserver;
private DataRoamingObserver mDataRoamingObserver;
private MetricsFeatureProvider mMetricsFeatureProvider;
- private Map<Integer, MobileDataContentObserver> mDataContentObserverMap = new HashMap<>();
private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
private int mCardState = UiccSlotInfo.CARD_STATE_INFO_ABSENT;
@@ -209,6 +208,9 @@
*/
public void addRegister(LifecycleOwner lifecycleOwner,
MobileNetworkCallback mobileNetworkCallback, int subId) {
+ if (DEBUG) {
+ Log.d(TAG, "addRegister by SUB ID " + subId);
+ }
if (sCallbacks.isEmpty()) {
mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(),
this);
@@ -222,7 +224,6 @@
observeAllUiccInfo(lifecycleOwner);
observeAllMobileNetworkInfo(lifecycleOwner);
if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- addRegisterBySubId(subId);
createTelephonyManagerBySubId(subId);
mDataRoamingObserver.register(mContext, subId);
}
@@ -231,19 +232,6 @@
sendAvailableSubInfoCache(mobileNetworkCallback);
}
- public void addRegisterBySubId(int subId) {
- MobileDataContentObserver dataContentObserver = new MobileDataContentObserver(
- new Handler(Looper.getMainLooper()));
- dataContentObserver.setOnMobileDataChangedListener(() -> {
- sExecutor.execute(() -> {
- insertMobileNetworkInfo(mContext, subId,
- getTelephonyManagerBySubId(mContext, subId));
- });
- });
- dataContentObserver.register(mContext, subId);
- mDataContentObserverMap.put(subId, dataContentObserver);
- }
-
private void createTelephonyManagerBySubId(int subId) {
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
|| mTelephonyCallbackMap.containsKey(subId)) {
@@ -253,7 +241,7 @@
return;
}
PhoneCallStateTelephonyCallback
- telephonyCallback = new PhoneCallStateTelephonyCallback();
+ telephonyCallback = new PhoneCallStateTelephonyCallback(subId);
TelephonyManager telephonyManager = mContext.getSystemService(
TelephonyManager.class).createForSubscriptionId(subId);
telephonyManager.registerTelephonyCallback(mContext.getMainExecutor(),
@@ -292,10 +280,6 @@
}
}
}
- if (mDataContentObserverMap.containsKey(subId)) {
- mDataContentObserverMap.get(subId).unRegister(mContext);
- mDataContentObserverMap.remove(subId);
- }
}
public void removeRegister(MobileNetworkCallback mobileNetworkCallback) {
@@ -304,10 +288,6 @@
mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
mAirplaneModeObserver.unRegister(mContext);
mDataRoamingObserver.unRegister(mContext);
- mDataContentObserverMap.forEach((id, observer) -> {
- observer.unRegister(mContext);
- });
- mDataContentObserverMap.clear();
mTelephonyManagerMap.forEach((id, manager) -> {
TelephonyCallback callback = mTelephonyCallbackMap.get(id);
@@ -768,7 +748,14 @@
}
private class PhoneCallStateTelephonyCallback extends TelephonyCallback implements
- TelephonyCallback.CallStateListener {
+ TelephonyCallback.CallStateListener,
+ TelephonyCallback.UserMobileDataStateListener {
+
+ private int mSubId;
+
+ public PhoneCallStateTelephonyCallback(int subId) {
+ mSubId = subId;
+ }
@Override
public void onCallStateChanged(int state) {
@@ -776,6 +763,15 @@
callback.onCallStateChanged(state);
}
}
+
+ @Override
+ public void onUserMobileDataStateChanged(boolean enabled) {
+ Log.d(TAG, "onUserMobileDataStateChanged enabled " + enabled + " on SUB " + mSubId);
+ sExecutor.execute(() -> {
+ insertMobileNetworkInfo(mContext, mSubId,
+ getTelephonyManagerBySubId(mContext, mSubId));
+ });
+ }
}
/**
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index 8426382..84cd874 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -96,9 +96,6 @@
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mMobileNetworkRepository.updateEntity();
- // Can not get default subId from database until get the callback, add register by subId
- // later.
- mMobileNetworkRepository.addRegisterBySubId(getDefaultSubscriptionId());
mDataSubscriptionChangedReceiver.registerReceiver();
}
diff --git a/src/com/android/settings/security/CredentialStorage.java b/src/com/android/settings/security/CredentialStorage.java
index ea33631..1d8a721 100644
--- a/src/com/android/settings/security/CredentialStorage.java
+++ b/src/com/android/settings/security/CredentialStorage.java
@@ -34,7 +34,7 @@
import android.security.IKeyChainService;
import android.security.KeyChain;
import android.security.KeyChain.KeyChainConnection;
-import android.security.KeyStore;
+import android.security.keystore.KeyProperties;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -126,9 +126,9 @@
final Bundle bundle = mInstallBundle;
mInstallBundle = null;
- final int uid = bundle.getInt(Credentials.EXTRA_INSTALL_AS_UID, KeyStore.UID_SELF);
+ final int uid = bundle.getInt(Credentials.EXTRA_INSTALL_AS_UID, KeyProperties.UID_SELF);
- if (uid != KeyStore.UID_SELF && !UserHandle.isSameUser(uid, Process.myUid())) {
+ if (uid != KeyProperties.UID_SELF && !UserHandle.isSameUser(uid, Process.myUid())) {
final int dstUserId = UserHandle.getUserId(uid);
// Restrict install target to the wifi uid.
@@ -279,7 +279,7 @@
// If this is not a WiFi key, mark it as user-selectable, so that it can be
// selected by users from the Certificate Selection prompt.
- if (mUid == Process.SYSTEM_UID || mUid == KeyStore.UID_SELF) {
+ if (mUid == Process.SYSTEM_UID || mUid == KeyProperties.UID_SELF) {
service.setUserSelectable(mAlias, true);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningAppearancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningAppearancePreferenceControllerTest.java
index 74fb440..b9de66d 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningAppearancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningAppearancePreferenceControllerTest.java
@@ -17,8 +17,10 @@
package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
+import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
+import android.os.Looper;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;
@@ -68,7 +70,9 @@
@Test
public void getSummary_smallestScale_shouldReturnExpectedSummary() {
- mShadowCaptioningManager.setFontScale(0.25f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.25f);
+ shadowOf(Looper.getMainLooper()).idle();
final String expectedSummary =
getSummaryCombo(/* fontScaleIndex= */ 0, DEFAULT_PRESET_INDEX);
@@ -77,7 +81,9 @@
@Test
public void getSummary_smallScale_shouldReturnExpectedSummary() {
- mShadowCaptioningManager.setFontScale(0.5f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.5f);
+ shadowOf(Looper.getMainLooper()).idle();
final String expectedSummary =
getSummaryCombo(/* fontScaleIndex= */ 1, DEFAULT_PRESET_INDEX);
@@ -86,7 +92,9 @@
@Test
public void getSummary_mediumScale_shouldReturnExpectedSummary() {
- mShadowCaptioningManager.setFontScale(1.0f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 1.0f);
+ shadowOf(Looper.getMainLooper()).idle();
final String expectedSummary =
getSummaryCombo(/* fontScaleIndex= */ 2, DEFAULT_PRESET_INDEX);
@@ -95,7 +103,9 @@
@Test
public void getSummary_largeScale_shouldReturnExpectedSummary() {
- mShadowCaptioningManager.setFontScale(1.5f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 1.5f);
+ shadowOf(Looper.getMainLooper()).idle();
final String expectedSummary =
getSummaryCombo(/* fontScaleIndex= */ 3, DEFAULT_PRESET_INDEX);
@@ -104,7 +114,9 @@
@Test
public void getSummary_largestScale_shouldReturnExpectedSummary() {
- mShadowCaptioningManager.setFontScale(2.0f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 2.0f);
+ shadowOf(Looper.getMainLooper()).idle();
final String expectedSummary =
getSummaryCombo(/* fontScaleIndex= */ 4, DEFAULT_PRESET_INDEX);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundColorControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundColorControllerTest.java
index 0ea7a41..e847f43 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundColorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundColorControllerTest.java
@@ -127,7 +127,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0xFFFF0000);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundOpacityControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundOpacityControllerTest.java
index 56a61ec..5036ba0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundOpacityControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningBackgroundOpacityControllerTest.java
@@ -103,7 +103,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0x80FFFFFF);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeColorControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeColorControllerTest.java
index f1a8566..c55e087 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeColorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeColorControllerTest.java
@@ -101,7 +101,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0xFFFF0000);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeTypeControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeTypeControllerTest.java
index 11871f8..354115f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeTypeControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningEdgeTypeControllerTest.java
@@ -103,7 +103,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, CaptionStyle.EDGE_TYPE_OUTLINE);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java
index 8aeb37e..b00d8d8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningFontSizeControllerTest.java
@@ -23,7 +23,10 @@
import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
+
import android.content.Context;
+import android.os.Looper;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;
@@ -85,7 +88,9 @@
@Test
public void updateState_bySmallValue_shouldReturnSmall() {
- mShadowCaptioningManager.setFontScale(0.5f);
+ Settings.Secure.putFloat(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE, 0.5f);
+ shadowOf(Looper.getMainLooper()).idle();
mController.updateState(mPreference);
@@ -94,7 +99,8 @@
@Test
public void onPreferenceChange_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onPreferenceChange(mPreference, "0.5");
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundColorControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundColorControllerTest.java
index 8991bad..9e9c926 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundColorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundColorControllerTest.java
@@ -127,7 +127,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0xFFFF0000);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundOpacityControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundOpacityControllerTest.java
index 1ffff60..a88b5f5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundOpacityControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningForegroundOpacityControllerTest.java
@@ -103,7 +103,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0x80FFFFFF);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningPresetControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningPresetControllerTest.java
index c91baa2..1614c8f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningPresetControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningPresetControllerTest.java
@@ -103,7 +103,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, CaptionStyle.PRESET_CUSTOM);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningTogglePreferenceControllerTest.java
index e0a04bc..7523db6 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningTogglePreferenceControllerTest.java
@@ -82,7 +82,8 @@
@Test
public void displayPreference_captionEnabled_shouldSetChecked() {
- mShadowCaptioningManager.setEnabled(true);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
mController.displayPreference(mScreen);
@@ -91,7 +92,8 @@
@Test
public void displayPreference_captionDisabled_shouldSetUnchecked() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
@@ -100,7 +102,8 @@
@Test
public void performClick_captionEnabled_shouldSetCaptionDisabled() {
- mShadowCaptioningManager.setEnabled(true);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, ON);
mController.displayPreference(mScreen);
mSwitchPreference.performClick();
@@ -111,7 +114,8 @@
@Test
public void performClick_captionDisabled_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mSwitchPreference.performClick();
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningTypefaceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningTypefaceControllerTest.java
index 4d33fb3..aa7d3eb 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningTypefaceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningTypefaceControllerTest.java
@@ -95,7 +95,8 @@
@Test
public void onPreferenceChange_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onPreferenceChange(mPreference, "serif");
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowColorControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowColorControllerTest.java
index f916778..1258214 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowColorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowColorControllerTest.java
@@ -128,7 +128,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0xFFFF0000);
diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowOpacityControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowOpacityControllerTest.java
index 99eb1e5..0e872a0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowOpacityControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/CaptioningWindowOpacityControllerTest.java
@@ -102,7 +102,8 @@
@Test
public void onValueChanged_shouldSetCaptionEnabled() {
- mShadowCaptioningManager.setEnabled(false);
+ Settings.Secure.putInt(
+ mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, OFF);
mController.displayPreference(mScreen);
mController.onValueChanged(mPreference, 0x80FFFFFF);
diff --git a/tests/robotests/src/com/android/settings/development/Enable16kPagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/Enable16kPagesPreferenceControllerTest.java
index 0c9906c..e27e3a2 100644
--- a/tests/robotests/src/com/android/settings/development/Enable16kPagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/Enable16kPagesPreferenceControllerTest.java
@@ -62,13 +62,13 @@
@Test
public void onSystemPropertyDisabled_shouldDisablePreference() {
- SystemProperties.set(Enable16kPagesPreferenceController.DEV_OPTION_PROPERTY, "false");
+ SystemProperties.set(Enable16kUtils.DEV_OPTION_PROPERTY, "false");
assertThat(mController.isAvailable()).isEqualTo(false);
}
@Test
public void onSystemPropertyEnabled_shouldEnablePreference() {
- SystemProperties.set(Enable16kPagesPreferenceController.DEV_OPTION_PROPERTY, "true");
+ SystemProperties.set(Enable16kUtils.DEV_OPTION_PROPERTY, "true");
assertThat(mController.isAvailable()).isEqualTo(true);
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyStore.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyStore.java
deleted file mode 100644
index 99eca0a..0000000
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyStore.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2017 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.testutils.shadow;
-
-import android.security.KeyStore;
-
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.annotation.Resetter;
-
-@Implements(KeyStore.class)
-public class ShadowKeyStore {
-
- private static boolean sIsHardwareBacked;
-
- @Resetter
- public static void reset() {
- sIsHardwareBacked = false;
- }
-
- @Implementation
- protected boolean isHardwareBacked() {
- return sIsHardwareBacked;
- }
-
- public static void setHardwareBacked(boolean hardwareBacked) {
- sIsHardwareBacked = hardwareBacked;
- }
-}
diff --git a/tests/spa_unit/AndroidManifest.xml b/tests/spa_unit/AndroidManifest.xml
index 5a7f565..e3bc5ad 100644
--- a/tests/spa_unit/AndroidManifest.xml
+++ b/tests/spa_unit/AndroidManifest.xml
@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.MANAGE_APPOPS" />
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
<uses-permission android:name="android.permission.WRITE_DEVICE_CONFIG" />
+ <uses-permission android:name="com.android.settings.BATTERY_DATA" />
<application android:debuggable="true">
<provider android:name="com.android.settings.slices.SettingsSliceProvider"