Snap for 4731145 from 8a3bcaa3e3
to pi-release
Change-Id: I3524f15ac6e2dfe41f4cd76382d6646df4fba0bd
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
android:title="@string/sound_settings"
|
android:title="@string/sound_settings"
|
||||||
android:key="sound_settings"
|
android:key="sound_settings"
|
||||||
settings:keywords="@string/keywords_sounds"
|
settings:keywords="@string/keywords_sounds"
|
||||||
settings:initialExpandedChildrenCount="8">
|
settings:initialExpandedChildrenCount="9">
|
||||||
|
|
||||||
<!-- Media volume -->
|
<!-- Media volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
|
@@ -40,6 +40,7 @@ import android.support.v7.preference.Preference;
|
|||||||
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
import android.text.BidiFormatter;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
@@ -313,7 +314,7 @@ public class AccountPreferenceController extends AbstractPreferenceController
|
|||||||
preferenceGroup.setOrder(mAccountProfileOrder++);
|
preferenceGroup.setOrder(mAccountProfileOrder++);
|
||||||
if (isSingleProfile()) {
|
if (isSingleProfile()) {
|
||||||
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
|
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header,
|
||||||
userInfo.name));
|
BidiFormatter.getInstance().unicodeWrap(userInfo.name)));
|
||||||
preferenceGroup.setContentDescription(
|
preferenceGroup.setContentDescription(
|
||||||
mContext.getString(R.string.account_settings));
|
mContext.getString(R.string.account_settings));
|
||||||
} else if (userInfo.isManagedProfile()) {
|
} else if (userInfo.isManagedProfile()) {
|
||||||
|
@@ -187,7 +187,7 @@ public class DataUsageSummaryPreference extends Preference {
|
|||||||
updateCarrierInfo(carrierInfo);
|
updateCarrierInfo(carrierInfo);
|
||||||
if (mLaunchIntent != null) {
|
if (mLaunchIntent != null) {
|
||||||
launchButton.setOnClickListener((view) -> {
|
launchButton.setOnClickListener((view) -> {
|
||||||
getContext().sendBroadcast(mLaunchIntent);
|
getContext().startActivity(mLaunchIntent);
|
||||||
});
|
});
|
||||||
launchButton.setVisibility(View.VISIBLE);
|
launchButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -107,7 +107,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
|||||||
BatteryHeaderPreferenceController mBatteryHeaderPreferenceController;
|
BatteryHeaderPreferenceController mBatteryHeaderPreferenceController;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean mNeedUpdateBatteryTip;
|
boolean mNeedUpdateBatteryTip;
|
||||||
private BatteryTipPreferenceController mBatteryTipPreferenceController;
|
@VisibleForTesting
|
||||||
|
BatteryTipPreferenceController mBatteryTipPreferenceController;
|
||||||
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
|
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -213,8 +214,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
|||||||
mAnomalySparseArray = new SparseArray<>();
|
mAnomalySparseArray = new SparseArray<>();
|
||||||
|
|
||||||
restartBatteryInfoLoader();
|
restartBatteryInfoLoader();
|
||||||
mNeedUpdateBatteryTip = icicle == null;
|
|
||||||
mBatteryTipPreferenceController.restoreInstanceState(icicle);
|
mBatteryTipPreferenceController.restoreInstanceState(icicle);
|
||||||
|
updateBatteryTipFlag(icicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -382,6 +383,11 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void updateBatteryTipFlag(Bundle icicle) {
|
||||||
|
mNeedUpdateBatteryTip = icicle == null || mBatteryTipPreferenceController.needUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View view) {
|
public boolean onLongClick(View view) {
|
||||||
showBothEstimates();
|
showBothEstimates();
|
||||||
|
@@ -52,6 +52,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
private Map<String, BatteryTip> mBatteryTipMap;
|
private Map<String, BatteryTip> mBatteryTipMap;
|
||||||
private SettingsActivity mSettingsActivity;
|
private SettingsActivity mSettingsActivity;
|
||||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
|
private boolean mNeedUpdate;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PreferenceGroup mPreferenceGroup;
|
PreferenceGroup mPreferenceGroup;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -71,6 +72,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
mSettingsActivity = settingsActivity;
|
mSettingsActivity = settingsActivity;
|
||||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||||
|
mNeedUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -111,6 +113,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
mBatteryTipMap.put(preference.getKey(), batteryTip);
|
mBatteryTipMap.put(preference.getKey(), batteryTip);
|
||||||
mPreferenceGroup.addPreference(preference);
|
mPreferenceGroup.addPreference(preference);
|
||||||
batteryTip.log(mContext, mMetricsFeatureProvider);
|
batteryTip.log(mContext, mMetricsFeatureProvider);
|
||||||
|
mNeedUpdate = batteryTip.needUpdate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +156,10 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
outState.putParcelableList(KEY_BATTERY_TIPS, mBatteryTips);
|
outState.putParcelableList(KEY_BATTERY_TIPS, mBatteryTips);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needUpdate() {
|
||||||
|
return mNeedUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener to give the control back to target fragment
|
* Listener to give the control back to target fragment
|
||||||
*/
|
*/
|
||||||
|
@@ -86,17 +86,23 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
protected int mType;
|
protected int mType;
|
||||||
protected int mState;
|
protected int mState;
|
||||||
protected boolean mShowDialog;
|
protected boolean mShowDialog;
|
||||||
|
/**
|
||||||
|
* Whether we need to update battery tip when configuration change
|
||||||
|
*/
|
||||||
|
protected boolean mNeedUpdate;
|
||||||
|
|
||||||
BatteryTip(Parcel in) {
|
BatteryTip(Parcel in) {
|
||||||
mType = in.readInt();
|
mType = in.readInt();
|
||||||
mState = in.readInt();
|
mState = in.readInt();
|
||||||
mShowDialog = in.readBoolean();
|
mShowDialog = in.readBoolean();
|
||||||
|
mNeedUpdate = in.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
BatteryTip(int type, int state, boolean showDialog) {
|
BatteryTip(int type, int state, boolean showDialog) {
|
||||||
mType = type;
|
mType = type;
|
||||||
mState = state;
|
mState = state;
|
||||||
mShowDialog = showDialog;
|
mShowDialog = showDialog;
|
||||||
|
mNeedUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,6 +115,7 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
dest.writeInt(mType);
|
dest.writeInt(mType);
|
||||||
dest.writeInt(mState);
|
dest.writeInt(mState);
|
||||||
dest.writeBoolean(mShowDialog);
|
dest.writeBoolean(mShowDialog);
|
||||||
|
dest.writeBoolean(mNeedUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract CharSequence getTitle(Context context);
|
public abstract CharSequence getTitle(Context context);
|
||||||
@@ -144,6 +151,10 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
|||||||
return mShowDialog;
|
return mShowDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needUpdate() {
|
||||||
|
return mNeedUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return KEY_PREFIX + mType;
|
return KEY_PREFIX + mType;
|
||||||
}
|
}
|
||||||
|
@@ -42,12 +42,14 @@ public class RestrictAppTip extends BatteryTip {
|
|||||||
public RestrictAppTip(@StateType int state, List<AppInfo> restrictApps) {
|
public RestrictAppTip(@StateType int state, List<AppInfo> restrictApps) {
|
||||||
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
|
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
|
||||||
mRestrictAppList = restrictApps;
|
mRestrictAppList = restrictApps;
|
||||||
|
mNeedUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestrictAppTip(@StateType int state, AppInfo appInfo) {
|
public RestrictAppTip(@StateType int state, AppInfo appInfo) {
|
||||||
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
|
super(TipType.APP_RESTRICTION, state, state == StateType.NEW /* showDialog */);
|
||||||
mRestrictAppList = new ArrayList<>();
|
mRestrictAppList = new ArrayList<>();
|
||||||
mRestrictAppList.add(appInfo);
|
mRestrictAppList.add(appInfo);
|
||||||
|
mNeedUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -125,7 +125,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
mControllers.add(new VibrationPreferenceController(context, mBackend));
|
||||||
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
|
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
|
||||||
mBackend));
|
mBackend));
|
||||||
mControllers.add(new DndPreferenceController(context, getLifecycle(), mBackend));
|
mControllers.add(new DndPreferenceController(context, mBackend));
|
||||||
mControllers.add(new AppLinkPreferenceController(context));
|
mControllers.add(new AppLinkPreferenceController(context));
|
||||||
mControllers.add(new DescriptionPreferenceController(context));
|
mControllers.add(new DescriptionPreferenceController(context));
|
||||||
mControllers.add(new NotificationsOffPreferenceController(context));
|
mControllers.add(new NotificationsOffPreferenceController(context));
|
||||||
|
@@ -18,13 +18,16 @@ package com.android.settings.notification;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.applications.AppInfoBase;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -38,6 +41,19 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
return MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
|
return MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
final PreferenceScreen screen = getPreferenceScreen();
|
||||||
|
Bundle args = getArguments();
|
||||||
|
// If linking to this screen from an external app, expand settings
|
||||||
|
if (screen != null && args != null) {
|
||||||
|
if (!args.getBoolean(ARG_FROM_SETTINGS, false)) {
|
||||||
|
screen.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -92,7 +108,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
mBackend));
|
mBackend));
|
||||||
mControllers.add(new LightsPreferenceController(context, mBackend));
|
mControllers.add(new LightsPreferenceController(context, mBackend));
|
||||||
mControllers.add(new BadgePreferenceController(context, mBackend));
|
mControllers.add(new BadgePreferenceController(context, mBackend));
|
||||||
mControllers.add(new DndPreferenceController(context, getLifecycle(), mBackend));
|
mControllers.add(new DndPreferenceController(context, mBackend));
|
||||||
mControllers.add(new NotificationsOffPreferenceController(context));
|
mControllers.add(new NotificationsOffPreferenceController(context));
|
||||||
return new ArrayList<>(mControllers);
|
return new ArrayList<>(mControllers);
|
||||||
}
|
}
|
||||||
|
@@ -28,17 +28,12 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
|||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
|
||||||
public class DndPreferenceController extends NotificationPreferenceController
|
public class DndPreferenceController extends NotificationPreferenceController
|
||||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
LifecycleObserver {
|
|
||||||
|
|
||||||
private static final String KEY_BYPASS_DND = "bypass_dnd";
|
private static final String KEY_BYPASS_DND = "bypass_dnd";
|
||||||
|
|
||||||
public DndPreferenceController(Context context, Lifecycle lifecycle,
|
public DndPreferenceController(Context context, NotificationBackend backend) {
|
||||||
NotificationBackend backend) {
|
|
||||||
super(context, backend);
|
super(context, backend);
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -58,6 +58,7 @@ import java.util.List;
|
|||||||
abstract public class NotificationSettingsBase extends DashboardFragment {
|
abstract public class NotificationSettingsBase extends DashboardFragment {
|
||||||
private static final String TAG = "NotifiSettingsBase";
|
private static final String TAG = "NotifiSettingsBase";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
protected static final String ARG_FROM_SETTINGS = "fromSettings";
|
||||||
|
|
||||||
protected PackageManager mPm;
|
protected PackageManager mPm;
|
||||||
protected NotificationBackend mBackend = new NotificationBackend();
|
protected NotificationBackend mBackend = new NotificationBackend();
|
||||||
@@ -249,6 +250,7 @@ abstract public class NotificationSettingsBase extends DashboardFragment {
|
|||||||
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
|
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
|
||||||
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
|
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
|
||||||
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
|
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
|
||||||
|
channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
|
||||||
channelPref.setIntent(new SubSettingLauncher(getActivity())
|
channelPref.setIntent(new SubSettingLauncher(getActivity())
|
||||||
.setDestination(ChannelNotificationSettings.class.getName())
|
.setDestination(ChannelNotificationSettings.class.getName())
|
||||||
.setArguments(channelArgs)
|
.setArguments(channelArgs)
|
||||||
|
@@ -26,6 +26,7 @@ import android.graphics.Typeface;
|
|||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -400,6 +401,31 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
assertThat(mDataRemaining.getText()).isEqualTo("");
|
assertThat(mDataRemaining.getText()).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetAppIntent_toMdpApp_intentCorrect() {
|
||||||
|
final Activity activity = Robolectric.setupActivity(Activity.class);
|
||||||
|
final Intent intent = new Intent(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
|
||||||
|
intent.setPackage("test-owner.example.com");
|
||||||
|
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 42);
|
||||||
|
|
||||||
|
mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
|
||||||
|
intent);
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mLaunchButton.getText())
|
||||||
|
.isEqualTo(mContext.getString(R.string.launch_mdp_app_text));
|
||||||
|
|
||||||
|
mLaunchButton.callOnClick();
|
||||||
|
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
|
||||||
|
Intent startedIntent = shadowActivity.getNextStartedActivity();
|
||||||
|
assertThat(startedIntent.getAction())
|
||||||
|
.isEqualTo(SubscriptionManager.ACTION_MANAGE_SUBSCRIPTION_PLANS);
|
||||||
|
assertThat(startedIntent.getPackage()).isEqualTo("test-owner.example.com");
|
||||||
|
assertThat(startedIntent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, -1))
|
||||||
|
.isEqualTo(42);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetWifiMode_withUsageInfo_dataUsageShown() {
|
public void testSetWifiMode_withUsageInfo_dataUsageShown() {
|
||||||
final int daysLeft = 3;
|
final int daysLeft = 3;
|
||||||
|
@@ -49,6 +49,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.applications.LayoutPreference;
|
import com.android.settings.applications.LayoutPreference;
|
||||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||||
|
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.XmlTestUtils;
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
@@ -187,7 +188,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateLastFullChargePreference_noAverageTime_showLastFullChargeSummary() {
|
public void updateLastFullChargePreference_noAverageTime_showLastFullChargeSummary() {
|
||||||
mFragment.mBatteryInfo = null;
|
mFragment.mBatteryInfo = null;
|
||||||
when(mFragment.getContext()).thenReturn(mRealContext);
|
when(mFragment.getContext()).thenReturn(mRealContext);
|
||||||
doReturn(TIME_SINCE_LAST_FULL_CHARGE_MS).when(
|
doReturn(TIME_SINCE_LAST_FULL_CHARGE_MS).when(
|
||||||
@@ -200,7 +201,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateLastFullChargePreference_hasAverageTime_showFullChargeLastSummary() {
|
public void updateLastFullChargePreference_hasAverageTime_showFullChargeLastSummary() {
|
||||||
mFragment.mBatteryInfo = mBatteryInfo;
|
mFragment.mBatteryInfo = mBatteryInfo;
|
||||||
mBatteryInfo.averageTimeToDischarge = TIME_SINCE_LAST_FULL_CHARGE_MS;
|
mBatteryInfo.averageTimeToDischarge = TIME_SINCE_LAST_FULL_CHARGE_MS;
|
||||||
when(mFragment.getContext()).thenReturn(mRealContext);
|
when(mFragment.getContext()).thenReturn(mRealContext);
|
||||||
@@ -212,7 +213,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonIndexableKeys_MatchPreferenceKeys() {
|
public void nonIndexableKeys_MatchPreferenceKeys() {
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final List<String> niks =
|
final List<String> niks =
|
||||||
PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
|
PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
|
||||||
@@ -224,7 +225,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
public void preferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||||
final Context context = RuntimeEnvironment.application;
|
final Context context = RuntimeEnvironment.application;
|
||||||
final PowerUsageSummary fragment = new PowerUsageSummary();
|
final PowerUsageSummary fragment = new PowerUsageSummary();
|
||||||
final List<String> preferenceScreenKeys =
|
final List<String> preferenceScreenKeys =
|
||||||
@@ -239,7 +240,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAnomalySparseArray() {
|
public void updateAnomalySparseArray() {
|
||||||
mFragment.mAnomalySparseArray = new SparseArray<>();
|
mFragment.mAnomalySparseArray = new SparseArray<>();
|
||||||
final List<Anomaly> anomalies = new ArrayList<>();
|
final List<Anomaly> anomalies = new ArrayList<>();
|
||||||
final Anomaly anomaly1 = new Anomaly.Builder().setUid(UID).build();
|
final Anomaly anomaly1 = new Anomaly.Builder().setUid(UID).build();
|
||||||
@@ -256,7 +257,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestartBatteryTipLoader() {
|
public void restartBatteryTipLoader() {
|
||||||
//TODO: add policy logic here when BatteryTipPolicy is implemented
|
//TODO: add policy logic here when BatteryTipPolicy is implemented
|
||||||
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowBothEstimates_summariesAreBothModified() {
|
public void showBothEstimates_summariesAreBothModified() {
|
||||||
when(mFeatureFactory.powerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(any()))
|
when(mFeatureFactory.powerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(any()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
doAnswer(new Answer() {
|
doAnswer(new Answer() {
|
||||||
@@ -296,7 +297,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDebugMode() {
|
public void debugMode() {
|
||||||
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
|
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
|
||||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
||||||
|
|
||||||
@@ -315,7 +316,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestartBatteryStatsLoader_notClearHeader_quickUpdateNotInvoked() {
|
public void restartBatteryStatsLoader_notClearHeader_quickUpdateNotInvoked() {
|
||||||
mFragment.mBatteryHeaderPreferenceController = mBatteryHeaderPreferenceController;
|
mFragment.mBatteryHeaderPreferenceController = mBatteryHeaderPreferenceController;
|
||||||
|
|
||||||
mFragment.restartBatteryStatsLoader(false /* clearHeader */);
|
mFragment.restartBatteryStatsLoader(false /* clearHeader */);
|
||||||
@@ -324,7 +325,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOptionsMenu_advancedPageEnabled() {
|
public void optionsMenu_advancedPageEnabled() {
|
||||||
when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
|
when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
|
|
||||||
@@ -335,7 +336,7 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOptionsMenu_clickAdvancedPage_fireIntent() {
|
public void optionsMenu_clickAdvancedPage_fireIntent() {
|
||||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||||
doAnswer(invocation -> {
|
doAnswer(invocation -> {
|
||||||
// Get the intent in which it has the app info bundle
|
// Get the intent in which it has the app info bundle
|
||||||
@@ -353,13 +354,27 @@ public class PowerUsageSummaryTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRefreshUi_deviceRotate_doNotUpdateBatteryTip() {
|
public void refreshUi_deviceRotate_doNotUpdateBatteryTip() {
|
||||||
mFragment.mNeedUpdateBatteryTip = false;
|
mFragment.mBatteryTipPreferenceController = mock(BatteryTipPreferenceController.class);
|
||||||
|
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(false);
|
||||||
|
mFragment.updateBatteryTipFlag(new Bundle());
|
||||||
|
|
||||||
mFragment.refreshUi();
|
mFragment.refreshUi();
|
||||||
|
|
||||||
verify(mFragment, never()).restartBatteryTipLoader();
|
verify(mFragment, never()).restartBatteryTipLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refreshUi_tipNeedUpdate_updateBatteryTip() {
|
||||||
|
mFragment.mBatteryTipPreferenceController = mock(BatteryTipPreferenceController.class);
|
||||||
|
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(true);
|
||||||
|
mFragment.updateBatteryTipFlag(new Bundle());
|
||||||
|
|
||||||
|
mFragment.refreshUi();
|
||||||
|
|
||||||
|
verify(mFragment).restartBatteryTipLoader();
|
||||||
|
}
|
||||||
|
|
||||||
public static class TestFragment extends PowerUsageSummary {
|
public static class TestFragment extends PowerUsageSummary {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
@@ -74,6 +74,7 @@ public class BatteryTipTest {
|
|||||||
assertThat(parcelTip.getTitle(mContext)).isEqualTo(TITLE);
|
assertThat(parcelTip.getTitle(mContext)).isEqualTo(TITLE);
|
||||||
assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY);
|
assertThat(parcelTip.getSummary(mContext)).isEqualTo(SUMMARY);
|
||||||
assertThat(parcelTip.getIconId()).isEqualTo(ICON_ID);
|
assertThat(parcelTip.getIconId()).isEqualTo(ICON_ID);
|
||||||
|
assertThat(parcelTip.needUpdate()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -64,8 +64,6 @@ public class DndPreferenceControllerTest {
|
|||||||
private UserManager mUm;
|
private UserManager mUm;
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
|
||||||
private Lifecycle mLifecycle;
|
|
||||||
|
|
||||||
private DndPreferenceController mController;
|
private DndPreferenceController mController;
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ public class DndPreferenceControllerTest {
|
|||||||
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
|
shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
|
||||||
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
|
shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mController = spy(new DndPreferenceController(mContext, mLifecycle, mBackend));
|
mController = spy(new DndPreferenceController(mContext, mBackend));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user