Snap for 4651078 from 388b5314d7 to pi-release

Change-Id: I9ed631bbe16b5a6eec61f1a97e817efdee8739b7
This commit is contained in:
android-build-team Robot
2018-03-13 09:48:30 +00:00
25 changed files with 602 additions and 79 deletions

View File

@@ -96,6 +96,9 @@
<!-- Whether device_administrators should be shown or not. -->
<bool name="config_show_device_administrators">true</bool>
<!-- Whether encryption_and_credentials_encryption_status should be shown or not. -->
<bool name="config_show_encryption_and_credentials_encryption_status">true</bool>
<!-- Whether premium_sms should be shown or not. -->
<bool name="config_show_premium_sms">true</bool>
@@ -153,6 +156,9 @@
<!-- Whether assist_and_voice_input should be shown or not. -->
<bool name="config_show_assist_and_voice_input">true</bool>
<!-- Whether reset_dashboard should be shown or not. -->
<bool name="config_show_reset_dashboard">true</bool>
<!-- Whether system_update_settings should be shown or not. -->
<bool name="config_show_system_update_settings">true</bool>

View File

@@ -1136,25 +1136,25 @@
<!-- Security Picker --><skip />
<!-- Title for suggested actions for screen lock [CHAR LIMIT=34] -->
<string name="suggested_lock_settings_title">Set screen lock for security</string>
<!-- Title for suggested actions for screen lock [CHAR LIMIT=46] -->
<string name="suggested_lock_settings_title">Secure your phone</string>
<!-- Summary for suggested actions for screen lock (tablet) -->
<string name="suggested_lock_settings_summary" product="tablet">Prevent others from using your tablet</string>
<!-- Summary for suggested actions for screen lock (device) -->
<string name="suggested_lock_settings_summary" product="device">Prevent others from using your device</string>
<!-- Summary for suggested actions for screen lock (phone) -->
<string name="suggested_lock_settings_summary" product="default">Prevent others from using your phone</string>
<!-- Summary for suggested actions for screen lock (tablet) [CHAR LIMIT=55] -->
<string name="suggested_lock_settings_summary" product="tablet">Set screen lock to protect tablet</string>
<!-- Summary for suggested actions for screen lock (device) [CHAR LIMIT=55] -->
<string name="suggested_lock_settings_summary" product="device">Set screen lock to protect device</string>
<!-- Summary for suggested actions for screen lock (phone) [CHAR LIMIT=55] -->
<string name="suggested_lock_settings_summary" product="default">Set screen lock to protect phone</string>
<!-- Title for suggested actions for settings up a fingerprint lock [CHAR LIMIT=34] -->
<!-- Title for suggested actions for settings up a fingerprint lock [CHAR LIMIT=46] -->
<string name="suggested_fingerprint_lock_settings_title">Unlock with fingerprint</string>
<!-- Summary for suggested actions for settings up a fingerprint lock (tablet) -->
<string name="suggested_fingerprint_lock_settings_summary" product="tablet">Unlock with your fingerprint</string>
<!-- Summary for suggested actions for settings up a fingerprint lock (device) -->
<string name="suggested_fingerprint_lock_settings_summary" product="device">Unlock with your fingerprint</string>
<!-- Summary for suggested actions for settings up a fingerprint lock (phone) -->
<string name="suggested_fingerprint_lock_settings_summary" product="default">Unlock with your fingerprint</string>
<!-- Summary for suggested actions for settings up a fingerprint lock (tablet) [CHAR LIMIT=55] -->
<string name="suggested_fingerprint_lock_settings_summary" product="tablet"></string>
<!-- Summary for suggested actions for settings up a fingerprint lock (device) [CHAR LIMIT=55] -->
<string name="suggested_fingerprint_lock_settings_summary" product="device"></string>
<!-- Summary for suggested actions for settings up a fingerprint lock (phone) [CHAR LIMIT=55] -->
<string name="suggested_fingerprint_lock_settings_summary" product="default"></string>
<!-- Title for security picker to choose the unlock method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
<string name="lock_settings_picker_title">Choose screen lock</string>
@@ -1676,10 +1676,10 @@
<string name="bluetooth_max_connected_audio_devices_string">Maximum connected Bluetooth audio devices</string>
<!-- Bluetooth developer settings: Maximum number of connected audio devices -->
<string name="bluetooth_max_connected_audio_devices_dialog_title">Select maximum number of connected Bluetooth audio devices</string>
<!-- Bluetooth developer settings: Checkbox title for enabling Bluetooth receiving AVDTP delay reports -->
<string name="bluetooth_enable_avdtp_delay_reports">Enable Bluetooth AVDTP delay reports</string>
<!-- Bluetooth developer settings: Summary of checkbox for enabling Bluetooth receiving AVDTP delay reports -->
<string name="bluetooth_enable_avdtp_delay_reports_summary">Allow receiving Bluetooth AVDTP delay reports</string>
<!-- Bluetooth developer settings: Checkbox title for disabling Bluetooth receiving AVDTP delay reports -->
<string name="bluetooth_disable_avdtp_delay_reports">Disable Bluetooth AVDTP delay reports</string>
<!-- Bluetooth developer settings: Summary of checkbox for disabling Bluetooth receiving AVDTP delay reports -->
<string name="bluetooth_disable_avdtp_delay_reports_summary">Disallow receiving Bluetooth AVDTP delay reports</string>
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
<string name="wifi_display_settings_title">Cast</string>
@@ -2251,10 +2251,10 @@
<!-- Wireless networks, item title to go into the WFC settings [CHAR LIMIT=30] -->
<string name="wifi_calling_settings_title">Wi-Fi calling</string>
<!-- Title of suggestion to turn on wifi calling [CHAR LIMIT=30] -->
<string name="wifi_calling_suggestion_title">Extend call coverage with Wi\u2011Fi</string>
<!-- Summary of suggestion to turn on wifi calling [CHAR LIMIT=60] -->
<string name="wifi_calling_suggestion_summary">Turn on Wi\u2011Fi calling</string>
<!-- Title of suggestion to turn on wifi calling [CHAR LIMIT=46] -->
<string name="wifi_calling_suggestion_title">Extend calls with Wi\u2011Fi</string>
<!-- Summary of suggestion to turn on wifi calling [CHAR LIMIT=55] -->
<string name="wifi_calling_suggestion_summary">Turn on Wi\u2011Fi calling to extend coverage</string>
<!-- Title of WFC preference item [CHAR LIMIT=30] -->
<string name="wifi_calling_mode_title">Calling preference</string>
<!-- Title of WFC preference selection dialog [CHAR LIMIT=30] -->
@@ -2532,9 +2532,9 @@
<string name="wallpaper_settings_summary_default">Default</string>
<!-- Wallpaper settings summary when wallpaper has been updated [CHAR LIMIT=NONE] -->
<string name="wallpaper_settings_summary_custom">Custom</string>
<!-- Wallpaper suggestion title [CHAR LIMIT=30] -->
<!-- Wallpaper suggestion title [CHAR LIMIT=46] -->
<string name="wallpaper_suggestion_title">Change wallpaper</string>
<!-- Wallpaper suggestion title [CHAR LIMIT=60] -->
<!-- Wallpaper suggestion summary [CHAR LIMIT=55] -->
<string name="wallpaper_suggestion_summary">Personalize your screen</string>
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
@@ -6917,6 +6917,9 @@
<!-- Do not disturb: Title for the page describing what can bypass DND. [CHAR LIMIT=30] -->
<string name="zen_mode_behavior_settings_title">Exceptions</string>
<!-- Do not disturb: Title for the dnd duration setting (user can specify how long dnd will last when toggling dnd on from qs or settings) [CHAR LIMIT=30] -->
<string name="zen_mode_duration_settings_title">Duration</string>
<!-- Do not disturb: Instructions indicating what types of sounds can bypass DND. [CHAR LIMIT=52] -->
<string name="zen_mode_behavior_allow_title">Allow sounds and vibrations from</string>
@@ -6941,10 +6944,10 @@
<!-- Do not disturb: Title for a specific zen mode automatic rule in settings. [CHAR LIMIT=30] -->
<string name="zen_mode_automatic_rule_settings_page_title">Automatic rule</string>
<!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=34] -->
<!-- Do not disturb: Title for the zen mode automation option Suggestion. [CHAR LIMIT=46] -->
<string name="zen_mode_automation_suggestion_title">Silence phone at certain times</string>
<!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=NONE] -->
<!-- Do not disturb: Summary for the zen mode automation option Suggestion. [CHAR LIMIT=55] -->
<string name="zen_mode_automation_suggestion_summary">Set Do Not Disturb rules</string>
<!-- Do not disturb: Switch toggle to toggle whether to use an automatic dnd rule or not [CHAR LIMIT=40] -->
@@ -7026,8 +7029,8 @@
<!-- [CHAR LIMIT=20] Accessibility string for current zen mode and selected exit condition. A template that simply concatenates existing mode string and the current condition description. -->
<string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string>
<!-- Sound settings screen, summary format of do not disturb when on. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_on">On / <xliff:g name="dnd_summary" example="No sound except alarms and media">%1$s</xliff:g></string>
<!-- Sound settings screen, summary format of do not disturb when on with extra info. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_on_with_info">On / <xliff:g name="dnd_summary" example="No sound except alarms and media">%1$s</xliff:g></string>
<!-- Sound settings screen, summary format of do not disturb when off with extra information. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_off_with_info">Off / <xliff:g name="dnd_summary" example="1 rule can turn on automatically">%1$s</xliff:g></string>
@@ -7035,6 +7038,24 @@
<!-- Sound settings screen, summary format of do not disturb when off with no extra information. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_off">Off</string>
<!-- Sound settings screen, summary format of do not disturb when on with no extra information. [CHAR LIMIT=NONE] -->
<string name="zen_mode_sound_summary_on">On</string>
<!-- Do not disturb: Summary for zen mode duration setting indicating user will be prompted to set dnd duration whenever dnd is manually toggled on [CHAR LIMIT=NONE]-->
<string name="zen_mode_duration_summary_always_prompt">Ask every time (unless turned on automatically)</string>
<!-- Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when dnd is manually toggled on [CHAR LIMIT=NONE] -->
<string name="zen_mode_duration_summary_forever">Until you turn off (unless turned on automatically)</string>
<!-- Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when dnd is manually toggled on [CHAR LIMIT=NONE] -->
<plurals name="zen_mode_duration_summary_time_hours">
<item quantity="one">1 hour (unless turned on automatically)</item>
<item quantity="other"><xliff:g id="num_hours" example="3">%d</xliff:g> hours (unless turned on automatically)</item>
</plurals>
<!-- Do not disturb: Summary for zen mode duration setting indicating how long dnd will last when toggled on -->
<string name="zen_mode_duration_summary_time_minutes"><xliff:g id="num_minutes" example="5">%d</xliff:g> minutes (unless turned on automatically)</string>
<!-- Summary for the Sound Do not Disturb option when at least one automatic rules is enabled. [CHAR LIMIT=NONE]-->
<plurals name="zen_mode_sound_summary_summary_off_info">
<item quantity="one">1 rule can turn on automatically</item>
@@ -8554,10 +8575,10 @@
<!-- Summary of condition that work mode is off [CHAR LIMIT=NONE] -->
<string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
<!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
<!-- Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=46] -->
<string name="night_display_suggestion_title">Set Night Light schedule</string>
<!-- Night display: Summary for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
<!-- Night display: Summary for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=55] -->
<string name="night_display_suggestion_summary">Automatically tint screen every night</string>
<!-- Title of condition that night display is on (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
@@ -8765,10 +8786,10 @@
<!-- Summary of the preference controlling whether the device encryption *password* must be entered before being able to start the device. [CHAR LIMIT=NONE]-->
<string name="lockpattern_settings_require_password_before_startup_summary">Require password to start up your device. While off, this device can\'t receive calls, messages, notifications, or alarms.</string>
<!-- Title for suggestion adding more fingerprints [CHAR LIMIT=30] -->
<!-- Title for suggestion adding more fingerprints [CHAR LIMIT=46] -->
<string name="suggestion_additional_fingerprints">Add another fingerprint</string>
<!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=60] -->
<!-- Summary for suggestion adding more fingerprints [CHAR LIMIT=55] -->
<string name="suggestion_additional_fingerprints_summary">Unlock with a different finger</string>
<!-- Summary of battery saver when on [CHAR LIMIT=NONE] -->
@@ -9449,4 +9470,13 @@
<!-- Summary for media output settings when the media stream is being captured by something else. -->
<string name="media_output_summary_unavailable">Unavailable</string>
<!-- Title for battery Suggestion. (tablet) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="tablet" >Improve tablet\'s battery life</string>
<!-- Title for battery Suggestion. (device) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="device" >Improve device\'s battery life</string>
<!-- Title for battery Suggestion. (phone) [CHAR LIMIT=46] -->
<string name="battery_suggestion_title" product="default" >Improve phone\'s battery life</string>
<!-- Summary for battery Suggestion. [CHAR LIMIT=55] -->
<string name="battery_suggestion_summary"></string>
</resources>

