Merge "[Settings] Remove the unexisted subinfo from map"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7200c80..8c05051 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3500,6 +3500,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..342ab70 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -312,6 +312,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/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 887b1c9..fe7f996 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -521,8 +521,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);
}
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/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/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/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);
+ }
+
+}