Merge "[Panlingual] Improve performance of displaying app list in Settings."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7200c80..74cf865 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -341,6 +341,25 @@
</receiver>
<activity
+ android:name="Settings$MemtagPageActivity"
+ android:label="@string/memtag_title"
+ android:icon="@drawable/ic_homepage_security"
+ android:exported="true"
+ android:configChanges="orientation|keyboardHidden|screenSize">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.MEMTAG_SETTINGS"/>
+ <category android:name="android.intent.category.BROWSABLE" />
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.security.MemtagPage"/>
+ <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
+ android:value="@string/menu_key_security"/>
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true"/>
+ </activity>
+
+ <activity
android:name="Settings$WifiSettingsActivity"
android:label="@string/wifi_settings"
android:icon="@drawable/ic_homepage_network"
@@ -3500,6 +3519,18 @@
android:value="@string/menu_key_notifications"/>
</activity>
+ <!-- Displays a list of apps available for cloning on the device -->
+ <activity android:name=".Settings$ClonedAppsListActivity"
+ android:label="@string/cloned_apps_dashboard_title"
+ android:exported="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.MANAGE_CLONED_APPS_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.manageapplications.ManageApplications" />
+ </activity>
+
<!-- Application-level notification settings page, same as above but only accessible
internally from system server -->
<activity android:name="Settings$NotificationReviewPermissionsActivity"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d249aa2..6992bd1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6987,6 +6987,8 @@
<!-- Title for setting tile leading to setting UI which allows user set default app to
handle actions such as open web page, making phone calls, default SMS apps [CHAR LIMIT=40]-->
<string name="app_default_dashboard_title">Default apps</string>
+ <!-- Title for setting tile leading to App Clones menu under the Apps page [CHAR LIMIT=40] -->
+ <string name="cloned_apps_dashboard_title">Cloned Apps</string>
<!-- Summary text for system preference title, showing important setting items under system setting [CHAR LIMIT=NONE]-->
<string name="system_dashboard_summary">Languages, gestures, time, backup</string>
<!-- Summary text for language preference title, showing important setting items under language setting [CHAR LIMIT=NONE]-->
diff --git a/res/xml/apps.xml b/res/xml/apps.xml
index 4dc7c4d..8fb72e8 100644
--- a/res/xml/apps.xml
+++ b/res/xml/apps.xml
@@ -62,6 +62,18 @@
<intent android:action="android.settings.MANAGE_DEFAULT_APPS_SETTINGS"/>
</Preference>
+ <Preference
+ android:key="cloned_apps"
+ android:title="@string/cloned_apps_dashboard_title"
+ android:order="-995"
+ settings:controller="com.android.settings.applications.ClonedAppsPreferenceController"
+ android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
+ <extra
+ android:name="classname"
+ android:value="com.android.settings.Settings$ClonedAppsListActivity"/>
+ <intent android:action="android.settings.MANAGE_CLONED_APPS_SETTINGS"/>
+ </Preference>
+
<PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="10"/>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 53960b4..b95c9b0 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -46,6 +46,8 @@
/*
* Settings subclasses for launching independently.
*/
+
+ public static class MemtagPageActivity extends SettingsActivity { /* empty */}
public static class AssistGestureSettingsActivity extends SettingsActivity { /* empty */}
public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
@@ -312,6 +314,8 @@
public static class AppBubbleNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationAssistantSettingsActivity extends SettingsActivity{ /* empty */ }
public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
+ /** Activity to manage Cloned Apps page */
+ public static class ClonedAppsListActivity extends SettingsActivity { /* empty */ }
public static class NotificationReviewPermissionsActivity extends SettingsActivity { /* empty */ }
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ChannelNotificationSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 8ee4eba..e57a32d 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -41,6 +41,7 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.content.pm.UserProperties;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -1163,7 +1164,7 @@
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
== ProfileSelectFragment.ProfileType.WORK : false;
try {
- if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
+ if (isNewTabNeeded(activity)
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
&& !isWork && !isPersonal) {
f = Fragment.instantiate(activity,
@@ -1178,6 +1179,24 @@
}
/**
+ * Checks if a new tab is needed or not for any user profile associated with the context user.
+ *
+ * <p> Checks if any user has the property {@link UserProperties#SHOW_IN_SETTINGS_SEPARATE} set.
+ */
+ public static boolean isNewTabNeeded(Activity activity) {
+ UserManager userManager = activity.getSystemService(UserManager.class);
+ List<UserHandle> profiles = userManager.getUserProfiles();
+ for (UserHandle userHandle : profiles) {
+ UserProperties userProperties = userManager.getUserProperties(userHandle);
+ if (userProperties.getShowInSettings()
+ == UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns true if current binder uid is Settings Intelligence.
*/
public static boolean isSettingsIntelligence(Context context) {
diff --git a/src/com/android/settings/applications/ClonedAppsPreferenceController.java b/src/com/android/settings/applications/ClonedAppsPreferenceController.java
new file mode 100644
index 0000000..76ccf06
--- /dev/null
+++ b/src/com/android/settings/applications/ClonedAppsPreferenceController.java
@@ -0,0 +1,46 @@
+/*
+ * 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.applications;
+
+import static com.android.settings.core.SettingsUIDeviceConfig.CLONED_APPS_ENABLED;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * A preference controller handling the logic for updating the summary of cloned apps.
+ */
+public class ClonedAppsPreferenceController extends BasePreferenceController {
+
+ public ClonedAppsPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ // todo(b/249916469): Update summary once we have mechanism of allowlisting available
+ // for cloned apps.
+ return null;
+ }
+ @Override
+ public int getAvailabilityStatus() {
+ return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
+ CLONED_APPS_ENABLED, false) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+}
diff --git a/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceController.java b/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceController.java
index 9444e72..b33d187 100644
--- a/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceController.java
@@ -47,19 +47,10 @@
private String mPackageName;
- private boolean mCanPackageHandleAllServicesIntent;
- private boolean mIsLocationProvider;
-
-
public AppAllServicesPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
mPackageManager = context.getPackageManager();
-
- // Set to false till we can confirm that the package can handle the intent.
- mCanPackageHandleAllServicesIntent = false;
- // Set to false till we can confirm that the package is a location provider.
- mIsLocationProvider = false;
}
@Override
@@ -71,9 +62,8 @@
}
}
- @VisibleForTesting
@Nullable
- CharSequence getStorageSummary() {
+ private CharSequence getStorageSummary() {
ResolveInfo resolveInfo = getResolveInfo(PackageManager.GET_META_DATA);
if (resolveInfo == null) {
Log.d(TAG, "mResolveInfo is null.");
@@ -96,18 +86,20 @@
@Override
public int getAvailabilityStatus() {
- if (mCanPackageHandleAllServicesIntent && mIsLocationProvider) {
+ if (canPackageHandleIntent() && isLocationProvider()) {
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
}
- private boolean isLocationProvider() {
+ @VisibleForTesting
+ boolean isLocationProvider() {
return Objects.requireNonNull(
mContext.getSystemService(LocationManager.class)).isProviderPackage(mPackageName);
}
- private boolean canPackageHandleIntent() {
+ @VisibleForTesting
+ boolean canPackageHandleIntent() {
return getResolveInfo(0) != null;
}
@@ -127,14 +119,6 @@
*/
public void setPackageName(String packageName) {
mPackageName = packageName;
-
- //Once we have package name. Update conditions for availability.
- updateAvailabilityConditions();
- }
-
- private void updateAvailabilityConditions() {
- mCanPackageHandleAllServicesIntent = canPackageHandleIntent();
- mIsLocationProvider = isLocationProvider();
}
private void startAllServicesActivity() {
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 887b1c9..a41230a 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -19,6 +19,7 @@
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
+import static com.android.internal.jank.InteractionJankMonitor.CUJ_SETTINGS_PAGE_SCROLL;
import static com.android.settings.ChangeIds.CHANGE_RESTRICT_SAW_INTENT;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_BATTERY_OPTIMIZED;
@@ -86,6 +87,7 @@
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.compat.IPlatformCompat;
+import com.android.internal.jank.InteractionJankMonitor;
import com.android.settings.R;
import com.android.settings.Settings.AlarmsAndRemindersActivity;
import com.android.settings.Settings.AppBatteryUsageActivity;
@@ -521,8 +523,9 @@
mFilterAdapter.enableFilter(filterType);
if (mListType == LIST_TYPE_MAIN) {
- if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly
- && !mIsPersonalOnly) {
+ // Apply the personal and work filter only if new tab should be added
+ // for a given user profile. Else let it use the default all apps filter.
+ if (Utils.isNewTabNeeded(getActivity()) && !mIsWorkOnly && !mIsPersonalOnly) {
mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL);
mFilterAdapter.enableFilter(FILTER_APPS_WORK);
}
@@ -1241,8 +1244,10 @@
@Override
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
+ final String className =
+ mManageApplications.getClass().getName() + "_" + mManageApplications.mListType;
mRecyclerView = recyclerView;
- mOnScrollListener = new OnScrollListener(this);
+ mOnScrollListener = new OnScrollListener(this, className);
mRecyclerView.addOnScrollListener(mOnScrollListener);
}
@@ -1802,11 +1807,15 @@
private boolean mDelayNotifyDataChange;
private ApplicationsAdapter mAdapter;
private InputMethodManager mInputMethodManager;
+ private InteractionJankMonitor mMonitor;
+ private String mClassName;
- public OnScrollListener(ApplicationsAdapter adapter) {
+ public OnScrollListener(ApplicationsAdapter adapter, String className) {
mAdapter = adapter;
mInputMethodManager = mAdapter.mContext.getSystemService(
InputMethodManager.class);
+ mMonitor = InteractionJankMonitor.getInstance();
+ mClassName = className;
}
@Override
@@ -1821,6 +1830,15 @@
mInputMethodManager.hideSoftInputFromWindow(recyclerView.getWindowToken(),
0);
}
+ // Start jank monitoring during page scrolling.
+ final InteractionJankMonitor.Configuration.Builder builder =
+ InteractionJankMonitor.Configuration.Builder.withView(
+ CUJ_SETTINGS_PAGE_SCROLL, recyclerView)
+ .setTag(mClassName);
+ mMonitor.begin(builder);
+ } else if (mScrollState == SCROLL_STATE_IDLE) {
+ // Stop jank monitoring on page scrolling.
+ mMonitor.end(CUJ_SETTINGS_PAGE_SCROLL);
}
}
diff --git a/src/com/android/settings/core/SettingsUIDeviceConfig.java b/src/com/android/settings/core/SettingsUIDeviceConfig.java
index 94074df..5689067 100644
--- a/src/com/android/settings/core/SettingsUIDeviceConfig.java
+++ b/src/com/android/settings/core/SettingsUIDeviceConfig.java
@@ -42,4 +42,9 @@
* {@code true} whether or not event_log for generic actions is enabled. Default is true.
*/
public static final String GENERIC_EVENT_LOGGING_ENABLED = "event_logging_enabled";
+
+ /**
+ * {@code true} if Cloned Apps menu is available in Apps page. Default is false.
+ */
+ public static final String CLONED_APPS_ENABLED = "cloned_apps_enabled";
}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 5e3fa5e..b55b024 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -160,6 +160,7 @@
import com.android.settings.privacy.PrivacyControlsFragment;
import com.android.settings.privacy.PrivacyDashboardFragment;
import com.android.settings.security.LockscreenDashboardFragment;
+import com.android.settings.security.MemtagPage;
import com.android.settings.security.SecurityAdvancedSettings;
import com.android.settings.security.SecuritySettings;
import com.android.settings.shortcut.CreateShortcut;
@@ -328,6 +329,7 @@
EnterprisePrivacySettings.class.getName(),
WebViewAppPicker.class.getName(),
LockscreenDashboardFragment.class.getName(),
+ MemtagPage.class.getName(),
BluetoothDeviceDetailsFragment.class.getName(),
BluetoothBroadcastDialog.class.getName(),
BluetoothFindBroadcastsFragment.class.getName(),
@@ -400,5 +402,6 @@
Settings.MyDeviceInfoActivity.class.getName(),
Settings.ModuleLicensesActivity.class.getName(),
UserBackupSettingsActivity.class.getName(),
+ Settings.MemtagPageActivity.class.getName(),
};
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index 6dd59b7..124d4b4 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -198,7 +198,7 @@
@Override
public void onDestroy() {
- if (mActivity.isChangingConfigurations()) {
+ if (mActivity == null || mActivity.isChangingConfigurations()) {
BatteryDiffEntry.clearCache();
}
mHandler.removeCallbacksAndMessages(/*token=*/ null);
diff --git a/src/com/android/settings/fuelgauge/batteryusage/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/batteryusage/PowerUsageAdvanced.java
index 7b085f7..e376d85 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/PowerUsageAdvanced.java
@@ -197,7 +197,7 @@
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new BatteryAppListPreferenceController(context,
+ controllers.add(new BatteryChartPreferenceController(context,
KEY_APP_LIST, null /* lifecycle */, null /* activity */,
null /* fragment */));
return controllers;
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index 8589807..6a75fce 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -163,6 +163,7 @@
/** @OnLifecycleEvent(ON_PAUSE) */
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
+ mMobileNetworkRepository.removeRegister();
mSummaryHelper.register(false);
}
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index 61ad25d..038490f 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -33,6 +33,7 @@
import android.telephony.UiccCardInfo;
import android.telephony.UiccPortInfo;
import android.telephony.UiccSlotInfo;
+import android.util.ArrayMap;
import android.util.Log;
import com.android.settings.network.telephony.MobileNetworkUtils;
@@ -49,7 +50,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@@ -63,6 +64,7 @@
public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptionsChangedListener {
private static final String TAG = "MobileNetworkRepository";
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
@@ -92,6 +94,7 @@
private boolean mIsEuicc = false;
private boolean mIsRemovable = false;
private boolean mIsActive = false;
+ private Map<Integer, SubscriptionInfo> mSubscriptionInfoMap = new ArrayMap<>();
public static MobileNetworkRepository create(Context context,
MobileNetworkCallback mobileNetworkCallback) {
@@ -157,7 +160,6 @@
}
public void removeRegister() {
- mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
mAirplaneModeObserver.unRegister(mContext);
mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
if (mDataSubscriptionChangedReceiver != null) {
@@ -234,15 +236,16 @@
mIsActive = portInfo.isActive();
mPortIndex = portInfo.getPortIndex();
break;
- } else {
+ } else if (DEBUG) {
Log.d(TAG,
- "Can not get port index and physicalSlotIndex for subId " + mSubId);
+ "Can not get port index and physicalSlotIndex for subId "
+ + mSubId);
}
}
if (mPhysicalSlotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
break;
}
- } else {
+ } else if (DEBUG) {
Log.d(TAG, "Can not get card state info");
}
}
@@ -257,8 +260,10 @@
.filter(SubscriptionInfoEntity::isActiveSubscription)
.filter(SubscriptionInfoEntity::isSubscriptionVisible)
.collect(Collectors.toList());
- Log.d(TAG, "onAvailableSubInfoChanged, availableSubInfoEntityList = "
- + availableSubInfoEntityList);
+ if (DEBUG) {
+ Log.d(TAG, "onAvailableSubInfoChanged, availableSubInfoEntityList = "
+ + availableSubInfoEntityList);
+ }
mCallback.onAvailableSubInfoChanged(availableSubInfoEntityList);
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_MOBILE_NETWORK_DB_NOTIFY_SUB_INFO_IS_CHANGED);
@@ -267,7 +272,10 @@
private void setActiveSubInfoList(
List<SubscriptionInfoEntity> activeSubInfoEntityList) {
- Log.d(TAG, "onActiveSubInfoChanged, activeSubInfoEntityList = " + activeSubInfoEntityList);
+ if (DEBUG) {
+ Log.d(TAG,
+ "onActiveSubInfoChanged, activeSubInfoEntityList = " + activeSubInfoEntityList);
+ }
mCallback.onActiveSubInfoChanged(mActiveSubInfoEntityList);
}
@@ -291,10 +299,11 @@
SubscriptionInfoEntity subInfoEntity =
convertToSubscriptionInfoEntity(context, info);
if (subInfoEntity != null) {
+ mSubscriptionInfoMap.put(info.getSubscriptionId(), info);
mMobileNetworkDatabase.insertSubsInfo(subInfoEntity);
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_MOBILE_NETWORK_DB_INSERT_SUB_INFO);
- } else {
+ } else if (DEBUG) {
Log.d(TAG, "Can not insert subInfo, the entity is null");
}
});
@@ -322,7 +331,9 @@
UiccSlotInfo[] uiccSlotInfos = mTelephonyManager.getUiccSlotsInfo();
if (uiccSlotInfos == null || uiccSlotInfos.length == 0) {
- Log.d(TAG, "uiccSlotInfos = null or empty");
+ if (DEBUG) {
+ Log.d(TAG, "uiccSlotInfos = null or empty");
+ }
return null;
} else {
getUiccInfoBySubscriptionInfo(uiccSlotInfos, subInfo);
@@ -332,7 +343,9 @@
context);
SubscriptionInfo subscriptionOrDefault = SubscriptionUtil.getSubscriptionOrDefault(
context, mSubId);
- Log.d(TAG, "convert subscriptionInfo to entity for subId = " + mSubId);
+ if(DEBUG){
+ Log.d(TAG, "convert subscriptionInfo to entity for subId = " + mSubId);
+ }
return new SubscriptionInfoEntity(String.valueOf(mSubId),
subInfo.getSimSlotIndex(),
subInfo.getCarrierId(), subInfo.getDisplayName().toString(),
@@ -399,7 +412,9 @@
private boolean isMultipleEnabledProfilesSupported() {
List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo();
if (cardInfos == null) {
- Log.w(TAG, "UICC card info list is empty.");
+ if (DEBUG) {
+ Log.d(TAG, "UICC card info list is empty.");
+ }
return false;
}
return cardInfos.stream().anyMatch(
@@ -414,28 +429,27 @@
private void insertAvailableSubInfoToEntity(List<SubscriptionInfo> availableInfoList) {
if ((availableInfoList == null || availableInfoList.size() == 0)
&& mAvailableSubInfoEntityList.size() != 0) {
- Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs");
+ if (DEBUG) {
+ Log.d(TAG, "availableSudInfoList from framework is empty, remove all subs");
+ }
for (SubscriptionInfoEntity info : mAvailableSubInfoEntityList) {
deleteAllInfoBySubId(info.subId);
}
} else if (availableInfoList != null) {
for (SubscriptionInfo subInfo : availableInfoList) {
- if (availableInfoList.size() < mAvailableSubInfoEntityList.size()) {
- Optional<SubscriptionInfoEntity> infoEntity =
- mAvailableSubInfoEntityList.stream().filter(
- info -> subInfo.getSubscriptionId()
- != Integer.parseInt(info.subId)).findFirst();
-
- if (infoEntity.isPresent()) {
- Log.d(TAG, "delete sudInfo " + infoEntity.get().subId
- + " from subInfoEntity");
- deleteAllInfoBySubId(infoEntity.get().subId);
- }
+ mSubscriptionInfoMap.remove(subInfo.getSubscriptionId());
+ if (DEBUG) {
+ Log.d(TAG,
+ "insert sudInfo " + subInfo.getSubscriptionId() + " to subInfoEntity");
}
-
- Log.d(TAG, "insert sudInfo " + subInfo.getSubscriptionId() + " to subInfoEntity");
insertSubInfo(mContext, subInfo);
}
+
+ if (!mSubscriptionInfoMap.isEmpty()) {
+ mSubscriptionInfoMap.forEach((key, value) -> {
+ deleteAllInfoBySubId(String.valueOf(key));
+ });
+ }
}
}
diff --git a/src/com/android/settings/network/MobileNetworkSummaryController.java b/src/com/android/settings/network/MobileNetworkSummaryController.java
index ab74988..a3799a2 100644
--- a/src/com/android/settings/network/MobileNetworkSummaryController.java
+++ b/src/com/android/settings/network/MobileNetworkSummaryController.java
@@ -101,6 +101,7 @@
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
+ mMobileNetworkRepository.removeRegister();
}
@Override
diff --git a/src/com/android/settings/network/NetworkProviderCallsSmsController.java b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
index 4abd2a2..95f8a25 100644
--- a/src/com/android/settings/network/NetworkProviderCallsSmsController.java
+++ b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
@@ -85,6 +85,7 @@
@OnLifecycleEvent(Event.ON_PAUSE)
public void onPause() {
+ mMobileNetworkRepository.removeRegister();
}
@Override
diff --git a/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java b/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
index fb861d8..abde7c0 100644
--- a/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderDownloadedSimListController.java
@@ -84,6 +84,7 @@
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
+ mMobileNetworkRepository.removeRegister();
}
@Override
diff --git a/src/com/android/settings/network/NetworkProviderSimListController.java b/src/com/android/settings/network/NetworkProviderSimListController.java
index e4ea392..478d97b 100644
--- a/src/com/android/settings/network/NetworkProviderSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderSimListController.java
@@ -80,6 +80,7 @@
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
+ mMobileNetworkRepository.removeRegister();
}
@Override
diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
index 6fa803d..4160299 100644
--- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
+++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java
@@ -379,7 +379,7 @@
DIALOG_TAG_DISABLE_SIM_CONFIRMATION,
title,
null,
- getString(R.string.yes),
+ getString(R.string.condition_turn_off),
getString(R.string.sim_action_cancel));
}
@@ -444,7 +444,7 @@
DIALOG_TAG_ENABLE_SIM_CONFIRMATION,
getEnableSubscriptionTitle(),
null /* msg */,
- getString(R.string.yes),
+ getString(R.string.condition_turn_on),
getString(R.string.sim_action_cancel));
}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 5f9f2fe..4b4813f 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -1489,7 +1489,7 @@
private void updateAddUserCommon(Context context, RestrictedPreference addUser,
boolean canAddRestrictedProfile) {
- if ((mUserCaps.mCanAddUser || !mUserCaps.mDisallowAddUserSetByAdmin)
+ if ((mUserCaps.mCanAddUser && !mUserCaps.mDisallowAddUserSetByAdmin)
&& WizardManagerHelper.isDeviceProvisioned(context)
&& mUserCaps.mUserSwitcherEnabled) {
addUser.setVisible(true);
diff --git a/tests/robotests/src/com/android/settings/applications/ClonedAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/ClonedAppsPreferenceControllerTest.java
new file mode 100644
index 0000000..9e30d60
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/ClonedAppsPreferenceControllerTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.applications;
+
+import static android.provider.DeviceConfig.NAMESPACE_SETTINGS_UI;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.SettingsUIDeviceConfig;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class ClonedAppsPreferenceControllerTest {
+
+ private ClonedAppsPreferenceController mController;
+ private static final String KEY = "key";
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ mController = new ClonedAppsPreferenceController(mContext, KEY);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureNotEnabled_shouldNotReturnAvailable() {
+ DeviceConfig.setProperty(NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.CLONED_APPS_ENABLED,
+ "false", true /* makeDefault */);
+
+ assertThat(mController.getAvailabilityStatus()).isNotEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureEnabled_shouldReturnAvailable() {
+ DeviceConfig.setProperty(NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.CLONED_APPS_ENABLED,
+ "true", true /* makeDefault */);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceControllerTest.java
new file mode 100644
index 0000000..c089c9e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppAllServicesPreferenceControllerTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.applications.appinfo;
+
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public class AppAllServicesPreferenceControllerTest {
+
+ @Mock
+ private AppInfoDashboardFragment mFragment;
+ @Mock
+ private Preference mPreference;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private AppAllServicesPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = spy(new AppAllServicesPreferenceController(mContext, "test_key"));
+ mController.setParentFragment(mFragment);
+ mController.setPackageName("Package1");
+ final String key = mController.getPreferenceKey();
+ when(mPreference.getKey()).thenReturn(key);
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldReturnAvailable() {
+ doReturn(true).when(mController).canPackageHandleIntent();
+ doReturn(true).when(mController).isLocationProvider();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_canNotHandleIntent_shouldReturnConditionallyUnavailable() {
+ doReturn(false).when(mController).canPackageHandleIntent();
+ doReturn(true).when(mController).isLocationProvider();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_isNotLocationProvider_shouldReturnConditionallyUnavailable() {
+ doReturn(true).when(mController).canPackageHandleIntent();
+ doReturn(false).when(mController).isLocationProvider();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_shouldReturnConditionallyUnavailable() {
+ doReturn(false).when(mController).canPackageHandleIntent();
+ doReturn(false).when(mController).isLocationProvider();
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void canPackageHandleIntent_nullPackageInfo_shouldNotCrash() {
+ mController.setPackageName(null);
+ mController.canPackageHandleIntent();
+ // no crash
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index da17f11..910fbed 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -60,6 +60,7 @@
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import com.android.settingslib.applications.ApplicationsState.AppFilter;
+import com.android.settingslib.testutils.shadow.ShadowInteractionJankMonitor;
import org.junit.Before;
import org.junit.Test;
@@ -75,7 +76,8 @@
import java.util.ArrayList;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowUserManager.class, ShadowAppUtils.class})
+@Config(shadows = {ShadowUserManager.class, ShadowAppUtils.class,
+ ShadowInteractionJankMonitor.class})
public class ManageApplicationsTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
index 54f579c..8002582 100644
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -417,12 +417,12 @@
}
@Test
- public void updateUserList_cannotAddUserButCanSwitchUser_shouldShowDisabledAddUser() {
+ public void updateUserList_cannotAddUserButCanSwitchUser_shouldNotShowAddUser() {
mUserCapabilities.mCanAddUser = false;
mFragment.updateUserList();
- verify(mAddUserPreference).setEnabled(false);
+ verify(mAddUserPreference).setVisible(false);
}
@Test