View File

@@ -264,9 +264,9 @@
android:summary="@string/bluetooth_disable_inband_ringing_summary" />
<SwitchPreference
android:key="bluetooth_enable_avdtp_delay_reports"
android:title="@string/bluetooth_enable_avdtp_delay_reports"
android:summary="@string/bluetooth_enable_avdtp_delay_reports_summary"/>
android:key="bluetooth_disable_avdtp_delay_reports"
android:title="@string/bluetooth_disable_avdtp_delay_reports"
android:summary="@string/bluetooth_disable_avdtp_delay_reports_summary"/>
<ListPreference
android:key="bluetooth_select_avrcp_version"

View File

@@ -46,7 +46,8 @@
android:summary="@string/reset_dashboard_summary"
android:icon="@drawable/ic_restore"
android:order="-50"
android:fragment="com.android.settings.system.ResetDashboardFragment" />
android:fragment="com.android.settings.system.ResetDashboardFragment"
settings:controller="com.android.settings.system.ResetPreferenceController"/>
<!-- System updates -->
<Preference

View File

@@ -31,6 +31,11 @@
android:title="@string/zen_mode_behavior_settings_title"
android:fragment="com.android.settings.notification.ZenModeBehaviorSettings" />
<!-- DND duration settings -->
<Preference
android:key="zen_mode_duration_settings"
android:title="@string/zen_mode_duration_settings_title" />
<!-- Automatic rules -->
<Preference
android:key="zen_mode_automation_settings"

