Merge "Check for whether fingerprint can be used in work challenge moved from onCreate() to onResume()"
diff --git a/res/drawable/wifi_friction.xml b/res/drawable/wifi_friction.xml
index cd13dac..c46f5b4 100644
--- a/res/drawable/wifi_friction.xml
+++ b/res/drawable/wifi_friction.xml
@@ -16,9 +16,10 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
- <item settings:state_encrypted="true"
- settings:state_saved="true"
- android:drawable="@drawable/ic_friction_lock_open"/>
+ <item
+ settings:state_encrypted="true"
+ settings:state_saved="true"
+ android:drawable="@drawable/ic_friction_lock_closed"/>
<item
settings:state_encrypted="true"
settings:state_saved="false"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4851fa5..da83867 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6329,6 +6329,9 @@
<!-- [CHAR LIMIT=NONE] App notification settings: channels title -->
<string name="notification_channels">Channels</string>
+ <!-- [CHAR LIMIT=60] App notification settings: Text to display for deleted channels -->
+ <string name="deleted_channel_name"><xliff:g id="channel_name" example="Promotions">%1$s</xliff:g> (deleted)</string>
+
<!-- [CHAR LIMIT=NONE] App notification settings: Block option title -->
<string name="app_notification_block_title">Block all</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 8f37bbe..0241e1a 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -122,7 +122,7 @@
layouts against a remote context using our local theme colors. Due to the implementation
details of Theme, we can't reference any local resources and MUST instead use the values
directly. So use #ff263238 instead of @color/theme_primary and so on. -->
- <style name="Theme.SettingsBase" parent="@*android:style/Theme.DeviceDefault.Settings.LightActionBar" />
+ <style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" />
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
@@ -144,7 +144,6 @@
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar</item>
- <item name="*android:actionBarSize">@dimen/actionbar_size</item>
<item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
@@ -157,8 +156,6 @@
<item name="*android:regularColor">@color/lock_pattern_view_regular_color</item>
<item name="*android:successColor">@color/lock_pattern_view_success_color</item>
<item name="*android:errorColor">@color/lock_pattern_view_error_color</item>
-
- <item name="android:statusBarColor">@color/status_bar_color</item>
</style>
<style name="Theme.SubSettings" parent="Theme.Settings">
@@ -178,7 +175,7 @@
<item name="android:backgroundDimEnabled">false</item>
</style>
- <style name="Theme.ActionBar" parent="@android:style/Widget.DeviceDefault.Light.ActionBar">
+ <style name="Theme.ActionBar" parent="@android:style/Widget.Material.ActionBar.Solid">
<item name="android:contentInsetStart">@dimen/actionbar_contentInsetStart</item>
</style>
@@ -186,16 +183,16 @@
<item name="android:contentInsetStart">@dimen/actionbar_subsettings_contentInsetStart</item>
</style>
- <style name="ThemeOverlay.SwitchBar.Settings" parent="@*android:style/ThemeOverlay.DeviceDefault.ActionBar.Accent">
+ <style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">?android:attr/colorBackground</item>
+ <item name="switchBarBackgroundColor">?android:attr/colorSecondary</item>
</style>
- <style name="ThemeOverlay.SwitchBar.SubSettings" parent="@*android:style/ThemeOverlay.DeviceDefault.ActionBar.Accent">
+ <style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">?android:attr/colorBackground</item>
+ <item name="switchBarBackgroundColor">?android:attr/colorSecondary</item>
</style>
<style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.DeviceDefault.Settings.DialogWhenLarge">
@@ -220,7 +217,7 @@
<style name="Theme.SubSettingsDialogWhenLarge" parent="Theme.DialogWhenLarge">
<item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:actionBarWidgetTheme">@null</item>
- <item name="android:actionBarTheme">@*android:style/ThemeOverlay.DeviceDefault.ActionBar.Accent</item>
+ <item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.ActionBar</item>
<item name="preferenceBackgroundColor">@drawable/preference_background</item>
</style>
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index e8d0abe..f77d778 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -16,7 +16,8 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:title="@string/double_twist_for_camera_mode_title">
<com.android.settings.widget.VideoPreference
android:key="gesture_double_twist_video"
diff --git a/res/xml/input_and_gesture.xml b/res/xml/input_and_gesture.xml
index c30178b..9abc797 100644
--- a/res/xml/input_and_gesture.xml
+++ b/res/xml/input_and_gesture.xml
@@ -15,7 +15,9 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/input_gesture_settings_title">
<PreferenceCategory
android:title="@string/keyboard_and_input_methods_category">
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index c4b97d4..3d49719 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -319,7 +319,7 @@
final int numSippers = usageList.size();
for (int i = 0; i < numSippers; i++) {
final BatterySipper sipper = usageList.get(i);
- if ((sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP) {
+ if (shouldHideSipper(sipper)) {
continue;
}
double totalPower = USE_FAKE_DATA ? 4000 : mStatsHelper.getTotalPower();
@@ -375,7 +375,7 @@
pref.setTitle(entry.getLabel());
pref.setOrder(i + 1);
pref.setPercent(percentOfMax, percentOfTotal);
- if ((sipper.drainType != DrainType.APP || sipper.uidObj.getUid() == 0)
+ if ((sipper.drainType != DrainType.APP || sipper.uidObj.getUid() == Process.ROOT_UID)
&& sipper.drainType != DrainType.USER) {
pref.setTint(colorControl);
}
@@ -396,6 +396,16 @@
}
@VisibleForTesting
+ boolean shouldHideSipper(BatterySipper sipper) {
+ final DrainType drainType = sipper.drainType;
+ final int uid = sipper.getUid();
+
+ return drainType == DrainType.IDLE || drainType == DrainType.CELL
+ || uid == Process.ROOT_UID || uid == Process.SYSTEM_UID
+ || (sipper.totalPowerMah * SECONDS_IN_HOUR) < MIN_POWER_THRESHOLD_MILLI_AMP;
+ }
+
+ @VisibleForTesting
String extractKeyFromSipper(BatterySipper sipper) {
if (sipper.uidObj != null) {
return Integer.toString(sipper.getUid());
diff --git a/src/com/android/settings/inputmethod/InputAndGestureSettings.java b/src/com/android/settings/inputmethod/InputAndGestureSettings.java
index 43d8b230b..4ad5af2 100644
--- a/src/com/android/settings/inputmethod/InputAndGestureSettings.java
+++ b/src/com/android/settings/inputmethod/InputAndGestureSettings.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.os.UserHandle;
+import android.provider.SearchIndexableResource;
import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
@@ -31,9 +32,12 @@
import com.android.settings.gestures.DoubleTwistPreferenceController;
import com.android.settings.gestures.PickupGesturePreferenceController;
import com.android.settings.gestures.SwipeToNotificationPreferenceController;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.drawer.CategoryKey;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class InputAndGestureSettings extends DashboardFragment {
@@ -90,4 +94,19 @@
void setAmbientDisplayConfig(AmbientDisplayConfiguration ambientConfig) {
mAmbientDisplayConfig = ambientConfig;
}
+
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
+ .isEnabled()) {
+ return null;
+ }
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.input_and_gesture;
+ return Arrays.asList(sir);
+ }
+ };
}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index c720bb5..b740b92 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -19,7 +19,6 @@
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
-import android.app.NotificationManager;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -42,7 +41,11 @@
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.RestrictedSwitchPreference;
+import java.text.Collator;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
+import java.util.Objects;
/** These settings are per app, so should not be returned in global search results. */
public class AppNotificationSettings extends NotificationSettingsBase {
@@ -94,6 +97,7 @@
rows.put(mAppRow.pkg, mAppRow);
collectConfigActivities(rows);
mChannelList = mBackend.getChannels(mPkg, mUid).getList();
+ Collections.sort(mChannelList, mChannelComparator);
if (mChannelList.isEmpty()) {
setVisible(mChannels, false);
@@ -105,16 +109,21 @@
channelPref.setDisabledByAdmin(mSuspendedAppsAdmin);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
- 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(ARG_CHANNEL, channel.getId());
- Intent topicIntent = Utils.onBuildStartFragmentIntent(getActivity(),
- ChannelNotificationSettings.class.getName(),
- channelArgs, null, 0, null, false);
- channelPref.setIntent(topicIntent);
+ if (channel.isDeleted()) {
+ channelPref.setTitle(
+ getString(R.string.deleted_channel_name, channel.getName()));
+ } else {
+ 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(ARG_CHANNEL, channel.getId());
+ Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(),
+ ChannelNotificationSettings.class.getName(),
+ channelArgs, null, 0, null, false);
+ channelPref.setIntent(channelIntent);
+ }
mChannels.addPreference(channelPref);
}
}
@@ -212,4 +221,20 @@
.setClassName(activityInfo.packageName, activityInfo.name);
}
}
+
+ private Comparator<NotificationChannel> mChannelComparator =
+ new Comparator<NotificationChannel>() {
+ private final Collator sCollator = Collator.getInstance();
+
+ @Override
+ public int compare(NotificationChannel left, NotificationChannel right) {
+ if (left.isDeleted() != right.isDeleted()) {
+ return Boolean.compare(left.isDeleted(), right.isDeleted());
+ }
+ if (!Objects.equals(left.getName(), right.getName())) {
+ return sCollator.compare(left.getName().toString(), right.getName().toString());
+ }
+ return left.getId().compareTo(right.getId());
+ }
+ };
}
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index 4013971..692e1f6 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -92,7 +92,7 @@
return null;
}
try {
- return sINM.getNotificationChannelForPackage(pkg, uid, channelId);
+ return sINM.getNotificationChannelForPackage(pkg, uid, channelId, true);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return null;
@@ -101,7 +101,7 @@
public ParceledListSlice<NotificationChannel> getChannels(String pkg, int uid) {
try {
- return sINM.getNotificationChannelsForPackage(pkg, uid);
+ return sINM.getNotificationChannelsForPackage(pkg, uid, true);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return ParceledListSlice.emptyList();
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index cc671ad..96d88c9 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -20,8 +20,11 @@
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.FragmentManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.media.AudioSystem;
import android.media.Ringtone;
import android.media.RingtoneManager;
@@ -46,11 +49,11 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
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;
-
public class WorkSoundPreferenceController extends PreferenceController implements
- OnPreferenceChangeListener, LifecycleObserver, OnResume {
+ OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause {
private static final String TAG = "WorkSoundPrefController";
private static final String KEY_WORK_CATEGORY = "sound_work_settings_section";
@@ -97,18 +100,18 @@
@Override
public void onResume() {
- if (isAvailable()) {
- if ((mWorkPreferenceCategory == null)) {
- // Work preferences not yet set
- mParent.addPreferencesFromResource(R.xml.sound_work_settings);
- initWorkPreferences();
- }
- if (!mWorkUsePersonalSounds.isChecked()) {
- updateWorkRingtoneSummaries();
- }
- } else {
- maybeRemoveWorkPreferences();
- }
+ IntentFilter managedProfileFilter = new IntentFilter();
+ managedProfileFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
+ managedProfileFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
+ mContext.registerReceiver(mManagedProfileReceiver, managedProfileFilter);
+
+ mManagedProfileId = mHelper.getManagedProfileId(mUserManager);
+ initWorkPreferences();
+ }
+
+ @Override
+ public void onPause() {
+ mContext.unregisterReceiver(mManagedProfileReceiver);
}
@Override
@@ -118,8 +121,8 @@
@Override
public boolean isAvailable() {
- mManagedProfileId = mHelper.getManagedProfileId(mUserManager);
- return mManagedProfileId != UserHandle.USER_NULL && shouldShowRingtoneSettings();
+ return mHelper.getManagedProfileId(mUserManager) != UserHandle.USER_NULL
+ && shouldShowRingtoneSettings();
}
@Override
@@ -184,17 +187,37 @@
}
private void initWorkPreferences() {
- mWorkPreferenceCategory = (PreferenceGroup) mParent.getPreferenceScreen()
- .findPreference(KEY_WORK_CATEGORY);
- mWorkUsePersonalSounds = (TwoStatePreference) mParent.getPreferenceScreen()
- .findPreference(KEY_WORK_USE_PERSONAL_SOUNDS);
- mWorkPhoneRingtonePreference = initWorkPreference(KEY_WORK_PHONE_RINGTONE);
- mWorkNotificationRingtonePreference = initWorkPreference(KEY_WORK_NOTIFICATION_RINGTONE);
- mWorkAlarmRingtonePreference = initWorkPreference(KEY_WORK_ALARM_RINGTONE);
+ if (mManagedProfileId == UserHandle.USER_NULL || !isAvailable()) {
+ maybeRemoveWorkPreferences();
+ return;
+ }
- if (!mVoiceCapable) {
- mWorkPreferenceCategory.removePreference(mWorkPhoneRingtonePreference);
- mWorkPhoneRingtonePreference = null;
+ if (mWorkPreferenceCategory == null) {
+ mParent.addPreferencesFromResource(R.xml.sound_work_settings);
+ final PreferenceScreen screen = mParent.getPreferenceScreen();
+
+ mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY);
+ mWorkUsePersonalSounds = (TwoStatePreference)
+ screen.findPreference(KEY_WORK_USE_PERSONAL_SOUNDS);
+ mWorkPhoneRingtonePreference = initWorkPreference(KEY_WORK_PHONE_RINGTONE);
+ mWorkNotificationRingtonePreference = initWorkPreference(
+ KEY_WORK_NOTIFICATION_RINGTONE);
+ mWorkAlarmRingtonePreference = initWorkPreference(KEY_WORK_ALARM_RINGTONE);
+
+ mWorkUsePersonalSounds.setOnPreferenceChangeListener((Preference p, Object value) -> {
+ if ((boolean) value) {
+ UnifyWorkDialogFragment.show(mParent);
+ return false;
+ } else {
+ disableWorkSync();
+ return true;
+ }
+ });
+
+ if (!mVoiceCapable) {
+ mWorkPreferenceCategory.removePreference(mWorkPhoneRingtonePreference);
+ mWorkPhoneRingtonePreference = null;
+ }
}
Context managedProfileContext = getManagedProfileContext();
@@ -204,19 +227,6 @@
} else {
disableWorkSyncSettings();
}
-
- mWorkUsePersonalSounds.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if ((boolean) newValue) {
- UnifyWorkDialogFragment.show(mParent);
- return false;
- } else {
- disableWorkSync();
- return true;
- }
- }
- });
}
void enableWorkSync() {
@@ -267,7 +277,6 @@
private void maybeRemoveWorkPreferences() {
if (mWorkPreferenceCategory == null) {
- // No work preferences to remove
return;
}
mParent.getPreferenceScreen().removePreference(mWorkPreferenceCategory);
@@ -277,6 +286,37 @@
mWorkAlarmRingtonePreference = null;
}
+ public void onManagedProfileAdded(@UserIdInt int profileId) {
+ if (mManagedProfileId == UserHandle.USER_NULL) {
+ mManagedProfileId = profileId;
+ initWorkPreferences();
+ }
+ }
+
+ public void onManagedProfileRemoved(@UserIdInt int profileId) {
+ if (mManagedProfileId == profileId) {
+ mManagedProfileId = mHelper.getManagedProfileId(mUserManager);
+ initWorkPreferences();
+ }
+ }
+
+ private final BroadcastReceiver mManagedProfileReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final int userId = ((UserHandle) intent.getExtra(Intent.EXTRA_USER)).getIdentifier();
+ switch (intent.getAction()) {
+ case Intent.ACTION_MANAGED_PROFILE_ADDED: {
+ onManagedProfileAdded(userId);
+ return;
+ }
+ case Intent.ACTION_MANAGED_PROFILE_REMOVED: {
+ onManagedProfileRemoved(userId);
+ return;
+ }
+ }
+ }
+ };
+
public static class UnifyWorkDialogFragment extends InstrumentedDialogFragment
implements DialogInterface.OnClickListener {
private static final String TAG = "UnifyWorkDialogFragment";
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index 8a158cd..cb848d8 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -55,6 +55,7 @@
import com.android.settings.gestures.PickupGestureSettings;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
+import com.android.settings.inputmethod.InputAndGestureSettings;
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
import com.android.settings.inputmethod.VirtualKeyboardFragment;
@@ -136,6 +137,7 @@
addIndex(DoubleTwistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
addIndex(SwipeToNotificationSettings.class, NO_DATA_RES_ID,
R.drawable.ic_settings_gestures);
+ addIndex(InputAndGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location);
addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location);
addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index 81adf8b..cd0822b 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -89,4 +89,5 @@
com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment
com.android.settings.applications.ConvertToFbe
com.android.settings.localepicker.LocaleListEditor
-com.android.settings.qstile.DevelopmentTileConfigActivity$DevelopmentTileConfigFragment
\ No newline at end of file
+com.android.settings.qstile.DevelopmentTileConfigActivity$DevelopmentTileConfigFragment
+com.android.settings.applications.ExternalSourcesDetails
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 1cf83f1..35df218 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.content.Intent;
+import android.os.Process;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuInflater;
@@ -28,7 +29,6 @@
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Test;
-
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
@@ -52,6 +52,7 @@
public class PowerUsageSummaryTest {
private static final String[] PACKAGE_NAMES = {"com.app1", "com.app2"};
private static final int UID = 123;
+ private static final int POWER_MAH = 100;
private static final Intent ADDITIONAL_BATTERY_INFO_INTENT =
new Intent("com.example.app.ADDITIONAL_BATTERY_INFO");
@@ -96,6 +97,7 @@
when(mBatterySipper.getPackages()).thenReturn(PACKAGE_NAMES);
when(mBatterySipper.getUid()).thenReturn(UID);
+ mBatterySipper.totalPowerMah = POWER_MAH;
}
@Test
@@ -152,6 +154,39 @@
assertThat(key).isEqualTo(Integer.toString(mBatterySipper.getUid()));
}
+ @Test
+ public void testShouldHideSipper_TypeIdle_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
+ assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSipper_TypeCell_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.CELL;
+ assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSipper_UidRoot_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(Process.ROOT_UID);
+ assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSipper_UidSystem_ReturnTrue() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(Process.SYSTEM_UID);
+ assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSipper_UidNormal_ReturnFalse() {
+ mBatterySipper.drainType = BatterySipper.DrainType.APP;
+ when(mBatterySipper.getUid()).thenReturn(UID);
+ assertThat(mPowerUsageSummary.shouldHideSipper(mBatterySipper)).isFalse();
+ }
+
public static class TestFragment extends PowerUsageSummary {
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
index 4d8101f..bb19533 100644
--- a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java
@@ -114,17 +114,8 @@
.thenReturn(UserHandle.myUserId());
when(mAudioHelper.isSingleVolume()).thenReturn(false);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
- when(mScreen.findPreference(KEY_WORK_CATEGORY))
- .thenReturn(mock(PreferenceGroup.class));
- when(mScreen.findPreference(KEY_WORK_USE_PERSONAL_SOUNDS))
- .thenReturn(mock(TwoStatePreference.class));
- when(mScreen.findPreference(KEY_WORK_PHONE_RINGTONE))
- .thenReturn(mock(DefaultRingtonePreference.class));
- when(mScreen.findPreference(KEY_WORK_NOTIFICATION_RINGTONE))
- .thenReturn(mock(DefaultRingtonePreference.class));
- when(mScreen.findPreference(KEY_WORK_ALARM_RINGTONE))
- .thenReturn(mock(DefaultRingtonePreference.class));
when(mAudioHelper.createPackageContextAsUser(anyInt())).thenReturn(mContext);
+ mockWorkCategory();
mController.onResume();
@@ -132,6 +123,50 @@
}
@Test
+ public void onManagedProfileAdded_shouldAddPreferenceCategory() {
+ // Given a device without any managed profiles:
+ when(mAudioHelper.isSingleVolume()).thenReturn(false);
+ when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ when(mAudioHelper.createPackageContextAsUser(anyInt())).thenReturn(mContext);
+ when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+ .thenReturn(UserHandle.USER_NULL);
+ mockWorkCategory();
+
+ // When the fragment first resumes, the category should not appear.
+ mController.onResume();
+
+ verify(mFragment, never()).addPreferencesFromResource(R.xml.sound_work_settings);
+
+ // However, when a managed profile is added after resuming, the category should appear.
+ when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+ .thenReturn(UserHandle.myUserId());
+ mController.onManagedProfileAdded(UserHandle.myUserId());
+
+ verify(mFragment).addPreferencesFromResource(R.xml.sound_work_settings);
+ }
+
+ @Test
+ public void onManagedProfileRemoved_shouldRemovePreferenceCategory() {
+ // Given a device with a managed profile:
+ when(mAudioHelper.isSingleVolume()).thenReturn(false);
+ when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ when(mAudioHelper.createPackageContextAsUser(anyInt())).thenReturn(mContext);
+ when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+ .thenReturn(UserHandle.myUserId());
+ mockWorkCategory();
+
+ // Which is in resumed state:
+ mController.onResume();
+
+ // When a managed profile is removed, the category should be removed.
+ when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
+ .thenReturn(UserHandle.USER_NULL);
+ mController.onManagedProfileRemoved(UserHandle.myUserId());
+
+ verify(mScreen).removePreference(mScreen.findPreference(KEY_WORK_CATEGORY));
+ }
+
+ @Test
public void onResume_notAvailable_shouldNotAddPreferenceCategory() {
when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
when(mAudioHelper.getManagedProfileId(any(UserManager.class)))
@@ -154,4 +189,16 @@
verify(preference).setSummary(anyString());
}
+ private void mockWorkCategory() {
+ when(mScreen.findPreference(KEY_WORK_CATEGORY))
+ .thenReturn(mock(PreferenceGroup.class));
+ when(mScreen.findPreference(KEY_WORK_USE_PERSONAL_SOUNDS))
+ .thenReturn(mock(TwoStatePreference.class));
+ when(mScreen.findPreference(KEY_WORK_PHONE_RINGTONE))
+ .thenReturn(mock(DefaultRingtonePreference.class));
+ when(mScreen.findPreference(KEY_WORK_NOTIFICATION_RINGTONE))
+ .thenReturn(mock(DefaultRingtonePreference.class));
+ when(mScreen.findPreference(KEY_WORK_ALARM_RINGTONE))
+ .thenReturn(mock(DefaultRingtonePreference.class));
+ }
}