Merge Ambient display into Lockscreen settings.
And remove the entry point from security page. Now we only have 1 entry point from Display page. Change-Id: I06bc15a6fd8802a4918d8772af2722d5aafa332e Fixes: 71892510 Test: robotests
This commit is contained in:
@@ -2643,11 +2643,6 @@
|
|||||||
<!-- [CHAR LIMIT=30] Title of the preference that opens the Ambient display settings screen. -->
|
<!-- [CHAR LIMIT=30] Title of the preference that opens the Ambient display settings screen. -->
|
||||||
<string name="ambient_display_screen_title">Ambient display</string>
|
<string name="ambient_display_screen_title">Ambient display</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=50] Summary of the preference that opens the Ambient display settings screen, when Ambient display is set to be always on -->
|
|
||||||
<string name="ambient_display_screen_summary_always_on">Always on / Increased battery usage</string>
|
|
||||||
<!-- [CHAR LIMIT=30] Summary of the preference that opens the Ambient display settings screen, when Ambient display is set to show when new notifications come in. -->
|
|
||||||
<string name="ambient_display_screen_summary_notifications">New notifications</string>
|
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=30] Category title for the settings that control when Ambient display shows. -->
|
<!-- [CHAR LIMIT=30] Category title for the settings that control when Ambient display shows. -->
|
||||||
<string name="ambient_display_category_triggers">When to show</string>
|
<string name="ambient_display_category_triggers">When to show</string>
|
||||||
<!-- [CHAR LIMIT=30] Ambient display screen, title for setting to change whether the ambient display feature is triggered for new incoming notifications. -->
|
<!-- [CHAR LIMIT=30] Ambient display screen, title for setting to change whether the ambient display feature is triggered for new incoming notifications. -->
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2017 The Android Open Source Project
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:key="ambient_display_preference_screen"
|
|
||||||
settings:keywords="@string/keywords_ambient_display_screen"
|
|
||||||
android:title="@string/ambient_display_screen_title">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="ambient_display_category_when_to_show"
|
|
||||||
android:title="@string/ambient_display_category_triggers">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="ambient_display_always_on"
|
|
||||||
android:title="@string/doze_always_on_title"
|
|
||||||
android:summary="@string/doze_always_on_summary"
|
|
||||||
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="ambient_display_double_tap"
|
|
||||||
android:title="@string/ambient_display_title"
|
|
||||||
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
|
|
||||||
settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="ambient_display_pick_up"
|
|
||||||
android:title="@string/ambient_display_pickup_title"
|
|
||||||
android:fragment="com.android.settings.gestures.PickupGestureSettings"
|
|
||||||
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="ambient_display_category_notification"
|
|
||||||
android:layout="@layout/preference_category_no_label">
|
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="ambient_display_notification"
|
|
||||||
android:title="@string/doze_title"
|
|
||||||
android:summary="@string/doze_summary"
|
|
||||||
settings:controller="com.android.settings.display.AmbientDisplayNotificationsPreferenceController" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
@@ -101,9 +101,10 @@
|
|||||||
android:fragment="com.android.settings.dream.DreamSettings" />
|
android:fragment="com.android.settings.dream.DreamSettings" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedPreference
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="ambient_display"
|
android:key="lockscreen_from_display_settings"
|
||||||
android:title="@string/ambient_display_screen_title"
|
android:title="@string/lockscreen_settings_title"
|
||||||
android:fragment="com.android.settings.display.AmbientDisplaySettings"
|
android:fragment="com.android.settings.security.LockscreenDashboardFragment"
|
||||||
|
settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController"
|
||||||
settings:userRestriction="no_ambient_display" />
|
settings:userRestriction="no_ambient_display" />
|
||||||
|
|
||||||
<!-- Hide night mode for now
|
<!-- Hide night mode for now
|
||||||
|
@@ -44,12 +44,6 @@
|
|||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
settings:keywords="@string/keywords_lockscreen" />
|
settings:keywords="@string/keywords_lockscreen" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="lockscreen_preferences"
|
|
||||||
android:title="@string/lockscreen_settings_title"
|
|
||||||
android:summary="@string/summary_placeholder"
|
|
||||||
android:fragment="com.android.settings.security.LockscreenDashboardFragment" />
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="fingerprint_settings"
|
android:key="fingerprint_settings"
|
||||||
android:title="@string/security_settings_fingerprint_preference_title"
|
android:title="@string/security_settings_fingerprint_preference_title"
|
||||||
|
@@ -18,8 +18,12 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="security_lockscreen_settings_screen"
|
android:key="security_lockscreen_settings_screen"
|
||||||
android:title="@string/lockscreen_settings_title">
|
android:title="@string/lockscreen_settings_title"
|
||||||
|
settings:keywords="@string/keywords_ambient_display_screen">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="lockscreen_what_to_show"
|
||||||
|
android:title="@string/lockscreen_settings_what_to_show_category">
|
||||||
<com.android.settings.RestrictedListPreference
|
<com.android.settings.RestrictedListPreference
|
||||||
android:key="security_setting_lock_screen_notif"
|
android:key="security_setting_lock_screen_notif"
|
||||||
android:title="@string/lock_screen_notifications_title"
|
android:title="@string/lock_screen_notifications_title"
|
||||||
@@ -40,12 +44,45 @@
|
|||||||
android:summary="@string/lockdown_settings_summary"
|
android:summary="@string/lockdown_settings_summary"
|
||||||
settings:controller="com.android.settings.security.LockdownButtonPreferenceController" />
|
settings:controller="com.android.settings.security.LockdownButtonPreferenceController" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="ambient_display_category_when_to_show"
|
||||||
|
android:title="@string/ambient_display_category_triggers"
|
||||||
|
android:order="1000">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="ambient_display_always_on"
|
||||||
|
android:title="@string/doze_always_on_title"
|
||||||
|
android:summary="@string/doze_always_on_summary"
|
||||||
|
settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="ambient_display_double_tap"
|
||||||
|
android:title="@string/ambient_display_title"
|
||||||
|
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
|
||||||
|
settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="ambient_display_pick_up"
|
||||||
|
android:title="@string/ambient_display_pickup_title"
|
||||||
|
android:fragment="com.android.settings.gestures.PickupGestureSettings"
|
||||||
|
settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="ambient_display_notification"
|
||||||
|
android:title="@string/doze_title"
|
||||||
|
android:summary="@string/doze_summary"
|
||||||
|
settings:controller="com.android.settings.display.AmbientDisplayNotificationsPreferenceController" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<!-- Work profile settings are at the bottom with high order value to avoid users thinking that
|
<!-- Work profile settings are at the bottom with high order value to avoid users thinking that
|
||||||
any of the above settings (including dynamic) are specific to the work profile. -->
|
any of the above settings (including dynamic) are specific to the work profile. -->
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="security_setting_lock_screen_notif_work_header"
|
android:key="security_setting_lock_screen_notif_work_header"
|
||||||
android:title="@string/profile_section_header"
|
android:title="@string/profile_section_header"
|
||||||
android:order="1000">
|
android:order="1001">
|
||||||
|
|
||||||
<com.android.settings.RestrictedListPreference
|
<com.android.settings.RestrictedListPreference
|
||||||
android:key="security_setting_lock_screen_notif_work"
|
android:key="security_setting_lock_screen_notif_work"
|
||||||
|
@@ -19,10 +19,8 @@ package com.android.settings;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.display.AmbientDisplayPreferenceController;
|
|
||||||
import com.android.settings.display.BrightnessLevelPreferenceController;
|
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||||
import com.android.settings.display.CameraGesturePreferenceController;
|
import com.android.settings.display.CameraGesturePreferenceController;
|
||||||
import com.android.settings.display.ColorModePreferenceController;
|
import com.android.settings.display.ColorModePreferenceController;
|
||||||
@@ -89,10 +87,6 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
controllers.add(new NightDisplayPreferenceController(context));
|
controllers.add(new NightDisplayPreferenceController(context));
|
||||||
controllers.add(new NightModePreferenceController(context));
|
controllers.add(new NightModePreferenceController(context));
|
||||||
controllers.add(new ScreenSaverPreferenceController(context));
|
controllers.add(new ScreenSaverPreferenceController(context));
|
||||||
controllers.add(new AmbientDisplayPreferenceController(
|
|
||||||
context,
|
|
||||||
new AmbientDisplayConfiguration(context),
|
|
||||||
KEY_AMBIENT_DISPLAY));
|
|
||||||
controllers.add(new TapToWakePreferenceController(context));
|
controllers.add(new TapToWakePreferenceController(context));
|
||||||
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
|
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
|
||||||
controllers.add(new VrDisplayPreferenceController(context));
|
controllers.add(new VrDisplayPreferenceController(context));
|
||||||
|
@@ -32,9 +32,9 @@ import java.util.concurrent.FutureTask;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
|
||||||
public class DeviceModelPreferenceController extends BasePreferenceController {
|
public class DeviceModelPreferenceController extends BasePreferenceController {
|
||||||
|
|
||||||
|
|
||||||
private static final String TAG = "DeviceModelPrefCtrl";
|
private static final String TAG = "DeviceModelPrefCtrl";
|
||||||
|
|
||||||
private Fragment mHost;
|
private Fragment mHost;
|
||||||
|
@@ -26,6 +26,7 @@ import com.android.settings.core.TogglePreferenceController;
|
|||||||
import com.android.settings.search.DatabaseIndexingUtils;
|
import com.android.settings.search.DatabaseIndexingUtils;
|
||||||
import com.android.settings.search.InlineSwitchPayload;
|
import com.android.settings.search.InlineSwitchPayload;
|
||||||
import com.android.settings.search.ResultPayload;
|
import com.android.settings.search.ResultPayload;
|
||||||
|
import com.android.settings.security.LockscreenDashboardFragment;
|
||||||
|
|
||||||
public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreferenceController {
|
public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
@@ -96,7 +97,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
@Override
|
@Override
|
||||||
public ResultPayload getResultPayload() {
|
public ResultPayload getResultPayload() {
|
||||||
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
||||||
AmbientDisplaySettings.class.getName(), getPreferenceKey(),
|
LockscreenDashboardFragment.class.getName(), getPreferenceKey(),
|
||||||
mContext.getString(R.string.ambient_display_screen_title));
|
mContext.getString(R.string.ambient_display_screen_title));
|
||||||
|
|
||||||
return new InlineSwitchPayload(Settings.Secure.DOZE_ALWAYS_ON,
|
return new InlineSwitchPayload(Settings.Secure.DOZE_ALWAYS_ON,
|
||||||
|
@@ -14,15 +14,12 @@
|
|||||||
package com.android.settings.display;
|
package com.android.settings.display;
|
||||||
|
|
||||||
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
||||||
|
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -31,8 +28,12 @@ import com.android.settings.overlay.FeatureFactory;
|
|||||||
import com.android.settings.search.DatabaseIndexingUtils;
|
import com.android.settings.search.DatabaseIndexingUtils;
|
||||||
import com.android.settings.search.InlineSwitchPayload;
|
import com.android.settings.search.InlineSwitchPayload;
|
||||||
import com.android.settings.search.ResultPayload;
|
import com.android.settings.search.ResultPayload;
|
||||||
|
import com.android.settings.security.LockscreenDashboardFragment;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
public class AmbientDisplayNotificationsPreferenceController extends
|
public class AmbientDisplayNotificationsPreferenceController extends
|
||||||
TogglePreferenceController implements Preference.OnPreferenceChangeListener {
|
TogglePreferenceController implements Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
|||||||
//TODO (b/69808376): Remove result payload
|
//TODO (b/69808376): Remove result payload
|
||||||
public ResultPayload getResultPayload() {
|
public ResultPayload getResultPayload() {
|
||||||
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
||||||
AmbientDisplaySettings.class.getName(), KEY_AMBIENT_DISPLAY_NOTIFICATIONS,
|
LockscreenDashboardFragment.class.getName(), KEY_AMBIENT_DISPLAY_NOTIFICATIONS,
|
||||||
mContext.getString(R.string.ambient_display_screen_title));
|
mContext.getString(R.string.ambient_display_screen_title));
|
||||||
|
|
||||||
return new InlineSwitchPayload(Settings.Secure.DOZE_ENABLED,
|
return new InlineSwitchPayload(Settings.Secure.DOZE_ENABLED,
|
||||||
|
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.android.settings.display;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
|
|
||||||
public class AmbientDisplayPreferenceController extends AbstractPreferenceController implements
|
|
||||||
PreferenceControllerMixin {
|
|
||||||
|
|
||||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
|
||||||
|
|
||||||
private final AmbientDisplayConfiguration mConfig;
|
|
||||||
private final String mKey;
|
|
||||||
|
|
||||||
public AmbientDisplayPreferenceController(Context context, AmbientDisplayConfiguration config,
|
|
||||||
String key) {
|
|
||||||
super(context);
|
|
||||||
mConfig = config;
|
|
||||||
mKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAvailable() {
|
|
||||||
return mConfig.available();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateState(Preference preference) {
|
|
||||||
super.updateState(preference);
|
|
||||||
if (mConfig.alwaysOnEnabled(MY_USER_ID)) {
|
|
||||||
preference.setSummary(R.string.ambient_display_screen_summary_always_on);
|
|
||||||
} else if (mConfig.pulseOnNotificationEnabled(MY_USER_ID)) {
|
|
||||||
preference.setSummary(R.string.ambient_display_screen_summary_notifications);
|
|
||||||
} else if (mConfig.enabled(MY_USER_ID)) {
|
|
||||||
preference.setSummary(R.string.switch_on_text);
|
|
||||||
} else {
|
|
||||||
preference.setSummary(R.string.switch_off_text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPreferenceKey() {
|
|
||||||
return mKey;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.display;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
|
||||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
import com.android.settings.search.Indexable;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings screen for Ambient display.
|
|
||||||
*/
|
|
||||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
|
||||||
public class AmbientDisplaySettings extends DashboardFragment {
|
|
||||||
|
|
||||||
public static final String KEY_AMBIENT_DISPLAY_ALWAYS_ON = "ambient_display_always_on";
|
|
||||||
|
|
||||||
private static final String TAG = "AmbientDisplaySettings";
|
|
||||||
|
|
||||||
private AmbientDisplayConfiguration mConfig;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
use(AmbientDisplayAlwaysOnPreferenceController.class)
|
|
||||||
.setConfig(getConfig(context))
|
|
||||||
.setCallback(this::updatePreferenceStates);
|
|
||||||
use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
|
|
||||||
use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
|
|
||||||
use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getLogTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getPreferenceScreenResId() {
|
|
||||||
return R.xml.ambient_display_settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return MetricsProto.MetricsEvent.AMBIENT_DISPLAY_SETTINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
|
||||||
new BaseSearchIndexProvider() {
|
|
||||||
@Override
|
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
|
||||||
boolean enabled) {
|
|
||||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
|
||||||
|
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = R.xml.ambient_display_settings;
|
|
||||||
result.add(sir);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private AmbientDisplayConfiguration getConfig(Context context) {
|
|
||||||
if (mConfig == null) {
|
|
||||||
mConfig = new AmbientDisplayConfiguration(context);
|
|
||||||
}
|
|
||||||
return mConfig;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,9 +19,14 @@ package com.android.settings.security;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController;
|
||||||
|
import com.android.settings.display.AmbientDisplayNotificationsPreferenceController;
|
||||||
|
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||||
|
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.users.AddUserWhenLockedPreferenceController;
|
import com.android.settings.users.AddUserWhenLockedPreferenceController;
|
||||||
@@ -42,6 +47,8 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
public class LockscreenDashboardFragment extends DashboardFragment
|
public class LockscreenDashboardFragment extends DashboardFragment
|
||||||
implements OwnerInfoPreferenceController.OwnerInfoCallback {
|
implements OwnerInfoPreferenceController.OwnerInfoCallback {
|
||||||
|
|
||||||
|
public static final String KEY_AMBIENT_DISPLAY_ALWAYS_ON = "ambient_display_always_on";
|
||||||
|
|
||||||
private static final String TAG = "LockscreenDashboardFragment";
|
private static final String TAG = "LockscreenDashboardFragment";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -56,6 +63,8 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
|||||||
static final String KEY_ADD_USER_FROM_LOCK_SCREEN =
|
static final String KEY_ADD_USER_FROM_LOCK_SCREEN =
|
||||||
"security_lockscreen_add_users_when_locked";
|
"security_lockscreen_add_users_when_locked";
|
||||||
|
|
||||||
|
|
||||||
|
private AmbientDisplayConfiguration mConfig;
|
||||||
private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
|
private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,6 +87,17 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
|||||||
return R.string.help_url_lockscreen;
|
return R.string.help_url_lockscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
use(AmbientDisplayAlwaysOnPreferenceController.class)
|
||||||
|
.setConfig(getConfig(context))
|
||||||
|
.setCallback(this::updatePreferenceStates);
|
||||||
|
use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
|
||||||
|
use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
|
||||||
|
use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
@@ -105,6 +125,13 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AmbientDisplayConfiguration getConfig(Context context) {
|
||||||
|
if (mConfig == null) {
|
||||||
|
mConfig = new AmbientDisplayConfiguration(context);
|
||||||
|
}
|
||||||
|
return mConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider() {
|
new BaseSearchIndexProvider() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -15,8 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.security;
|
package com.android.settings.security;
|
||||||
|
|
||||||
import static com.android.settings.security.EncryptionStatusPreferenceController
|
import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
||||||
.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -35,7 +34,6 @@ import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceContro
|
|||||||
import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
|
import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
|
||||||
import com.android.settings.location.LocationPreferenceController;
|
import com.android.settings.location.LocationPreferenceController;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.security.screenlock.LockScreenPreferenceController;
|
|
||||||
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
||||||
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
||||||
import com.android.settings.widget.PreferenceCategoryController;
|
import com.android.settings.widget.PreferenceCategoryController;
|
||||||
@@ -128,7 +126,6 @@ public class SecuritySettings extends DashboardFragment {
|
|||||||
|
|
||||||
final List<AbstractPreferenceController> securityPreferenceControllers = new ArrayList<>();
|
final List<AbstractPreferenceController> securityPreferenceControllers = new ArrayList<>();
|
||||||
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
||||||
securityPreferenceControllers.add(new LockScreenPreferenceController(context, lifecycle));
|
|
||||||
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
||||||
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||||
.setChildren(securityPreferenceControllers));
|
.setChildren(securityPreferenceControllers));
|
||||||
|
@@ -20,33 +20,28 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
public class LockScreenPreferenceController extends BasePreferenceController implements
|
public class LockScreenPreferenceController extends BasePreferenceController implements
|
||||||
LifecycleObserver, OnResume {
|
LifecycleObserver, OnResume {
|
||||||
|
|
||||||
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
|
|
||||||
|
|
||||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||||
private final LockPatternUtils mLockPatternUtils;
|
private final LockPatternUtils mLockPatternUtils;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
public LockScreenPreferenceController(Context context, Lifecycle lifecycle) {
|
public LockScreenPreferenceController(Context context, String key) {
|
||||||
super(context, KEY_LOCKSCREEN_PREFERENCES);
|
super(context, key);
|
||||||
mLockPatternUtils = FeatureFactory.getFactory(context)
|
mLockPatternUtils = FeatureFactory.getFactory(context)
|
||||||
.getSecurityFeatureProvider().getLockPatternUtils(context);
|
.getSecurityFeatureProvider().getLockPatternUtils(context);
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.display;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.annotation.Config;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
|
||||||
@Config(shadows = ShadowSecureSettings.class)
|
|
||||||
public class AmbientDisplayPreferenceControllerTest {
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Context mContext;
|
|
||||||
@Mock
|
|
||||||
private AmbientDisplayConfiguration mConfig;
|
|
||||||
@Mock
|
|
||||||
private Preference mPreference;
|
|
||||||
|
|
||||||
private AmbientDisplayPreferenceController mController;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mController = new AmbientDisplayPreferenceController(mContext, mConfig, "key");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_available() {
|
|
||||||
when(mConfig.available()).thenReturn(true);
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_unavailable() {
|
|
||||||
when(mConfig.available()).thenReturn(false);
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_alwaysOn() {
|
|
||||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true);
|
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
|
||||||
|
|
||||||
verify(mPreference).setSummary(R.string.ambient_display_screen_summary_always_on);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_notifications() {
|
|
||||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
|
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
|
||||||
|
|
||||||
verify(mPreference).setSummary(R.string.ambient_display_screen_summary_notifications);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_gestures() {
|
|
||||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.enabled(anyInt())).thenReturn(true);
|
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
|
||||||
|
|
||||||
verify(mPreference).setSummary(R.string.switch_on_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updateState_off() {
|
|
||||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
|
|
||||||
when(mConfig.pulseOnPickupEnabled(anyInt())).thenReturn(false);
|
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
|
||||||
|
|
||||||
verify(mPreference).setSummary(R.string.switch_off_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getPreferenceKey() {
|
|
||||||
assertThat(mController.getPreferenceKey()).isEqualTo("key");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.display;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.any;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
|
||||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
|
||||||
public class AmbientDisplaySettingsTest {
|
|
||||||
|
|
||||||
private TestFragment mTestFragment;
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mContext = RuntimeEnvironment.application;
|
|
||||||
mTestFragment = spy(new TestFragment());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onAttach_alwaysOn_shouldInvokeSetters() {
|
|
||||||
final AmbientDisplayAlwaysOnPreferenceController controller = spy(
|
|
||||||
new AmbientDisplayAlwaysOnPreferenceController(mContext, "key"));
|
|
||||||
doReturn(controller).when(mTestFragment).use(
|
|
||||||
AmbientDisplayAlwaysOnPreferenceController.class);
|
|
||||||
|
|
||||||
mTestFragment.onAttach(mContext);
|
|
||||||
verify(controller).setConfig(any());
|
|
||||||
verify(controller).setCallback(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onAttach_notifications_shouldInvokeSetters() {
|
|
||||||
final AmbientDisplayNotificationsPreferenceController controller = spy(
|
|
||||||
new AmbientDisplayNotificationsPreferenceController(mContext, "key"));
|
|
||||||
doReturn(controller).when(mTestFragment).use(
|
|
||||||
AmbientDisplayNotificationsPreferenceController.class);
|
|
||||||
|
|
||||||
mTestFragment.onAttach(mContext);
|
|
||||||
verify(controller).setConfig(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onAttach_doubleTap_shouldInvokeSetters() {
|
|
||||||
final DoubleTapScreenPreferenceController controller = spy(
|
|
||||||
new DoubleTapScreenPreferenceController(mContext, "key"));
|
|
||||||
doReturn(controller).when(mTestFragment).use(DoubleTapScreenPreferenceController.class);
|
|
||||||
|
|
||||||
mTestFragment.onAttach(mContext);
|
|
||||||
verify(controller).setConfig(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onAttach_pickUp_shouldInvokeSetters() {
|
|
||||||
final PickupGesturePreferenceController controller = spy(
|
|
||||||
new PickupGesturePreferenceController(mContext, "key"));
|
|
||||||
doReturn(controller).when(mTestFragment).use(PickupGesturePreferenceController.class);
|
|
||||||
|
|
||||||
mTestFragment.onAttach(mContext);
|
|
||||||
verify(controller).setConfig(any());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestFragment extends AmbientDisplaySettings {
|
|
||||||
@Override
|
|
||||||
protected <T extends AbstractPreferenceController> T use(Class<T> clazz) {
|
|
||||||
return super.use(clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -17,30 +17,105 @@
|
|||||||
package com.android.settings.security;
|
package com.android.settings.security;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController;
|
||||||
|
import com.android.settings.display.AmbientDisplayNotificationsPreferenceController;
|
||||||
|
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||||
|
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(shadows = {
|
||||||
|
ShadowUtils.class, ShadowLockPatternUtils.class
|
||||||
|
})
|
||||||
public class LockscreenDashboardFragmentTest {
|
public class LockscreenDashboardFragmentTest {
|
||||||
|
|
||||||
private LockscreenDashboardFragment mFragment;
|
private TestFragment mTestFragment;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
|
mTestFragment = spy(new TestFragment());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containsNotificationSettingsForPrimaryUserAndWorkProfile() {
|
public void containsNotificationSettingsForPrimaryUserAndWorkProfile() {
|
||||||
mFragment = new LockscreenDashboardFragment();
|
|
||||||
|
|
||||||
List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(RuntimeEnvironment.application,
|
List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(RuntimeEnvironment.application,
|
||||||
mFragment.getPreferenceScreenResId());
|
mTestFragment.getPreferenceScreenResId());
|
||||||
|
|
||||||
assertThat(keys).containsAllOf(LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON,
|
assertThat(keys).containsAllOf(LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON,
|
||||||
LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE,
|
LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE,
|
||||||
LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER);
|
LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAttach_alwaysOn_shouldInvokeSetters() {
|
||||||
|
final AmbientDisplayAlwaysOnPreferenceController controller = spy(
|
||||||
|
new AmbientDisplayAlwaysOnPreferenceController(mContext, "key"));
|
||||||
|
doReturn(controller).when(mTestFragment).use(
|
||||||
|
AmbientDisplayAlwaysOnPreferenceController.class);
|
||||||
|
|
||||||
|
mTestFragment.onAttach(mContext);
|
||||||
|
verify(controller).setConfig(any());
|
||||||
|
verify(controller).setCallback(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAttach_notifications_shouldInvokeSetters() {
|
||||||
|
final AmbientDisplayNotificationsPreferenceController controller = spy(
|
||||||
|
new AmbientDisplayNotificationsPreferenceController(mContext, "key"));
|
||||||
|
doReturn(controller).when(mTestFragment).use(
|
||||||
|
AmbientDisplayNotificationsPreferenceController.class);
|
||||||
|
|
||||||
|
mTestFragment.onAttach(mContext);
|
||||||
|
verify(controller).setConfig(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAttach_doubleTap_shouldInvokeSetters() {
|
||||||
|
final DoubleTapScreenPreferenceController controller = spy(
|
||||||
|
new DoubleTapScreenPreferenceController(mContext, "key"));
|
||||||
|
doReturn(controller).when(mTestFragment).use(DoubleTapScreenPreferenceController.class);
|
||||||
|
|
||||||
|
mTestFragment.onAttach(mContext);
|
||||||
|
verify(controller).setConfig(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onAttach_pickUp_shouldInvokeSetters() {
|
||||||
|
final PickupGesturePreferenceController controller = spy(
|
||||||
|
new PickupGesturePreferenceController(mContext, "key"));
|
||||||
|
doReturn(controller).when(mTestFragment).use(PickupGesturePreferenceController.class);
|
||||||
|
|
||||||
|
mTestFragment.onAttach(mContext);
|
||||||
|
verify(controller).setConfig(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestFragment extends LockscreenDashboardFragment {
|
||||||
|
@Override
|
||||||
|
protected <T extends AbstractPreferenceController> T use(Class<T> clazz) {
|
||||||
|
return super.use(clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,11 +26,8 @@ import static org.mockito.ArgumentMatchers.anyInt;
|
|||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
@@ -45,6 +42,10 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class LockScreenPreferenceControllerTest {
|
public class LockScreenPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ public class LockScreenPreferenceControllerTest {
|
|||||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||||
mLifecycleOwner = () -> mLifecycle;
|
mLifecycleOwner = () -> mLifecycle;
|
||||||
mLifecycle = new Lifecycle(mLifecycleOwner);
|
mLifecycle = new Lifecycle(mLifecycleOwner);
|
||||||
mController = new LockScreenPreferenceController(mContext, mLifecycle);
|
mController = new LockScreenPreferenceController(mContext, "Test_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user