Merge "p2p: Close the channel when onStop is called." into tm-dev
diff --git a/res/color/dream_card_icon_color_state_list.xml b/res/color/dream_card_icon_color_state_list.xml
new file mode 100644
index 0000000..c2e32cb
--- /dev/null
+++ b/res/color/dream_card_icon_color_state_list.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <item android:state_selected="true" android:color="?androidprv:attr/textColorOnAccent"/>
+ <item android:color="?androidprv:attr/colorAccentPrimaryVariant"/>
+</selector>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d16a63e..d845dfd 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2919,6 +2919,8 @@
<string name="screen_resolution_summary_high">1080p FHD+</string>
<!-- Display settings screen, "QHD+" screen resolution summary [CHAR LIMIT=NONE] -->
<string name="screen_resolution_summary_highest">1440p QHD+</string>
+ <!-- The footer message for switch screen resolution [CHAR LIMIT=NONE] -->
+ <string name="screen_resolution_footer">Switching your resolution might cause some apps currently running to close.</string>
<!-- Display settings screen, Color mode settings title [CHAR LIMIT=30] -->
<string name="color_mode_title">Colors</string>
@@ -12315,6 +12317,14 @@
<!-- Location setting: preference summary - describes the behavior of forcing full raw GNSS satellite measurements [CHAR LIMIT=NONE] -->
<string name="enable_gnss_raw_meas_full_tracking_summary">Track all GNSS constellations and frequencies with no duty cycling</string>
+ <!-- Developer options Input method category strings -->
+ <!-- Title for input method category [CHAR LIMIT=30]-->
+ <string name="input_method_category">Input Method</string>
+ <!-- [CHAR LIMIT=30] Title for Stylus handwriting settings -->
+ <string name="stylus_handwriting">Stylus handwriting</string>
+ <!-- [CHAR LIMIT=130] Summary for Stylus handwriting toggle -->
+ <string name="stylus_handwriting_summary">When enabled, current Input method receives stylus MotionEvent if an Editor is focused.</string>
+
<!-- Name of setting for switching device theme [CHAR LIMIT=60] -->
<string name="device_theme">Device theme</string>
<!-- Name of default device theme [CHAR LIMIT=60] -->
diff --git a/res/xml/accessibility_color_and_motion.xml b/res/xml/accessibility_color_and_motion.xml
index 86b6564..af18dbe 100644
--- a/res/xml/accessibility_color_and_motion.xml
+++ b/res/xml/accessibility_color_and_motion.xml
@@ -39,6 +39,16 @@
settings:keywords="@string/keywords_color_inversion"
settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
+ <com.android.settings.display.darkmode.DarkModePreference
+ android:key="dark_ui_mode_accessibility"
+ android:icon="@drawable/ic_dark_ui"
+ android:title="@string/dark_ui_mode"
+ android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
+ android:widgetLayout="@null"
+ settings:widgetLayout="@null"
+ settings:controller="com.android.settings.display.DarkUIPreferenceController"
+ settings:searchable="false"/>
+
<SwitchPreference
android:key="toggle_disable_animations"
android:persistent="false"
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 22226a1..2e253e2 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -60,16 +60,6 @@
settings:keywords="@string/keywords_reduce_bright_colors"
settings:controller="com.android.settings.accessibility.ReduceBrightColorsPreferenceController"/>
- <com.android.settings.display.darkmode.DarkModePreference
- android:key="dark_ui_mode_accessibility"
- android:icon="@drawable/ic_dark_ui"
- android:title="@string/dark_ui_mode"
- android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
- android:widgetLayout="@null"
- settings:widgetLayout="@null"
- settings:controller="com.android.settings.display.DarkUIPreferenceController"
- settings:searchable="false"/>
-
<Preference
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
android:key="magnification_preference_screen"
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index f29930c..cbf7704 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -648,7 +648,7 @@
android:title="@string/reset_shortcut_manager_throttling" />
</PreferenceCategory>
- <com.android.settings.development.autofill.AutofillPreferenceCategory
+ <PreferenceCategory
android:key="debug_autofill_category"
android:title="@string/debug_autofill_category"
settings:searchable="false"
@@ -672,7 +672,7 @@
android:key="autofill_reset_developer_options"
android:title="@string/autofill_reset_developer_options" />
- </com.android.settings.development.autofill.AutofillPreferenceCategory>
+ </PreferenceCategory>
<PreferenceCategory
android:key="storage_category"
@@ -709,4 +709,15 @@
android:key="location_indicator_settings"
settings:controller="com.android.settings.location.LocationIndicatorsPreferenceController"/>
</PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="input_method_category"
+ android:title="@string/input_method_category"
+ android:order="1400">
+
+ <SwitchPreference
+ android:key="stylus_handwriting"
+ android:title="@string/stylus_handwriting"
+ android:summary="@string/stylus_handwriting_summary" />
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index ae24168..da21729 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -34,8 +34,6 @@
import android.hardware.usb.UsbManager;
import android.net.ConnectivityManager;
import android.net.EthernetManager;
-import android.net.EthernetManager.InterfaceState;
-import android.net.EthernetManager.Role;
import android.net.IpConfiguration;
import android.net.TetheringManager;
import android.net.wifi.WifiManager;
@@ -650,8 +648,8 @@
}
private final class EthernetListener implements EthernetManager.InterfaceStateListener {
- public void onInterfaceStateChanged(@NonNull String iface, @InterfaceState int state,
- @Role int role, @NonNull IpConfiguration configuration) {
+ public void onInterfaceStateChanged(@NonNull String iface, int state, int role,
+ @NonNull IpConfiguration configuration) {
if (state == EthernetManager.STATE_LINK_UP) {
mAvailableInterfaces.add(iface);
} else {
diff --git a/src/com/android/settings/dashboard/ControllerFutureTask.java b/src/com/android/settings/dashboard/ControllerFutureTask.java
deleted file mode 100644
index 84d11fd..0000000
--- a/src/com/android/settings/dashboard/ControllerFutureTask.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.dashboard;
-
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import java.util.concurrent.FutureTask;
-
-/**
- * {@link FutureTask} of the Controller.
- */
-public class ControllerFutureTask extends FutureTask<Void> {
- private final AbstractPreferenceController mController;
-
- public ControllerFutureTask(ControllerTask task, Void result) {
- super(task, result);
- mController = task.getController();
- }
-
- AbstractPreferenceController getController() {
- return mController;
- }
-}
diff --git a/src/com/android/settings/dashboard/ControllerTask.java b/src/com/android/settings/dashboard/ControllerTask.java
deleted file mode 100644
index c62e738..0000000
--- a/src/com/android/settings/dashboard/ControllerTask.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.dashboard;
-
-import android.app.settings.SettingsEnums;
-import android.os.SystemClock;
-import android.text.TextUtils;
-import android.util.Log;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import com.android.settingslib.utils.ThreadUtils;
-
-/**
- * A {@link Runnable} controller task. This task handle the visibility of the controller in the
- * background. Also handle the state updating in the main thread.
- */
-public class ControllerTask implements Runnable {
- private static final String TAG = "ControllerTask";
- private static final int CONTROLLER_UPDATESTATE_TIME_THRESHOLD = 50;
-
- private final AbstractPreferenceController mController;
- private final PreferenceScreen mScreen;
- private final int mMetricsCategory;
- private final MetricsFeatureProvider mMetricsFeature;
-
- public ControllerTask(AbstractPreferenceController controller, PreferenceScreen screen,
- MetricsFeatureProvider metricsFeature, int metricsCategory) {
- mController = controller;
- mScreen = screen;
- mMetricsFeature = metricsFeature;
- mMetricsCategory = metricsCategory;
- }
-
- @Override
- public void run() {
- if (!mController.isAvailable()) {
- return;
- }
-
- final String key = mController.getPreferenceKey();
- if (TextUtils.isEmpty(key)) {
- Log.d(TAG, String.format("Preference key is %s in Controller %s",
- key, mController.getClass().getSimpleName()));
- return;
- }
-
- final Preference preference = mScreen.findPreference(key);
- if (preference == null) {
- Log.d(TAG, String.format("Cannot find preference with key %s in Controller %s",
- key, mController.getClass().getSimpleName()));
- return;
- }
- ThreadUtils.postOnMainThread(() -> {
- final long t = SystemClock.elapsedRealtime();
- mController.updateState(preference);
- final int elapsedTime = (int) (SystemClock.elapsedRealtime() - t);
- if (elapsedTime > CONTROLLER_UPDATESTATE_TIME_THRESHOLD) {
- Log.w(TAG, "The updateState took " + elapsedTime + " ms in Controller "
- + mController.getClass().getSimpleName());
- if (mMetricsFeature != null) {
- mMetricsFeature.action(SettingsEnums.PAGE_UNKNOWN,
- SettingsEnums.ACTION_CONTROLLER_UPDATE_STATE, mMetricsCategory,
- mController.getClass().getSimpleName(), elapsedTime);
- }
- }
- });
- }
-
- AbstractPreferenceController getController() {
- return mController;
- }
-}
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 8b1d633..26fe1b1 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -48,7 +48,6 @@
import com.android.settingslib.drawer.ProviderTile;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.search.Indexable;
-import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.Arrays;
@@ -58,7 +57,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
/**
* Base fragment for dashboard style UI containing a list of static and dynamic setting items.
@@ -222,7 +220,7 @@
super.onResume();
updatePreferenceStates();
writeElapsedTimeMetric(SettingsEnums.ACTION_DASHBOARD_VISIBLE_TIME,
- "isParalleledControllers:" + isParalleledControllers());
+ "isParalleledControllers:false");
}
@Override
@@ -349,14 +347,6 @@
}
/**
- * @return {@code true} if the underlying controllers should be executed in parallel.
- * Override this function to enable/disable the behavior.
- */
- protected boolean isParalleledControllers() {
- return false;
- }
-
- /**
* Get current PreferenceController(s)
*/
protected Collection<List<AbstractPreferenceController>> getPreferenceControllers() {
@@ -395,36 +385,6 @@
}
/**
- * Use parallel method to update state of each preference managed by PreferenceController.
- */
- @VisibleForTesting
- // To use this parallel approach will cause the side effect of the UI flicker. Such as
- // the thumb sliding of the toggle button.
- void updatePreferenceStatesInParallel() {
- final PreferenceScreen screen = getPreferenceScreen();
- final Collection<List<AbstractPreferenceController>> controllerLists =
- mPreferenceControllers.values();
- final List<ControllerFutureTask> taskList = new ArrayList<>();
- for (List<AbstractPreferenceController> controllerList : controllerLists) {
- for (AbstractPreferenceController controller : controllerList) {
- final ControllerFutureTask task = new ControllerFutureTask(
- new ControllerTask(controller, screen, mMetricsFeatureProvider,
- getMetricsCategory()), null /* result */);
- taskList.add(task);
- ThreadUtils.postOnBackgroundThread(task);
- }
- }
-
- for (ControllerFutureTask task : taskList) {
- try {
- task.get();
- } catch (InterruptedException | ExecutionException e) {
- Log.w(TAG, task.getController().getPreferenceKey() + " " + e.getMessage());
- }
- }
- }
-
- /**
* Refresh all preference items, including both static prefs from xml, and dynamic items from
* DashboardCategory.
*/
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 025c51f..57114e2 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -47,6 +47,7 @@
import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.RestrictedDashboardFragment;
+import com.android.settings.development.autofill.AutofillCategoryController;
import com.android.settings.development.autofill.AutofillLoggingLevelPreferenceController;
import com.android.settings.development.autofill.AutofillResetOptionsPreferenceController;
import com.android.settings.development.bluetooth.AbstractBluetoothDialogPreferenceController;
@@ -566,6 +567,7 @@
controllers.add(new DefaultLaunchPreferenceController(context, "density"));
controllers.add(new DefaultLaunchPreferenceController(context, "background_check"));
controllers.add(new DefaultLaunchPreferenceController(context, "inactive_apps"));
+ controllers.add(new AutofillCategoryController(context, lifecycle));
controllers.add(new AutofillLoggingLevelPreferenceController(context, lifecycle));
controllers.add(new AutofillResetOptionsPreferenceController(context));
controllers.add(new BluetoothCodecDialogPreferenceController(context, lifecycle,
@@ -582,6 +584,7 @@
bluetoothA2dpConfigStore, fragment));
controllers.add(new SharedDataPreferenceController(context));
controllers.add(new OverlaySettingsPreferenceController(context));
+ controllers.add(new StylusHandwritingPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/development/StylusHandwritingPreferenceController.java b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
new file mode 100644
index 0000000..69b5bad
--- /dev/null
+++ b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+class StylusHandwritingPreferenceController extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
+
+ static final int SETTING_VALUE_ON = 1;
+ static final int SETTING_VALUE_OFF = 0;
+
+ private static final String STYLUS_HANDWRITING_OPTIONS_KEY = "stylus_handwriting";
+
+ StylusHandwritingPreferenceController(Context context) {
+ super(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return STYLUS_HANDWRITING_OPTIONS_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean isEnabled = (Boolean) newValue;
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED,
+ isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
+
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ final int enable = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ ((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ super.onDeveloperOptionsSwitchDisabled();
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ ((SwitchPreference) mPreference).setChecked(false);
+ }
+}
diff --git a/src/com/android/settings/development/autofill/AutofillCategoryController.java b/src/com/android/settings/development/autofill/AutofillCategoryController.java
new file mode 100644
index 0000000..91b3b9c
--- /dev/null
+++ b/src/com/android/settings/development/autofill/AutofillCategoryController.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development.autofill;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.Looper;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.autofill.AutofillManager;
+
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * Controller class for observing the state of AutofillManager.
+ */
+public class AutofillCategoryController extends DeveloperOptionsPreferenceController implements
+ LifecycleObserver, OnStart, OnStop {
+
+ private static final String TAG = "AutofillCategoryController";
+
+ private static final String CATEGORY_KEY = "debug_autofill_category";
+ private static final long DELAYED_MESSAGE_TIME_MS = 2000;
+
+ private ContentResolver mContentResolver;
+ private ContentObserver mSettingsObserver;
+ private final Handler mHandler = new Handler(Looper.getMainLooper());
+
+ public AutofillCategoryController(Context context, Lifecycle lifecycle) {
+ super(context);
+
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+
+ mSettingsObserver = new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange, Uri uri, int userId) {
+ // We cannot apply the change yet because AutofillManager.isEnabled() state is
+ // updated by a ContentObserver as well and there's no guarantee of which observer
+ // is called first - hence, it's possible that the state didn't change here yet.
+ mHandler.postDelayed(
+ () -> mPreference.notifyDependencyChange(shouldDisableDependents()),
+ DELAYED_MESSAGE_TIME_MS);
+ }
+ };
+ mContentResolver = context.getContentResolver();
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return CATEGORY_KEY;
+ }
+
+ @Override
+ public void onStart() {
+ mContentResolver.registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE), false,
+ mSettingsObserver);
+
+ }
+
+ @Override
+ public void onStop() {
+ mContentResolver.unregisterContentObserver(mSettingsObserver);
+ }
+
+ // PreferenceCategory.isEnabled() always return false, so we rather not change that logic
+ // decide whether the children should be shown using isAutofillEnabled() instead.
+ private boolean isAutofillEnabled() {
+ final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
+ final boolean enabled = afm != null && afm.isEnabled();
+ Log.v(TAG, "isAutofillEnabled(): " + enabled);
+ return enabled;
+ }
+
+ private boolean shouldDisableDependents() {
+ final boolean shouldIt = !isAutofillEnabled();
+ Log.v(TAG, "shouldDisableDependents(): " + shouldIt);
+ return shouldIt;
+ }
+}
diff --git a/src/com/android/settings/development/autofill/AutofillPreferenceCategory.java b/src/com/android/settings/development/autofill/AutofillPreferenceCategory.java
deleted file mode 100644
index cbfbdd3..0000000
--- a/src/com/android/settings/development/autofill/AutofillPreferenceCategory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.settings.development.autofill;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.Looper;
-import android.provider.Settings;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.autofill.AutofillManager;
-
-import androidx.preference.PreferenceCategory;
-
-public final class AutofillPreferenceCategory extends PreferenceCategory {
-
- private static final String TAG = "AutofillPreferenceCategory";
- private static final long DELAYED_MESSAGE_TIME_MS = 2000;
-
- private final ContentResolver mContentResolver;
- private final ContentObserver mSettingsObserver;
- private final Handler mHandler = new Handler(Looper.getMainLooper());
-
- public AutofillPreferenceCategory(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- mSettingsObserver = new ContentObserver(mHandler) {
- @Override
- public void onChange(boolean selfChange, Uri uri, int userId) {
- // We cannot apply the change yet because AutofillManager.isEnabled() state is
- // updated by a ContentObserver as well and there's no guarantee of which observer
- // is called first - hence, it's possible that the state didn't change here yet.
- mHandler.postDelayed(() -> notifyDependencyChange(shouldDisableDependents()),
- DELAYED_MESSAGE_TIME_MS);
- }
- };
- mContentResolver = context.getContentResolver();
- }
-
- @Override
- public void onAttached() {
- super.onAttached();
-
- mContentResolver.registerContentObserver(
- Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE), false,
- mSettingsObserver);
- }
-
- @Override
- public void onDetached() {
- mContentResolver.unregisterContentObserver(mSettingsObserver);
-
- super.onDetached();
- }
-
- // PreferenceCategory.isEnabled() always return false, so we rather not change that logic
- // decide whether the children should be shown using isAutofillEnabled() instead.
- private boolean isAutofillEnabled() {
- final AutofillManager afm = getContext().getSystemService(AutofillManager.class);
- final boolean enabled = afm != null && afm.isEnabled();
- Log.v(TAG, "isAutofillEnabled(): " + enabled);
- return enabled;
- }
-
- @Override
- public boolean shouldDisableDependents() {
- final boolean shouldIt = !isAutofillEnabled();
- Log.v(TAG, "shouldDisableDependents(): " + shouldIt);
- return shouldIt;
- }
-}
diff --git a/src/com/android/settings/display/ScreenResolutionFragment.java b/src/com/android/settings/display/ScreenResolutionFragment.java
index 3195772..3b08ae7 100644
--- a/src/com/android/settings/display/ScreenResolutionFragment.java
+++ b/src/com/android/settings/display/ScreenResolutionFragment.java
@@ -36,7 +36,9 @@
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.widget.CandidateInfo;
+import com.android.settingslib.widget.FooterPreference;
import com.android.settingslib.widget.IllustrationPreference;
+import com.android.settingslib.widget.SelectorWithWidgetPreference;
import java.util.ArrayList;
import java.util.HashSet;
@@ -55,6 +57,7 @@
private Display mDefaultDisplay;
private String[] mScreenResolutionOptions;
private Set<Point> mResolutions;
+ private String[] mScreenResolutionSummaries;
private IllustrationPreference mImagePreference;
@@ -67,6 +70,8 @@
mResources = context.getResources();
mScreenResolutionOptions =
mResources.getStringArray(R.array.config_screen_resolution_options_strings);
+ mScreenResolutionSummaries =
+ mResources.getStringArray(R.array.config_screen_resolution_summaries_strings);
mResolutions = getAllSupportedResolution();
mImagePreference = new IllustrationPreference(context);
}
@@ -80,6 +85,24 @@
protected void addStaticPreferences(PreferenceScreen screen) {
updateIllustrationImage(mImagePreference);
screen.addPreference(mImagePreference);
+
+ final FooterPreference footerPreference = new FooterPreference(screen.getContext());
+ footerPreference.setTitle(R.string.screen_resolution_footer);
+ footerPreference.setSelectable(false);
+ footerPreference.setLayoutResource(R.layout.preference_footer);
+ screen.addPreference(footerPreference);
+ }
+
+ @Override
+ public void bindPreferenceExtra(
+ SelectorWithWidgetPreference pref,
+ String key,
+ CandidateInfo info,
+ String defaultKey,
+ String systemDefaultKey) {
+ final ScreenResolutionCandidateInfo candidateInfo = (ScreenResolutionCandidateInfo) info;
+ final CharSequence summary = candidateInfo.loadSummary();
+ if (summary != null) pref.setSummary(summary);
}
@Override
@@ -90,6 +113,7 @@
candidates.add(
new ScreenResolutionCandidateInfo(
mScreenResolutionOptions[i],
+ mScreenResolutionSummaries[i],
mScreenResolutionOptions[i],
true /* enabled */));
}
@@ -134,9 +158,9 @@
/** Get the key corresponding to the resolution. */
@VisibleForTesting
String getKeyForResolution(int width) {
- return width == FHD_WIDTH
- ? mScreenResolutionOptions[FHD_INDEX]
- : width == QHD_WIDTH ? mScreenResolutionOptions[QHD_INDEX] : null;
+ return width == FHD_WIDTH ? mScreenResolutionOptions[FHD_INDEX]
+ : width == QHD_WIDTH ? mScreenResolutionOptions[QHD_INDEX]
+ : null;
}
@Override
@@ -175,13 +199,17 @@
return SettingsEnums.SCREEN_RESOLUTION;
}
- static class ScreenResolutionCandidateInfo extends CandidateInfo {
+ /** This is an extension of the CandidateInfo class, which adds summary information. */
+ public static class ScreenResolutionCandidateInfo extends CandidateInfo {
private final CharSequence mLabel;
+ private final CharSequence mSummary;
private final String mKey;
- ScreenResolutionCandidateInfo(CharSequence label, String key, boolean enabled) {
+ ScreenResolutionCandidateInfo(
+ CharSequence label, CharSequence summary, String key, boolean enabled) {
super(enabled);
mLabel = label;
+ mSummary = summary;
mKey = key;
}
@@ -190,6 +218,11 @@
return mLabel;
}
+ /** It is the summary for radio options. */
+ public CharSequence loadSummary() {
+ return mSummary;
+ }
+
@Override
public Drawable loadIcon() {
return null;
diff --git a/src/com/android/settings/dream/DreamAdapter.java b/src/com/android/settings/dream/DreamAdapter.java
index 44f77e3..f196500 100644
--- a/src/com/android/settings/dream/DreamAdapter.java
+++ b/src/com/android/settings/dream/DreamAdapter.java
@@ -84,6 +84,9 @@
mPreviewView.setImageDrawable(previewImage);
mPreviewView.setClipToOutline(true);
mPreviewPlaceholderView.setVisibility(View.GONE);
+ } else {
+ mPreviewView.setImageDrawable(null);
+ mPreviewPlaceholderView.setVisibility(View.VISIBLE);
}
final Drawable icon = item.isActive()
@@ -91,7 +94,7 @@
: item.getIcon();
if (icon instanceof VectorDrawable) {
icon.setTintList(
- mContext.getColorStateList(R.color.dream_card_text_color_state_list));
+ mContext.getColorStateList(R.color.dream_card_icon_color_state_list));
}
final int iconSize = mContext.getResources().getDimensionPixelSize(
R.dimen.dream_item_icon_size);
diff --git a/src/com/android/settings/flashlight/FlashlightHandleActivity.java b/src/com/android/settings/flashlight/FlashlightHandleActivity.java
index 5894965..0847d49 100644
--- a/src/com/android/settings/flashlight/FlashlightHandleActivity.java
+++ b/src/com/android/settings/flashlight/FlashlightHandleActivity.java
@@ -21,12 +21,13 @@
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
+import android.util.Log;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.List;
@@ -39,6 +40,9 @@
public static final String EXTRA_FALLBACK_TO_HOMEPAGE = "fallback_to_homepage";
+ private static final String TAG = "FlashlightActivity";
+ private static final String DATA_KEY = "flashlight";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -69,10 +73,20 @@
data.intentTargetPackage = context.getPackageName();
data.intentTargetClass = FlashlightHandleActivity.class.getName();
data.intentAction = Intent.ACTION_MAIN;
- data.key = "flashlight";
+ data.key = DATA_KEY;
result.add(data);
return result;
}
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ List<String> keys = super.getNonIndexableKeys(context);
+ if (!FlashlightSlice.isFlashlightAvailable(context)) {
+ Log.i(TAG, "Flashlight is unavailable");
+ keys.add(DATA_KEY);
+ }
+ return keys;
+ }
};
}
diff --git a/src/com/android/settings/flashlight/FlashlightSlice.java b/src/com/android/settings/flashlight/FlashlightSlice.java
index eaf059a..5feaf4f 100644
--- a/src/com/android/settings/flashlight/FlashlightSlice.java
+++ b/src/com/android/settings/flashlight/FlashlightSlice.java
@@ -39,7 +39,6 @@
import androidx.slice.builders.ListBuilder.RowBuilder;
import androidx.slice.builders.SliceAction;
-import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.slices.CustomSliceRegistry;
@@ -138,7 +137,6 @@
return null;
}
- @VisibleForTesting
static boolean isFlashlightAvailable(Context context) {
int defaultAvailability = 0;
try {
diff --git a/src/com/android/settings/network/UiccSlotUtil.java b/src/com/android/settings/network/UiccSlotUtil.java
index d28d93a..c4f495c 100644
--- a/src/com/android/settings/network/UiccSlotUtil.java
+++ b/src/com/android/settings/network/UiccSlotUtil.java
@@ -25,6 +25,7 @@
import android.telephony.UiccSlotMapping;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.utils.ThreadUtils;
import com.google.common.collect.ImmutableList;
@@ -33,6 +34,7 @@
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -126,7 +128,10 @@
performSwitchToSlot(telMgr,
prepareUiccSlotMappings(uiccSlotMappings,
- inactiveRemovableSlot, /*removable sim's port Id*/ 0, removedSubInfo,
+ /*slot is psim*/ true,
+ inactiveRemovableSlot,
+ /*removable sim's port Id*/ TelephonyManager.DEFAULT_PORT_INDEX,
+ removedSubInfo,
telMgr.isMultiSimEnabled()),
context);
}
@@ -159,7 +164,7 @@
}
performSwitchToSlot(telMgr,
- prepareUiccSlotMappings(uiccSlotMappings,
+ prepareUiccSlotMappings(uiccSlotMappings, /*slot is not psim*/ false,
physicalSlotId, port, removedSubInfo, telMgr.isMultiSimEnabled()),
context);
}
@@ -251,9 +256,27 @@
return INVALID_PHYSICAL_SLOT_ID;
}
- private static Collection<UiccSlotMapping> prepareUiccSlotMappings(
- Collection<UiccSlotMapping> uiccSlotMappings, int physicalSlotId, int port,
- SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) {
+ // Device | |Slot |
+ // Working| |Mapping|
+ // State |Type |Mode |Friendly name
+ //--------------------------------------------------------------------------
+ // Single |SIM pSIM [RIL 0] |1 |pSIM active
+ // Single |SIM MEP Port #0 [RIL0] |2 |eSIM Port0 active
+ // Single |SIM MEP Port #1 [RIL0] |2.1 |eSIM Port1 active
+ // DSDS |pSIM [RIL 0] + MEP Port #0 [RIL 1] |3 |pSIM+Port0
+ // DSDS |pSIM [RIL 0] + MEP Port #1 [RIL 1] |3.1 |pSIM+Port1
+ // DSDS |MEP Port #0 [RIL 0] + MEP Port #1 [RIL1]|3.2 |Dual-Ports-A
+ // DSDS |MEP Port #1 [RIL 0] + MEP Port #0 [RIL1]|4 |Dual-Ports-B
+ //
+ // The rules are:
+ // 1. pSIM's logical slots always is [RIL 0].
+ // 2. assign the new active port to the same stack that will be de-activated
+ // For example: mode#3->mode#4
+
+ @VisibleForTesting
+ static Collection<UiccSlotMapping> prepareUiccSlotMappings(
+ Collection<UiccSlotMapping> uiccSlotMappings, boolean isPsim, int physicalSlotId,
+ int port, SubscriptionInfo removedSubInfo, boolean isMultiSimEnabled) {
Collection<UiccSlotMapping> newUiccSlotMappings = new ArrayList<>();
if (!isMultiSimEnabled) {
// In the 'SS mode', the port is 0.
@@ -268,25 +291,59 @@
+ "PhysicalSlotId%d-Port%d",
removedSubInfo.getSubscriptionId(), removedSubInfo.getSimSlotIndex(),
removedSubInfo.getPortIndex(), physicalSlotId, port));
+
+ int logicalSlotIndex = 0;
+ if (isPsim) {
+ // The target slot is psim
+ newUiccSlotMappings.add(
+ new UiccSlotMapping(port, physicalSlotId, logicalSlotIndex++));
+ }
+ Collection<UiccSlotMapping> tempUiccSlotMappings =
+ uiccSlotMappings.stream()
+ .sorted(Comparator.comparingInt(UiccSlotMapping::getLogicalSlotIndex))
+ .collect(Collectors.toList());
+ for (UiccSlotMapping uiccSlotMapping : tempUiccSlotMappings) {
+ if (isSubInfoMappingIntoUiccSlotMapping(uiccSlotMapping, removedSubInfo)) {
+ if (!isPsim) {
+ // Replace this uiccSlotMapping
+ newUiccSlotMappings.add(new UiccSlotMapping(port, physicalSlotId,
+ uiccSlotMapping.getLogicalSlotIndex()));
+ }
+ continue;
+ }
+
+ // If the psim is inserted, then change the
+ // logicalSlotIndex for another uiccSlotMappings.
+ newUiccSlotMappings.add(isPsim
+ ? new UiccSlotMapping(
+ uiccSlotMapping.getPortIndex(),
+ uiccSlotMapping.getPhysicalSlotIndex(),
+ logicalSlotIndex++
+ ) : uiccSlotMapping);
+ }
+ } else {
+ // For no inserted psim case in DSDS+MEP, there is only one esim in device and
+ // then user inserts another esim in DSDS+MEP.
+ // If the target is esim, then replace the psim.
+ Log.i(TAG, "The removedSubInfo is null");
newUiccSlotMappings =
uiccSlotMappings.stream().map(uiccSlotMapping -> {
- if (uiccSlotMapping.getLogicalSlotIndex()
- == removedSubInfo.getSimSlotIndex()
- && uiccSlotMapping.getPortIndex()
- == removedSubInfo.getPortIndex()) {
+ if (!isPsim && uiccSlotMapping.getPhysicalSlotIndex() != physicalSlotId) {
return new UiccSlotMapping(port, physicalSlotId,
uiccSlotMapping.getLogicalSlotIndex());
}
return uiccSlotMapping;
}).collect(Collectors.toList());
- } else {
- // DSDS+no MEP
- // The removable slot should be in UiccSlotMapping.
- newUiccSlotMappings = uiccSlotMappings;
- Log.i(TAG, "The removedSubInfo is null");
}
Log.i(TAG, "The SimSlotMapping: " + newUiccSlotMappings);
return newUiccSlotMappings;
}
+
+ private static boolean isSubInfoMappingIntoUiccSlotMapping(UiccSlotMapping uiccSlotMapping,
+ SubscriptionInfo subscriptionInfo) {
+ return uiccSlotMapping != null
+ && uiccSlotMapping.getLogicalSlotIndex() == subscriptionInfo.getSimSlotIndex()
+ && uiccSlotMapping.getPortIndex() == subscriptionInfo.getPortIndex();
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppBaseActivity.java b/src/com/android/settings/wifi/dpp/WifiDppBaseActivity.java
index f55960b..938d224 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppBaseActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppBaseActivity.java
@@ -26,6 +26,8 @@
import com.android.settings.SetupWizardUtils;
import com.android.settings.core.InstrumentedActivity;
+import com.google.android.setupdesign.util.ThemeHelper;
+
public abstract class WifiDppBaseActivity extends InstrumentedActivity {
protected FragmentManager mFragmentManager;
@@ -35,6 +37,8 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ applyTheme();
+
setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
@@ -45,8 +49,18 @@
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
- final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
- theme.applyStyle(R.style.SetupWizardPartnerResource, /* force */ true);
- super.onApplyThemeResource(theme, new_resid, first);
+ theme.applyStyle(R.style.SetupWizardPartnerResource, true);
+ super.onApplyThemeResource(theme, resid, first);
+ }
+
+ private void applyTheme() {
+ if (ThemeHelper.trySetDynamicColor(this)) {
+ final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
+ ? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
+ : R.style.SudDynamicColorThemeSettings_SetupWizard;
+ setTheme(appliedTheme);
+ } else {
+ setTheme(SetupWizardUtils.getTheme(this, getIntent()));
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java b/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java
deleted file mode 100644
index c66f2b5..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/ControllerFutureTaskTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.dashboard;
-
-import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.core.BasePreferenceController;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class ControllerFutureTaskTest {
- private static final String KEY = "my_key";
-
- private Context mContext;
- private TestPreferenceController mTestController;
- private PreferenceScreen mScreen;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mTestController = new TestPreferenceController(mContext, KEY);
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- }
-
- @Test
- public void getController_addTask_checkControllerKey() {
- final ControllerFutureTask futureTask = new ControllerFutureTask(
- new ControllerTask(mTestController, mScreen, null /* metricsFeature */,
- METRICS_CATEGORY_UNKNOWN), null /* result */);
-
- assertThat(futureTask.getController().getPreferenceKey()).isEqualTo(KEY);
- }
-
-
- static class TestPreferenceController extends BasePreferenceController {
- TestPreferenceController(Context context, String preferenceKey) {
- super(context, preferenceKey);
- }
-
- @Override
- public int getAvailabilityStatus() {
- return AVAILABLE;
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java b/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java
deleted file mode 100644
index 17ab79c..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/ControllerTaskTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.dashboard;
-
-import static com.android.settingslib.core.instrumentation.Instrumentable.METRICS_CATEGORY_UNKNOWN;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.content.Context;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class ControllerTaskTest {
- private static final String KEY = "my_key";
-
- private Context mContext;
- private PreferenceScreen mScreen;
- private TestPreferenceController mTestController;
- private ControllerTask mControllerTask;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- final PreferenceManager preferenceManager = new PreferenceManager(mContext);
- mScreen = preferenceManager.createPreferenceScreen(mContext);
- mTestController = spy(new TestPreferenceController(mContext));
- mControllerTask = new ControllerTask(mTestController, mScreen, null /* metricsFeature */,
- METRICS_CATEGORY_UNKNOWN);
- }
-
- @Test
- public void doRun_controlNotAvailable_noRunUpdateState() {
- mTestController.setAvailable(false);
-
- mControllerTask.run();
-
- verify(mTestController, never()).updateState(any(Preference.class));
- }
-
- @Test
- public void doRun_emptyKey_noRunUpdateState() {
- mTestController.setKey("");
-
- mControllerTask.run();
-
- verify(mTestController, never()).updateState(any(Preference.class));
- }
-
- @Test
- public void doRun_preferenceNotExist_noRunUpdateState() {
- mTestController.setKey(KEY);
-
- mControllerTask.run();
-
- verify(mTestController, never()).updateState(any(Preference.class));
- }
-
- @Test
- public void doRun_executeUpdateState() {
- mTestController.setKey(KEY);
- final Preference preference = new Preference(mContext);
- preference.setKey(KEY);
- mScreen.addPreference(preference);
-
- mControllerTask.run();
-
- verify(mTestController).updateState(any(Preference.class));
- }
-
- static class TestPreferenceController extends AbstractPreferenceController {
- private boolean mAvailable;
- private String mKey;
-
- TestPreferenceController(Context context) {
- super(context);
- mAvailable = true;
- }
-
- @Override
- public boolean isAvailable() {
- return mAvailable;
- }
-
- @Override
- public String getPreferenceKey() {
- return mKey;
- }
-
- void setAvailable(boolean available) {
- mAvailable = available;
- }
-
- void setKey(String key) {
- mKey = key;
- }
- }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index aa5f980..894a6c5 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -390,7 +390,6 @@
private final ContentResolver mContentResolver;
public final PreferenceScreen mScreen;
- private boolean mIsParalleled;
public TestFragment(Context context) {
mContext = context;
@@ -398,7 +397,6 @@
mScreen = mock(PreferenceScreen.class);
mContentResolver = mock(ContentResolver.class);
mControllers = new ArrayList<>();
- mIsParalleled = true;
when(mPreferenceManager.getContext()).thenReturn(mContext);
ReflectionHelpers.setField(
@@ -445,13 +443,6 @@
return mContentResolver;
}
- protected boolean isParalleledControllers() {
- return mIsParalleled;
- }
-
- void setUsingControllerEnhancement(boolean isParalleled) {
- mIsParalleled = isParalleled;
- }
}
private static class TestDynamicDataObserver extends DynamicDataObserver {
diff --git a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
new file mode 100644
index 0000000..12b5fe9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development;
+
+import static com.android.settings.development.StylusHandwritingPreferenceController.SETTING_VALUE_OFF;
+import static com.android.settings.development.StylusHandwritingPreferenceController.SETTING_VALUE_ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class StylusHandwritingPreferenceControllerTest {
+
+ @Mock
+ private SwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private StylusHandwritingPreferenceController mController;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new StylusHandwritingPreferenceController(mContext);
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
+ .thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
+ mController.onPreferenceChange(mPreference, true /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(SETTING_VALUE_ON);
+ }
+
+ @Test
+ public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
+ mController.onPreferenceChange(mPreference, false /* new value */);
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
+ }
+
+ @Test
+ public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void updateState_settingEnabled_preferenceShouldBeChecked() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
+ mController.onDeveloperOptionsSwitchDisabled();
+
+ final int mode = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+
+ assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
+ verify(mPreference).setChecked(false);
+ verify(mPreference).setEnabled(false);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/display/ScreenResolutionFragmentTest.java b/tests/unit/src/com/android/settings/display/ScreenResolutionFragmentTest.java
index 225a1d9..b7d37df 100644
--- a/tests/unit/src/com/android/settings/display/ScreenResolutionFragmentTest.java
+++ b/tests/unit/src/com/android/settings/display/ScreenResolutionFragmentTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -28,6 +29,8 @@
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settingslib.widget.SelectorWithWidgetPreference;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -87,4 +90,19 @@
verify(mFragment).setDisplayMode(QHD_WIDTH);
}
+
+ @Test
+ @UiThreadTest
+ public void bindPreferenceExtra_setSummary() {
+ mFragment.onAttach(mContext);
+ SelectorWithWidgetPreference preference = new SelectorWithWidgetPreference(mContext);
+ ScreenResolutionFragment.ScreenResolutionCandidateInfo candidates =
+ mock(ScreenResolutionFragment.ScreenResolutionCandidateInfo.class);
+ CharSequence summary = "test summary";
+ doReturn(summary).when(candidates).loadSummary();
+
+ mFragment.bindPreferenceExtra(preference, "com.example.test", candidates, null, null);
+
+ assertThat(preference.getSummary().toString().contentEquals(summary)).isTrue();
+ }
}
diff --git a/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java b/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
index 1a6879d..8a0a4b0 100644
--- a/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
+++ b/tests/unit/src/com/android/settings/network/UiccSlotUtilTest.java
@@ -24,9 +24,11 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.telephony.UiccPortInfo;
import android.telephony.UiccSlotInfo;
+import android.telephony.UiccSlotMapping;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -39,8 +41,12 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
@RunWith(AndroidJUnit4.class)
public class UiccSlotUtilTest {
@@ -48,6 +54,9 @@
@Mock
private TelephonyManager mTelephonyManager;
+ private static final int ESIM_PHYSICAL_SLOT = 0;
+ private static final int PSIM_PHYSICAL_SLOT = 1;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -58,7 +67,7 @@
@Test
public void getSlotInfos_oneSimSlotDevice_returnTheCorrectSlotInfoList() {
- when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(oneSimSlotDevice_ActivePsim());
+ when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(oneSimSlotDeviceActivePsim());
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
UiccSlotUtil.getSlotInfos(mTelephonyManager);
@@ -68,7 +77,7 @@
@Test
public void getSlotInfos_twoSimSlotsDevice_returnTheCorrectSlotInfoList() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
- twoSimSlotsDevice_ActivePsimActiveEsim());
+ twoSimSlotsDeviceActivePsimActiveEsim());
ImmutableList<UiccSlotInfo> testUiccSlotInfos =
UiccSlotUtil.getSlotInfos(mTelephonyManager);
@@ -78,7 +87,7 @@
@Test
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot0_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
- twoSimSlotsDevice_ActiveEsimActivePsim());
+ twoSimSlotsDeviceActiveEsimActivePsim());
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
assertThat(testSlot).isEqualTo(0);
@@ -87,7 +96,7 @@
@Test
public void getEsimSlotId_twoSimSlotsDeviceAndEsimIsSlot1_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
- twoSimSlotsDevice_ActivePsimActiveEsim());
+ twoSimSlotsDeviceActivePsimActiveEsim());
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
assertThat(testSlot).isEqualTo(1);
@@ -96,12 +105,253 @@
@Test
public void getEsimSlotId_noEimSlotDevice_returnTheCorrectEsimSlot() {
when(mTelephonyManager.getUiccSlotsInfo()).thenReturn(
- oneSimSlotDevice_ActivePsim());
+ oneSimSlotDeviceActivePsim());
int testSlot = UiccSlotUtil.getEsimSlotId(mContext);
assertThat(testSlot).isEqualTo(-1);
}
+ @Test
+ public void prepareUiccSlotMappings_fromPsimActiveToEsimPort0Active_esimPort0Active() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingSsModePsimActive();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingSsModeEsimPort0Active();
+
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, false);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromEsimPort0ActiveToPsimActive_psimActive() {
+ Collection<UiccSlotMapping> uiccSlotMappings =
+ createUiccSlotMappingSsModeEsimPort0Active();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingSsModePsimActive();
+
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, null, false);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromPsimAndPort0ToPsimAndPort1_psimAndPort1() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort1();
+ SubscriptionInfo subInfo = createSubscriptionInfo(1, 0);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromPsimAndPort1ToPsimAndPort0_psimAndPort0() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort0();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromPsimAndPort0ToDualPortsB_dualPortsB() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingDualPortsB();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromPsimAndPort1ToDualPortsA_dualPortsA() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingDualPortsA();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_noPsimAndFromPsimAndPort0ToDualPortsB_dualPortsB() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort0();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingDualPortsB();
+
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 1, null, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_noPsimAndFromPsimAndPort1ToDualPortsA_dualPortsA() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingPsimAndPort1();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingDualPortsA();
+
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, false, ESIM_PHYSICAL_SLOT, 0, null, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromDualPortsAToPsimAndPort1_psimAndPort1() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort1();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(0, 0);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromDualPortsAToPsimAndPort0_psimAndPort0() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsA();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort0();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(1, 1);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromDualPortsBToPsimAndPort1_psimAndPort1() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort1();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(1, 0);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ @Test
+ public void prepareUiccSlotMappings_fromDualPortsBToPsimAndPort0_psimAndPort0() {
+ Collection<UiccSlotMapping> uiccSlotMappings = createUiccSlotMappingDualPortsB();
+ Collection<UiccSlotMapping> verifyUiccSlotMappings =
+ createUiccSlotMappingPsimAndPort0();
+
+ SubscriptionInfo subInfo = createSubscriptionInfo(0, 1);
+ Collection<UiccSlotMapping> testUiccSlotMappings = UiccSlotUtil.prepareUiccSlotMappings(
+ uiccSlotMappings, true, PSIM_PHYSICAL_SLOT, 0, subInfo, true);
+
+ compareTwoUiccSlotMappings(testUiccSlotMappings, verifyUiccSlotMappings);
+ }
+
+ private SubscriptionInfo createSubscriptionInfo(int logicalSlotIndex, int portIndex) {
+ return new SubscriptionInfo(
+ 0, "", logicalSlotIndex, "", "", 0, 0, "", 0, null, "", "", "",
+ true /* isEmbedded */,
+ null, "", 25,
+ false, null, false, 0, 0, 0, null, null, true, portIndex);
+ }
+
+ private void compareTwoUiccSlotMappings(Collection<UiccSlotMapping> testUiccSlotMappings,
+ Collection<UiccSlotMapping> verifyUiccSlotMappings) {
+ assertThat(testUiccSlotMappings.size()).isEqualTo(verifyUiccSlotMappings.size());
+ Iterator<UiccSlotMapping> testIterator = testUiccSlotMappings.iterator();
+ Iterator<UiccSlotMapping> verifyIterator = verifyUiccSlotMappings.iterator();
+ while (testIterator.hasNext()) {
+ UiccSlotMapping testUiccSlotMapping = testIterator.next();
+ UiccSlotMapping verifyUiccSlotMapping = verifyIterator.next();
+ assertThat(testUiccSlotMapping.getLogicalSlotIndex()).isEqualTo(
+ verifyUiccSlotMapping.getLogicalSlotIndex());
+ assertThat(testUiccSlotMapping.getPortIndex()).isEqualTo(
+ verifyUiccSlotMapping.getPortIndex());
+ assertThat(testUiccSlotMapping.getPhysicalSlotIndex()).isEqualTo(
+ verifyUiccSlotMapping.getPhysicalSlotIndex());
+ }
+ }
+
+ // Device | |Slot |
+ // Working| |Mapping|
+ // State |Type |Mode |Friendly name
+ //--------------------------------------------------------------------------
+ // Single |SIM pSIM [RIL 0] |1 |pSIM active
+ // Single |SIM MEP Port #0 [RIL0] |2 |eSIM Port0 active
+ // Single |SIM MEP Port #1 [RIL0] |2.1 |eSIM Port1 active
+ // DSDS |pSIM [RIL 0] + MEP Port #0 [RIL 1] |3 |pSIM+Port0
+ // DSDS |pSIM [RIL 0] + MEP Port #1 [RIL 1] |3.1 |pSIM+Port1
+ // DSDS |MEP Port #0 [RIL 0] + MEP Port #1 [RIL1]|3.2 |Dual-Ports-A
+ // DSDS |MEP Port #1 [RIL 0] + MEP Port #0 [RIL1]|4 |Dual-Ports-B
+ private List<UiccSlotMapping> createUiccSlotMappingSsModePsimActive() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingSsModeEsimPort0Active() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 0));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingSsModeEsimPort1Active() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 0));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingPsimAndPort0() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
+ slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 1));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingPsimAndPort1() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(0, PSIM_PHYSICAL_SLOT, 0));
+ slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 1));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingDualPortsA() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 0));
+ slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 1));
+
+ return slotMap;
+ }
+
+ private List<UiccSlotMapping> createUiccSlotMappingDualPortsB() {
+ List<UiccSlotMapping> slotMap = new ArrayList<>();
+ slotMap.add(new UiccSlotMapping(1, ESIM_PHYSICAL_SLOT, 0));
+ slotMap.add(new UiccSlotMapping(0, ESIM_PHYSICAL_SLOT, 1));
+
+ return slotMap;
+ }
+
/**
* The "oneSimSlotDevice" has below cases
* 1) The device is one psim slot and no esim slot
@@ -112,27 +362,27 @@
* 2) The device is two psim slots
*/
- private UiccSlotInfo[] oneSimSlotDevice_ActivePsim() {
+ private UiccSlotInfo[] oneSimSlotDeviceActivePsim() {
return new UiccSlotInfo[]{createUiccSlotInfo(false, true, 0, true)};
}
- private UiccSlotInfo[] oneSimSlotDevice_ActiveEsim() {
+ private UiccSlotInfo[] oneSimSlotDeviceActiveEsim() {
return new UiccSlotInfo[]{createUiccSlotInfo(true, false, 1, true)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_ActivePsimActiveEsim() {
+ private UiccSlotInfo[] twoSimSlotsDeviceActivePsimActiveEsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(false, true, 0, true),
createUiccSlotInfo(true, false, 1, true)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_ActiveEsimActivePsim() {
+ private UiccSlotInfo[] twoSimSlotsDeviceActiveEsimActivePsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(true, false, 0, true),
createUiccSlotInfo(false, true, 1, true)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_twoActiveEsims() {
+ private UiccSlotInfo[] twoSimSlotsDeviceTwoActiveEsims() {
// device supports MEP, so device can enable two esims.
// If device has psim slot, the UiccSlotInfo of psim always be in UiccSlotInfo[].
return new UiccSlotInfo[]{
@@ -140,19 +390,19 @@
createUiccSlotInfoForEsimMep(0, true, 1, true)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_ActivePsimInactiveEsim() {
+ private UiccSlotInfo[] twoSimSlotsDeviceActivePsimInactiveEsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(false, true, 0, true),
createUiccSlotInfo(true, false, -1, false)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_InactivePsimActiveEsim() {
+ private UiccSlotInfo[] twoSimSlotsDeviceInactivePsimActiveEsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(false, true, 0, false),
createUiccSlotInfo(true, false, 1, true)};
}
- private UiccSlotInfo[] twoSimSlotsDevice_NoInsertPsimActiveEsim() {
+ private UiccSlotInfo[] twoSimSlotsDeviceNoInsertPsimActiveEsim() {
return new UiccSlotInfo[]{
createUiccSlotInfo(false, true, -1, false),
createUiccSlotInfo(true, false, 1, true)};