Snap for 9232464 from 47d84b41ac
to tm-qpr2-release
Change-Id: Ie525c7d06bc31b8200a04209626094f993b69a9c
This commit is contained in:
@@ -1216,6 +1216,20 @@
|
|||||||
<item>90</item>
|
<item>90</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Options for screensaver "When to start" for devices that do not support screensavers
|
||||||
|
while on battery -->
|
||||||
|
<string-array name="when_to_start_screensaver_entries_no_battery" translatable="false">
|
||||||
|
<item>@string/screensaver_settings_summary_sleep</item>
|
||||||
|
<item>@string/screensaver_settings_summary_dock_and_charging</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Values for screensaver "When to start" for devices that do not support screensavers
|
||||||
|
while on battery -->
|
||||||
|
<string-array name="when_to_start_screensaver_values_no_battery" translatable="false">
|
||||||
|
<item>while_charging_only</item>
|
||||||
|
<item>while_docked_only</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="when_to_start_screensaver_entries" translatable="false">
|
<string-array name="when_to_start_screensaver_entries" translatable="false">
|
||||||
<item>@string/screensaver_settings_summary_sleep</item>
|
<item>@string/screensaver_settings_summary_sleep</item>
|
||||||
<item>@string/screensaver_settings_summary_dock</item>
|
<item>@string/screensaver_settings_summary_dock</item>
|
||||||
|
@@ -3365,6 +3365,8 @@
|
|||||||
<string name="screensaver_settings_toggle_title">Use screen saver</string>
|
<string name="screensaver_settings_toggle_title">Use screen saver</string>
|
||||||
<!-- Display settings screen, summary fragment for screen saver options, activated when docked or asleep and charging [CHAR LIMIT=35] -->
|
<!-- Display settings screen, summary fragment for screen saver options, activated when docked or asleep and charging [CHAR LIMIT=35] -->
|
||||||
<string name="screensaver_settings_summary_either_long">While charging or docked</string>
|
<string name="screensaver_settings_summary_either_long">While charging or docked</string>
|
||||||
|
<!-- Display settings screen, summary fragment for screen saver options, actived while docked and charging [CHAR LIMIT=35] -->
|
||||||
|
<string name="screensaver_settings_summary_dock_and_charging">While docked and charging</string>
|
||||||
<!-- Display settings screen, summary fragment for screen saver options, activated when asleep and charging [CHAR LIMIT=35] -->
|
<!-- Display settings screen, summary fragment for screen saver options, activated when asleep and charging [CHAR LIMIT=35] -->
|
||||||
<string name="screensaver_settings_summary_sleep">While charging</string>
|
<string name="screensaver_settings_summary_sleep">While charging</string>
|
||||||
<!-- Display settings screen, summary fragment for screen saver options, activated when docked [CHAR LIMIT=35] -->
|
<!-- Display settings screen, summary fragment for screen saver options, activated when docked [CHAR LIMIT=35] -->
|
||||||
@@ -9895,6 +9897,9 @@
|
|||||||
<!-- [CHAR LIMIT=NONE] Text appearing when channel group notifications are off -->
|
<!-- [CHAR LIMIT=NONE] Text appearing when channel group notifications are off -->
|
||||||
<string name="channel_group_notifications_off_desc">At your request, Android is blocking this group of notifications from appearing on this device</string>
|
<string name="channel_group_notifications_off_desc">At your request, Android is blocking this group of notifications from appearing on this device</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] Text appearing when app does not send notifications -->
|
||||||
|
<string name="app_notifications_not_send_desc">This app does not send notifications</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
|
<!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
|
||||||
<string name="notification_channels">Categories</string>
|
<string name="notification_channels">Categories</string>
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@ import com.android.settings.development.bluetooth.BluetoothQualityDialogPreferen
|
|||||||
import com.android.settings.development.bluetooth.BluetoothSampleRateDialogPreferenceController;
|
import com.android.settings.development.bluetooth.BluetoothSampleRateDialogPreferenceController;
|
||||||
import com.android.settings.development.qstile.DevelopmentTiles;
|
import com.android.settings.development.qstile.DevelopmentTiles;
|
||||||
import com.android.settings.development.storage.SharedDataPreferenceController;
|
import com.android.settings.development.storage.SharedDataPreferenceController;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.actionbar.SearchMenuController;
|
import com.android.settings.search.actionbar.SearchMenuController;
|
||||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||||
@@ -308,6 +309,8 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
DisableDevSettingsDialogFragment.show(this /* host */);
|
DisableDevSettingsDialogFragment.show(this /* host */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FeatureFactory.getFactory(
|
||||||
|
getContext()).getSearchFeatureProvider().sendPreIndexIntent(getContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,12 +372,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
|
|
||||||
final BluetoothLeAudioHwOffloadPreferenceController leAudioController =
|
final BluetoothLeAudioHwOffloadPreferenceController leAudioController =
|
||||||
getDevelopmentOptionsController(
|
getDevelopmentOptionsController(
|
||||||
BluetoothLeAudioHwOffloadPreferenceController.class);
|
BluetoothLeAudioHwOffloadPreferenceController.class);
|
||||||
leAudioController.onRebootDialogConfirmed();
|
leAudioController.onRebootDialogConfirmed();
|
||||||
|
|
||||||
final BluetoothLeAudioPreferenceController leAudioFeatureController =
|
final BluetoothLeAudioPreferenceController leAudioFeatureController =
|
||||||
getDevelopmentOptionsController(
|
getDevelopmentOptionsController(
|
||||||
BluetoothLeAudioPreferenceController.class);
|
BluetoothLeAudioPreferenceController.class);
|
||||||
leAudioFeatureController.onRebootDialogConfirmed();
|
leAudioFeatureController.onRebootDialogConfirmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,12 +389,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
|||||||
|
|
||||||
final BluetoothLeAudioHwOffloadPreferenceController leAudioController =
|
final BluetoothLeAudioHwOffloadPreferenceController leAudioController =
|
||||||
getDevelopmentOptionsController(
|
getDevelopmentOptionsController(
|
||||||
BluetoothLeAudioHwOffloadPreferenceController.class);
|
BluetoothLeAudioHwOffloadPreferenceController.class);
|
||||||
leAudioController.onRebootDialogCanceled();
|
leAudioController.onRebootDialogCanceled();
|
||||||
|
|
||||||
final BluetoothLeAudioPreferenceController leAudioFeatureController =
|
final BluetoothLeAudioPreferenceController leAudioFeatureController =
|
||||||
getDevelopmentOptionsController(
|
getDevelopmentOptionsController(
|
||||||
BluetoothLeAudioPreferenceController.class);
|
BluetoothLeAudioPreferenceController.class);
|
||||||
leAudioFeatureController.onRebootDialogCanceled();
|
leAudioFeatureController.onRebootDialogCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -240,6 +240,8 @@ public class BuildNumberPreferenceController extends BasePreferenceController im
|
|||||||
mDevHitToast = Toast.makeText(mContext, R.string.show_dev_on,
|
mDevHitToast = Toast.makeText(mContext, R.string.show_dev_on,
|
||||||
Toast.LENGTH_LONG);
|
Toast.LENGTH_LONG);
|
||||||
mDevHitToast.show();
|
mDevHitToast.show();
|
||||||
|
|
||||||
|
FeatureFactory.getFactory(mContext).getSearchFeatureProvider().sendPreIndexIntent(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -90,12 +90,14 @@ public class DreamSettings extends DashboardFragment implements OnMainSwitchChan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getDreamSettingDescriptionResId(@WhenToDream int dreamSetting) {
|
static int getDreamSettingDescriptionResId(@WhenToDream int dreamSetting,
|
||||||
|
boolean enabledOnBattery) {
|
||||||
switch (dreamSetting) {
|
switch (dreamSetting) {
|
||||||
case WHILE_CHARGING:
|
case WHILE_CHARGING:
|
||||||
return R.string.screensaver_settings_summary_sleep;
|
return R.string.screensaver_settings_summary_sleep;
|
||||||
case WHILE_DOCKED:
|
case WHILE_DOCKED:
|
||||||
return R.string.screensaver_settings_summary_dock;
|
return enabledOnBattery ? R.string.screensaver_settings_summary_dock
|
||||||
|
: R.string.screensaver_settings_summary_dock_and_charging;
|
||||||
case EITHER:
|
case EITHER:
|
||||||
return R.string.screensaver_settings_summary_either_long;
|
return R.string.screensaver_settings_summary_either_long;
|
||||||
case NEVER:
|
case NEVER:
|
||||||
|
@@ -32,12 +32,15 @@ public class WhenToDreamPicker extends RadioButtonPickerFragment {
|
|||||||
|
|
||||||
private static final String TAG = "WhenToDreamPicker";
|
private static final String TAG = "WhenToDreamPicker";
|
||||||
private DreamBackend mBackend;
|
private DreamBackend mBackend;
|
||||||
|
private boolean mDreamsSupportedOnBattery;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
mBackend = DreamBackend.getInstance(context);
|
mBackend = DreamBackend.getInstance(context);
|
||||||
|
mDreamsSupportedOnBattery = getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_dreamsEnabledOnBattery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,11 +72,17 @@ public class WhenToDreamPicker extends RadioButtonPickerFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String[] entries() {
|
private String[] entries() {
|
||||||
return getResources().getStringArray(R.array.when_to_start_screensaver_entries);
|
if (mDreamsSupportedOnBattery) {
|
||||||
|
return getResources().getStringArray(R.array.when_to_start_screensaver_entries);
|
||||||
|
}
|
||||||
|
return getResources().getStringArray(R.array.when_to_start_screensaver_entries_no_battery);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] keys() {
|
private String[] keys() {
|
||||||
return getResources().getStringArray(R.array.when_to_start_screensaver_values);
|
if (mDreamsSupportedOnBattery) {
|
||||||
|
return getResources().getStringArray(R.array.when_to_start_screensaver_values);
|
||||||
|
}
|
||||||
|
return getResources().getStringArray(R.array.when_to_start_screensaver_values_no_battery);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -33,19 +33,24 @@ public class WhenToDreamPreferenceController extends AbstractPreferenceControlle
|
|||||||
private static final String WHEN_TO_START = "when_to_start";
|
private static final String WHEN_TO_START = "when_to_start";
|
||||||
private final DreamBackend mBackend;
|
private final DreamBackend mBackend;
|
||||||
private final boolean mDreamsDisabledByAmbientModeSuppression;
|
private final boolean mDreamsDisabledByAmbientModeSuppression;
|
||||||
|
private final boolean mDreamsEnabledOnBattery;
|
||||||
|
|
||||||
WhenToDreamPreferenceController(Context context) {
|
WhenToDreamPreferenceController(Context context) {
|
||||||
this(context, context.getResources().getBoolean(
|
this(context, context.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_dreamsDisabledByAmbientModeSuppressionConfig));
|
com.android.internal.R.bool.config_dreamsDisabledByAmbientModeSuppressionConfig),
|
||||||
|
context.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_dreamsEnabledOnBattery));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
WhenToDreamPreferenceController(Context context,
|
WhenToDreamPreferenceController(Context context,
|
||||||
boolean dreamsDisabledByAmbientModeSuppression) {
|
boolean dreamsDisabledByAmbientModeSuppression,
|
||||||
|
boolean dreamsEnabledOnBattery) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
mBackend = DreamBackend.getInstance(context);
|
mBackend = DreamBackend.getInstance(context);
|
||||||
mDreamsDisabledByAmbientModeSuppression = dreamsDisabledByAmbientModeSuppression;
|
mDreamsDisabledByAmbientModeSuppression = dreamsDisabledByAmbientModeSuppression;
|
||||||
|
mDreamsEnabledOnBattery = dreamsEnabledOnBattery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,7 +62,7 @@ public class WhenToDreamPreferenceController extends AbstractPreferenceControlle
|
|||||||
preference.setSummary(R.string.screensaver_settings_when_to_dream_bedtime);
|
preference.setSummary(R.string.screensaver_settings_when_to_dream_bedtime);
|
||||||
} else {
|
} else {
|
||||||
final int resId = DreamSettings.getDreamSettingDescriptionResId(
|
final int resId = DreamSettings.getDreamSettingDescriptionResId(
|
||||||
mBackend.getWhenToDreamSetting());
|
mBackend.getWhenToDreamSetting(), mDreamsEnabledOnBattery);
|
||||||
preference.setSummary(resId);
|
preference.setSummary(resId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
|||||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.support.SupportPreferenceController;
|
import com.android.settings.support.SupportPreferenceController;
|
||||||
import com.android.settings.widget.HomepagePreference;
|
import com.android.settings.widget.HomepagePreference;
|
||||||
@@ -157,6 +158,8 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mFirstStarted) {
|
if (mFirstStarted) {
|
||||||
mFirstStarted = false;
|
mFirstStarted = false;
|
||||||
|
FeatureFactory.getFactory(getContext()).getSearchFeatureProvider().sendPreIndexIntent(
|
||||||
|
getContext());
|
||||||
} else if (mIsEmbeddingActivityEnabled && isOnlyOneActivityInTask()
|
} else if (mIsEmbeddingActivityEnabled && isOnlyOneActivityInTask()
|
||||||
&& !SplitController.getInstance().isActivityEmbedded(getActivity())) {
|
&& !SplitController.getInstance().isActivityEmbedded(getActivity())) {
|
||||||
// Set default highlight menu key for 1-pane homepage since it will show the placeholder
|
// Set default highlight menu key for 1-pane homepage since it will show the placeholder
|
||||||
@@ -346,7 +349,9 @@ public class TopLevelSettings extends DashboardFragment implements SplitLayoutLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private interface PreferenceJob {
|
private interface PreferenceJob {
|
||||||
default void init() {}
|
default void init() {
|
||||||
|
}
|
||||||
|
|
||||||
void doForEach(Preference preference);
|
void doForEach(Preference preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,6 +126,7 @@ public class NotificationBackend {
|
|||||||
if (app.requestedPermissions == null || Arrays.stream(app.requestedPermissions)
|
if (app.requestedPermissions == null || Arrays.stream(app.requestedPermissions)
|
||||||
.noneMatch(p -> p.equals(android.Manifest.permission.POST_NOTIFICATIONS))) {
|
.noneMatch(p -> p.equals(android.Manifest.permission.POST_NOTIFICATIONS))) {
|
||||||
row.lockedImportance = true;
|
row.lockedImportance = true;
|
||||||
|
row.permissionStateLocked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -684,6 +685,9 @@ public class NotificationBackend {
|
|||||||
public boolean systemApp;
|
public boolean systemApp;
|
||||||
public boolean lockedImportance;
|
public boolean lockedImportance;
|
||||||
public boolean showBadge;
|
public boolean showBadge;
|
||||||
|
// For apps target T but have not but has not requested the permission
|
||||||
|
// we cannot change the permission state
|
||||||
|
public boolean permissionStateLocked;
|
||||||
public int bubblePreference = NotificationManager.BUBBLE_PREFERENCE_NONE;
|
public int bubblePreference = NotificationManager.BUBBLE_PREFERENCE_NONE;
|
||||||
public int userId;
|
public int userId;
|
||||||
public int blockedChannelCount;
|
public int blockedChannelCount;
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.notification;
|
|||||||
import static com.android.settings.notification.SettingPref.TYPE_SECURE;
|
import static com.android.settings.notification.SettingPref.TYPE_SECURE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
@@ -27,16 +28,18 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
|||||||
public class VibrateIconPreferenceController extends SettingPrefController {
|
public class VibrateIconPreferenceController extends SettingPrefController {
|
||||||
|
|
||||||
private static final String KEY_VIBRATE_ICON = "vibrate_icon";
|
private static final String KEY_VIBRATE_ICON = "vibrate_icon";
|
||||||
|
private final boolean mHasVibrator;
|
||||||
|
|
||||||
public VibrateIconPreferenceController(Context context, SettingsPreferenceFragment parent,
|
public VibrateIconPreferenceController(Context context, SettingsPreferenceFragment parent,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
super(context, parent, lifecycle);
|
super(context, parent, lifecycle);
|
||||||
|
mHasVibrator = context.getSystemService(Vibrator.class).hasVibrator();
|
||||||
mPreference = new SettingPref(
|
mPreference = new SettingPref(
|
||||||
TYPE_SECURE, KEY_VIBRATE_ICON, Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0 /*default off*/);
|
TYPE_SECURE, KEY_VIBRATE_ICON, Secure.STATUS_BAR_SHOW_VIBRATE_ICON, 0 /*default off*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return true;
|
return mHasVibrator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,8 @@ public class NotificationsOffPreferenceController extends NotificationPreference
|
|||||||
preference.setTitle(R.string.channel_notifications_off_desc);
|
preference.setTitle(R.string.channel_notifications_off_desc);
|
||||||
} else if (mChannelGroup != null) {
|
} else if (mChannelGroup != null) {
|
||||||
preference.setTitle(R.string.channel_group_notifications_off_desc);
|
preference.setTitle(R.string.channel_group_notifications_off_desc);
|
||||||
|
} else if (mAppRow.permissionStateLocked) {
|
||||||
|
preference.setTitle(R.string.app_notifications_not_send_desc);
|
||||||
} else {
|
} else {
|
||||||
preference.setTitle(R.string.app_notifications_off_desc);
|
preference.setTitle(R.string.app_notifications_off_desc);
|
||||||
}
|
}
|
||||||
|
@@ -71,6 +71,12 @@ public interface SearchFeatureProvider {
|
|||||||
return context.getString(R.string.config_settingsintelligence_package_name);
|
return context.getString(R.string.config_settingsintelligence_package_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the pre-index intent.
|
||||||
|
*/
|
||||||
|
default void sendPreIndexIntent(Context context){
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the search toolbar.
|
* Initializes the search toolbar.
|
||||||
*/
|
*/
|
||||||
|
@@ -29,33 +29,40 @@ import com.android.settingslib.dream.DreamBackend.WhenToDream;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class DreamSettingsTest {
|
public class DreamSettingsTest {
|
||||||
|
|
||||||
private static final List<String> KEYS = Arrays.asList(
|
private static final List<String> KEYS = Arrays.asList(
|
||||||
DreamSettings.WHILE_CHARGING_ONLY,
|
DreamSettings.WHILE_CHARGING_ONLY,
|
||||||
DreamSettings.WHILE_DOCKED_ONLY,
|
DreamSettings.WHILE_DOCKED_ONLY,
|
||||||
DreamSettings.EITHER_CHARGING_OR_DOCKED,
|
DreamSettings.EITHER_CHARGING_OR_DOCKED,
|
||||||
DreamSettings.NEVER_DREAM
|
DreamSettings.NEVER_DREAM
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final @WhenToDream int[] SETTINGS = {
|
private static final @WhenToDream int[] SETTINGS = {
|
||||||
DreamBackend.WHILE_CHARGING,
|
DreamBackend.WHILE_CHARGING,
|
||||||
DreamBackend.WHILE_DOCKED,
|
DreamBackend.WHILE_DOCKED,
|
||||||
DreamBackend.EITHER,
|
DreamBackend.EITHER,
|
||||||
DreamBackend.NEVER,
|
DreamBackend.NEVER,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int[] RES_IDS = {
|
private static final int[] RES_IDS = {
|
||||||
R.string.screensaver_settings_summary_sleep,
|
R.string.screensaver_settings_summary_sleep,
|
||||||
R.string.screensaver_settings_summary_dock,
|
R.string.screensaver_settings_summary_dock,
|
||||||
R.string.screensaver_settings_summary_either_long,
|
R.string.screensaver_settings_summary_either_long,
|
||||||
R.string.screensaver_settings_summary_never
|
R.string.screensaver_settings_summary_never
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final int[] RES_IDS_NO_BATTERY = {
|
||||||
|
R.string.screensaver_settings_summary_sleep,
|
||||||
|
R.string.screensaver_settings_summary_dock_and_charging,
|
||||||
|
R.string.screensaver_settings_summary_either_long,
|
||||||
|
R.string.screensaver_settings_summary_never
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -81,11 +88,17 @@ public class DreamSettingsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getDreamSettingDescriptionResId() {
|
public void getDreamSettingDescriptionResId() {
|
||||||
for (int i = 0; i < SETTINGS.length; i++) {
|
for (int i = 0; i < SETTINGS.length; i++) {
|
||||||
assertThat(DreamSettings.getDreamSettingDescriptionResId(SETTINGS[i]))
|
assertThat(DreamSettings.getDreamSettingDescriptionResId(
|
||||||
|
SETTINGS[i], /* enabledOnBattery= */ false))
|
||||||
|
.isEqualTo(RES_IDS_NO_BATTERY[i]);
|
||||||
|
assertThat(DreamSettings.getDreamSettingDescriptionResId(
|
||||||
|
SETTINGS[i], /* enabledOnBattery= */ true))
|
||||||
.isEqualTo(RES_IDS[i]);
|
.isEqualTo(RES_IDS[i]);
|
||||||
}
|
}
|
||||||
// Default
|
// Default
|
||||||
assertThat(DreamSettings.getDreamSettingDescriptionResId(-1))
|
assertThat(DreamSettings.getDreamSettingDescriptionResId(-1, /* enabledOnBattery= */ false))
|
||||||
|
.isEqualTo(R.string.screensaver_settings_summary_never);
|
||||||
|
assertThat(DreamSettings.getDreamSettingDescriptionResId(-1, /* enabledOnBattery= */ true))
|
||||||
.isEqualTo(R.string.screensaver_settings_summary_never);
|
.isEqualTo(R.string.screensaver_settings_summary_never);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ import android.os.UserManager;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||||
import com.android.settingslib.dream.DreamBackend;
|
import com.android.settingslib.dream.DreamBackend;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -37,9 +38,11 @@ import org.mockito.Answers;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(shadows = SettingsShadowResources.class)
|
||||||
public class WhenToDreamPickerTest {
|
public class WhenToDreamPickerTest {
|
||||||
|
|
||||||
private WhenToDreamPicker mPicker;
|
private WhenToDreamPicker mPicker;
|
||||||
@@ -53,10 +56,15 @@ public class WhenToDreamPickerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
final Context context = spy(ApplicationProvider.getApplicationContext());
|
final Context context = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
|
||||||
|
SettingsShadowResources.overrideResource(
|
||||||
|
com.android.internal.R.bool.config_dreamsEnabledOnBattery,
|
||||||
|
true);
|
||||||
|
|
||||||
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
when(context.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||||
FakeFeatureFactory.setupForTest();
|
FakeFeatureFactory.setupForTest();
|
||||||
|
|
||||||
mPicker = new WhenToDreamPicker();
|
mPicker = spy(new WhenToDreamPicker());
|
||||||
|
when(mPicker.getContext()).thenReturn(context);
|
||||||
mPicker.onAttach(context);
|
mPicker.onAttach(context);
|
||||||
|
|
||||||
ReflectionHelpers.setField(mPicker, "mBackend", mBackend);
|
ReflectionHelpers.setField(mPicker, "mBackend", mBackend);
|
||||||
|
@@ -64,7 +64,7 @@ public class WhenToDreamPreferenceControllerTest {
|
|||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mController = new WhenToDreamPreferenceController(mContext, true);
|
mController = new WhenToDreamPreferenceController(mContext, true, true);
|
||||||
ReflectionHelpers.setField(mController, "mBackend", mBackend);
|
ReflectionHelpers.setField(mController, "mBackend", mBackend);
|
||||||
when(mContext.getSystemService(PowerManager.class)).thenReturn(mPowerManager);
|
when(mContext.getSystemService(PowerManager.class)).thenReturn(mPowerManager);
|
||||||
when(mPowerManager.isAmbientDisplaySuppressedForTokenByApp(anyString(), anyInt()))
|
when(mPowerManager.isAmbientDisplaySuppressedForTokenByApp(anyString(), anyInt()))
|
||||||
@@ -88,7 +88,7 @@ public class WhenToDreamPreferenceControllerTest {
|
|||||||
final Preference mockPref = mock(Preference.class);
|
final Preference mockPref = mock(Preference.class);
|
||||||
when(mockPref.getContext()).thenReturn(mContext);
|
when(mockPref.getContext()).thenReturn(mContext);
|
||||||
when(mBackend.getWhenToDreamSetting()).thenReturn(testSetting);
|
when(mBackend.getWhenToDreamSetting()).thenReturn(testSetting);
|
||||||
final int expectedResId = DreamSettings.getDreamSettingDescriptionResId(testSetting);
|
final int expectedResId = DreamSettings.getDreamSettingDescriptionResId(testSetting, true);
|
||||||
|
|
||||||
mController.updateState(mockPref);
|
mController.updateState(mockPref);
|
||||||
verify(mockPref).setSummary(expectedResId);
|
verify(mockPref).setSummary(expectedResId);
|
||||||
|
@@ -20,6 +20,7 @@ import static android.app.NotificationManager.IMPORTANCE_NONE;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -32,6 +33,7 @@ import android.os.UserManager;
|
|||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.notification.NotificationBackend;
|
import com.android.settings.notification.NotificationBackend;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -157,4 +159,23 @@ public class NotificationsOffPreferenceControllerTest {
|
|||||||
assertThat(pref.getTitle().toString()).contains("app");
|
assertThat(pref.getTitle().toString()).contains("app");
|
||||||
assertThat(pref.isSelectable()).isFalse();
|
assertThat(pref.isSelectable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_whenToggleDisabled() {
|
||||||
|
// Given: the app does not request to post notifications
|
||||||
|
// and it's preference toggle is disabled
|
||||||
|
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||||
|
appRow.banned = true;
|
||||||
|
appRow.permissionStateLocked = true;
|
||||||
|
mController.onResume(appRow, null, null, null, null, null, null);
|
||||||
|
Preference pref = new Preference(RuntimeEnvironment.application);
|
||||||
|
|
||||||
|
// When: updateState(Preference preference) is called
|
||||||
|
mController.updateState(pref);
|
||||||
|
|
||||||
|
// Then: title of pref should be app_notifications_not_send_desc
|
||||||
|
assertEquals(
|
||||||
|
RuntimeEnvironment.application.getString(R.string.app_notifications_not_send_desc),
|
||||||
|
pref.getTitle().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user