View File

@@ -105,6 +105,7 @@ import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.ZenAccessSettings;
import com.android.settings.notification.ZenModeAutomationSettings;
import com.android.settings.notification.ZenModeBehaviorSettings;
import com.android.settings.notification.ZenModeBlockedEffectsSettings;
import com.android.settings.notification.ZenModeEventRuleSettings;
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
@@ -220,6 +221,7 @@ public class SettingsGateway {
ZenModeBehaviorSettings.class.getName(),
ZenModeScheduleRuleSettings.class.getName(),
ZenModeEventRuleSettings.class.getName(),
ZenModeBlockedEffectsSettings.class.getName(),
ProcessStatsUi.class.getName(),
AdvancedPowerUsageDetail.class.getName(),
ProcessStatsSummary.class.getName(),

View File

@@ -25,7 +25,9 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.SearchView;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -130,6 +132,19 @@ public abstract class BaseTimeZonePicker extends InstrumentedFragment
mSearchView.setActivated(true);
mSearchView.setQuery("", true /* submit */);
}
// Set zero margin and padding to align with the text horizontally in the preference
final TextView searchViewView = (TextView) mSearchView.findViewById(
com.android.internal.R.id.search_src_text);
searchViewView.setPadding(0, searchViewView.getPaddingTop(), 0,
searchViewView.getPaddingBottom());
final View editFrame = mSearchView.findViewById(
com.android.internal.R.id.search_edit_frame);
final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editFrame
.getLayoutParams();
params.setMarginStart(0);
params.setMarginEnd(0);
editFrame.setLayoutParams(params);
}
}

