Merge "Fix action bar background not wide enough on tablets" into oc-dev
diff --git a/res/drawable/ic_instant_apps_badge.xml b/res/drawable/ic_instant_apps_badge.xml
deleted file mode 100644
index 115aa83..0000000
--- a/res/drawable/ic_instant_apps_badge.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="48dp"
- android:viewportWidth="48"
- android:viewportHeight="48">
- <path
- android:fillColor="#FFFFFF"
- android:fillType="evenOdd"
- android:pathData="M 24.5 2.7 C 35.5456949966 2.7 44.5 11.6543050034 44.5 22.7 C 44.5 33.7456949966 35.5456949966 42.7 24.5 42.7 C 13.4543050034 42.7 4.5 33.7456949966 4.5 22.7 C 4.5 11.6543050034 13.4543050034 2.7 24.5 2.7 Z" />
- <path
- android:fillColor="#757575"
- android:fillType="evenOdd"
- android:pathData="M 33.3 19.1 L 26.4 19.1 L 26.4 5.8 L 16.6 26.4 L 23.5 26.3 L 23.5 39.6 Z" />
- <path
- android:fillType="evenOdd"
- android:pathData="M 0.5 0 H 48.5 V 48 H 0.5 V 0 Z" />
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_instant_apps_badge_bg.xml b/res/drawable/ic_instant_apps_badge_bg.xml
deleted file mode 100644
index bf8d3ea..0000000
--- a/res/drawable/ic_instant_apps_badge_bg.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2017 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="oval">
- <gradient android:type="radial"
- android:startColor="#4d000000"
- android:endColor="#00000000"
- android:gradientRadius="12dp"/>
-</shape>
\ No newline at end of file
diff --git a/res/layout/app_details.xml b/res/layout/app_details.xml
index 8cfa8b9..b05c0dc 100644
--- a/res/layout/app_details.xml
+++ b/res/layout/app_details.xml
@@ -31,28 +31,13 @@
android:paddingEnd="0dp"
android:paddingTop="24dp"
android:paddingBottom="24dp">
-
- <FrameLayout android:id="@+id/app_icon_frame"
- android:layout_width="56dp"
- android:layout_height="56dp"
- android:clipChildren="false"
- android:clipToPadding="false">
- <ImageView
- android:id="@+id/app_detail_icon"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="fitXY"
- android:layout_gravity="center_horizontal"
- android:antialias="true"/>
- <ImageView android:id="@+id/app_icon_instant_apps_badge"
- android:layout_width="22dp"
- android:layout_height="22dp"
- android:layout_gravity="end|bottom"
- android:layout_margin="4dp"
- android:elevation="20dp"
- android:background="@drawable/ic_instant_apps_badge_bg"
- android:src="@drawable/ic_instant_apps_badge" />
- </FrameLayout>
+ <ImageView
+ android:id="@+id/app_detail_icon"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:scaleType="fitXY"
+ android:layout_gravity="center_horizontal"
+ android:antialias="true"/>
<LinearLayout
android:id="@+id/app_detail_links"
@@ -86,7 +71,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_toEndOf="@id/app_icon_frame"
+ android:layout_toEndOf="@id/app_detail_icon"
android:layout_toStartOf="@id/app_detail_links"
android:paddingStart="24dp"
android:paddingEnd="24dp"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index ec8fca9..4a09594 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -79,6 +79,8 @@
<!-- Accessibility SUW colors -->
<color name="material_blue_500">#4285F4</color>
<color name="material_blue_700">#3367D6</color>
+ <color name="material_grey_100">#f5f5f5</color>
+ <color name="material_grey_200">#ffffff</color>
<color name="message_text_incoming">#ffffffff</color>
<color name="message_text_outgoing">#ff323232</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 8173d8a..6495ab0 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -242,7 +242,6 @@
<dimen name="mdm_app_icon_width_height">56dp</dimen>
<!-- Launcher Icons -->
- <dimen name="launcher_icon_elevation">6dp</dimen>
<dimen name="shortcut_size_maskable">120dp</dimen>
<dimen name="shortcut_size">40dp</dimen>
<dimen name="shortcut_icon_size">16dp</dimen>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 7ca109b..3dbaa8b 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -108,16 +108,17 @@
<!-- Accessibility portion of Setup Wizard -->
<style name="SetupWizardAccessibilityTheme" parent="Theme.SettingsBase">
<item name="android:windowLightStatusBar">false</item>
- <item name="android:colorPrimary">@color/material_blue_700</item>
- <item name="android:colorPrimaryDark">@color/material_blue_700</item>
- <item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.Dark.ActionBar</item>
+ <item name="android:colorPrimary">@color/material_grey_100</item>
+ <item name="android:colorAccent">@color/material_blue_700</item>
+ <item name="android:titleTextColor">@color/material_blue_700</item>
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="switchBarTheme">@style/SetupWizardAccessibilitySwitchBarTheme</item>
</style>
<style name="SetupWizardAccessibilitySwitchBarTheme" parent="ThemeOverlay.SwitchBar.Settings">
- <item name="switchBarBackgroundColor">@color/material_blue_500</item>
- <item name="android:colorControlActivated">@android:color/white</item>
+ <item name="switchBarBackgroundColor">@color/material_grey_200</item>
+ <item name="android:colorControlActivated">@color/material_blue_500</item>
+ <item name="android:textColorPrimary">@android:color/black</item>
</style>
<!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 795d35e..02b9949 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -57,11 +57,6 @@
android:title="@string/accessibility_screen_magnification_title"
android:icon="@mipmap/ic_accessibility_magnification" />
- <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_large_pointer_icon"
android:title="@string/accessibility_toggle_large_pointer_icon_title" />
@@ -118,6 +113,11 @@
android:key="toggle_high_text_contrast_preference"
android:title="@string/accessibility_toggle_high_text_contrast_preference_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_inversion_preference"
android:title="@string/accessibility_display_inversion_preference_title"
diff --git a/res/xml/legacy_channel_notification_settings.xml b/res/xml/legacy_channel_notification_settings.xml
new file mode 100644
index 0000000..4e341a9
--- /dev/null
+++ b/res/xml/legacy_channel_notification_settings.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" >
+
+
+ <!-- Importance toggle -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="allow_sound"
+ android:title="@string/allow_sound" />
+
+ <!-- Visibility Override -->
+ <com.android.settings.notification.RestrictedDropDownPreference
+ android:key="visibility_override"
+ 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"
+ settings:useAdditionalSummary="true" />
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 1230ae5..b29f8a0 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -104,7 +104,7 @@
controllers.add(new VrDisplayPreferenceController(context));
controllers.add(new WallpaperPreferenceController(context));
controllers.add(new ThemePreferenceController(context));
- controllers.add(new BrightnessLevelPreferenceController(context));
+ controllers.add(new BrightnessLevelPreferenceController(context, lifecycle));
return controllers;
}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1d3e125..44dd353 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -550,6 +550,22 @@
}
private void updateSystemPreferences() {
+ // Move color inversion and color correction preferences to Display category if device
+ // supports HWC hardware-accelerated color transform.
+ if (isColorTransformAccelerated(getContext())) {
+ PreferenceCategory experimentalCategory =
+ mCategoryToPrefCategoryMap.get(CATEGORY_EXPERIMENTAL);
+ PreferenceCategory displayCategory =
+ mCategoryToPrefCategoryMap.get(CATEGORY_DISPLAY);
+ experimentalCategory.removePreference(mToggleInversionPreference);
+ experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
+ mToggleInversionPreference.setOrder(mToggleLargePointerIconPreference.getOrder());
+ mDisplayDaltonizerPreferenceScreen.setOrder(mToggleInversionPreference.getOrder());
+ mToggleInversionPreference.setSummary(R.string.summary_empty);
+ displayCategory.addPreference(mToggleInversionPreference);
+ displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
+ }
+
// Text contrast.
mToggleHighTextContrastPreference.setChecked(
Settings.Secure.getInt(getContentResolver(),
@@ -601,6 +617,11 @@
updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
}
+ private boolean isColorTransformAccelerated(Context context) {
+ return context.getResources()
+ .getBoolean(com.android.internal.R.bool.config_setColorTransformAccelerated);
+ }
+
private void updateMagnificationSummary(Preference pref) {
final boolean tripleTapEnabled = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 6ed06da..24320b3 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -42,12 +42,9 @@
public static final String SHORTCUT_SERVICE_KEY = "accessibility_shortcut_service";
public static final String ON_LOCK_SCREEN_KEY = "accessibility_shortcut_on_lock_screen";
- // ID for dialog that confirms shortcut capabilities
- private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
private Preference mServicePreference;
private SwitchPreference mOnLockScreenSwitchPreference;
- private String mSelectedServiceComponentNameString;
@Override
public int getMetricsCategory() {
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
index 8b6d52a..3250521 100644
--- a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.accessibility;
+import static android.content.DialogInterface.BUTTON_POSITIVE;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.AlertDialog;
@@ -147,7 +149,7 @@
@Override
public void onClick(DialogInterface dialog, int which) {
final Fragment fragment = getTargetFragment();
- if (fragment instanceof DefaultAppPickerFragment) {
+ if ((which == BUTTON_POSITIVE) && (fragment instanceof DefaultAppPickerFragment)) {
final Bundle bundle = getArguments();
((ShortcutServicePickerFragment) fragment).onServiceConfirmed(
bundle.getString(EXTRA_KEY));
diff --git a/src/com/android/settings/accounts/AutoSyncDataPreferenceController.java b/src/com/android/settings/accounts/AutoSyncDataPreferenceController.java
index 79776a0..f5d7b64 100644
--- a/src/com/android/settings/accounts/AutoSyncDataPreferenceController.java
+++ b/src/com/android/settings/accounts/AutoSyncDataPreferenceController.java
@@ -28,8 +28,8 @@
import android.os.UserManager;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
-
import android.util.Log;
+
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
@@ -41,9 +41,10 @@
private static final String TAG_CONFIRM_AUTO_SYNC_CHANGE = "confirmAutoSyncChange";
private static final String KEY_AUTO_SYNC_ACCOUNT = "auto_sync_account_data";
- protected UserManager mUserManager;
- private UserHandle mUserHandle;
- private Fragment mParentFragment;
+ protected final UserManager mUserManager;
+ private final Fragment mParentFragment;
+
+ protected UserHandle mUserHandle;
public AutoSyncDataPreferenceController(Context context, Fragment parent) {
super(context);
diff --git a/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceController.java b/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceController.java
index 899f77d..1d08968 100644
--- a/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceController.java
+++ b/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceController.java
@@ -18,6 +18,8 @@
import android.app.Fragment;
import android.content.Context;
+import com.android.settings.Utils;
+
public class AutoSyncWorkDataPreferenceController extends AutoSyncPersonalDataPreferenceController {
private static final String TAG = "AutoSyncWorkData";
@@ -25,11 +27,11 @@
public AutoSyncWorkDataPreferenceController(Context context, Fragment parent) {
super(context, parent);
+ mUserHandle = Utils.getManagedProfile(mUserManager);
}
@Override
public String getPreferenceKey() {
return KEY_AUTO_SYNC_WORK_ACCOUNT;
}
-
}
diff --git a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
index 51225aa..9018d9b 100644
--- a/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
+++ b/src/com/android/settings/applications/AppAndNotificationDashboardFragment.java
@@ -25,7 +25,6 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -56,13 +55,7 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
- return buildPreferenceControllers(context);
- }
-
- private static List<PreferenceController> buildPreferenceControllers(Context context) {
- final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new SpecialAppAccessPreferenceController(context));
- return controllers;
+ return null;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -74,10 +67,5 @@
sir.xmlResId = R.xml.app_and_notification;
return Arrays.asList(sir);
}
-
- @Override
- public List<PreferenceController> getPreferenceControllers(Context context) {
- return buildPreferenceControllers(context);
- }
};
}
diff --git a/src/com/android/settings/applications/AppHeaderController.java b/src/com/android/settings/applications/AppHeaderController.java
index 0cfd024..45938ae 100644
--- a/src/com/android/settings/applications/AppHeaderController.java
+++ b/src/com/android/settings/applications/AppHeaderController.java
@@ -64,6 +64,7 @@
}
public static final String PREF_KEY_APP_HEADER = "pref_app_header";
+
private static final String TAG = "AppDetailFeature";
private final Context mContext;
@@ -180,10 +181,6 @@
ImageView iconView = mAppHeader.findViewById(R.id.app_detail_icon);
if (iconView != null) {
iconView.setImageDrawable(mIcon);
- ImageView badgeView = mAppHeader.findViewById(R.id.app_icon_instant_apps_badge);
- if (badgeView != null) {
- badgeView.setVisibility(mIsInstantApp ? View.VISIBLE : View.GONE);
- }
}
setText(R.id.app_detail_title, mLabel);
setText(R.id.app_detail_summary, mSummary);
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
index 2c9599b..6b1ef67 100644
--- a/src/com/android/settings/applications/AppInfoWithHeader.java
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -21,6 +21,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.preference.Preference;
+import android.util.IconDrawableFactory;
import android.util.Log;
import com.android.settings.overlay.FeatureFactory;
@@ -43,7 +44,8 @@
final Preference pref = FeatureFactory.getFactory(activity)
.getApplicationFeatureProvider(activity)
.newAppHeaderController(this, null /* appHeader */)
- .setIcon(mPackageInfo.applicationInfo.loadIcon(mPm))
+ .setIcon(IconDrawableFactory.newInstance(activity)
+ .getBadgedIcon(mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 3cc40151..f24c3f7 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -23,7 +23,6 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
-import android.graphics.drawable.AdaptiveIconDrawable;
import android.icu.text.AlphabeticIndex;
import android.os.Bundle;
import android.os.Environment;
@@ -35,7 +34,6 @@
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.ArraySet;
-import android.util.LauncherIcons;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -55,8 +53,8 @@
import android.widget.ListView;
import android.widget.SectionIndexer;
import android.widget.Spinner;
-
import android.widget.TextView;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.Settings.AllApplicationsActivity;
@@ -826,7 +824,6 @@
private final AppStateBaseBridge mExtraInfoBridge;
private final Handler mBgHandler;
private final Handler mFgHandler;
- private final LauncherIcons mLauncherIcons;
private int mFilterMode;
private ArrayList<ApplicationsState.AppEntry> mBaseEntries;
@@ -882,7 +879,6 @@
mContext = manageApplications.getActivity();
mPm = mContext.getPackageManager();
mFilterMode = filterMode;
- mLauncherIcons = new LauncherIcons(mContext);
if (mManageApplications.mListType == LIST_TYPE_NOTIFICATION) {
mExtraInfoBridge = new AppStateNotificationBridge(mContext, mState, this,
manageApplications.mNotifBackend);
@@ -1317,9 +1313,6 @@
}
mState.ensureIcon(entry);
if (entry.icon != null) {
- if (entry.icon instanceof AdaptiveIconDrawable) {
- entry.icon = mLauncherIcons.wrapIconDrawableWithShadow(entry.icon);
- }
holder.appIcon.setImageDrawable(entry.icon);
}
updateSummary(holder);
diff --git a/src/com/android/settings/applications/ProcessStatsDetail.java b/src/com/android/settings/applications/ProcessStatsDetail.java
index c23da04..6c0928c 100644
--- a/src/com/android/settings/applications/ProcessStatsDetail.java
+++ b/src/com/android/settings/applications/ProcessStatsDetail.java
@@ -39,6 +39,7 @@
import android.support.v7.preference.PreferenceCategory;
import android.text.format.Formatter;
import android.util.ArrayMap;
+import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -129,7 +130,7 @@
.getApplicationFeatureProvider(activity)
.newAppHeaderController(this, null /* appHeader */)
.setIcon(mApp.mUiTargetApp != null
- ? mApp.mUiTargetApp.loadIcon(mPm)
+ ? IconDrawableFactory.newInstance(activity).getBadgedIcon(mApp.mUiTargetApp)
: new ColorDrawable(0))
.setLabel(mApp.mUiLabel)
.setPackageName(mApp.mPackage)
diff --git a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
deleted file mode 100644
index 5b05602..0000000
--- a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package com.android.settings.applications;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import com.android.settings.R;
-import com.android.settings.core.PreferenceController;
-import com.android.settings.datausage.DataSaverBackend;
-
-public class SpecialAppAccessPreferenceController extends PreferenceController {
-
- private static final String KEY_SPECIAL_ACCESS = "special_access";
-
- private DataSaverBackend mDataSaverBackend;
-
- public SpecialAppAccessPreferenceController(Context context) {
- super(context);
- mDataSaverBackend = new DataSaverBackend(context);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_SPECIAL_ACCESS;
- }
-
- @Override
- public void updateState(Preference preference) {
- final int count = mDataSaverBackend.getWhitelistedCount();
- preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.special_access_summary, count, count));
- }
-}
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index e98ca20..a448b5c 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -40,6 +40,7 @@
import android.support.v7.preference.PreferenceCategory;
import android.text.format.Formatter;
import android.util.ArraySet;
+import android.util.IconDrawableFactory;
import android.view.View;
import android.widget.AdapterView;
@@ -158,7 +159,7 @@
PackageManager pm = getPackageManager();
try {
ApplicationInfo info = pm.getApplicationInfo(mPackages.valueAt(0), 0);
- mIcon = info.loadIcon(pm);
+ mIcon = IconDrawableFactory.newInstance(getActivity()).getBadgedIcon(info);
mLabel = info.loadLabel(pm);
mPackageName = info.packageName;
} catch (PackageManager.NameNotFoundException e) {
diff --git a/src/com/android/settings/display/BrightnessLevelPreferenceController.java b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
index e0000d6..d012ac3 100644
--- a/src/com/android/settings/display/BrightnessLevelPreferenceController.java
+++ b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
@@ -13,20 +13,79 @@
*/
package com.android.settings.display;
-import static android.provider.Settings.System.SCREEN_BRIGHTNESS;
-
+import android.content.ContentResolver;
import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.PowerManager;
+import android.os.RemoteException;
+import android.os.ServiceManager;
import android.provider.Settings;
+import android.provider.Settings.System;
+import android.service.vr.IVrManager;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.util.Log;
+
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnPause;
+import com.android.settings.core.lifecycle.events.OnResume;
+
import java.text.NumberFormat;
-public class BrightnessLevelPreferenceController extends PreferenceController {
+public class BrightnessLevelPreferenceController extends PreferenceController implements
+ LifecycleObserver, OnResume, OnPause {
+ private static final String TAG = "BrightnessPrefCtrl";
private static final String KEY_BRIGHTNESS = "brightness";
+ private static final Uri BRIGHTNESS_MODE_URI;
+ private static final Uri BRIGHTNESS_URI;
+ private static final Uri BRIGHTNESS_FOR_VR_URI;
+ private static final Uri BRIGHTNESS_ADJ_URI;
- public BrightnessLevelPreferenceController(Context context) {
+ private final int mMinBrightness;
+ private final int mMaxBrightness;
+ private final int mMinVrBrightness;
+ private final int mMaxVrBrightness;
+ private final ContentResolver mContentResolver;
+
+ private Preference mPreference;
+
+ static {
+ BRIGHTNESS_MODE_URI = System.getUriFor(System.SCREEN_BRIGHTNESS_MODE);
+ BRIGHTNESS_URI = System.getUriFor(System.SCREEN_BRIGHTNESS);
+ BRIGHTNESS_FOR_VR_URI = System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR);
+ BRIGHTNESS_ADJ_URI = System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ);
+ }
+
+ private ContentObserver mBrightnessObserver = new ContentObserver(new Handler()) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updatedSummary(mPreference);
+ }
+ };
+
+ public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle) {
+ this(context, lifecycle, new PowerManagerWrapper(
+ (PowerManager) context.getSystemService(Context.POWER_SERVICE)));
+ }
+
+ @VisibleForTesting
+ public BrightnessLevelPreferenceController(Context context, Lifecycle lifecycle,
+ PowerManagerWrapper powerManagerWrapper) {
super(context);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ mMinBrightness = powerManagerWrapper.getMinimumScreenBrightnessSetting();
+ mMaxBrightness = powerManagerWrapper.getMaximumScreenBrightnessSetting();
+ mMinVrBrightness = powerManagerWrapper.getMinimumScreenBrightnessForVrSetting();
+ mMaxVrBrightness = powerManagerWrapper.getMaximumScreenBrightnessForVrSetting();
+ mContentResolver = mContext.getContentResolver();
}
@Override
@@ -40,10 +99,66 @@
}
@Override
- public void updateState(Preference preference) {
- final double brightness = Settings.System.getInt(mContext.getContentResolver(),
- SCREEN_BRIGHTNESS, 0);
- preference.setSummary(NumberFormat.getPercentInstance().format(brightness / 255));
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(KEY_BRIGHTNESS);
}
+ @Override
+ public void updateState(Preference preference) {
+ updatedSummary(preference);
+ }
+
+ @Override
+ public void onResume() {
+ mContentResolver.registerContentObserver(BRIGHTNESS_MODE_URI, false, mBrightnessObserver);
+ mContentResolver.registerContentObserver(BRIGHTNESS_URI, false, mBrightnessObserver);
+ mContentResolver.registerContentObserver(BRIGHTNESS_FOR_VR_URI, false, mBrightnessObserver);
+ mContentResolver.registerContentObserver(BRIGHTNESS_ADJ_URI, false, mBrightnessObserver);
+ }
+
+ @Override
+ public void onPause() {
+ mContentResolver.unregisterContentObserver(mBrightnessObserver);
+ }
+
+ private void updatedSummary(Preference preference) {
+ if (preference != null) {
+ preference.setSummary(NumberFormat.getPercentInstance().format(getCurrentBrightness()));
+ }
+ }
+
+ private double getCurrentBrightness() {
+ if (isInVrMode()) {
+ final double value = System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS_FOR_VR,
+ mMaxBrightness);
+ return getPercentage(value, mMinVrBrightness, mMaxVrBrightness);
+ }
+ final int brightnessMode = Settings.System.getInt(mContentResolver,
+ System.SCREEN_BRIGHTNESS_MODE, System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+ if (brightnessMode == System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+ final float value = Settings.System.getFloat(mContentResolver,
+ System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0);
+ // auto brightness is between -1 and 1
+ return ((value + 1)) / 2;
+ }
+ final double value = Settings.System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS,
+ mMinBrightness);
+ return getPercentage(value, mMinBrightness, mMaxBrightness);
+ }
+
+ private double getPercentage(double value, int min, int max) {
+ return (value - min) / (max - min);
+ }
+
+ @VisibleForTesting
+ boolean isInVrMode() {
+ try {
+ return IVrManager.Stub.asInterface(ServiceManager.getService(Context.VR_SERVICE))
+ .getVrModeState();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to check vr mode!", e);
+ }
+ return false;
+ }
}
diff --git a/src/com/android/settings/display/PowerManagerWrapper.java b/src/com/android/settings/display/PowerManagerWrapper.java
new file mode 100644
index 0000000..afa2f33
--- /dev/null
+++ b/src/com/android/settings/display/PowerManagerWrapper.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.display;
+
+import android.os.PowerManager;
+
+/**
+ * This class replicates a subset of the android.os.PowerManager. The class exists so that we can
+ * use a thin wrapper around the PowerManager in production code and a mock in tests. We cannot
+ * directly mock or shadow the PowerManager, because some of the methods we rely on are newer than
+ * the API version supported by Robolectric or are hidden.
+ */
+public class PowerManagerWrapper {
+ private final PowerManager mPowerManager;
+
+ public PowerManagerWrapper(PowerManager powerManager) {
+ mPowerManager = powerManager;
+ }
+
+ public int getMinimumScreenBrightnessSetting() {
+ return mPowerManager.getMinimumScreenBrightnessSetting();
+ }
+
+ public int getMaximumScreenBrightnessSetting() {
+ return mPowerManager.getMaximumScreenBrightnessSetting();
+ }
+
+ public int getMinimumScreenBrightnessForVrSetting() {
+ return mPowerManager.getMinimumScreenBrightnessForVrSetting();
+ }
+
+ public int getMaximumScreenBrightnessForVrSetting() {
+ return mPowerManager.getMaximumScreenBrightnessForVrSetting();
+ }
+}
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index 01670fe..fb59c59 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -47,6 +47,7 @@
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.style.URLSpan;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -604,7 +605,9 @@
private void renameFingerPrint(int fingerId, String newName) {
mFingerprintManager.rename(fingerId, mUserId, newName);
- mFingerprintsRenaming.put(fingerId, newName);
+ if (!TextUtils.isEmpty(newName)) {
+ mFingerprintsRenaming.put(fingerId, newName);
+ }
updatePreferences();
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 4b060cb..bcf9c3f 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -16,6 +16,7 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_NONE;
@@ -56,9 +57,13 @@
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static final String KEY_BLOCK = "block";
+ private static final String KEY_IMPORTANCE = "allow_sound";
private List<NotificationChannelGroup> mChannelGroupList;
private List<PreferenceCategory> mChannelGroups = new ArrayList();
+ private RestrictedSwitchPreference mImportanceToggle;
+
+ private boolean mShowLegacyChannelConfig = false;
@Override
public int getMetricsCategory() {
@@ -139,6 +144,15 @@
empty.setTitle(R.string.no_channels);
empty.setEnabled(false);
groupCategory.addPreference(empty);
+
+ } else if (mChannelGroupList.size() == 1 &&
+ mChannelGroupList.get(0).getChannels().get(0).getId()
+ .equals(NotificationChannel.DEFAULT_CHANNEL_ID)) {
+ // Legacy app using only default channel. Hoist default channel settings to main panel.
+ mShowLegacyChannelConfig = true;
+ mChannel = mChannelGroupList.get(0).getChannels().get(0);
+ populateDefaultChannelPrefs();
+
} else {
for (NotificationChannelGroup group : mChannelGroupList) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
@@ -159,39 +173,7 @@
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
- MasterSwitchPreference channelPref = new MasterSwitchPreference(
- getPrefContext());
- channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && !mAppRow.systemApp);
- channelPref.setKey(channel.getId());
- channelPref.setTitle(channel.getName());
- channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
- 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);
-
- return true;
- }
- });
- groupCategory.addPreference(channelPref);
+ populateSingleChannelPrefs(groupCategory, channel);
}
}
@@ -215,6 +197,74 @@
updateDependents(mAppRow.banned);
}
+ private void populateSingleChannelPrefs(PreferenceCategory groupCategory,
+ final NotificationChannel channel) {
+ MasterSwitchPreference channelPref = new MasterSwitchPreference(
+ getPrefContext());
+ channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && !mAppRow.systemApp);
+ channelPref.setKey(channel.getId());
+ channelPref.setTitle(channel.getName());
+ channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
+ 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);
+
+ return true;
+ }
+ });
+ groupCategory.addPreference(channelPref);
+ }
+
+ private void populateDefaultChannelPrefs() {
+ addPreferencesFromResource(R.xml.legacy_channel_notification_settings);
+ mPriority =
+ (RestrictedSwitchPreference) findPreference(KEY_BYPASS_DND);
+ mVisibilityOverride =
+ (RestrictedDropDownPreference) findPreference(KEY_VISIBILITY_OVERRIDE);
+ mImportanceToggle = (RestrictedSwitchPreference) findPreference(KEY_IMPORTANCE);
+
+ if (mPkgInfo != null && mChannel != null) {
+ setupPriorityPref(mChannel.canBypassDnd());
+ setupVisOverridePref(mChannel.getLockscreenVisibility());
+ setupImportanceToggle();
+ }
+ }
+
+ private void setupImportanceToggle() {
+ mImportanceToggle.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mImportanceToggle.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT);
+ mImportanceToggle.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final int importance = ((Boolean) newValue ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
+ mChannel.setImportance(importance);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+ }
+
private void setupBadge() {
mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
mBadge.setChecked(mAppRow.showBadge);
@@ -254,6 +304,11 @@
setVisible(category, !banned);
}
setVisible(mBadge, !banned);
+ if (mShowLegacyChannelConfig) {
+ setVisible(mImportanceToggle, !banned);
+ setVisible(mPriority, !banned);
+ setVisible(mVisibilityOverride, !banned);
+ }
if (mAppRow.systemApp && !mAppRow.banned) {
setVisible(mBlock, false);
}
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 8ba5b8b..f6a7b42 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -22,16 +22,13 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import android.app.Activity;
-import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
-import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.UserHandle;
import android.provider.Settings;
-import android.service.notification.NotificationListenerService.Ranking;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -44,7 +41,6 @@
import com.android.settings.RingtonePreference;
import com.android.settings.applications.AppHeaderController;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
import java.util.ArrayList;
@@ -53,9 +49,6 @@
public class ChannelNotificationSettings extends NotificationSettingsBase {
private static final String TAG = "ChannelSettings";
- protected static final String KEY_BYPASS_DND = "bypass_dnd";
- protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
- protected static final String KEY_IMPORTANCE = "importance";
protected static final String KEY_LIGHTS = "lights";
protected static final String KEY_VIBRATE = "vibrate";
protected static final String KEY_RINGTONE = "ringtone";
@@ -63,9 +56,6 @@
protected RestrictedSwitchPreference mLights;
protected RestrictedSwitchPreference mVibrate;
protected NotificationSoundPreference mRingtone;
- protected RestrictedDropDownPreference mImportance;
- protected RestrictedSwitchPreference mPriority;
- protected RestrictedDropDownPreference mVisibilityOverride;
@Override
public int getMetricsCategory() {
@@ -224,7 +214,7 @@
final int numImportances = IMPORTANCE_HIGH - IMPORTANCE_MIN + 1;
List<String> summaries = new ArrayList<>();
List<String> values = new ArrayList<>();
- ;
+
for (int i = 0; i < numImportances; i++) {
int importance = i + 1;
summaries.add(getImportanceSummary(importance));
@@ -256,105 +246,6 @@
}
}
- protected void setupPriorityPref(boolean priority) {
- mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
- mPriority.setChecked(priority);
- mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean bypassZenMode = (Boolean) newValue;
- mChannel.setBypassDnd(bypassZenMode);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- return true;
- }
- });
- }
-
- protected void setupVisOverridePref(int sensitive) {
- ArrayList<CharSequence> entries = new ArrayList<>();
- ArrayList<CharSequence> values = new ArrayList<>();
-
- mVisibilityOverride.clearRestrictedItems();
- if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
- final String summaryShowEntry =
- getString(R.string.lock_screen_notifications_summary_show);
- final String summaryShowEntryValue =
- Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE);
- entries.add(summaryShowEntry);
- values.add(summaryShowEntryValue);
- setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue,
- DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
- | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
- }
-
- final String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
- final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
- entries.add(summaryHideEntry);
- values.add(summaryHideEntryValue);
- setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue,
- DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
- entries.add(getString(R.string.lock_screen_notifications_summary_disable));
- values.add(Integer.toString(Notification.VISIBILITY_SECRET));
- mVisibilityOverride.setEntries(entries.toArray(new CharSequence[entries.size()]));
- mVisibilityOverride.setEntryValues(values.toArray(new CharSequence[values.size()]));
-
- if (sensitive == Ranking.VISIBILITY_NO_OVERRIDE) {
- mVisibilityOverride.setValue(Integer.toString(getGlobalVisibility()));
- } else {
- mVisibilityOverride.setValue(Integer.toString(sensitive));
- }
- mVisibilityOverride.setSummary("%s");
-
- mVisibilityOverride.setOnPreferenceChangeListener(
- new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- int sensitive = Integer.parseInt((String) newValue);
- if (sensitive == getGlobalVisibility()) {
- sensitive = Ranking.VISIBILITY_NO_OVERRIDE;
- }
- mChannel.setLockscreenVisibility(sensitive);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- return true;
- }
- });
- mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
- }
-
- private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
- CharSequence entryValue, int keyguardNotificationFeatures) {
- RestrictedLockUtils.EnforcedAdmin admin =
- RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
- mContext, keyguardNotificationFeatures, mUserId);
- if (admin != null) {
- RestrictedDropDownPreference.RestrictedItem item =
- new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
- mVisibilityOverride.addRestrictedItem(item);
- }
- }
-
- private int getGlobalVisibility() {
- int globalVis = Ranking.VISIBILITY_NO_OVERRIDE;
- if (!getLockscreenNotificationsEnabled()) {
- globalVis = Notification.VISIBILITY_SECRET;
- } else if (!getLockscreenAllowPrivateNotifications()) {
- globalVis = Notification.VISIBILITY_PRIVATE;
- }
- return globalVis;
- }
-
- private boolean getLockscreenNotificationsEnabled() {
- return Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
- }
-
- private boolean getLockscreenAllowPrivateNotifications() {
- return Settings.Secure.getInt(getContentResolver(),
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
- }
-
private boolean isLockScreenSecure() {
LockPatternUtils utils = new LockPatternUtils(getActivity());
boolean lockscreenSecure = utils.isSecure(UserHandle.myUserId());
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index c1ef018..6226eac 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -18,7 +18,6 @@
import android.app.INotificationManager;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
-import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -28,6 +27,7 @@
import android.graphics.drawable.Drawable;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.util.IconDrawableFactory;
import android.util.Log;
import com.android.settingslib.Utils;
@@ -48,7 +48,7 @@
Log.e(TAG, "Error loading application label for " + row.pkg, t);
row.label = row.pkg;
}
- row.icon = app.loadIcon(pm);
+ row.icon = IconDrawableFactory.newInstance(context).getBadgedIcon(app);
row.banned = getNotificationsBanned(row.pkg, row.uid);
row.showBadge = canShowBadge(row.pkg, row.uid);
row.userId = UserHandle.getUserId(row.uid);
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 960c3b8..ff0a512 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -18,15 +18,14 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
import android.app.Notification;
import android.app.NotificationChannel;
-import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
+import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -39,6 +38,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
+import android.service.notification.NotificationListenerService;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -47,6 +47,7 @@
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import java.util.ArrayList;
import java.util.List;
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
@@ -59,6 +60,9 @@
protected static final String KEY_BLOCK = "block";
protected static final String KEY_BADGE = "badge";
+ protected static final String KEY_BYPASS_DND = "bypass_dnd";
+ protected static final String KEY_VISIBILITY_OVERRIDE = "visibility_override";
+ protected static final String KEY_IMPORTANCE = "importance";
protected PackageManager mPm;
protected UserManager mUm;
@@ -71,6 +75,10 @@
protected PackageInfo mPkgInfo;
protected RestrictedSwitchPreference mBlock;
protected RestrictedSwitchPreference mBadge;
+ protected RestrictedDropDownPreference mImportance;
+ protected RestrictedSwitchPreference mPriority;
+ protected RestrictedDropDownPreference mVisibilityOverride;
+
protected EnforcedAdmin mSuspendedAppsAdmin;
protected boolean mDndVisualEffectsSuppressed;
@@ -249,4 +257,105 @@
return getContext().getString(R.string.notification_importance_high);
}
}
+
+ protected void setupPriorityPref(boolean priority) {
+ mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mPriority.setChecked(priority);
+ mPriority.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean bypassZenMode = (Boolean) newValue;
+ mChannel.setBypassDnd(bypassZenMode);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_PRIORITY);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+ }
+
+ protected void setupVisOverridePref(int sensitive) {
+ ArrayList<CharSequence> entries = new ArrayList<>();
+ ArrayList<CharSequence> values = new ArrayList<>();
+
+ mVisibilityOverride.clearRestrictedItems();
+ if (getLockscreenNotificationsEnabled() && getLockscreenAllowPrivateNotifications()) {
+ final String summaryShowEntry =
+ getString(R.string.lock_screen_notifications_summary_show);
+ final String summaryShowEntryValue =
+ Integer.toString(NotificationManager.VISIBILITY_NO_OVERRIDE);
+ entries.add(summaryShowEntry);
+ values.add(summaryShowEntryValue);
+ setRestrictedIfNotificationFeaturesDisabled(summaryShowEntry, summaryShowEntryValue,
+ DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS
+ | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
+ }
+
+ final String summaryHideEntry = getString(R.string.lock_screen_notifications_summary_hide);
+ final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
+ entries.add(summaryHideEntry);
+ values.add(summaryHideEntryValue);
+ setRestrictedIfNotificationFeaturesDisabled(summaryHideEntry, summaryHideEntryValue,
+ DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+ entries.add(getString(R.string.lock_screen_notifications_summary_disable));
+ values.add(Integer.toString(Notification.VISIBILITY_SECRET));
+ mVisibilityOverride.setEntries(entries.toArray(new CharSequence[entries.size()]));
+ mVisibilityOverride.setEntryValues(values.toArray(new CharSequence[values.size()]));
+
+ if (sensitive == NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE) {
+ mVisibilityOverride.setValue(Integer.toString(getGlobalVisibility()));
+ } else {
+ mVisibilityOverride.setValue(Integer.toString(sensitive));
+ }
+ mVisibilityOverride.setSummary("%s");
+
+ mVisibilityOverride.setOnPreferenceChangeListener(
+ new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ int sensitive = Integer.parseInt((String) newValue);
+ if (sensitive == getGlobalVisibility()) {
+ sensitive = NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE;
+ }
+ mChannel.setLockscreenVisibility(sensitive);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_VISIBILITY);
+ mBackend.updateChannel(mPkg, mUid, mChannel);
+ return true;
+ }
+ });
+ mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
+ }
+
+
+ private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
+ CharSequence entryValue, int keyguardNotificationFeatures) {
+ RestrictedLockUtils.EnforcedAdmin admin =
+ RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
+ mContext, keyguardNotificationFeatures, mUserId);
+ if (admin != null) {
+ RestrictedDropDownPreference.RestrictedItem item =
+ new RestrictedDropDownPreference.RestrictedItem(entry, entryValue, admin);
+ mVisibilityOverride.addRestrictedItem(item);
+ }
+ }
+
+ private int getGlobalVisibility() {
+ int globalVis = NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE;
+ if (!getLockscreenNotificationsEnabled()) {
+ globalVis = Notification.VISIBILITY_SECRET;
+ } else if (!getLockscreenAllowPrivateNotifications()) {
+ globalVis = Notification.VISIBILITY_PRIVATE;
+ }
+ return globalVis;
+ }
+
+
+ private boolean getLockscreenNotificationsEnabled() {
+ return Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
+ }
+
+ private boolean getLockscreenAllowPrivateNotifications() {
+ return Settings.Secure.getInt(getContentResolver(),
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
+ }
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 01551da..66e8c54 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -191,8 +191,10 @@
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- getPreferenceManager().setPreferenceComparisonCallback(
- new PreferenceManager.SimplePreferenceComparisonCallback());
+ // TODO(b/37429702): Add animations and preference comparator back after initial screen is
+ // loaded (ODR).
+ setAnimationAllowed(false);
+
addPreferencesFromResource(R.xml.wifi_settings);
mConnectedAccessPointPreferenceCategory =
@@ -204,9 +206,6 @@
mConfigureWifiSettingsPreference = findPreference(PREF_KEY_CONFIGURE_WIFI_SETTINGS);
mSavedNetworksPreference = findPreference(PREF_KEY_SAVED_NETWORKS);
- // Hide additional settings until access points are shown during onStart
- showAdditionalSettings(false);
-
Context prefContext = getPrefContext();
mAddPreference = new Preference(prefContext);
mAddPreference.setIcon(R.drawable.ic_menu_add_inset);
@@ -224,17 +223,6 @@
mBgThread.start();
}
- // TODO(b/37429702): Figure out how to temporarily disable animations during startup and remove
- // this method.
- private void showAdditionalSettings(boolean visible) {
- mAdditionalSettingsPreferenceCategory.setVisible(visible);
- mAdditionalSettingsPreferenceCategory.removeAll();
- if (visible) {
- mAdditionalSettingsPreferenceCategory.addPreference(mConfigureWifiSettingsPreference);
- mAdditionalSettingsPreferenceCategory.addPreference(mSavedNetworksPreference);
- }
- }
-
@Override
public void onDestroy() {
mBgThread.quit();
@@ -359,8 +347,6 @@
getView().removeCallbacks(mUpdateAccessPointsRunnable);
updateAccessPointPreferences();
}
-
- showAdditionalSettings(true);
}
/**
@@ -394,7 +380,6 @@
mWifiTracker.stopTracking();
getView().removeCallbacks(mUpdateAccessPointsRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
- showAdditionalSettings(false);
super.onStop();
}
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index e8bca37..21fda30 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -301,6 +301,7 @@
Preference pref = new Preference(mPrefContext);
pref.setKey(ip);
pref.setTitle(ip);
+ pref.setSelectable(false);
mIpv6AddressCategory.addPreference(pref);
mIpv6AddressCategory.setVisible(true);
}
diff --git a/tests/robotests/src/android/util/IconDrawableFactory.java b/tests/robotests/src/android/util/IconDrawableFactory.java
new file mode 100644
index 0000000..9d0d7df
--- /dev/null
+++ b/tests/robotests/src/android/util/IconDrawableFactory.java
@@ -0,0 +1,44 @@
+/*
+ * 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 android.util;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageItemInfo;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+
+/**
+ * This class is only needed to get around Robolectric issue.
+ */
+public class IconDrawableFactory {
+
+ public static IconDrawableFactory newInstance(Context context) {
+ return new IconDrawableFactory();
+ }
+
+ public Drawable getBadgedIcon(ApplicationInfo appInfo) {
+ return getBadgedIcon(appInfo, 0);
+ }
+
+ public Drawable getBadgedIcon(ApplicationInfo appInfo, int userId) {
+ return getBadgedIcon(appInfo, appInfo, userId);
+ }
+
+ public Drawable getBadgedIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo, int userId) {
+ return new ColorDrawable(0);
+ }
+}
diff --git a/tests/robotests/src/android/util/LauncherIcons.java b/tests/robotests/src/android/util/LauncherIcons.java
deleted file mode 100644
index a18cfae..0000000
--- a/tests/robotests/src/android/util/LauncherIcons.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.util;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-
-/**
- * This class is only needed to get around RoboElectric issue.
- */
-public final class LauncherIcons {
-
- public LauncherIcons(Context context) {
- }
-
- public Drawable wrapIconDrawableWithShadow(Drawable drawable) {
- return drawable;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceControllerTest.java
new file mode 100644
index 0000000..d93d3a7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accounts/AutoSyncWorkDataPreferenceControllerTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.accounts;
+
+
+import static android.content.pm.UserInfo.FLAG_MANAGED_PROFILE;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.when;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AutoSyncWorkDataPreferenceControllerTest {
+
+ @Mock(answer = RETURNS_DEEP_STUBS)
+ private UserManager mUserManager;
+ @Mock(answer = RETURNS_DEEP_STUBS)
+ private Fragment mFragment;
+ @Mock
+ private Context mContext;
+
+ private AutoSyncWorkDataPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+
+ mController = new AutoSyncWorkDataPreferenceController(mContext, mFragment);
+ }
+
+ @Test
+ public void checkIsAvailable_managedProfile_shouldNotDisplay() {
+ when(mUserManager.isManagedProfile()).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void checkIsAvailable_linkedUser_shouldNotDisplay() {
+ when(mUserManager.isManagedProfile()).thenReturn(false);
+ when(mUserManager.isLinkedUser()).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void checkIsAvailable_singleUserProfile_shouldNotDisplay() {
+ final List<UserInfo> infos = new ArrayList<>();
+ infos.add(new UserInfo(1, "user 1", 0));
+ when(mUserManager.isManagedProfile()).thenReturn(false);
+ when(mUserManager.isLinkedUser()).thenReturn(false);
+ when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void multipleProfile_shouldInitWithWorkProfileUserHandle() {
+ final int id1 = 1;
+ final int id2 = 2;
+ final UserInfo managedUser = new UserInfo(id2, "user 2", FLAG_MANAGED_PROFILE);
+ final List<UserHandle> infos = new ArrayList<>();
+ infos.add(new UserHandle(id1));
+ infos.add(new UserHandle(id2));
+ when(mUserManager.getUserProfiles()).thenReturn(infos);
+ when(mUserManager.getUserHandle()).thenReturn(id1);
+ when(mUserManager.getUserInfo(id2)).thenReturn(managedUser);
+
+ mController = new AutoSyncWorkDataPreferenceController(mContext, mFragment);
+
+ assertThat(mController.mUserHandle.getIdentifier()).isEqualTo(id2);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
index bff94a4..37a7521 100644
--- a/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppHeaderControllerTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
@@ -38,7 +39,6 @@
import android.support.v7.preference.Preference;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.ImageView;
import android.widget.TextView;
import com.android.settings.R;
@@ -276,17 +276,6 @@
.isEqualTo(View.GONE);
}
- // Ensure that the instant app label does not show up when we haven't told the controller the
- // app is instant.
- @Test
- public void instantApps_normalAppsDontGetInstantAppsBadge() {
- final View appHeader = mLayoutInflater.inflate(R.layout.app_details, null /* root */);
- mController = new AppHeaderController(mContext, mFragment, appHeader);
- mController.done(mActivity);
- assertThat(appHeader.findViewById(R.id.app_icon_instant_apps_badge).getVisibility())
- .isEqualTo(View.GONE);
- }
-
// Test that the "instant apps" label is present in the header when we have an instant app.
@Test
public void instantApps_expectedHeaderItem() {
@@ -295,8 +284,6 @@
mController.setIsInstantApp(true);
mController.done(mActivity);
TextView label = appHeader.findViewById(R.id.install_type);
- ImageView badgeView = appHeader.findViewById(R.id.app_icon_instant_apps_badge);
- assertThat(badgeView.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(label.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(label.getText()).isEqualTo(
appHeader.getResources().getString(R.string.install_type_instant));
diff --git a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
deleted file mode 100644
index 44ca9f7..0000000
--- a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import com.android.settings.R;
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.datausage.DataSaverBackend;
-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.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SpecialAppAccessPreferenceControllerTest {
- private Context mContext;
- @Mock
- private DataSaverBackend mBackend;
- @Mock
- private Preference mPreference;
-
- private SpecialAppAccessPreferenceController mController;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = new SpecialAppAccessPreferenceController(mContext);
- ReflectionHelpers.setField(mController, "mDataSaverBackend", mBackend);
- }
-
- @Test
- public void isAvailable_shouldAlwaysReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void updateState_shouldSetSummary() {
- when(mBackend.getWhitelistedCount()).thenReturn(0);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setSummary(mContext.getResources().getQuantityString(
- R.plurals.special_access_summary, 0, 0));
-
- when(mBackend.getWhitelistedCount()).thenReturn(1);
-
- mController.updateState(mPreference);
-
- verify(mPreference).setSummary(mContext.getResources().getQuantityString(
- R.plurals.special_access_summary, 1, 1));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
index 025e1ae..0b33089 100644
--- a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
@@ -16,27 +16,31 @@
package com.android.settings.display;
-import static android.provider.Settings.System.SCREEN_BRIGHTNESS;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
import android.content.Context;
-import android.provider.Settings;
+import android.provider.Settings.System;
import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
-import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
-import java.text.NumberFormat;
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.internal.ShadowExtractor;
+import org.robolectric.shadows.ShadowContentResolver;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -46,6 +50,10 @@
@Mock
private ContentResolver mContentResolver;
@Mock
+ private PowerManagerWrapper mPowerManager;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
private Preference mPreference;
private BrightnessLevelPreferenceController mController;
@@ -53,8 +61,15 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
+ when(mContext.getContentResolver()).thenReturn(mContentResolver);
+ when(mPowerManager.getMinimumScreenBrightnessSetting()).thenReturn(0);
+ when(mPowerManager.getMaximumScreenBrightnessSetting()).thenReturn(100);
+ when(mPowerManager.getMinimumScreenBrightnessForVrSetting()).thenReturn(0);
+ when(mPowerManager.getMaximumScreenBrightnessForVrSetting()).thenReturn(100);
+ when(mScreen.findPreference(anyString())).thenReturn(mPreference);
+ mController = spy(new BrightnessLevelPreferenceController(mContext, null, mPowerManager));
+ doReturn(false).when(mController).isInVrMode();
- mController = new BrightnessLevelPreferenceController(mContext);
}
@Test
@@ -63,14 +78,80 @@
}
@Test
- public void updateState_shouldSetSummary() {
- final NumberFormat formatter = NumberFormat.getPercentInstance();
- when(mContext.getContentResolver()).thenReturn(mContentResolver);
- Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS, 45);
+ public void onResume_shouldRegisterObserver() {
+ Context context = RuntimeEnvironment.application;
+ BrightnessLevelPreferenceController controller =
+ new BrightnessLevelPreferenceController(context, null, mPowerManager);
+ ShadowContentResolver shadowContentResolver =
+ (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
+
+ controller.onResume();
+
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isNotEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS))).isNotEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isNotEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isNotEmpty();
+ }
+
+ @Test
+ public void onPause_shouldUnregisterObserver() {
+ Context context = RuntimeEnvironment.application;
+ BrightnessLevelPreferenceController controller =
+ new BrightnessLevelPreferenceController(context, null, mPowerManager);
+ ShadowContentResolver shadowContentResolver =
+ (ShadowContentResolver) ShadowExtractor.extract(context.getContentResolver());
+
+ controller.displayPreference(mScreen);
+ controller.onResume();
+ controller.onPause();
+
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS))).isEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isEmpty();
+ assertThat(shadowContentResolver.getContentObservers(
+ System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ))).isEmpty();
+ }
+
+ @Test
+ public void updateState_inVrMode_shouldSetSummaryToVrBrightness() {
+ doReturn(true).when(mController).isInVrMode();
+ System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS_FOR_VR, 85);
mController.updateState(mPreference);
- verify(mPreference).setSummary(formatter.format(45.0 / 255));
+ verify(mPreference).setSummary("85%");
}
+ @Test
+ public void updateState_autoBrightness_shouldSetSummaryToVrBrightness() {
+ doReturn(false).when(mController).isInVrMode();
+ System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS_MODE,
+ System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
+
+ System.putFloat(mContentResolver, System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary("50%");
+ }
+
+ @Test
+ public void updateState_manualBrightness_shouldSetSummaryToVrBrightness() {
+ doReturn(false).when(mController).isInVrMode();
+ System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS_MODE,
+ System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+
+ System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS, 45);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setSummary("45%");
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
index f4370fc..fa0170c 100644
--- a/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/search/DatabaseIndexingUtilsTest.java
@@ -17,35 +17,30 @@
package com.android.settings.search;
-import android.content.Context;
+import static com.google.common.truth.Truth.assertThat;
+import android.content.Context;
import android.util.ArrayMap;
+
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.core.PreferenceController;
-import com.android.settings.display.AutoBrightnessPreferenceController;
-import com.android.settings.gestures.DoubleTapPowerPreferenceController;
-import com.android.settings.gestures.DoubleTapScreenPreferenceController;
-import com.android.settings.gestures.DoubleTwistPreferenceController;
-import com.android.settings.gestures.PickupGesturePreferenceController;
-import com.android.settings.gestures.SwipeToNotificationPreferenceController;
+import com.android.settings.deviceinfo.SystemUpdatePreferenceController;
import com.android.settings.search2.DatabaseIndexingUtils;
-
import com.android.settings.search2.IntentPayload;
import com.android.settings.search2.ResultPayload;
+
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 java.util.Map;
-import static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class DatabaseIndexingUtilsTest {
@@ -57,7 +52,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = ShadowApplication.getInstance().getApplicationContext();
+ mContext = RuntimeEnvironment.application;
}
@Test
@@ -74,11 +69,11 @@
@Test
public void testGetPreferenceControllerUriMap_CompatibleClass_ReturnsValidMap() {
- String className = "com.android.settings.DisplaySettings";
-
- Map map = DatabaseIndexingUtils.getPreferenceControllerUriMap(className, mContext);
- assertThat(map.get("auto_brightness"))
- .isInstanceOf(AutoBrightnessPreferenceController.class);
+ final String className = "com.android.settings.system.SystemDashboardFragment";
+ final Map<String, PreferenceController> map =
+ DatabaseIndexingUtils.getPreferenceControllerUriMap(className, mContext);
+ assertThat(map.get("system_update_settings"))
+ .isInstanceOf(SystemUpdatePreferenceController.class);
}
@Test
@@ -106,7 +101,7 @@
return new IntentPayload(null);
}
};
- ArrayMap<String,PreferenceController> map = new ArrayMap<>();
+ ArrayMap<String, PreferenceController> map = new ArrayMap<>();
map.put(key, prefController);
ResultPayload payload = DatabaseIndexingUtils.getPayloadFromUriMap(map, key);
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index efe0c1c..8d28dee 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -54,11 +54,13 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -73,6 +75,7 @@
private static final String SECURITY = "None";
private InetAddress mIpv4Address;
+ private Inet6Address mIpv6Address;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceScreen mockScreen;
@@ -113,6 +116,12 @@
try {
mIpv4Address = InetAddress.getByAddress(
new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 255 });
+ mIpv6Address = Inet6Address.getByAddress(
+ "123", /* host */
+ new byte[] {
+ (byte) 0xFE, (byte) 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x11, 0x25,
+ (byte) 0xFF, (byte) 0xFE, (byte) 0xF8, (byte) 0x7C, (byte) 0xB2},
+ 1 /*scope id */);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
@@ -153,6 +162,8 @@
}
private void setupMockedPreferenceScreen() {
+ when(mockScreen.getPreferenceManager().getContext()).thenReturn(mContext);
+
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_CONNECTION_DETAIL_PREF))
.thenReturn(mockConnectionDetailPref);
when(mockScreen.findPreference(WifiDetailPreferenceController.KEY_SIGNAL_STRENGTH_PREF))
@@ -420,4 +431,30 @@
verify(mockActivity).finish();
}
+
+ @Test
+ public void ipv6AddressPref_shouldHaveHostAddressTextSet() {
+ LinkAddress ipv6Address = new LinkAddress(mIpv6Address, 128);
+
+ mLinkProperties.addLinkAddress(ipv6Address);
+
+ mController.onResume();
+
+ ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(Preference.class);
+ verify(mockIpv6AddressCategory).addPreference(preferenceCaptor.capture());
+ assertThat(preferenceCaptor.getValue().getTitle()).isEqualTo(mIpv6Address.getHostAddress());
+ }
+
+ @Test
+ public void ipv6AddressPref_shouldNotBeSelectable() {
+ LinkAddress ipv6Address = new LinkAddress(mIpv6Address, 128);
+
+ mLinkProperties.addLinkAddress(ipv6Address);
+
+ mController.onResume();
+
+ ArgumentCaptor<Preference> preferenceCaptor = ArgumentCaptor.forClass(Preference.class);
+ verify(mockIpv6AddressCategory).addPreference(preferenceCaptor.capture());
+ assertThat(preferenceCaptor.getValue().isSelectable()).isFalse();
+ }
}
diff --git a/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
new file mode 100644
index 0000000..70087ae
--- /dev/null
+++ b/tests/unit/src/com/android/settings/RegulatoryInfoDisplayActivityTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.RootMatchers.isDialog;
+import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static junit.framework.Assert.fail;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class RegulatoryInfoDisplayActivityTest {
+
+ private Instrumentation mInstrumentation;
+ private Intent mRegulatoryInfoIntent;
+
+ @Before
+ public void setUp() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mRegulatoryInfoIntent = new Intent("android.settings.SHOW_REGULATORY_INFO")
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .setPackage(mInstrumentation.getTargetContext().getPackageName());
+ }
+
+ @Test
+ public void resolveRegulatoryInfoIntent_intentShouldMatchConfig() {
+ // Load intent from PackageManager and load config from Settings app
+ final Context context = mInstrumentation.getTargetContext();
+
+ final boolean hasRegulatoryInfo = context.getResources()
+ .getBoolean(R.bool.config_show_regulatory_info);
+ final ResolveInfo resolveInfo = mInstrumentation.getTargetContext().getPackageManager()
+ .resolveActivity(mRegulatoryInfoIntent, 0 /* flags */);
+
+ // Check config and intent both enable or both disabled.
+ if (hasRegulatoryInfo && resolveInfo == null) {
+ fail("Config enables regulatory info but there is no handling intent");
+ return;
+ }
+ if (!hasRegulatoryInfo && resolveInfo != null) {
+ fail("Config disables regulatory info but there is at least one handling intent");
+ return;
+ }
+ }
+
+ @Test
+ public void launchRegulatoryInfo_shouldNotCrash() {
+ final Context context = mInstrumentation.getTargetContext();
+ final boolean hasRegulatoryInfo = context.getResources()
+ .getBoolean(R.bool.config_show_regulatory_info);
+
+ if (!hasRegulatoryInfo) {
+ return;
+ }
+ // Launch intent
+ mInstrumentation.startActivitySync(mRegulatoryInfoIntent);
+
+ onView(withId(R.id.regulatoryInfo))
+ .inRoot(isDialog())
+ .check(matches(isDisplayed()));
+ }
+
+}