Merge "Filter out SecuritySettings search results when alternative available." into sc-dev
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e8670f9..d9a55e6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -145,7 +145,6 @@
<item name="android:layout_marginStart">4dip</item>
<item name="android:textAlignment">viewStart</item>
<item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
- <item name="android:textColorHint">?android:attr/textColorSecondary</item>
<item name="android:minHeight">@dimen/min_tap_target_size</item>
</style>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index af44276..555a045 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -32,6 +32,7 @@
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:datePickerDialogTheme">@style/PickerDialogTheme.Settings</item>
<item name="android:progressBarStyleHorizontal">@style/HorizontalProgressBarStyle</item>
+ <item name="android:textColorHint">?android:attr/textColorSecondary</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="face_layout_theme">@style/FaceLayoutTheme</item>
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 725390e..6d73ad6 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -21,140 +21,157 @@
android:key="top_level_settings">
<Preference
+ android:fragment="com.android.settings.network.NetworkDashboardFragment"
+ android:icon="@drawable/ic_settings_wireless"
android:key="top_level_network"
+ android:order="-150"
android:title="@string/network_dashboard_title"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_network"
- android:order="-120"
- android:fragment="com.android.settings.network.NetworkDashboardFragment"
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
<Preference
+ android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
+ android:icon="@drawable/ic_devices_other"
android:key="top_level_connected_devices"
+ android:order="-140"
android:title="@string/connected_devices_dashboard_title"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_connected_device"
- android:order="-110"
- android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
<Preference
- android:key="top_level_apps_and_notifs"
- android:title="@string/app_and_notification_dashboard_title"
- android:summary="@string/app_and_notification_dashboard_summary"
- android:icon="@drawable/ic_homepage_apps"
- android:order="-100"
- android:fragment="com.android.settings.applications.AppAndNotificationDashboardFragment"/>
+ android:fragment="com.android.settings.applications.AppDashboardFragment"
+ android:icon="@drawable/ic_apps"
+ android:key="top_level_apps"
+ android:order="-130"
+ android:title="@string/apps_dashboard_title"
+ android:summary="@string/app_and_notification_dashboard_summary"/>
<Preference
+ android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
+ android:icon="@drawable/ic_notifications"
+ android:key="top_level_notification"
+ android:order="-120"
+ android:title="@string/configure_notification_settings"
+ android:summary="@string/notification_dashboard_summary"/>
+
+ <Preference
+ android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
+ android:icon="@drawable/ic_settings_battery_white"
android:key="top_level_battery"
+ android:order="-110"
android:title="@string/power_usage_summary_title"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_battery"
- android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
- android:order="-90"
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
<Preference
- android:key="top_level_display"
- android:title="@string/display_settings"
- android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_display"
- android:order="-80"
- android:fragment="com.android.settings.DisplaySettings"
- settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
-
- <Preference
- android:key="top_level_sound"
- android:title="@string/sound_settings"
- android:summary="@string/sound_dashboard_summary"
- android:icon="@drawable/ic_homepage_sound"
- android:order="-70"
- android:fragment="com.android.settings.notification.SoundSettings"/>
-
- <Preference
+ android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
+ android:icon="@drawable/ic_storage_white"
android:key="top_level_storage"
+ android:order="-100"
android:title="@string/storage_settings"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_storage"
- android:order="-60"
- android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
<Preference
- android:key="top_level_privacy"
- android:title="@string/privacy_dashboard_title"
- android:summary="@string/privacy_dashboard_summary"
- android:icon="@drawable/ic_homepage_privacy"
- android:order="-55"
- android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"/>
+ android:fragment="com.android.settings.notification.SoundSettings"
+ android:icon="@drawable/ic_volume_up_24dp"
+ android:key="top_level_sound"
+ android:order="-90"
+ android:title="@string/sound_settings"
+ android:summary="@string/sound_dashboard_summary"/>
<Preference
- android:key="top_level_location"
- android:title="@string/location_settings_title"
- android:summary="@string/location_settings_loading_app_permission_stats"
- android:icon="@drawable/ic_homepage_location"
- android:order="-50"
- android:fragment="com.android.settings.location.LocationSettings"
- settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
+ android:fragment="com.android.settings.DisplaySettings"
+ android:icon="@drawable/ic_settings_display_white"
+ android:key="top_level_display"
+ android:order="-80"
+ android:title="@string/display_settings"
+ android:summary="@string/display_dashboard_summary"
+ settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
+
+ <com.android.settingslib.RestrictedTopLevelPreference
+ android:icon="@drawable/ic_settings_wallpaper_white"
+ android:key="top_level_wallpaper"
+ android:order="-70"
+ android:title="@string/wallpaper_settings_title"
+ android:summary="@string/wallpaper_dashboard_summary"
+ settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
<Preference
- android:key="top_level_security"
- android:title="@string/security_settings_title"
- android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_security"
- android:order="-40"
+ android:fragment="com.android.settings.accessibility.AccessibilitySettings"
+ android:icon="@drawable/ic_settings_accessibility"
+ android:key="top_level_accessibility"
+ android:order="-60"
+ android:title="@string/accessibility_settings"
+ android:summary="@string/accessibility_settings_summary"
+ settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
+
+ <Preference
android:fragment="com.android.settings.security.SecuritySettings"
+ android:icon="@drawable/ic_settings_security_white"
+ android:key="top_level_security"
+ android:order="-50"
+ android:title="@string/security_settings_title"
+ android:summary="@string/security_dashboard_summary"
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
<Preference
- android:key="top_level_accounts"
- android:title="@string/account_dashboard_title"
- android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_accounts"
- android:order="-30"
- android:fragment="com.android.settings.accounts.AccountDashboardFragment"
- settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
+ android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
+ android:icon="@drawable/ic_settings_privacy"
+ android:key="top_level_privacy"
+ android:order="-40"
+ android:title="@string/privacy_dashboard_title"
+ android:summary="@string/privacy_dashboard_summary"/>
<Preference
- android:key="top_level_accessibility"
- android:title="@string/accessibility_settings"
- android:summary="@string/accessibility_settings_summary"
- android:icon="@drawable/ic_homepage_accessibility"
- android:order="-20"
- android:fragment="com.android.settings.accessibility.AccessibilitySettings"
- settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
+ android:fragment="com.android.settings.location.LocationSettings"
+ android:icon="@drawable/ic_settings_location"
+ android:key="top_level_location"
+ android:order="-30"
+ android:title="@string/location_settings_title"
+ android:summary="@string/location_settings_loading_app_permission_stats"
+ settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
<Preference
android:key="top_level_emergency"
android:title="@string/emergency_settings_preference_title"
- android:icon="@drawable/ic_homepage_emergency"
- android:order="-10"
+ android:summary="@string/emergency_dashboard_summary"
+ android:icon="@drawable/ic_settings_emergency"
+ android:order="-20"
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
<Preference
- android:key="top_level_system"
- android:title="@string/header_category_system"
- android:summary="@string/system_dashboard_summary"
- android:icon="@drawable/ic_homepage_system_dashboard"
- android:order="10"
- android:fragment="com.android.settings.system.SystemDashboardFragment"/>
+ android:fragment="com.android.settings.accounts.AccountDashboardFragment"
+ android:icon="@drawable/ic_settings_accounts"
+ android:key="top_level_accounts"
+ android:order="-10"
+ android:title="@string/account_dashboard_title"
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
<Preference
+ android:fragment="com.android.settings.system.SystemDashboardFragment"
+ android:icon="@drawable/ic_settings_system_dashboard_white"
+ android:key="top_level_system"
+ android:order="10"
+ android:title="@string/header_category_system"
+ android:summary="@string/system_dashboard_summary"/>
+
+ <Preference
+ android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
+ android:icon="@drawable/ic_phone_info"
android:key="top_level_about_device"
+ android:order="20"
android:title="@string/about_settings"
android:summary="@string/summary_placeholder"
- android:icon="@drawable/ic_homepage_about"
- android:order="20"
- android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
<Preference
+ android:icon="@drawable/ic_help"
android:key="top_level_support"
- android:summary="@string/support_summary"
- android:title="@string/page_tab_title_support"
- android:icon="@drawable/ic_homepage_support"
android:order="100"
+ android:title="@string/page_tab_title_support"
+ android:summary="@string/support_summary"
settings:controller="com.android.settings.support.SupportPreferenceController"/>
</PreferenceScreen>
diff --git a/res/xml/top_level_settings_grouped.xml b/res/xml/top_level_settings_grouped.xml
deleted file mode 100644
index 7b4f8a1..0000000
--- a/res/xml/top_level_settings_grouped.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="top_level_settings_grouped">
-
- <Preference
- android:fragment="com.android.settings.network.NetworkDashboardFragment"
- android:icon="@drawable/ic_settings_wireless"
- android:key="top_level_network"
- android:order="-150"
- android:title="@string/network_dashboard_title"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
- android:icon="@drawable/ic_devices_other"
- android:key="top_level_connected_devices"
- android:order="-140"
- android:title="@string/connected_devices_dashboard_title"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.applications.AppDashboardFragment"
- android:icon="@drawable/ic_apps"
- android:key="top_level_apps"
- android:order="-130"
- android:title="@string/apps_dashboard_title"
- android:summary="@string/app_and_notification_dashboard_summary"/>
-
- <Preference
- android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
- android:icon="@drawable/ic_notifications"
- android:key="top_level_notification"
- android:order="-120"
- android:title="@string/configure_notification_settings"
- android:summary="@string/notification_dashboard_summary"/>
-
- <Preference
- android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
- android:icon="@drawable/ic_settings_battery_white"
- android:key="top_level_battery"
- android:order="-110"
- android:title="@string/power_usage_summary_title"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
- android:icon="@drawable/ic_storage_white"
- android:key="top_level_storage"
- android:order="-100"
- android:title="@string/storage_settings"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.notification.SoundSettings"
- android:icon="@drawable/ic_volume_up_24dp"
- android:key="top_level_sound"
- android:order="-90"
- android:title="@string/sound_settings"
- android:summary="@string/sound_dashboard_summary"/>
-
- <Preference
- android:fragment="com.android.settings.DisplaySettings"
- android:icon="@drawable/ic_settings_display_white"
- android:key="top_level_display"
- android:order="-80"
- android:title="@string/display_settings"
- android:summary="@string/display_dashboard_summary"
- settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
-
- <com.android.settingslib.RestrictedTopLevelPreference
- android:icon="@drawable/ic_settings_wallpaper_white"
- android:key="top_level_wallpaper"
- android:order="-70"
- android:title="@string/wallpaper_settings_title"
- android:summary="@string/wallpaper_dashboard_summary"
- settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.accessibility.AccessibilitySettings"
- android:icon="@drawable/ic_settings_accessibility"
- android:key="top_level_accessibility"
- android:order="-60"
- android:title="@string/accessibility_settings"
- android:summary="@string/accessibility_settings_summary"
- settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.security.SecuritySettings"
- android:icon="@drawable/ic_settings_security_white"
- android:key="top_level_security"
- android:order="-50"
- android:title="@string/security_settings_title"
- android:summary="@string/security_dashboard_summary"
- settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
- android:icon="@drawable/ic_settings_privacy"
- android:key="top_level_privacy"
- android:order="-40"
- android:title="@string/privacy_dashboard_title"
- android:summary="@string/privacy_dashboard_summary"/>
-
- <Preference
- android:fragment="com.android.settings.location.LocationSettings"
- android:icon="@drawable/ic_settings_location"
- android:key="top_level_location"
- android:order="-30"
- android:title="@string/location_settings_title"
- android:summary="@string/location_settings_loading_app_permission_stats"
- settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
-
- <Preference
- android:key="top_level_emergency"
- android:title="@string/emergency_settings_preference_title"
- android:summary="@string/emergency_dashboard_summary"
- android:icon="@drawable/ic_settings_emergency"
- android:order="-20"
- android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
-
- <Preference
- android:fragment="com.android.settings.accounts.AccountDashboardFragment"
- android:icon="@drawable/ic_settings_accounts"
- android:key="top_level_accounts"
- android:order="-10"
- android:title="@string/account_dashboard_title"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
-
- <Preference
- android:fragment="com.android.settings.system.SystemDashboardFragment"
- android:icon="@drawable/ic_settings_system_dashboard_white"
- android:key="top_level_system"
- android:order="10"
- android:title="@string/header_category_system"
- android:summary="@string/system_dashboard_summary"/>
-
- <Preference
- android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
- android:icon="@drawable/ic_phone_info"
- android:key="top_level_about_device"
- android:order="20"
- android:title="@string/about_settings"
- android:summary="@string/summary_placeholder"
- settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
-
- <Preference
- android:icon="@drawable/ic_help"
- android:key="top_level_support"
- android:order="100"
- android:title="@string/page_tab_title_support"
- android:summary="@string/support_summary"
- settings:controller="com.android.settings.support.SupportPreferenceController"/>
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
index 0f90c69..5f7e56f 100644
--- a/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
+++ b/src/com/android/settings/applications/appinfo/DrawOverlayDetails.java
@@ -158,6 +158,10 @@
}
public static CharSequence getSummary(Context context, AppEntry entry) {
+ if (entry == null) {
+ return "";
+ }
+
OverlayState state;
if (entry.extraInfo instanceof OverlayState) {
state = (OverlayState) entry.extraInfo;
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 5a686c2..0de86f5 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -47,7 +47,6 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Pair;
import android.widget.Toast;
@@ -60,7 +59,6 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.PrimarySwitchPreference;
@@ -399,8 +397,7 @@
private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon,
String iconPackage, Icon icon) {
Drawable iconDrawable = icon.loadDrawable(preference.getContext());
- if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
- && TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
+ if (TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext()));
} else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
iconDrawable = new AdaptiveIcon(mContext, iconDrawable,
diff --git a/src/com/android/settings/display/SmartAutoRotateController.java b/src/com/android/settings/display/SmartAutoRotateController.java
index 90b0d55..61bbd18 100644
--- a/src/com/android/settings/display/SmartAutoRotateController.java
+++ b/src/com/android/settings/display/SmartAutoRotateController.java
@@ -18,6 +18,9 @@
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
import static android.provider.Settings.Secure.CAMERA_AUTOROTATE;
+import static androidx.lifecycle.Lifecycle.Event.ON_START;
+import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
+
import android.Manifest;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
@@ -32,7 +35,9 @@
import android.service.rotationresolver.RotationResolverService;
import android.text.TextUtils;
+import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -41,14 +46,12 @@
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import com.android.settingslib.core.lifecycle.events.OnStart;
-import com.android.settingslib.core.lifecycle.events.OnStop;
/**
* SmartAutoRotateController controls whether auto rotation is enabled
*/
public class SmartAutoRotateController extends TogglePreferenceController implements
- Preference.OnPreferenceChangeListener, LifecycleObserver, OnStart, OnStop {
+ Preference.OnPreferenceChangeListener, LifecycleObserver {
private final MetricsFeatureProvider mMetricsFeatureProvider;
private final SensorPrivacyManager mPrivacyManager;
@@ -60,6 +63,7 @@
}
};
private Preference mPreference;
+ private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
public SmartAutoRotateController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -70,6 +74,10 @@
mPowerManager = context.getSystemService(PowerManager.class);
}
+ public void init(Lifecycle lifecycle) {
+ lifecycle.addObserver(this);
+ }
+
@Override
public int getAvailabilityStatus() {
if (!isRotationResolverServiceAvailable(mContext)) {
@@ -101,22 +109,36 @@
return mPowerManager.isPowerSaveMode();
}
- @Override
+ @OnLifecycleEvent(ON_START)
public void onStart() {
mContext.registerReceiver(mReceiver,
new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ if (mRotationPolicyListener == null) {
+ mRotationPolicyListener = new RotationPolicy.RotationPolicyListener() {
+ @Override
+ public void onChange() {
+ updateState(mPreference);
+ }
+ };
+ }
+ RotationPolicy.registerRotationPolicyListener(mContext, mRotationPolicyListener);
}
- @Override
+ @OnLifecycleEvent(ON_STOP)
public void onStop() {
mContext.unregisterReceiver(mReceiver);
+ if (mRotationPolicyListener != null) {
+ RotationPolicy.unregisterRotationPolicyListener(mContext, mRotationPolicyListener);
+ mRotationPolicyListener = null;
+ }
}
@Override
public boolean isChecked() {
- return hasSufficientPermission(mContext) && !isCameraLocked() && !isPowerSaveMode()
- && Settings.Secure.getInt(mContext.getContentResolver(),
- CAMERA_AUTOROTATE, 0) == 1;
+ return !RotationPolicy.isRotationLocked(mContext) && hasSufficientPermission(mContext)
+ && !isCameraLocked() && !isPowerSaveMode() && Settings.Secure.getInt(
+ mContext.getContentResolver(),
+ CAMERA_AUTOROTATE, 0) == 1;
}
@Override
diff --git a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
index f697a8c..d56b21e 100644
--- a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
+++ b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
@@ -15,13 +15,11 @@
*/
package com.android.settings.display;
-import static com.android.settings.display.SmartAutoRotateController.hasSufficientPermission;
import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable;
import android.app.settings.SettingsEnums;
-import android.hardware.SensorPrivacyManager;
+import android.content.Context;
import android.os.Bundle;
-import android.os.PowerManager;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
@@ -49,10 +47,7 @@
private static final String TAG = "SmartAutoRotatePreferenceFragment";
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
- private SensorPrivacyManager mPrivacyManager;
private AutoRotateSwitchBarController mSwitchBarController;
- private PowerManager mPowerManager;
- private static final String FACE_SWITCH_PREFERENCE_ID = "face_based_rotate";
@Override
protected int getPreferenceScreenResId() {
@@ -60,6 +55,12 @@
}
@Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ use(SmartAutoRotateController.class).init(getLifecycle());
+ }
+
+ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
@@ -70,8 +71,6 @@
switchBar.show();
mSwitchBarController = new AutoRotateSwitchBarController(activity, switchBar,
getSettingsLifecycle());
- mPrivacyManager = SensorPrivacyManager.getInstance(activity);
- mPowerManager = getSystemService(PowerManager.class);
final Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
if (footerPreference != null) {
footerPreference.setTitle(Html.fromHtml(getString(R.string.smart_rotate_text_headline),
@@ -89,14 +88,6 @@
@Override
public void onChange() {
mSwitchBarController.onChange();
- final boolean isLocked = RotationPolicy.isRotationLocked(getContext());
- final boolean isCameraLocked = mPrivacyManager.isSensorPrivacyEnabled(
- SensorPrivacyManager.Sensors.CAMERA);
- final boolean isBatterySaver = mPowerManager.isPowerSaveMode();
- final Preference preference = findPreference(FACE_SWITCH_PREFERENCE_ID);
- if (preference != null && hasSufficientPermission(getContext())) {
- preference.setEnabled(!isLocked && !isCameraLocked && !isBatterySaver);
- }
}
};
}
diff --git a/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
index c435f8f..7486f22 100644
--- a/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryChartPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.fuelgauge;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
@@ -35,7 +36,9 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnCreate;
@@ -88,9 +91,10 @@
private final String mPreferenceKey;
private final SettingsActivity mActivity;
private final InstrumentedPreferenceFragment mFragment;
- private final Handler mHandler = new Handler(Looper.getMainLooper());
- private final CharSequence[] mNotAllowShowSummaryPackages;
private final CharSequence[] mNotAllowShowEntryPackages;
+ private final CharSequence[] mNotAllowShowSummaryPackages;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
+ private final Handler mHandler = new Handler(Looper.getMainLooper());
// Preference cache to avoid create new instance each time.
@VisibleForTesting
@@ -110,6 +114,8 @@
.getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
mNotAllowShowEntryPackages = context.getResources()
.getTextArray(R.array.allowlist_hide_entry_in_battery_usage);
+ mMetricsFeatureProvider =
+ FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
if (lifecycle != null) {
lifecycle.addObserver(this);
}
@@ -126,6 +132,7 @@
savedInstanceState.getBoolean(KEY_EXPAND_SYSTEM_INFO, mIsExpanded);
Log.d(TAG, String.format("onCreate() slotIndex=%d isExpanded=%b",
mTrapezoidIndex, mIsExpanded));
+ mMetricsFeatureProvider.action(mPrefContext, SettingsEnums.OPEN_BATTERY_USAGE);
}
@Override
@@ -190,15 +197,22 @@
final BatteryDiffEntry diffEntry = powerPref.getBatteryDiffEntry();
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
final String packageName = histEntry.mPackageName;
+ final boolean isAppEntry = histEntry.isAppEntry();
// Checks whether the package is installed or not.
boolean isValidPackage = true;
- if (histEntry.isAppEntry()) {
+ if (isAppEntry) {
if (mBatteryUtils == null) {
mBatteryUtils = BatteryUtils.getInstance(mPrefContext);
}
isValidPackage = mBatteryUtils.getPackageUid(packageName)
!= BatteryUtils.UID_NULL;
}
+ mMetricsFeatureProvider.action(
+ mPrefContext,
+ isAppEntry
+ ? SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM
+ : SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM,
+ packageName);
Log.d(TAG, String.format("handleClick() label=%s key=%s isValid:%b\n%s",
diffEntry.getAppLabel(), histEntry.getKey(), isValidPackage, histEntry));
if (isValidPackage) {
@@ -214,11 +228,20 @@
public void onSelect(int trapezoidIndex) {
Log.d(TAG, "onChartSelect:" + trapezoidIndex);
refreshUi(trapezoidIndex, /*isForce=*/ false);
+ mMetricsFeatureProvider.action(
+ mPrefContext,
+ trapezoidIndex == BatteryChartView.SELECTED_INDEX_ALL
+ ? SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL
+ : SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
}
@Override
public void onExpand(boolean isExpanded) {
mIsExpanded = isExpanded;
+ mMetricsFeatureProvider.action(
+ mPrefContext,
+ SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
+ isExpanded);
refreshExpandUi();
}
@@ -591,6 +614,27 @@
return true;
}
+ static List<BatteryDiffEntry> getBatteryLast24HrUsageData(Context context) {
+ final long start = System.currentTimeMillis();
+ final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap =
+ FeatureFactory.getFactory(context)
+ .getPowerUsageFeatureProvider(context)
+ .getBatteryHistory(context);
+ if (batteryHistoryMap == null || batteryHistoryMap.isEmpty()) {
+ return null;
+ }
+ Log.d(TAG, String.format("getBatteryLast24HrData() size=%d time=&d/ms",
+ batteryHistoryMap.size(), (System.currentTimeMillis() - start)));
+ final Map<Integer, List<BatteryDiffEntry>> batteryIndexedMap =
+ ConvertUtils.getIndexedUsageMap(
+ context,
+ /*timeSlotSize=*/ CHART_LEVEL_ARRAY_SIZE - 1,
+ getBatteryHistoryKeys(batteryHistoryMap),
+ batteryHistoryMap,
+ /*purgeLowPercentageAndFakeData=*/ true);
+ return batteryIndexedMap.get(BatteryChartView.SELECTED_INDEX_ALL);
+ }
+
private static long[] getBatteryHistoryKeys(
final Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap) {
final List<Long> batteryHistoryKeyList =
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index c59b805..5950e4b 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -96,12 +96,7 @@
getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
}
- if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)) {
- showSuggestionFragment();
- } else {
- findViewById(R.id.homepage_title).setVisibility(View.GONE);
- avatarView.setVisibility(View.GONE);
- }
+ showSuggestionFragment();
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index f4f7f61..681ea51 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -23,8 +23,6 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.provider.SearchIndexableResource;
-import android.util.FeatureFlagUtils;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
@@ -33,7 +31,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -41,9 +38,6 @@
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.search.SearchIndexable;
-import java.util.Arrays;
-import java.util.List;
-
@SearchIndexable(forTarget = MOBILE)
public class TopLevelSettings extends DashboardFragment implements
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
@@ -59,9 +53,6 @@
@Override
protected int getPreferenceScreenResId() {
- if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- return R.xml.top_level_settings_grouped;
- }
return R.xml.top_level_settings;
}
@@ -108,9 +99,6 @@
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
- if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
- return;
- }
final PreferenceScreen screen = getPreferenceScreen();
if (screen == null) {
return;
@@ -137,16 +125,7 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
-
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME)
- ? R.xml.top_level_settings_grouped : R.xml.top_level_settings;
- return Arrays.asList(sir);
- }
+ new BaseSearchIndexProvider(R.xml.top_level_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index bbe36d1..2c80668 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -306,12 +306,6 @@
super.onDestroy();
}
- @Override
- public boolean onNavigateUp() {
- finish();
- return true;
- }
-
private @ColorInt int obtainThemeColor(@AttrRes int attrRes) {
Resources.Theme theme = new ContextThemeWrapper(this,
android.R.style.Theme_DeviceDefault_DayNight).getTheme();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
index 3c371a0..4371472 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
@@ -26,6 +26,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.ContentValues;
import android.content.pm.PackageManager;
@@ -43,6 +44,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import org.junit.Before;
import org.junit.Test;
@@ -82,12 +84,16 @@
@Mock private Resources mResources;
private Context mContext;
+ private FakeFeatureFactory mFeatureFactory;
private BatteryDiffEntry mBatteryDiffEntry;
+ private MetricsFeatureProvider mMetricsFeatureProvider;
private BatteryChartPreferenceController mBatteryChartPreferenceController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
mContext = spy(RuntimeEnvironment.application);
mBatteryChartPreferenceController = createController();
mBatteryChartPreferenceController.mPrefContext = mContext;
@@ -331,9 +337,14 @@
}
@Test
- public void testHandlePreferenceTreeClick_notPowerGaugePreference_returnFalse() {
+ public void testHandlePreferenceTreeiClick_notPowerGaugePreference_returnFalse() {
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(mAppListGroup))
.isFalse();
+
+ verify(mMetricsFeatureProvider, never())
+ .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM);
+ verify(mMetricsFeatureProvider, never())
+ .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM);
}
@Test
@@ -343,6 +354,11 @@
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(
mPowerGaugePreference)).isTrue();
+ verify(mMetricsFeatureProvider)
+ .action(
+ mContext,
+ SettingsEnums.ACTION_BATTERY_USAGE_SYSTEM_ITEM,
+ mBatteryHistEntry.mPackageName);
}
@Test
@@ -355,6 +371,11 @@
assertThat(mBatteryChartPreferenceController.handlePreferenceTreeClick(
mPowerGaugePreference)).isFalse();
+ verify(mMetricsFeatureProvider)
+ .action(
+ mContext,
+ SettingsEnums.ACTION_BATTERY_USAGE_APP_ITEM,
+ mBatteryHistEntry.mPackageName);
}
@Test
@@ -474,6 +495,11 @@
verify(mAppListGroup).addPreference(captor.capture());
// Verifies the added preference.
assertThat(captor.getValue().getKey()).isEqualTo(PREF_KEY);
+ verify(mMetricsFeatureProvider)
+ .action(
+ mContext,
+ SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
+ true /*isExpanded*/);
}
@Test
@@ -489,6 +515,28 @@
verify(mAppListGroup).findPreference(PREF_KEY);
verify(mAppListGroup).removePreference(mPowerGaugePreference);
assertThat(mBatteryChartPreferenceController.mPreferenceCache).hasSize(1);
+ verify(mMetricsFeatureProvider)
+ .action(
+ mContext,
+ SettingsEnums.ACTION_BATTERY_USAGE_EXPAND_ITEM,
+ false /*isExpanded*/);
+ }
+
+ @Test
+ public void testOnSelect_selectSpecificTimeSlot_logMetric() {
+ mBatteryChartPreferenceController.onSelect(1 /*slot index*/);
+
+ verify(mMetricsFeatureProvider)
+ .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_TIME_SLOT);
+ }
+
+ @Test
+ public void testOnSelect_selectAll_logMetric() {
+ mBatteryChartPreferenceController.onSelect(
+ BatteryChartView.SELECTED_INDEX_ALL /*slot index*/);
+
+ verify(mMetricsFeatureProvider)
+ .action(mContext, SettingsEnums.ACTION_BATTERY_USAGE_SHOW_ALL);
}
@Test
@@ -610,6 +658,8 @@
assertThat(mBatteryChartPreferenceController.mTrapezoidIndex)
.isEqualTo(expectedIndex);
assertThat(mBatteryChartPreferenceController.mIsExpanded).isTrue();
+ verify(mMetricsFeatureProvider)
+ .action(mContext, SettingsEnums.OPEN_BATTERY_USAGE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
index 216b118..63a0b3d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/ConvertUtilsTest.java
@@ -26,6 +26,8 @@
import android.os.BatteryUsageStats;
import android.os.UserHandle;
+import com.android.settings.testutils.FakeFeatureFactory;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,15 +47,18 @@
public final class ConvertUtilsTest {
private Context mContext;
- @Mock
- private BatteryUsageStats mBatteryUsageStats;
- @Mock
- private BatteryEntry mockBatteryEntry;
+ @Mock private BatteryUsageStats mBatteryUsageStats;
+ @Mock private BatteryEntry mockBatteryEntry;
+
+ private FakeFeatureFactory mFeatureFactory;
+ private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
}
@Test
@@ -250,6 +255,21 @@
// Verifies the fake data is cleared out.
assertThat(entryList.get(0).getPackageName())
.isNotEqualTo(ConvertUtils.FAKE_PACKAGE_NAME);
+
+ // Adds lacked data into the battery history map.
+ final int remainingSize = 25 - batteryHistoryKeys.length;
+ for (int index = 0; index < remainingSize; index++) {
+ batteryHistoryMap.put(105L + index + 1, new HashMap<>());
+ }
+ when(mPowerUsageFeatureProvider.getBatteryHistory(mContext))
+ .thenReturn(batteryHistoryMap);
+
+ final List<BatteryDiffEntry> batteryDiffEntryList =
+ BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext);
+
+ assertThat(batteryDiffEntryList).isNotEmpty();
+ final BatteryDiffEntry resultEntry = batteryDiffEntryList.get(0);
+ assertThat(resultEntry.getPackageName()).isEqualTo("package2");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
index 663d7f7..da2f8b5 100644
--- a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
@@ -28,13 +28,11 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.util.FeatureFlagUtils;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
@@ -66,19 +64,6 @@
}
@Test
- public void getPreferenceScreenResId_silkyHomeDisabled_defaultSettings() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
- assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(R.xml.top_level_settings);
- }
-
- @Test
- public void getPreferenceScreenResId_silkyHomeEnabled_groupedSettings() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true);
- assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(
- R.xml.top_level_settings_grouped);
- }
-
- @Test
public void onCreatePreferences_shouldTintPreferenceIcon() {
final Preference preference = new Preference(mContext);
preference.setTitle(R.string.network_dashboard_title);