View File

@@ -28,11 +28,11 @@ import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothDelayReportsPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY =
"bluetooth_enable_avdtp_delay_reports";
private static final String BLUETOOTH_DISABLE_AVDTP_DELAY_REPORT_KEY =
"bluetooth_disable_avdtp_delay_reports";
@VisibleForTesting
static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY =
"persist.bluetooth.enabledelayreports";
static final String BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY =
"persist.bluetooth.disabledelayreports";
public BluetoothDelayReportsPreferenceController(Context context) {
super(context);
@@ -40,22 +40,22 @@ public class BluetoothDelayReportsPreferenceController extends DeveloperOptionsP
@Override
public String getPreferenceKey() {
return BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY;
return BLUETOOTH_DISABLE_AVDTP_DELAY_REPORT_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
isEnabled ? "true" : "false");
final boolean isDisabled = (Boolean) newValue;
SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
isDisabled ? "true" : "false");
return true;
}
@Override
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isEnabled);
final boolean isDisabled = SystemProperties.getBoolean(
BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
((SwitchPreference) mPreference).setChecked(isDisabled);
}
@Override
@@ -63,7 +63,7 @@ public class BluetoothDelayReportsPreferenceController extends DeveloperOptionsP
super.onDeveloperOptionsSwitchDisabled();
// the default setting for this preference is the disabled state
((SwitchPreference) mPreference).setChecked(false);
SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false");
SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false");
}
}

