Merge "Update logPackageName() to use new MetricsLogger API"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 546259c..9c1beaa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4363,11 +4363,6 @@
can't verify user consent. [CHAR LIMIT=NONE] -->
<string name="touch_filtered_warning">Because an app is obscuring a permission request, Settings
can’t verify your response.</string>
- <!-- Warning shown when user input has been blocked due to another app overlaying screen
- content. Since we don't know what the app is showing on top of the input target, we
- can't verify user consent. [CHAR LIMIT=NONE] -->
- <string name="window_obscured_warning">Because another app is displaying on top of these options,
- Settings can\u2019t respond to your action.</string>
<!-- Warning that the device data will not be encrypted with password or PIN if
enabling an accessibility service and there is a secure lock setup. [CHAR LIMIT=NONE] -->
<string name="enable_service_encryption_warning">If you turn on <xliff:g id="service"
@@ -6596,8 +6591,8 @@
<!-- Configure Notifications: Work profile section header [CHAR LIMIT=30] -->
<string name="profile_section_header">Work notifications</string>
- <!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30] -->
- <string name="notification_badging_title">Allow icon badges</string>
+ <!-- Configure Notifications: Title for the notification badging option. [CHAR LIMIT=30 BACKUP_MESSAGE_ID=5125022693565388760] -->
+ <string name="notification_badging_title">Allow notification dots</string>
<!-- Configure Notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
<string name="notification_pulse_title">Blink light</string>
@@ -6826,9 +6821,6 @@
<item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> categories deleted</item>
</plurals>
- <!-- [CHAR LIMIT=45\ Global notification badge setting -->
- <string name="notification_badges">Notification badges</string>
-
<!-- [CHAR LIMIT=NONE] App notification settings: notifications enabled-->
<string name="notification_toggle_on">On</string>
@@ -6847,8 +6839,11 @@
<!-- [CHAR LIMIT=NONE] Channel notification settings: Block option description-->
<string name="notification_content_block_summary">Never show notifications in the shade or on peripheral devices</string>
- <!-- [CHAR LIMIT=NONE] [BACKUP_MESSAGE_ID:7166470350070693657] Channel notification settings: Badging option title -->
- <string name="notification_badge_title">Allow icon badge</string>
+ <!-- [CHAR LIMIT=NONE BACKUP_MESSAGE_ID:7166470350070693657] App notification settings: Badging option title -->
+ <string name="notification_badge_title">Allow notification dot</string>
+
+ <!-- [CHAR LIMIT=NONE BACKUP_MESSAGE_ID:7166470350070693657] Channel notification settings: Badging option title -->
+ <string name="notification_channel_badge_title">Show notification dot</string>
<!-- [CHAR LIMIT=NONE] App notification settings: Override DND option title -->
<string name="app_notification_override_dnd_title">Override Do Not Disturb</string>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 2a4416e..d10440e 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -15,21 +15,32 @@
-->
<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/lockscreen_settings_title">
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/lockscreen_settings_title">
+
+ <com.android.settings.notification.RestrictedDropDownPreference
+ android:key="security_setting_lock_screen_notif"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="@string/summary_placeholder" />
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="add_users_when_locked"
+ android:title="@string/user_add_on_lockscreen_menu" />
+
+ <com.android.settingslib.RestrictedPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary" />
+
+ <PreferenceCategory
+ android:key="security_setting_lock_screen_notif_work_header"
+ android:title="@string/profile_section_header">
<com.android.settings.notification.RestrictedDropDownPreference
- android:key="lock_screen_notifications"
+ android:key="security_setting_lock_screen_notif_work"
android:title="@string/lock_screen_notifications_title"
- android:summary="@string/summary_placeholder"/>
+ android:summary="@string/summary_placeholder" />
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="add_users_when_locked"
- android:title="@string/user_add_on_lockscreen_menu"/>
-
- <com.android.settingslib.RestrictedPreference
- android:key="owner_info_settings"
- android:title="@string/owner_info_settings_title"
- android:summary="@string/owner_info_settings_summary"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/upgraded_channel_notification_settings.xml b/res/xml/upgraded_channel_notification_settings.xml
index 4cf171f..7925bb7 100644
--- a/res/xml/upgraded_channel_notification_settings.xml
+++ b/res/xml/upgraded_channel_notification_settings.xml
@@ -40,7 +40,7 @@
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
- android:title="@string/notification_badge_title"
+ android:title="@string/notification_channel_badge_title"
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 3bb82cf..fb2f29f 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -65,8 +65,6 @@
import com.android.settings.users.UserDialogs;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.SecureTouchListener;
-
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
@@ -352,8 +350,6 @@
final View restrictedAction = findViewById(R.id.restricted_action);
restrictedAction.setFilterTouchesWhenObscured(true);
- restrictedAction.setOnTouchListener(
- new SecureTouchListener(getString(R.string.window_obscured_warning)));
restrictedAction.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mAdding) {
diff --git a/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceController.java
index 5c0f9a3..219ce0f 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultBrowserPreferenceController.java
@@ -18,16 +18,20 @@
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
+import android.util.Log;
import java.util.List;
public class DefaultBrowserPreferenceController extends DefaultAppPreferenceController {
+ private static final String TAG = "BrowserPrefCtrl";
+
static final Intent BROWSE_PROBE = new Intent()
.setAction(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
@@ -60,9 +64,10 @@
@Override
protected DefaultAppInfo getDefaultAppInfo() {
try {
+ final String packageName = mPackageManager.getDefaultBrowserPackageNameAsUser(mUserId);
+ Log.d(TAG, "Get default browser package: " + packageName);
return new DefaultAppInfo(mPackageManager,
- mPackageManager.getPackageManager().getApplicationInfo(
- mPackageManager.getDefaultBrowserPackageNameAsUser(mUserId), 0));
+ mPackageManager.getPackageManager().getApplicationInfo(packageName, 0));
} catch (PackageManager.NameNotFoundException e) {
return null;
}
@@ -90,7 +95,12 @@
// Resolve that intent and check that the handleAllWebDataURI boolean is set
final List<ResolveInfo> list = getCandidates();
if (list != null && list.size() == 1) {
- return list.get(0).loadLabel(mPackageManager.getPackageManager()).toString();
+ final ResolveInfo info = list.get(0);
+ final String label = info.loadLabel(mPackageManager.getPackageManager()).toString();
+ final ComponentInfo cn = info.getComponentInfo();
+ final String packageName = cn == null ? null : cn.packageName;
+ Log.d(TAG, "Getting label for the only browser app: " + packageName + label);
+ return label;
}
return null;
}
diff --git a/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
index f4f6c36..6b4c8a9 100644
--- a/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
@@ -98,6 +98,8 @@
@VisibleForTesting
Button mUninstallButton;
@VisibleForTesting
+ String mPackageName;
+ @VisibleForTesting
boolean mDisableAfterUninstall = false;
private final int mRequestUninstall;
@@ -113,7 +115,6 @@
private MetricsFeatureProvider mMetricsFeatureProvider;
private LayoutPreference mButtonsPref;
- private String mPackageName;
private int mUserId;
private boolean mUpdatedSysApp = false;
private boolean mListeningToPackageRemove = false;
@@ -134,7 +135,6 @@
mMetricsFeatureProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
mState = state;
- mSession = mState.newSession(this);
mDpm = dpm;
mUserManager = userManager;
mPm = packageManager;
@@ -145,10 +145,10 @@
mRequestUninstall = requestUninstall;
mRequestRemoveDeviceAdmin = requestRemoveDeviceAdmin;
- lifecycle.addObserver(this);
-
if (packageName != null) {
mAppEntry = mState.getEntry(packageName, mUserId);
+ mSession = mState.newSession(this);
+ lifecycle.addObserver(this);
} else {
mFinishing = true;
}
@@ -620,7 +620,11 @@
return false;
}
- private boolean refreshUi() {
+ @VisibleForTesting
+ boolean refreshUi() {
+ if (mPackageName == null) {
+ return false;
+ }
retrieveAppEntry();
if (mAppEntry == null || mPackageInfo == null) {
return false;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index e7be62f..4cbe692 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -201,7 +201,8 @@
final NotificationChannel channel) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(
getPrefContext());
- channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && !mAppRow.systemApp);
+ channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null
+ && isChannelBlockable(mAppRow.systemApp, channel));
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index f7bf1ca..6b4129c 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -228,7 +228,7 @@
mBlockBar.setKey(KEY_BLOCK);
getPreferenceScreen().addPreference(mBlockBar);
- if (mAppRow.systemApp && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE) {
+ if (!isChannelBlockable(mAppRow.systemApp, mChannel)) {
setVisible(mBlockBar, false);
}
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 3e363d7..26fc0a0 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -69,7 +69,10 @@
final PulseNotificationPreferenceController pulseController =
new PulseNotificationPreferenceController(context);
final LockScreenNotificationPreferenceController lockScreenNotificationController =
- new LockScreenNotificationPreferenceController(context);
+ new LockScreenNotificationPreferenceController(context,
+ "lock_screen_notifications",
+ "lock_screen_notifications_profile_header",
+ "lock_screen_notifications_profile");
if (lifecycle != null) {
lifecycle.addObserver(pulseController);
lifecycle.addObserver(lockScreenNotificationController);
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index b84d961..228e185 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -26,6 +26,7 @@
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.widget.LockPatternUtils;
@@ -46,11 +47,10 @@
Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause {
private static final String TAG = "LockScreenNotifPref";
- private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "lock_screen_notifications";
- private static final String KEY_LOCK_SCREEN_PROFILE_HEADER =
- "lock_screen_notifications_profile_header";
- private static final String KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS =
- "lock_screen_notifications_profile";
+
+ private final String mSettingKey;
+ private final String mWorkSettingCategoryKey;
+ private final String mWorkSettingKey;
private RestrictedDropDownPreference mLockscreen;
private RestrictedDropDownPreference mLockscreenProfile;
@@ -64,7 +64,16 @@
private int mLockscreenSelectedValueProfile;
public LockScreenNotificationPreferenceController(Context context) {
+ this(context, null, null, null);
+ }
+
+ public LockScreenNotificationPreferenceController(Context context,
+ String settingKey, String workSettingCategoryKey, String workSettingKey) {
super(context);
+ mSettingKey = settingKey;
+ mWorkSettingCategoryKey = workSettingCategoryKey;
+ mWorkSettingKey = workSettingKey;
+
mProfileChallengeUserId = Utils.getManagedProfileId(
UserManager.get(context), UserHandle.myUserId());
final LockPatternUtils utils = new LockPatternUtils(context);
@@ -79,17 +88,17 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mLockscreen =
- (RestrictedDropDownPreference) screen.findPreference(KEY_LOCK_SCREEN_NOTIFICATIONS);
+ (RestrictedDropDownPreference) screen.findPreference(mSettingKey);
if (mLockscreen == null) {
- Log.i(TAG, "Preference not found: " + KEY_LOCK_SCREEN_NOTIFICATIONS);
+ Log.i(TAG, "Preference not found: " + mSettingKey);
return;
}
if (mProfileChallengeUserId != UserHandle.USER_NULL) {
mLockscreenProfile = (RestrictedDropDownPreference) screen.findPreference(
- KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS);
+ mWorkSettingKey);
} else {
- removePreference(screen, KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS);
- removePreference(screen, KEY_LOCK_SCREEN_PROFILE_HEADER);
+ removePreference(screen, mWorkSettingKey);
+ removePreference(screen, mWorkSettingCategoryKey);
}
mSettingObserver = new SettingObserver();
initLockScreenNotificationPrefDisplay();
@@ -136,7 +145,7 @@
private void initLockscreenNotificationPrefForProfile() {
if (mLockscreenProfile == null) {
- Log.i(TAG, "Preference not found: " + KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS);
+ Log.i(TAG, "Preference not found: " + mWorkSettingKey);
return;
}
ArrayList<CharSequence> entries = new ArrayList<>();
@@ -205,8 +214,8 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- switch (preference.getKey()) {
- case KEY_LOCK_SCREEN_PROFILE_NOTIFICATIONS: {
+ final String key = preference.getKey();
+ if (TextUtils.equals(mWorkSettingKey, key)) {
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValueProfile) {
return false;
@@ -223,8 +232,7 @@
enabled ? 1 : 0, mProfileChallengeUserId);
mLockscreenSelectedValueProfile = val;
return true;
- }
- case KEY_LOCK_SCREEN_NOTIFICATIONS: {
+ } else if (TextUtils.equals(mSettingKey, key)) {
final int val = Integer.parseInt((String) newValue);
if (val == mLockscreenSelectedValue) {
return false;
@@ -238,10 +246,8 @@
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
mLockscreenSelectedValue = val;
return true;
- }
- default:
- return false;
}
+ return false;
}
private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
@@ -295,6 +301,7 @@
final boolean enabled = getLockscreenNotificationsEnabled(mProfileChallengeUserId);
final boolean allowPrivate = !mSecureProfile
|| getLockscreenAllowPrivateNotifications(mProfileChallengeUserId);
+ mLockscreenProfile.setSummary("%s");
mLockscreenSelectedValueProfile = !enabled
? R.string.lock_screen_notifications_summary_disable_profile
: (allowPrivate ? R.string.lock_screen_notifications_summary_show_profile
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index e055133..fe426e7 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -443,4 +443,12 @@
return lockscreenSecure;
}
+
+ protected boolean isChannelBlockable(boolean systemApp, NotificationChannel channel) {
+ if (!mAppRow.systemApp) {
+ return true;
+ }
+ return channel.isBlockableSystem()
+ || channel.getImportance() == NotificationManager.IMPORTANCE_NONE;
+ }
}
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index f3b18f2..92142a9 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -18,6 +18,8 @@
import android.content.Context;
import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.accounts.AddUserWhenLockedPreferenceController;
@@ -26,6 +28,7 @@
import com.android.settings.notification.LockScreenNotificationPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -38,6 +41,15 @@
private static final String TAG = "LockscreenDashboardFragment";
+ @VisibleForTesting
+ static final String KEY_LOCK_SCREEN_NOTIFICATON = "security_setting_lock_screen_notif";
+ @VisibleForTesting
+ static final String KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER =
+ "security_setting_lock_screen_notif_work_header";
+ @VisibleForTesting
+ static final String KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE =
+ "security_setting_lock_screen_notif_work";
+
private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
@Override
@@ -60,7 +72,10 @@
final List<PreferenceController> controllers = new ArrayList<>();
final Lifecycle lifecycle = getLifecycle();
final LockScreenNotificationPreferenceController notificationController =
- new LockScreenNotificationPreferenceController(context);
+ new LockScreenNotificationPreferenceController(context,
+ KEY_LOCK_SCREEN_NOTIFICATON,
+ KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER,
+ KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE);
lifecycle.addObserver(notificationController);
controllers.add(notificationController);
final AddUserWhenLockedPreferenceController addUserWhenLockedController =
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 70d3ce5..c9e0805 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -78,6 +78,7 @@
private Lifecycle mLifecycle;
private RecyclerView mRecyclerView;
private Drawable mIcon;
+ private String mIconContentDescription;
private CharSequence mLabel;
private CharSequence mSummary;
private String mPackageName;
@@ -122,6 +123,10 @@
return this;
}
+ /**
+ * Set the icon in the header. Callers should also consider calling setIconContentDescription
+ * to provide a description of this icon for accessibility purposes.
+ */
public EntityHeaderController setIcon(Drawable icon) {
if (icon != null) {
mIcon = icon.getConstantState().newDrawable(mAppContext.getResources());
@@ -129,6 +134,11 @@
return this;
}
+ /**
+ * Convenience method to set the header icon from an ApplicationsState.AppEntry. Callers should
+ * also consider calling setIconContentDescription to provide a description of this icon for
+ * accessibility purposes.
+ */
public EntityHeaderController setIcon(ApplicationsState.AppEntry appEntry) {
if (appEntry.icon != null) {
mIcon = appEntry.icon.getConstantState().newDrawable(mAppContext.getResources());
@@ -136,6 +146,11 @@
return this;
}
+ public EntityHeaderController setIconContentDescription(String contentDescription) {
+ mIconContentDescription = contentDescription;
+ return this;
+ }
+
public EntityHeaderController setLabel(CharSequence label) {
mLabel = label;
return this;
@@ -204,6 +219,7 @@
ImageView iconView = mHeader.findViewById(R.id.entity_header_icon);
if (iconView != null) {
iconView.setImageDrawable(mIcon);
+ iconView.setContentDescription(mIconContentDescription);
}
setText(R.id.entity_header_title, mLabel);
setText(R.id.entity_header_summary, mSummary);
diff --git a/tests/robotests/assets/whitelist_duplicate_index_key b/tests/robotests/assets/whitelist_duplicate_index_key
index 0b8d675..a761f35 100644
--- a/tests/robotests/assets/whitelist_duplicate_index_key
+++ b/tests/robotests/assets/whitelist_duplicate_index_key
@@ -1,6 +1,5 @@
add_users_when_locked
additional_system_update_settings
-screen_zoom
dashboard_tile_placeholder
-lock_screen_notifications
-usage_access
\ No newline at end of file
+screen_zoom
+usage_access
diff --git a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
index be04eec..1bc859f 100644
--- a/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deletionhelper/AutomaticStorageManagerSwitchBarControllerTest.java
@@ -71,6 +71,7 @@
mSwitchBar = new SwitchBar(mContext);
Context fakeContextForFakeProvider = mock(Context.class, RETURNS_DEEP_STUBS);
+ FakeFeatureFactory.setupForTest(fakeContextForFakeProvider);
FeatureFactory featureFactory = FakeFeatureFactory.getFactory(fakeContextForFakeProvider);
mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
mPreference = new Preference(mContext);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
index 2008afd..92df48e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AppButtonsPreferenceControllerTest.java
@@ -344,6 +344,14 @@
assertThat(controllable).isTrue();
}
+ @Test
+ public void testRefreshUi_packageNull_shouldNotCrash() {
+ mController.mPackageName = null;
+
+ // Should not crash in this method
+ assertThat(mController.refreshUi()).isFalse();
+ }
+
/**
* The test fragment which implements
* {@link ButtonActionDialogFragment.AppButtonsDialogListener}
diff --git a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
new file mode 100644
index 0000000..c6a0e53
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.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.security;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.XmlTestUtils;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class LockscreenDashboardFragmentTest {
+
+ private LockscreenDashboardFragment mFragment;
+
+ @Test
+ public void containsNotificationSettingsForPrimaryUserAndWorkProfile() {
+ mFragment = new LockscreenDashboardFragment();
+
+ List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(RuntimeEnvironment.application,
+ mFragment.getPreferenceScreenResId());
+
+ assertThat(keys).containsAllOf(LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON,
+ LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE,
+ LockscreenDashboardFragment.KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index e386282..c29068f 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -234,6 +234,33 @@
}
@Test
+ public void iconContentDescription_shouldWorkWithSetIcon() {
+ final View view = mLayoutInflater
+ .inflate(R.layout.settings_entity_header, null /* root */);
+ when(mFragment.getActivity()).thenReturn(mock(Activity.class));
+ mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
+ String description = "Fake Description";
+ mController.setIcon(mShadowContext.getDrawable(R.drawable.ic_add));
+ mController.setIconContentDescription(description);
+ mController.done(mActivity);
+ assertThat(view.findViewById(R.id.entity_header_icon).getContentDescription().toString())
+ .isEqualTo(description);
+ }
+
+ @Test
+ public void iconContentDescription_shouldWorkWithoutSetIcon() {
+ final View view = mLayoutInflater
+ .inflate(R.layout.settings_entity_header, null /* root */);
+ when(mFragment.getActivity()).thenReturn(mock(Activity.class));
+ mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
+ String description = "Fake Description";
+ mController.setIconContentDescription(description);
+ mController.done(mActivity);
+ assertThat(view.findViewById(R.id.entity_header_icon).getContentDescription().toString())
+ .isEqualTo(description);
+ }
+
+ @Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);