Merge "Change strings for system alert window setting"
diff --git a/res/values/config.xml b/res/values/config.xml
index 0fa2b71..f81bf9b 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -67,4 +67,36 @@
<!-- If the support features are enabled. -->
<bool name="config_support_enabled">false</bool>
+ <!-- List containing the component names of pre-installed screen reader services. -->
+ <string-array name="config_preinstalled_screen_reader_services" translatable="false">
+ <!--
+ <item>com.example.package.first/com.example.class.FirstService</item>
+ <item>com.example.package.second/com.example.class.SecondService</item>
+ -->
+ </string-array>
+
+ <!-- List containing the component names of pre-installed audio and captioning services. -->
+ <string-array name="config_preinstalled_audio_and_caption_services" translatable="false">
+ <!--
+ <item>com.example.package.first/com.example.class.FirstService</item>
+ <item>com.example.package.second/com.example.class.SecondService</item>
+ -->
+ </string-array>
+
+ <!-- List containing the component names of pre-installed display services. -->
+ <string-array name="config_preinstalled_display_services" translatable="false">
+ <!--
+ <item>com.example.package.first/com.example.class.FirstService</item>
+ <item>com.example.package.second/com.example.class.SecondService</item>
+ -->
+ </string-array>
+
+ <!-- List containing the component names of pre-installed interaction control services. -->
+ <string-array name="config_preinstalled_interaction_control_services" translatable="false">
+ <!--
+ <item>com.example.package.first/com.example.class.FirstService</item>
+ <item>com.example.package.second/com.example.class.SecondService</item>
+ -->
+ </string-array>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 568a3d6..4120b75 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3997,22 +3997,30 @@
<string name="vision_settings_title">Vision Settings</string>
<!-- Settings description for a brief version of Vision-Related Accessibility Settings. Tells the user that they can adjust these settings now to help them through the remainder of the Setup Wizard and that they can later be changed in Settings. Displayed in Setup Wizard only. [CHAR LIMIT=none] -->
<string name="vision_settings_description">You can customize this device to fit your needs. These accessibility features can be changed later in Settings.</string>
- <!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] -->
- <string name="accessibility_services_title">Services</string>
+ <!-- Title for the accessibility preference category of screen reader services and settings. [CHAR LIMIT=50] -->
+ <string name="screen_reader_category_title">Screen readers</string>
+ <!-- Title for the accessibility preference category of audio services and settings. [CHAR LIMIT=50] -->
+ <string name="audio_and_captions_category_title">Audio & on-screen text</string>
+ <!-- Title for the accessibility preference category of display services and settings. [CHAR LIMIT=50] -->
+ <string name="display_category_title">Display</string>
+ <!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
+ <string name="interaction_control_category_title">Interaction controls</string>
+ <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
+ <string name="user_installed_services_category_title">Downloaded services</string>
+ <!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
+ <string name="experimental_category_title">Experimental</string>
<!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
<string name="talkback_title">Talkback</string>
<!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
<string name="talkback_summary">Screen reader primarily for people with blindness and low vision</string>
<!-- Summary for the Select to Speak Accessibility Service. [CHAR_LIMIT=none] -->
<string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
- <!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
- <string name="accessibility_system_title">System</string>
- <!-- Title for the accessibility preference category of display related preferences. [CHAR LIMIT=25] -->
- <string name="accessibility_display_title">Display</string>
<!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
<string name="accessibility_captioning_title">Captions</string>
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
- <string name="accessibility_screen_magnification_title">Magnification gesture</string>
+ <string name="accessibility_screen_magnification_title">Magnification</string>
+ <!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
+ <string name="accessibility_preference_magnification_summary">Zoom in on screen</string>
<!-- Short summary for Magnification gesture. Tells the user that this feature allows the user to magnify the screen by tapping 3 times. Appears in accessibility portion of setup wizard -->
<string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
<!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] -->
@@ -4040,7 +4048,7 @@
<!-- Title for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
<string name="accessibility_display_inversion_preference_title">Color inversion</string>
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
- <string name="accessibility_display_inversion_preference_subtitle">(Experimental) May affect performance</string>
+ <string name="accessibility_display_inversion_preference_subtitle">May affect performance</string>
<!-- Title for accessibility preference for configuring feature that performs click action soon after mouse/trackpad pointer stops moving. [CHAR LIMIT=NONE] -->
<string name="accessibility_autoclick_preference_title">Click after pointer stops moving</string>
<!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
@@ -4199,10 +4207,10 @@
<string name="disable_service_message">Tapping OK will
stop <xliff:g id="service" example="TalkBack">%1$s</xliff:g>.</string>
- <!-- Title for the prompt shown as a placeholder if no accessibility serivices are installed. [CHAR LIMIT=50] -->
+ <!-- Title for the prompt shown as a placeholder if no accessibility services are installed. [CHAR LIMIT=50] -->
<string name="accessibility_no_services_installed">No services installed</string>
- <!-- Default description for an accessibility serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
+ <!-- Default description for an accessibility service if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
<string name="accessibility_service_default_description">No description provided.</string>
<!-- Accessibility settings: button for lauching settings for an accessibility service -->
@@ -4223,7 +4231,7 @@
<!-- Title for print service settings screen [CHAR LIMIT=25] -->
<string name="print_settings_title">Print services</string>
- <!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] -->
+ <!-- Title for the prompt shown as a placeholder if no print services are installed. [CHAR LIMIT=50] -->
<string name="print_no_services_installed">No services installed</string>
<!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
@@ -6465,8 +6473,14 @@
<!-- [CHAR LIMIT=NONE] App notification settings: no channels -->
<string name="no_channels">This app has not posted any notifications</string>
- <!-- [CHAR LIMIT=60] App notification settings: Text to display for deleted channels -->
- <string name="deleted_channel_name"><xliff:g id="channel_name" example="Promotions">%1$s</xliff:g> (deleted)</string>
+ <!-- [CHAR LIMIT=NONE] App notification settings: link to app notification settings-->
+ <string name="app_settings_link">Additional settings in the app</string>
+
+ <!-- [CHAR LIMIT=NONE] Footer listing a count of deleted channels. -->
+ <plurals name="deleted_channels">
+ <item quantity="one">%d category deleted</item>
+ <item quantity="other">%d categories deleted</item>
+ </plurals>
<!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
<string name="app_notification_block_title">Block all</string>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index ee21017..5c67d6e 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -18,43 +18,61 @@
android:title="@string/accessibility_settings"
android:persistent="true">
+ <ListPreference
+ android:key="accessibility_shortcut_preference"
+ android:title="@string/accessibility_global_gesture_preference_title"/>
+
<PreferenceCategory
- android:key="services_category"
- android:title="@string/accessibility_services_title">
+ android:key="user_installed_services_category"
+ android:title="@string/user_installed_services_category_title">
</PreferenceCategory>
<PreferenceCategory
- android:key="system_category"
- android:title="@string/accessibility_system_title">
+ android:key="screen_reader_category"
+ android:title="@string/screen_reader_category_title">
<Preference
- android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
- android:key="captioning_preference_screen"
- android:title="@string/accessibility_captioning_title" />
+ android:key="tts_settings_preference"
+ android:fragment="com.android.settings.tts.TextToSpeechSettings"
+ android:title="@string/tts_settings_title"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="display_category"
+ android:title="@string/display_category_title">
<Preference
- android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
- android:key="screen_magnification_preference_screen"
- android:title="@string/accessibility_screen_magnification_title"/>
-
- <Preference
- android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
- android:key="font_size_preference_screen"
- android:title="@string/title_font_size"/>
+ android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+ android:key="font_size_preference_screen"
+ android:title="@string/title_font_size"/>
<com.android.settings.display.ScreenZoomPreference
- android:key="screen_zoom"
- android:title="@string/screen_zoom_title"/>
+ android:key="screen_zoom"
+ android:title="@string/screen_zoom_title"/>
<Preference
- android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
- android:key="autoclick_preference_screen"
- android:title="@string/accessibility_autoclick_preference_title"/>
+ android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+ android:key="screen_magnification_preference_screen"
+ android:title="@string/accessibility_screen_magnification_title" />
+
+ <Preference
+ android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
+ android:key="daltonizer_preference_screen"
+ android:title="@string/accessibility_display_daltonizer_preference_title" />
<SwitchPreference
- android:key="toggle_high_text_contrast_preference"
- android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
- android:summary="@string/experimental_preference"/>
+ android:key="toggle_large_pointer_icon"
+ android:title="@string/accessibility_toggle_large_pointer_icon_title" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="interaction_control_category"
+ android:title="@string/interaction_control_category_title">
+
+ <Preference
+ android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
+ android:key="autoclick_preference_screen"
+ android:title="@string/accessibility_autoclick_preference_title"/>
<SwitchPreference
android:key="toggle_power_button_ends_call_preference"
@@ -66,9 +84,17 @@
android:title="@string/accelerometer_title"
android:persistent="false"/>
- <SwitchPreference
- android:key="toggle_large_pointer_icon"
- android:title="@string/accessibility_toggle_large_pointer_icon_title" />
+ <ListPreference
+ android:key="select_long_press_timeout_preference"
+ android:title="@string/accessibility_long_press_timeout_preference_title"
+ android:entries="@array/long_press_timeout_selector_titles"
+ android:entryValues="@array/long_press_timeout_selector_values"
+ android:persistent="false"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="audio_and_captions_category"
+ android:title="@string/audio_and_captions_category_title">
<SwitchPreference
android:key="toggle_master_mono"
@@ -76,35 +102,24 @@
android:summary="@string/accessibility_toggle_master_mono_summary"
android:persistent="false"/>
- <ListPreference
- android:key="accessibility_shortcut_preference"
- android:title="@string/accessibility_global_gesture_preference_title"/>
-
<Preference
- android:key="tts_settings_preference"
- android:fragment="com.android.settings.tts.TextToSpeechSettings"
- android:title="@string/tts_settings_title"/>
-
- <ListPreference android:key="select_long_press_timeout_preference"
- android:title="@string/accessibility_long_press_timeout_preference_title"
- android:entries="@array/long_press_timeout_selector_titles"
- android:entryValues="@array/long_press_timeout_selector_values"
- android:persistent="false"/>
-
+ android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
+ android:key="captioning_preference_screen"
+ android:title="@string/accessibility_captioning_title" />
</PreferenceCategory>
<PreferenceCategory
- android:key="display_category"
- android:title="@string/accessibility_display_title" >
- <SwitchPreference
- android:key="toggle_inversion_preference"
- android:title="@string/accessibility_display_inversion_preference_title"
- android:summary="@string/accessibility_display_inversion_preference_subtitle"
- android:persistent="false" />
- <Preference
- android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
- android:key="daltonizer_preference_screen"
- android:title="@string/accessibility_display_daltonizer_preference_title" />
- </PreferenceCategory>
+ android:key="experimental_category"
+ android:title="@string/experimental_category_title">
+ <SwitchPreference
+ android:key="toggle_high_text_contrast_preference"
+ android:title="@string/accessibility_toggle_high_text_contrast_preference_title" />
+
+ <SwitchPreference
+ android:key="toggle_inversion_preference"
+ android:title="@string/accessibility_display_inversion_preference_title"
+ android:summary="@string/accessibility_display_inversion_preference_subtitle"
+ android:persistent="false" />
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 4af9fe8..fde1bfa 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -23,29 +23,25 @@
android:key="block"
android:title="@string/app_notification_block_title"
android:summary="@string/app_notification_block_summary"
- android:order="1"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
<!-- Importance -->
<com.android.settings.notification.RestrictedDropDownPreference
android:key="importance"
- android:title="@string/notification_importance_title"
- android:order="2"/>
+ android:title="@string/notification_importance_title" />
<!-- Default ringtone -->
<com.android.settings.notification.DefaultNotificationTonePreference
android:key="ringtone"
android:title="@string/notification_ringtone_title"
android:dialogTitle="@string/notification_ringtone_title"
- android:order="3"
android:ringtoneType="notification" />
<!-- Vibration -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="vibrate"
android:title="@string/notification_vibrate_title"
- android:order="4"
settings:useAdditionalSummary="true" />
<!-- Show badge -->
@@ -53,7 +49,6 @@
android:key="badge"
android:title="@string/notification_badge_title"
android:summary="@string/notification_badge_summary"
- android:order="5"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
@@ -61,21 +56,18 @@
<com.android.settingslib.RestrictedSwitchPreference
android:key="lights"
android:title="@string/notification_show_lights_title"
- android:order="6"
settings:useAdditionalSummary="true" />
<!-- Visibility Override -->
<com.android.settings.notification.RestrictedDropDownPreference
android:key="visibility_override"
- android:title="@string/app_notification_visibility_override_title"
- android:order="7" />
+ android:title="@string/app_notification_visibility_override_title" />
<!-- Bypass DND -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd"
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary"
- android:order="8"
settings:useAdditionalSummary="true" />
</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 807371e..86c340d 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -35,7 +36,9 @@
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
+import android.util.ArrayMap;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.accessibility.AccessibilityManager;
@@ -46,18 +49,17 @@
import com.android.internal.view.RotationPolicy.RotationPolicyListener;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.SingleLineSummaryPreference;
import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,9 +70,20 @@
public class AccessibilitySettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, Indexable {
+ // Index of the first preference in a preference category.
+ private static final int FIRST_PREFERENCE_IN_CATEGORY_INDEX = -1;
+
// Preference categories
- private static final String SERVICES_CATEGORY = "services_category";
- private static final String SYSTEM_CATEGORY = "system_category";
+ private static final String CATEGORY_SCREEN_READER = "screen_reader_category";
+ private static final String CATEGORY_AUDIO_AND_CAPTIONS = "audio_and_captions_category";
+ private static final String CATEGORY_DISPLAY = "display_category";
+ private static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
+ private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
+
+ private static final String[] CATEGORIES = new String[] {
+ CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY,
+ CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
+ };
// Preferences
private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
@@ -118,10 +131,7 @@
// ID for dialog that confirms shortcut capabilities
private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
- // Auxiliary members.
- static final Set<ComponentName> sInstalledServices = new HashSet<>();
-
- private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
+ private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
private final Handler mHandler = new Handler();
@@ -129,7 +139,7 @@
@Override
public void run() {
if (getActivity() != null) {
- updateServicesPreferences();
+ updateServicePreferences();
}
}
};
@@ -164,7 +174,7 @@
new SettingsContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- updateServicesPreferences();
+ updateServicePreferences();
}
};
@@ -175,9 +185,12 @@
}
};
- // Preference controls.
- private PreferenceCategory mServicesCategory;
- private PreferenceCategory mSystemsCategory;
+ private final Map<String, PreferenceCategory> mCategoryToPrefCategoryMap =
+ new ArrayMap<>();
+ private final Map<Preference, PreferenceCategory> mServicePreferenceToPreferenceCategoryMap =
+ new ArrayMap<>();
+ private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
+ new ArrayMap<>();
private SwitchPreference mToggleHighTextContrastPreference;
private SwitchPreference mTogglePowerButtonEndsCallPreference;
@@ -260,7 +273,7 @@
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.LONG_PRESS_TIMEOUT, Integer.parseInt(stringValue));
mSelectLongPressTimeoutPreference.setSummary(
- mLongPressTimeoutValuetoTitleMap.get(stringValue));
+ mLongPressTimeoutValueToTitleMap.get(stringValue));
}
private void handleToggleInversionPreferenceChange(boolean checked) {
@@ -386,8 +399,10 @@
}
private void initializeAllPreferences() {
- mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
- mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
+ for (int i = 0; i < CATEGORIES.length; i++) {
+ PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
+ mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
+ }
// Text contrast.
mToggleHighTextContrastPreference =
@@ -402,14 +417,16 @@
(SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
|| !Utils.isVoiceCapable(getActivity())) {
- mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference);
+ mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
+ .removePreference(mTogglePowerButtonEndsCallPreference);
}
// Lock screen rotation.
mToggleLockScreenRotationPreference =
(SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE);
if (!RotationPolicy.isRotationSupported(getActivity())) {
- mSystemsCategory.removePreference(mToggleLockScreenRotationPreference);
+ mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
+ .removePreference(mToggleLockScreenRotationPreference);
}
// Large pointer icon.
@@ -424,7 +441,7 @@
mSelectLongPressTimeoutPreference =
(ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
- if (mLongPressTimeoutValuetoTitleMap.size() == 0) {
+ if (mLongPressTimeoutValueToTitleMap.size() == 0) {
String[] timeoutValues = getResources().getStringArray(
R.array.long_press_timeout_selector_values);
mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
@@ -432,7 +449,7 @@
R.array.long_press_timeout_selector_titles);
final int timeoutValueCount = timeoutValues.length;
for (int i = 0; i < timeoutValueCount; i++) {
- mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]);
+ mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
}
}
@@ -459,17 +476,32 @@
}
private void updateAllPreferences() {
- updateServicesPreferences();
updateSystemPreferences();
+ updateServicePreferences();
}
- private void updateServicesPreferences() {
+ private void updateServicePreferences() {
// Since services category is auto generated we have to do a pass
// to generate it since services can come and go and then based on
// the global accessibility state to decided whether it is enabled.
// Generate.
- mServicesCategory.removeAll();
+ ArrayList<Preference> servicePreferences =
+ new ArrayList<>(mServicePreferenceToPreferenceCategoryMap.keySet());
+ for (int i = 0; i < servicePreferences.size(); i++) {
+ Preference service = servicePreferences.get(i);
+ PreferenceCategory category = mServicePreferenceToPreferenceCategoryMap.get(service);
+ category.removePreference(service);
+ }
+
+ initializePreBundledServicesMapFromArray(CATEGORY_SCREEN_READER,
+ R.array.config_preinstalled_screen_reader_services);
+ initializePreBundledServicesMapFromArray(CATEGORY_AUDIO_AND_CAPTIONS,
+ R.array.config_preinstalled_audio_and_caption_services);
+ initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY,
+ R.array.config_preinstalled_display_services);
+ initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL,
+ R.array.config_preinstalled_interaction_control_services);
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity());
@@ -482,36 +514,49 @@
final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
+ PreferenceCategory downloadedServicesCategory =
+ mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
+ // Temporarily add the downloaded services category back if it was previously removed.
+ if (findPreference(CATEGORY_DOWNLOADED_SERVICES) == null) {
+ getPreferenceScreen().addPreference(downloadedServicesCategory);
+ }
+
for (int i = 0, count = installedServices.size(); i < count; ++i) {
AccessibilityServiceInfo info = installedServices.get(i);
- RestrictedPreference preference =
- new RestrictedPreference(mServicesCategory.getContext());
+ SingleLineSummaryPreference preference =
+ new SingleLineSummaryPreference(downloadedServicesCategory.getContext(), null);
String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
+ Drawable icon = info.getResolveInfo().loadIcon(getPackageManager());
+ if (icon == null) {
+ // todo (saigem): add a default
+ }
+
ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
- ComponentName componentName = new ComponentName(serviceInfo.packageName,
- serviceInfo.name);
+ String packageName = serviceInfo.packageName;
+ ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
+ String componentNameKey = componentName.flattenToString();
preference.setKey(componentName.flattenToString());
preference.setTitle(title);
+ preference.setIcon(icon);
final boolean serviceEnabled = accessibilityEnabled
&& enabledServices.contains(componentName);
- String serviceEnabledString;
- if (serviceEnabled) {
- serviceEnabledString = getString(R.string.accessibility_feature_state_on);
- } else {
- serviceEnabledString = getString(R.string.accessibility_feature_state_off);
- }
+ String serviceState = serviceEnabled ?
+ getString(R.string.accessibility_feature_state_on) :
+ getString(R.string.accessibility_feature_state_off);
+ String serviceSummary = info.loadSummary(getPackageManager());
+ serviceSummary = (TextUtils.isEmpty(serviceSummary)) ? serviceState :
+ serviceSummary;
// Disable all accessibility services that are not permitted.
- String packageName = serviceInfo.packageName;
boolean serviceAllowed =
permittedServices == null || permittedServices.contains(packageName);
if (!serviceAllowed && !serviceEnabled) {
EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
- getActivity(), serviceInfo.packageName, UserHandle.myUserId());
+ getActivity(), packageName, UserHandle.myUserId());
if (admin != null) {
preference.setDisabledByAdmin(admin);
} else {
@@ -521,9 +566,7 @@
preference.setEnabled(true);
}
- preference.setSummary(serviceEnabledString);
-
- preference.setOrder(i);
+ preference.setSummary(serviceSummary);
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
preference.setPersistent(true);
@@ -543,26 +586,33 @@
extras.putString(EXTRA_SETTINGS_TITLE,
getString(R.string.accessibility_menu_item_settings));
extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
- new ComponentName(info.getResolveInfo().serviceInfo.packageName,
- settingsClassName).flattenToString());
+ new ComponentName(packageName, settingsClassName).flattenToString());
}
-
extras.putParcelable(EXTRA_COMPONENT_NAME, componentName);
- mServicesCategory.addPreference(preference);
+ PreferenceCategory prefCategory = downloadedServicesCategory;
+ // Set the appropriate category if the service comes pre-installed.
+ if (mPreBundledServiceComponentToCategoryMap.containsKey(componentName)) {
+ prefCategory = mPreBundledServiceComponentToCategoryMap.get(componentName);
+ }
+ preference.setOrder(FIRST_PREFERENCE_IN_CATEGORY_INDEX);
+ prefCategory.addPreference(preference);
+ mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory);
}
- if (mServicesCategory.getPreferenceCount() == 0) {
- if (mNoServicesMessagePreference == null) {
- mNoServicesMessagePreference = new Preference(getPrefContext());
- mNoServicesMessagePreference.setPersistent(false);
- mNoServicesMessagePreference.setLayoutResource(
- R.layout.text_description_preference);
- mNoServicesMessagePreference.setSelectable(false);
- mNoServicesMessagePreference.setSummary(
- getString(R.string.accessibility_no_services_installed));
- }
- mServicesCategory.addPreference(mNoServicesMessagePreference);
+ // If the user has not installed any additional services, hide the category.
+ if (downloadedServicesCategory.getPreferenceCount() == 0) {
+ PreferenceScreen screen = getPreferenceScreen();
+ screen.removePreference(downloadedServicesCategory);
+ }
+ }
+
+ private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
+ String[] services = getResources().getStringArray(key);
+ PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
+ for (int i = 0; i < services.length; i++) {
+ ComponentName component = ComponentName.unflattenFromString(services[i]);
+ mPreBundledServiceComponentToCategoryMap.put(component, category);
}
}
@@ -602,7 +652,7 @@
Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
String value = String.valueOf(longPressTimeout);
mSelectLongPressTimeoutPreference.setValue(value);
- mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValuetoTitleMap.get(value));
+ mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValueToTitleMap.get(value));
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
mCaptioningPreferenceScreen);
@@ -706,7 +756,7 @@
context.getSystemService(AccessibilityManager.class);
String screenTitle = context.getResources().getString(
- R.string.accessibility_services_title);
+ R.string.accessibility_settings);
// Indexing all services, regardless if enabled.
List<AccessibilityServiceInfo> services = accessibilityManager
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index d12842c..24405b3 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -34,6 +34,7 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.AppHeader;
+import com.android.settings.DimmableIconPreference;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.applications.AppHeaderController;
@@ -66,14 +67,18 @@
}
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onResume() {
+ super.onResume();
+
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
Log.w(TAG, "Missing package or uid or packageinfo");
- toastAndFinish();
+ finish();
return;
}
- final Activity activity = getActivity();
+
+ if (getPreferenceScreen() != null) {
+ getPreferenceScreen().removeAll();
+ }
addPreferencesFromResource(R.xml.app_notification_settings);
getPreferenceScreen().setOrderingAsAdded(true);
@@ -81,44 +86,38 @@
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE);
- if (mPkgInfo != null) {
- setupBlock();
- setupBadge();
- // load settings intent
- ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
- rows.put(mAppRow.pkg, mAppRow);
- collectConfigActivities(rows);
- new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground(Void... unused) {
- mChannelGroupList = mBackend.getChannelGroups(mPkg, mUid).getList();
- Collections.sort(mChannelGroupList, mChannelGroupComparator);
- return null;
- }
+ setupBlock();
+ setupBadge();
+ // load settings intent
+ ArrayMap<String, AppRow> rows = new ArrayMap<String, AppRow>();
+ rows.put(mAppRow.pkg, mAppRow);
+ collectConfigActivities(rows);
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... unused) {
+ mChannelGroupList = mBackend.getChannelGroups(mPkg, mUid).getList();
+ Collections.sort(mChannelGroupList, mChannelGroupComparator);
+ return null;
+ }
- @Override
- protected void onPostExecute(Void unused) {
- populateChannelList();
- }
- }.execute();
- }
- final Preference pref = FeatureFactory.getFactory(activity)
- .getApplicationFeatureProvider(activity)
- .newAppHeaderController(this /* fragment */, null /* appHeader */)
- .setIcon(mAppRow.icon)
- .setLabel(mAppRow.label)
- .setPackageName(mAppRow.pkg)
- .setUid(mAppRow.uid)
- .setAppNotifPrefIntent(mAppRow.settingsIntent)
- .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO,
- AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE)
- .done(getPrefContext());
+ @Override
+ protected void onPostExecute(Void unused) {
+ populateChannelList();
+ }
+ }.execute();
+
+ final Preference pref = FeatureFactory.getFactory(getActivity())
+ .getApplicationFeatureProvider(getActivity())
+ .newAppHeaderController(this /* fragment */, null /* appHeader */)
+ .setIcon(mAppRow.icon)
+ .setLabel(mAppRow.label)
+ .setPackageName(mAppRow.pkg)
+ .setUid(mAppRow.uid)
+ .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO,
+ AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE)
+ .done(getPrefContext());
getPreferenceScreen().addPreference(pref);
- }
- @Override
- public void onResume() {
- super.onResume();
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
Log.w(TAG, "Missing package or uid or packageinfo");
finish();
@@ -145,7 +144,7 @@
? R.string.notification_channels_other
: R.string.notification_channels);
} else {
- groupCategory.setTitle(getNotificationGroupLabel(group));
+ groupCategory.setTitle(group.getName());
}
groupCategory.setKey(group.getId());
groupCategory.setOrderingAsAdded(true);
@@ -161,45 +160,55 @@
getPrefContext());
channelPref.setDisabledByAdmin(mSuspendedAppsAdmin);
channelPref.setKey(channel.getId());
- channelPref.setTitle(getNotificationChannelLabel(channel));
+ channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
channelPref.setMultiLine(true);
+ channelPref.setSummary(getImportanceSummary(channel.getImportance()));
+ Bundle channelArgs = new Bundle();
+ channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
+ channelArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
+ channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
+ channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
+ Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(),
+ ChannelNotificationSettings.class.getName(),
+ channelArgs, null, 0, null, false, getMetricsCategory());
+ channelPref.setIntent(channelIntent);
- if (channel.isDeleted()) {
- channelPref.setTitle(getString(R.string.deleted_channel_name,
- getNotificationChannelLabel(channel)));
- channelPref.setEnabled(false);
- } else {
- channelPref.setSummary(getImportanceSummary(channel.getImportance()));
- Bundle channelArgs = new Bundle();
- channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
- channelArgs.putBoolean(AppHeader.EXTRA_HIDE_INFO_BUTTON, true);
- channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
- channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
- Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(),
- ChannelNotificationSettings.class.getName(),
- channelArgs, null, 0, null, false, getMetricsCategory());
- channelPref.setIntent(channelIntent);
+ channelPref.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference,
+ Object o) {
+ boolean value = (Boolean) o;
+ int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ channel.setImportance(importance);
+ channel.lockFields(
+ NotificationChannel.USER_LOCKED_IMPORTANCE);
+ mBackend.updateChannel(mPkg, mUid, channel);
- channelPref.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference,
- Object o) {
- boolean value = (Boolean) o;
- int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
- channel.setImportance(importance);
- channel.lockFields(
- NotificationChannel.USER_LOCKED_IMPORTANCE);
- mBackend.updateChannel(mPkg, mUid, channel);
-
- return true;
- }
- });
- }
+ return true;
+ }
+ });
groupCategory.addPreference(channelPref);
}
}
+
+ if (mAppRow.settingsIntent != null) {
+ Preference intentPref = new Preference(getPrefContext());
+ intentPref.setIntent(mAppRow.settingsIntent);
+ intentPref.setTitle(mContext.getString(R.string.app_settings_link));
+ getPreferenceScreen().addPreference(intentPref);
+ }
+
+ int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
+ if (deletedChannelCount > 0) {
+ DimmableIconPreference deletedPref = new DimmableIconPreference(getPrefContext());
+ deletedPref.setEnabled(false);
+ deletedPref.setTitle(getResources().getQuantityString(
+ R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
+ deletedPref.setIcon(R.drawable.ic_info);
+ getPreferenceScreen().addPreference(deletedPref);
+ }
}
updateDependents(mAppRow.banned);
}
@@ -257,8 +266,8 @@
if (left.isDeleted() != right.isDeleted()) {
return Boolean.compare(left.isDeleted(), right.isDeleted());
}
- CharSequence leftName = getNotificationChannelLabel(left);
- CharSequence rightName = getNotificationChannelLabel(right);
+ CharSequence leftName = left.getName();
+ CharSequence rightName = right.getName();
if (!Objects.equals(leftName, rightName)) {
return sCollator.compare(leftName.toString(), rightName.toString());
}
@@ -278,8 +287,8 @@
} else if (right.getId() == null && left.getId() != null) {
return -1;
}
- CharSequence leftName = getNotificationGroupLabel(left);
- CharSequence rightName = getNotificationGroupLabel(right);
+ CharSequence leftName = left.getName();
+ CharSequence rightName = right.getName();
// sort rest of the groups by name
if (!Objects.equals(leftName, rightName)) {
return sCollator.compare(leftName.toString(), rightName.toString());
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 18e00f8..7f7aa08 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -73,19 +73,22 @@
}
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ public void onResume() {
+ super.onResume();
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
Log.w(TAG, "Missing package or uid or packageinfo or channel");
- toastAndFinish();
+ finish();
return;
}
- final Activity activity = getActivity();
+
+ if (getPreferenceScreen() != null) {
+ getPreferenceScreen().removeAll();
+ }
addPreferencesFromResource(R.xml.channel_notification_settings);
+ getPreferenceScreen().setOrderingAsAdded(true);
// load settings intent
- ArrayMap<String, NotificationBackend.AppRow>
- rows = new ArrayMap<String, NotificationBackend.AppRow>();
+ ArrayMap<String, NotificationBackend.AppRow> rows = new ArrayMap<String, NotificationBackend.AppRow>();
rows.put(mAppRow.pkg, mAppRow);
collectConfigActivities(rows);
@@ -109,36 +112,25 @@
setupBlockAndImportance();
updateDependents();
}
- final Preference pref = FeatureFactory.getFactory(activity)
- .getApplicationFeatureProvider(activity)
- .newAppHeaderController(this /* fragment */, null /* appHeader */)
- .setIcon(mAppRow.icon)
- .setLabel(getNotificationChannelLabel(mChannel))
- .setSummary(mAppRow.label)
- .setPackageName(mAppRow.pkg)
- .setUid(mAppRow.uid)
- .setAppNotifPrefIntent(mAppRow.settingsIntent)
- .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO,
- AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE)
- .done(getPrefContext());
+ final Preference pref = FeatureFactory.getFactory(getActivity())
+ .getApplicationFeatureProvider(getActivity())
+ .newAppHeaderController(this /* fragment */, null /* appHeader */)
+ .setIcon(mAppRow.icon)
+ .setLabel(mChannel.getName())
+ .setSummary(mAppRow.label)
+ .setPackageName(mAppRow.pkg)
+ .setUid(mAppRow.uid)
+ .setButtonActions(AppHeaderController.ActionType.ACTION_APP_INFO,
+ AppHeaderController.ActionType.ACTION_NOTIF_PREFERENCE)
+ .done(getPrefContext());
getPreferenceScreen().addPreference(pref);
- }
- @Override
- public void onResume() {
- super.onResume();
- if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
- Log.w(TAG, "Missing package or uid or packageinfo or channel");
- finish();
- return;
+ if (mAppRow.settingsIntent != null) {
+ Preference intentPref = new Preference(getPrefContext());
+ intentPref.setIntent(mAppRow.settingsIntent);
+ intentPref.setTitle(mContext.getString(R.string.app_settings_link));
+ getPreferenceScreen().addPreference(intentPref);
}
- mLights.setDisabledByAdmin(mSuspendedAppsAdmin);
- mVibrate.setDisabledByAdmin(mSuspendedAppsAdmin);
- if (mImportance.isEnabled()) {
- mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
- mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
}
private void setupLights() {
@@ -321,6 +313,7 @@
return true;
}
});
+ mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
}
private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 0881eb7..c1ef018 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -124,7 +124,7 @@
public ParceledListSlice<NotificationChannelGroup> getChannelGroups(String pkg, int uid) {
try {
- return sINM.getNotificationChannelGroupsForPackage(pkg, uid, true);
+ return sINM.getNotificationChannelGroupsForPackage(pkg, uid, false);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return ParceledListSlice.emptyList();
@@ -139,6 +139,15 @@
}
}
+ public int getDeletedChannelCount(String pkg, int uid) {
+ try {
+ return sINM.getDeletedChannelCount(pkg, uid);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return 0;
+ }
+ }
+
static class Row {
public String section;
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 6a40ea5..960c3b8 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -127,15 +127,6 @@
}
mUserId = UserHandle.getUserId(mUid);
- mAppRow = mBackend.loadAppRow(mContext, mPm, mPkgInfo);
- mChannel = (args != null && args.containsKey(Settings.EXTRA_CHANNEL_ID)) ?
- mBackend.getChannel(mPkg, mUid, args.getString(Settings.EXTRA_CHANNEL_ID)) : null;
-
- mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
- mContext, mPkg, mUserId);
- NotificationManager.Policy policy =
- NotificationManager.from(mContext).getNotificationPolicy();
- mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
}
@Override
@@ -146,12 +137,19 @@
finish();
return;
}
+ mAppRow = mBackend.loadAppRow(mContext, mPm, mPkgInfo);
+ Bundle args = getArguments();
+ mChannel = (args != null && args.containsKey(Settings.EXTRA_CHANNEL_ID)) ?
+ mBackend.getChannel(mPkg, mUid, args.getString(Settings.EXTRA_CHANNEL_ID)) : null;
+
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
- if (mBlock.isEnabled()) {
- mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
- mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
+ NotificationManager.Policy policy =
+ NotificationManager.from(mContext).getNotificationPolicy();
+ mDndVisualEffectsSuppressed = policy == null ? false : policy.suppressedVisualEffects != 0;
+
+ mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
+ mContext, mPkg, mUserId);
}
protected void setVisible(Preference p, boolean visible) {
@@ -251,25 +249,4 @@
return getContext().getString(R.string.notification_importance_high);
}
}
-
- protected CharSequence getNotificationGroupLabel(NotificationChannelGroup group) {
- return getLabel(group.getName(), group.getNameResId());
- }
-
- protected CharSequence getNotificationChannelLabel(NotificationChannel channel) {
- return getLabel(channel.getName(), channel.getNameResId());
- }
-
- private CharSequence getLabel(CharSequence name, int nameResId) {
- if (!TextUtils.isEmpty(name)) {
- return name;
- }
- try {
- ApplicationInfo info = mPm.getApplicationInfoAsUser(mAppRow.pkg, 0, mAppRow.userId);
- return mPm.getText(mAppRow.pkg, nameResId, info);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- }
- return null;
- }
}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 5f489f2..1ed25f2 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -32,6 +32,7 @@
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.lifecycle.Lifecycle;
@@ -53,15 +54,24 @@
LifecycleObserver, OnResume {
private static final String TAG = "WifiDetailsPrefCtrl";
- private static final String KEY_CONNECTION_DETAIL_PREF = "connection_detail";
- private static final String KEY_SIGNAL_STRENGTH_PREF = "signal_strength";
- private static final String KEY_FREQUENCY_PREF = "frequency";
- private static final String KEY_SECURITY_PREF = "security";
- private static final String KEY_IP_ADDRESS_PREF = "ip_address";
- private static final String KEY_ROUTER_PREF = "router";
- private static final String KEY_SUBNET_MASK_PREF = "subnet_mask";
- private static final String KEY_DNS_PREF = "dns";
- private static final String KEY_IPV6_ADDRESS_CATEGORY = "ipv6_details_category";
+ @VisibleForTesting
+ static final String KEY_CONNECTION_DETAIL_PREF = "connection_detail";
+ @VisibleForTesting
+ static final String KEY_SIGNAL_STRENGTH_PREF = "signal_strength";
+ @VisibleForTesting
+ static final String KEY_FREQUENCY_PREF = "frequency";
+ @VisibleForTesting
+ static final String KEY_SECURITY_PREF = "security";
+ @VisibleForTesting
+ static final String KEY_IP_ADDRESS_PREF = "ip_address";
+ @VisibleForTesting
+ static final String KEY_ROUTER_PREF = "router";
+ @VisibleForTesting
+ static final String KEY_SUBNET_MASK_PREF = "subnet_mask";
+ @VisibleForTesting
+ static final String KEY_DNS_PREF = "dns";
+ @VisibleForTesting
+ static final String KEY_IPV6_ADDRESS_CATEGORY = "ipv6_details_category";
private AccessPoint mAccessPoint;
private NetworkInfo mNetworkInfo;
@@ -166,7 +176,7 @@
R.color.wifi_details_icon_color, mContext.getTheme()));
mSignalStrengthPref.setIcon(wifiIconDark);
- int summarySignalLevel = WifiManager.calculateSignalLevel(mRssi, mSignalStr.length);
+ int summarySignalLevel = mAccessPoint.getLevel();
mSignalStrengthPref.setDetailText(mSignalStr[summarySignalLevel]);
// Frequency Pref
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index 0a80f21..0073202 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -23,7 +23,6 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
-import com.android.settings.SettingsActivity;
import com.android.settings.applications.LayoutPreference;
import com.android.settings.core.PreferenceController;
import com.android.settings.dashboard.DashboardFragment;
diff --git a/tests/robotests/src/android/net/NetworkBadging.java b/tests/robotests/src/android/net/NetworkBadging.java
new file mode 100644
index 0000000..32bb31f
--- /dev/null
+++ b/tests/robotests/src/android/net/NetworkBadging.java
@@ -0,0 +1,34 @@
+package android.net;
+
+import android.annotation.IntDef;
+import android.annotation.Nullable;
+import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Implementation for {@link android.net.NetworkBadging}.
+ *
+ * <p>Can be removed once Robolectric supports Android O.
+ */
+public class NetworkBadging {
+ @IntDef({BADGING_NONE, BADGING_SD, BADGING_HD, BADGING_4K})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Badging {}
+
+ public static final int BADGING_NONE = 0;
+ public static final int BADGING_SD = 10;
+ public static final int BADGING_HD = 20;
+ public static final int BADGING_4K = 30;
+
+ private static Drawable drawable;
+
+ public static Drawable getWifiIcon(
+ int signalLevel, @NetworkBadging.Badging int badging, @Nullable Resources.Theme theme) {
+ return new ColorDrawable(Color.GREEN);
+ }
+}
diff --git a/tests/robotests/src/android/net/wifi/WifiNetworkScoreCache.java b/tests/robotests/src/android/net/wifi/WifiNetworkScoreCache.java
new file mode 100644
index 0000000..08b2971
--- /dev/null
+++ b/tests/robotests/src/android/net/wifi/WifiNetworkScoreCache.java
@@ -0,0 +1,10 @@
+package android.net.wifi;
+
+/**
+ * Empty class def for {@link android.net.wifi.WifiNetworkScoreCache}.
+ *
+ * <p>Can be removed once Robolectric supports Android O.
+ */
+public class WifiNetworkScoreCache {
+
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
new file mode 100644
index 0000000..b2648ac
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -0,0 +1,185 @@
+/*
+ * 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.wifi.details;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.net.NetworkBadging;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.wifi.WifiDetailPreference;
+import com.android.settingslib.wifi.AccessPoint;
+
+import org.junit.Before;
+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;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class WifiDetailPreferenceControllerTest {
+
+ private static final int LEVEL = 1;
+ private static final int RSSI = -55;
+ private static final String SECURITY = "None";
+
+ private Context mContext = RuntimeEnvironment.application;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Drawable mockWifiIcon;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mockScreen;
+
+ @Mock private AccessPoint mockAccessPoint;
+ @Mock private WifiManager mockWifiManager;
+ @Mock private NetworkInfo mockNetworkInfo;
+ @Mock private WifiConfiguration mockWifiConfig;
+ @Mock private WifiInfo mockWifiInfo;
+
+ @Mock private Preference mockConnectionDetailPref;
+ @Mock private WifiDetailPreference mockSignalStrengthPref;
+ @Mock private WifiDetailPreference mockFrequencyPref;
+ @Mock private WifiDetailPreference mockSecurityPref;
+ @Mock private WifiDetailPreference mockIpAddressPref;
+ @Mock private WifiDetailPreference mockRouterPref;
+ @Mock private WifiDetailPreference mockSubnetPref;
+ @Mock private WifiDetailPreference mockDnsPref;
+ @Mock private PreferenceCategory mockIpv6AddressCategory;
+
+ private Lifecycle mLifecycle;
+ private WifiDetailPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mLifecycle = new Lifecycle();
+ mController = new WifiDetailPreferenceController(
+ mockAccessPoint, mContext, mLifecycle, mockWifiManager);
+
+ when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
+ when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
+ when(mockAccessPoint.getNetworkInfo()).thenReturn(mockNetworkInfo);
+ when(mockAccessPoint.getRssi()).thenReturn(RSSI);
+ when(mockAccessPoint.getSecurityString(false)).thenReturn(SECURITY);
+
+ setupMockedPreferenceScreen();
+
+ when (mockWifiInfo.getRssi()).thenReturn(RSSI);
+ when(mockWifiManager.getConnectionInfo()).thenReturn(mockWifiInfo);
+ when(mockWifiManager.getWifiApConfiguration()).thenReturn(mockWifiConfig);
+ }
+
+ private void setupMockedPreferenceScreen() {
+
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_CONNECTION_DETAIL_PREF))
+ .thenReturn(mockConnectionDetailPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SIGNAL_STRENGTH_PREF))
+ .thenReturn(mockSignalStrengthPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_FREQUENCY_PREF))
+ .thenReturn(mockFrequencyPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SECURITY_PREF))
+ .thenReturn(mockSecurityPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_IP_ADDRESS_PREF))
+ .thenReturn(mockIpAddressPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_ROUTER_PREF))
+ .thenReturn(mockRouterPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SUBNET_MASK_PREF))
+ .thenReturn(mockSubnetPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_DNS_PREF))
+ .thenReturn(mockDnsPref);
+ when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_IPV6_ADDRESS_CATEGORY))
+ .thenReturn(mockIpv6AddressCategory);
+
+ mController.displayPreference(mockScreen);
+ }
+
+ @Test
+ public void isAvailable_shouldAlwaysReturnTrue() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void securityPreference_stringShouldBeSet() {
+ verify(mockSecurityPref).setDetailText(SECURITY);
+ }
+
+ @Test
+ public void latestWifiInfoAndConfig_shouldBeFetchedOnResume() {
+ mController.onResume();
+
+ verify(mockWifiManager).getConnectionInfo();
+ verify(mockWifiManager).getWifiApConfiguration();
+ }
+
+ @Test
+ public void connectionDetailPref_shouldHaveIconSet() {
+ Drawable expectedIcon =
+ NetworkBadging.getWifiIcon(LEVEL, NetworkBadging.BADGING_NONE, mContext.getTheme());
+
+ mController.onResume();
+
+ verify(mockConnectionDetailPref).setIcon(expectedIcon);
+ }
+
+ @Test
+ public void connectionDetailPref_shouldHaveTitleSet() {
+ String summary = "summary";
+ when(mockAccessPoint.getSettingsSummary()).thenReturn(summary);
+
+ mController.onResume();
+
+ verify(mockConnectionDetailPref).setTitle(summary);
+ }
+
+ @Test
+ public void signalStrengthPref_shouldHaveIconSet() {
+ mController.onResume();
+
+ verify(mockSignalStrengthPref).setIcon(any(Drawable.class));
+ }
+
+ @Test
+ public void signalStrengthPref_shouldHaveDetailTextSet() {
+ String expectedStrength =
+ mContext.getResources().getStringArray(R.array.wifi_signal)[LEVEL];
+
+ mController.onResume();
+
+ verify(mockSignalStrengthPref).setDetailText(expectedStrength);
+ }
+}