View File

@@ -112,10 +112,17 @@ abstract public class AbstractZenModePreferenceController extends
mBackend.mZenMode);
}
protected int getZenDuration() {
return Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ZEN_DURATION,
0);
}
class SettingObserver extends ContentObserver {
private final Uri ZEN_MODE_URI = Settings.Global.getUriFor(Settings.Global.ZEN_MODE);
private final Uri ZEN_MODE_CONFIG_ETAG_URI = Settings.Global.getUriFor(
Settings.Global.ZEN_MODE_CONFIG_ETAG);
private final Uri ZEN_MODE_DURATION_URI = Settings.Global.getUriFor(
Settings.Global.ZEN_DURATION);
private final Preference mPreference;
@@ -127,6 +134,7 @@ abstract public class AbstractZenModePreferenceController extends
public void register(ContentResolver cr) {
cr.registerContentObserver(ZEN_MODE_URI, false, this, UserHandle.USER_ALL);
cr.registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false, this, UserHandle.USER_ALL);
cr.registerContentObserver(ZEN_MODE_DURATION_URI, false, this, UserHandle.USER_ALL);
}
public void unregister(ContentResolver cr) {
@@ -136,11 +144,8 @@ abstract public class AbstractZenModePreferenceController extends
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
if (ZEN_MODE_URI.equals(uri)) {
updateState(mPreference);
}
if (ZEN_MODE_CONFIG_ETAG_URI.equals(uri)) {
if (ZEN_MODE_URI.equals(uri) || ZEN_MODE_CONFIG_ETAG_URI.equals(uri)
|| ZEN_MODE_DURATION_URI.equals(uri)) {
updateState(mPreference);
}
}

View File

@@ -0,0 +1,37 @@
/*
* 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.notification;
import android.app.Dialog;
import android.os.Bundle;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class SettingsZenDurationDialog extends InstrumentedDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new com.android.settingslib.notification.ZenDurationDialog(
getContext()).createDialog();
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.NOTIFICATION_ZEN_MODE_DURATION_DIALOG;
}
}

View File

@@ -1,3 +1,19 @@
/*
* 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.notification;
import android.content.Context;

View File

@@ -16,9 +16,11 @@
package com.android.settings.notification;
import android.app.ActivityManager;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
import android.content.Context;
import android.net.Uri;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.support.annotation.VisibleForTesting;
@@ -79,7 +81,15 @@ public class ZenModeBackend {
protected void setZenMode(int zenMode) {
NotificationManager.from(mContext).setZenMode(zenMode, null, TAG);
mZenMode = zenMode;
mZenMode = getZenMode();
}
protected void setZenModeForDuration(int minutes) {
Uri conditionId = ZenModeConfig.toTimeCondition(mContext, minutes,
ActivityManager.getCurrentUser(), true).id;
mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
conditionId, TAG);
mZenMode = getZenMode();
}
protected int getZenMode() {

View File

@@ -1,3 +1,19 @@
/*
* 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.notification;
import android.content.Context;

View File

@@ -61,8 +61,7 @@ public class ZenModeButtonPreferenceController extends AbstractZenModePreference
if (null == mZenButtonOn) {
mZenButtonOn = (Button) ((LayoutPreference) preference)
.findViewById(R.id.zen_mode_settings_turn_on_button);
mZenButtonOn.setOnClickListener(v ->
new SettingsEnableZenModeDialog().show(mFragment, TAG));
updateZenButtonOnClickListener();
}
if (null == mZenButtonOff) {
@@ -89,7 +88,34 @@ public class ZenModeButtonPreferenceController extends AbstractZenModePreference
case Settings.Global.ZEN_MODE_OFF:
default:
mZenButtonOff.setVisibility(View.GONE);
updateZenButtonOnClickListener();
mZenButtonOn.setVisibility(View.VISIBLE);
}
}
private void updateZenButtonOnClickListener() {
int zenDuration = getZenDuration();
switch (zenDuration) {
case Settings.Global.ZEN_DURATION_PROMPT:
mZenButtonOn.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext,
MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
new SettingsEnableZenModeDialog().show(mFragment, TAG);
});
break;
case Settings.Global.ZEN_DURATION_FOREVER:
mZenButtonOn.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext,
MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
mBackend.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
});
break;
default:
mZenButtonOn.setOnClickListener(v -> {
mMetricsFeatureProvider.action(mContext,
MetricsProto.MetricsEvent.ACTION_ZEN_TOGGLE_DND_BUTTON, false);
mBackend.setZenModeForDuration(zenDuration);
});
}
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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.notification;
import android.app.FragmentManager;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle;
public class ZenModeDurationPreferenceController extends AbstractZenModePreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceClickListener {
private static final String TAG = "ZenModeDurationDialog";
protected static final String KEY = "zen_mode_duration_settings";
private FragmentManager mFragment;
public ZenModeDurationPreferenceController(Context context, Lifecycle lifecycle, FragmentManager
fragment) {
super(context, KEY, lifecycle);
mFragment = fragment;
}
@Override
public boolean isAvailable() {
return true;
}
@Override
public String getPreferenceKey() {
return KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
screen.findPreference(KEY).setOnPreferenceClickListener(this);
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
String summary = "";
int zenDuration = getZenDuration();
if (zenDuration < 0) {
summary = mContext.getString(R.string.zen_mode_duration_summary_always_prompt);
} else if (zenDuration == 0) {
summary = mContext.getString(R.string.zen_mode_duration_summary_forever);
} else {
if (zenDuration >= 60) {
int hours = zenDuration / 60;
summary = mContext.getResources().getQuantityString(
R.plurals.zen_mode_duration_summary_time_hours, hours, hours);
} else {
summary = mContext.getResources().getString(
R.string.zen_mode_duration_summary_time_minutes, zenDuration);
}
}
preference.setSummary(summary);
}
@Override
public boolean onPreferenceClick(Preference preference) {
new SettingsZenDurationDialog().show(mFragment, TAG);
return true;
}
}

View File

@@ -23,6 +23,7 @@ import android.app.NotificationManager.Policy;
import android.content.Context;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
import android.support.annotation.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -64,6 +65,8 @@ public class ZenModeSettings extends ZenModeSettingsBase {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new ZenModeBehaviorPreferenceController(context, lifecycle));
controllers.add(new ZenModeBlockedEffectsPreferenceController(context, lifecycle));
controllers.add(new ZenModeDurationPreferenceController(context, lifecycle,
fragmentManager));
controllers.add(new ZenModeAutomationPreferenceController(context));
controllers.add(new ZenModeButtonPreferenceController(context, lifecycle, fragmentManager));
controllers.add(new ZenModeSettingsFooterPreferenceController(context, lifecycle));
@@ -122,9 +125,15 @@ public class ZenModeSettings extends ZenModeSettingsBase {
int zenMode = NotificationManager.from(mContext).getZenMode();
if (zenMode != Settings.Global.ZEN_MODE_OFF) {
Policy policy = NotificationManager.from(mContext).getNotificationPolicy();
return mContext.getString(R.string.zen_mode_sound_summary_on,
getBehaviorSettingSummary(policy, zenMode));
ZenModeConfig config = NotificationManager.from(mContext).getZenModeConfig();
String description = ZenModeConfig.getDescription(mContext, true, config);
if (description == null) {
return mContext.getString(R.string.zen_mode_sound_summary_on);
} else {
return mContext.getString(R.string.zen_mode_sound_summary_on_with_info,
description);
}
} else {
final int count = getEnabledAutomaticRulesCount();
if (count > 0) {
@@ -243,6 +252,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
keys.add(ZenModeDurationPreferenceController.KEY);
keys.add(ZenModeButtonPreferenceController.KEY);
return keys;
}

View File

@@ -41,6 +41,12 @@ public class EncryptionStatusPreferenceController extends BasePreferenceControll
@Override
public int getAvailabilityStatus() {
if (TextUtils.equals(getPreferenceKey(), PREF_KEY_ENCRYPTION_DETAIL_PAGE) &&
!mContext.getResources().getBoolean(
R.bool.config_show_encryption_and_credentials_encryption_status)) {
return DISABLED_UNSUPPORTED;
}
return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER;
}

View File

@@ -0,0 +1,35 @@
/*
* 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.system;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
public class ResetPreferenceController extends BasePreferenceController {
public ResetPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard)
? AVAILABLE
: DISABLED_UNSUPPORTED;
}
}

View File

@@ -34,6 +34,7 @@
<bool name="config_show_screen_locking_sounds">false</bool>
<bool name="config_show_touch_sounds">false</bool>
<bool name="config_show_device_administrators">false</bool>
<bool name="config_show_encryption_and_credentials_encryption_status">false</bool>
<bool name="config_show_premium_sms">false</bool>
<bool name="config_show_data_saver">false</bool>
<bool name="config_show_enabled_vr_listeners">false</bool>
@@ -54,6 +55,7 @@
<bool name="config_show_tts_settings_summary">false</bool>
<bool name="config_show_pointer_speed">false</bool>
<bool name="config_show_vibrate_input_devices">false</bool>
<bool name="config_show_reset_dashboard">false</bool>
<bool name="config_show_system_update_settings">false</bool>
<bool name="config_wifi_support_connected_mac_randomization">false</bool>
<bool name="config_show_device_model">false</bool>

View File

@@ -44,23 +44,25 @@ import com.android.settings.SettingsActivity;
import com.android.settings.dashboard.DashboardAdapter;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.ShadowCardView;
import com.android.settingslib.suggestions.SuggestionControllerMixin;
import com.android.settingslib.utils.IconCache;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = ShadowCardView.class)
public class SuggestionAdapterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -143,7 +145,6 @@ public class SuggestionAdapterTest {
.isEqualTo(R.layout.suggestion_tile_with_button);
}
@Ignore
@Test
public void onBindViewHolder_shouldLog() {
final View view = spy(LayoutInflater.from(mContext).inflate(
@@ -164,7 +165,6 @@ public class SuggestionAdapterTest {
mOneSuggestion.get(0).getId());
}
@Ignore
@Test
public void onBindViewHolder_itemViewShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -178,7 +178,6 @@ public class SuggestionAdapterTest {
verify(suggestions.get(0).getPendingIntent()).send();
}
@Ignore
@Test
public void onBindViewHolder_hasButton_buttonShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -205,7 +204,6 @@ public class SuggestionAdapterTest {
verify(pendingIntent).send();
}
@Ignore
@Test
public void getSuggestions_shouldReturnSuggestionWhenMatch() {
final List<Suggestion> suggestions = makeSuggestions("pkg1");
@@ -214,7 +212,6 @@ public class SuggestionAdapterTest {
assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
}
@Ignore
@Test
public void onBindViewHolder_closeButtonShouldHandleClick()
throws PendingIntent.CanceledException {
@@ -236,7 +233,6 @@ public class SuggestionAdapterTest {
verify(callback).onSuggestionClosed(suggestion);
}
@Ignore
@Test
public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
throws PendingIntent.CanceledException {
@@ -263,7 +259,6 @@ public class SuggestionAdapterTest {
verify(drawable, never()).setTint(anyInt());
}
@Ignore
@Test
public void onBindViewHolder_iconTintable_shouldTintIcon()
throws PendingIntent.CanceledException {
@@ -296,7 +291,6 @@ public class SuggestionAdapterTest {
verify(drawable).setTint(colorAccent);
}
@Ignore
@Test
public void onBindViewHolder_closeButtonShouldHaveContentDescription()
throws PendingIntent.CanceledException {
@@ -310,7 +304,6 @@ public class SuggestionAdapterTest {
.isNotNull();
}
@Ignore
@Test
public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
final List<Suggestion> suggestions = makeSuggestions("pkg1");

View File

@@ -16,7 +16,9 @@
package com.android.settings.development;
import static com.android.settings.development.BluetoothDelayReportsPreferenceController.BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY;
import static com.android.settings.development.BluetoothDelayReportsPreferenceController
.BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -57,11 +59,11 @@ public class BluetoothDelayReportsPreferenceControllerTest {
}
@Test
public void onPreferenceChanged_settingEnabled_turnOnDelayReports() {
public void onPreferenceChanged_settingDisabled_turnOnDelayReports() {
mController.onPreferenceChange(mPreference, true /* new value */);
final boolean mode = SystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isTrue();
}
@@ -71,14 +73,14 @@ public class BluetoothDelayReportsPreferenceControllerTest {
mController.onPreferenceChange(mPreference, false /* new value */);
final boolean mode = SystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
}
@Test
public void updateState_settingEnabled_preferenceShouldBeChecked() {
SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
public void updateState_settingDisabled_preferenceShouldBeChecked() {
SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
Boolean.toString(true));
mController.updateState(mPreference);
@@ -87,7 +89,7 @@ public class BluetoothDelayReportsPreferenceControllerTest {
@Test
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY,
SystemProperties.set(BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY,
Boolean.toString(false));
mController.updateState(mPreference);
@@ -99,7 +101,7 @@ public class BluetoothDelayReportsPreferenceControllerTest {
mController.onDeveloperOptionsDisabled();
final boolean mode = SystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
BLUETOOTH_DISABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
assertThat(mPreference.isEnabled()).isFalse();

View File

@@ -0,0 +1,111 @@
/*
* 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.notification;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.FragmentManager;
import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
public class ZenModeDurationPreferenceControllerTest {
private ZenModeDurationPreferenceController mController;
@Mock
private ZenModeBackend mBackend;
@Mock
private NotificationManager mNotificationManager;
@Mock
private Preference mockPref;
@Mock
private NotificationManager.Policy mPolicy;
@Mock
private PreferenceScreen mPreferenceScreen;
private ContentResolver mContentResolver;
private Context mContext;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
ShadowApplication shadowApplication = ShadowApplication.getInstance();
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
mContext = shadowApplication.getApplicationContext();
mContentResolver = RuntimeEnvironment.application.getContentResolver();
mController = new ZenModeDurationPreferenceController(mContext, mock(Lifecycle.class),
mock(FragmentManager.class));
when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
ReflectionHelpers.setField(mController, "mBackend", mBackend);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(
mockPref);
mController.displayPreference(mPreferenceScreen);
}
@Test
public void updateState_DurationForever() {
Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
Settings.Global.ZEN_DURATION_FOREVER);
final Preference mockPref = mock(Preference.class);
mController.updateState(mockPref);
verify(mockPref).setSummary(mContext.getString(R.string.zen_mode_duration_summary_forever));
}
@Test
public void updateState_DurationPrompt() {
Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
Settings.Global.ZEN_DURATION_PROMPT);
final Preference mockPref = mock(Preference.class);
mController.updateState(mockPref);
verify(mockPref).setSummary(mContext.getString(
R.string.zen_mode_duration_summary_always_prompt));
}
@Test
public void updateState_DurationCustom() {
int zenDuration = 45;
Settings.Global.putInt(mContentResolver, Settings.Global.ZEN_DURATION,
zenDuration);
final Preference mockPref = mock(Preference.class);
mController.updateState(mockPref);
verify(mockPref).setSummary(mContext.getResources().getString(
R.string.zen_mode_duration_summary_time_minutes, zenDuration));
}
}

View File

@@ -67,6 +67,23 @@ public class EncryptionStatusPreferenceControllerTest {
assertThat(mController.isAvailable()).isFalse();
}
@Test
@Config(qualifiers = "mcc999")
public void isAvailable_notVisible_false() {
assertThat(mController.isAvailable()).isFalse();
}
@Test
@Config(qualifiers = "mcc999")
public void isAvailable_notVisible_butNotDetailPage_true() {
mController = new EncryptionStatusPreferenceController(mContext,
PREF_KEY_ENCRYPTION_SECURITY_PAGE);
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
Shadows.shadowOf(userManager).setIsAdminUser(true);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void updateSummary_encrypted_shouldSayEncrypted() {
ShadowLockPatternUtils.setDeviceEncryptionEnabled(true);

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2016 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.system;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
public class ResetPreferenceControllerTest {
private static final String KEY_RESET_DASHBOARD = "reset_dashboard";
private Context mContext;
private ResetPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mController = new ResetPreferenceController(mContext, KEY_RESET_DASHBOARD);
}
@Test
public void isAvailable_byDefault_true() {
assertThat(mController.isAvailable()).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void isAvailable_ifNotVisible_false() {
assertThat(mController.isAvailable()).isFalse();
}
}

View File

@@ -0,0 +1,36 @@
/*
* 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.testutils.shadow;
import android.content.Context;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;
import org.robolectric.annotation.Implements;
import org.robolectric.shadows.ShadowFrameLayout;
/**
* Shadow for CardView to get around view not implemented error.
*/
@Implements(CardView.class)
public class ShadowCardView extends ShadowFrameLayout {
public void __constructor__(Context context, AttributeSet attrs, int defStyleAttr) {
// do nothing
}
}