Merge changes I1c3620d3,Ic0bf23f6
* changes: Move some subsetting launch to SubSettingLauncher Migrate more subsetting launching to SubSettingLauncher
This commit is contained in:
@@ -59,6 +59,7 @@ import com.android.settings.Settings.WifiSettingsActivity;
|
||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||
import com.android.settings.backup.BackupSettingsActivity;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.core.gateway.SettingsGateway;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardSummary;
|
||||
@@ -612,11 +613,10 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
* @param fragmentClass Full name of the class implementing the fragment.
|
||||
* @param args Any desired arguments to supply to the fragment.
|
||||
* @param titleRes Optional resource identifier of the title of this fragment.
|
||||
* @param titleText Optional text of the title of this fragment.
|
||||
* @param userHandle The user for which the panel has to be started.
|
||||
*/
|
||||
public void startPreferencePanelAsUser(Fragment caller, String fragmentClass,
|
||||
Bundle args, int titleRes, CharSequence titleText, UserHandle userHandle) {
|
||||
Bundle args, int titleRes, UserHandle userHandle) {
|
||||
// This is a workaround.
|
||||
//
|
||||
// Calling startWithFragmentAsUser() without specifying FLAG_ACTIVITY_NEW_TASK to the intent
|
||||
@@ -628,19 +628,17 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
// another check here to call startPreferencePanel() instead of startWithFragmentAsUser()
|
||||
// when we're calling it as the same user.
|
||||
if (userHandle.getIdentifier() == UserHandle.myUserId()) {
|
||||
startPreferencePanel(caller, fragmentClass, args, titleRes, titleText, null, 0);
|
||||
startPreferencePanel(caller, fragmentClass, args, titleRes, null /* titleText */,
|
||||
null, 0);
|
||||
} else {
|
||||
String title = null;
|
||||
if (titleRes < 0) {
|
||||
if (titleText != null) {
|
||||
title = titleText.toString();
|
||||
} else {
|
||||
// There not much we can do in that case
|
||||
title = "";
|
||||
}
|
||||
}
|
||||
Utils.startWithFragmentAsUser(this, fragmentClass, args, titleRes, title,
|
||||
mIsShortcut, mMetricsFeatureProvider.getMetricsCategory(caller), userHandle);
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(fragmentClass)
|
||||
.setArguments(args)
|
||||
.setTitle(titleRes)
|
||||
.setIsShortCut(mIsShortcut)
|
||||
.setSourceMetricsCategory(mMetricsFeatureProvider.getMetricsCategory(caller))
|
||||
.setUserHandle(userHandle)
|
||||
.launch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -412,26 +412,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
metricsCategory);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start a new instance of the activity, showing only the given fragment.
|
||||
* When launched in this mode, the given preference fragment will be instantiated and fill the
|
||||
* entire activity.
|
||||
*
|
||||
* @param context The context.
|
||||
* @param fragmentName The name of the fragment to display.
|
||||
* @param titleResId resource id for the String to display for the title of this set
|
||||
* of preferences.
|
||||
* @param metricsCategory The current metricsCategory for logging source when fragment starts
|
||||
* @param intentFlags flag that should be added to the intent.
|
||||
*/
|
||||
public static void startWithFragment(Context context, String fragmentName, int titleResId,
|
||||
int metricsCategory, int intentFlags) {
|
||||
startWithFragment(context, fragmentName, null, null, 0,
|
||||
null /* titleResPackageName */, titleResId, null, false /* not a shortcut */,
|
||||
metricsCategory, intentFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new instance of the activity, showing only the given fragment.
|
||||
* When launched in this mode, the given preference fragment will be instantiated and fill the
|
||||
@@ -463,17 +443,9 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
|
||||
CharSequence title, boolean isShortcut, int metricsCategory) {
|
||||
startWithFragment(context, fragmentName, args, resultTo, resultRequestCode,
|
||||
titleResPackageName, titleResId, title, isShortcut, metricsCategory,
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
|
||||
public static void startWithFragment(Context context, String fragmentName, Bundle args,
|
||||
Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
|
||||
CharSequence title, boolean isShortcut, int metricsCategory, int flags) {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResPackageName,
|
||||
titleResId, title, isShortcut, metricsCategory);
|
||||
intent.addFlags(flags);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (resultTo == null) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
@@ -481,22 +453,6 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void startWithFragmentAsUser(Context context, String fragmentName, Bundle args,
|
||||
int titleResId, CharSequence title, boolean isShortcut, int metricsCategory,
|
||||
UserHandle userHandle) {
|
||||
// workaround to avoid crash in b/17523189
|
||||
if (userHandle.getIdentifier() == UserHandle.myUserId()) {
|
||||
startWithFragment(context, fragmentName, args, null, 0, titleResId, title, isShortcut,
|
||||
metricsCategory);
|
||||
} else {
|
||||
Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
|
||||
null /* titleResPackageName */, titleResId, title, isShortcut, metricsCategory);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivityAsUser(intent, userHandle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an Intent to launch a new activity showing the selected fragment.
|
||||
* The implementation constructs an Intent that re-launches the current activity with the
|
||||
|
@@ -88,7 +88,7 @@ public class BluetoothMasterSwitchPreferenceController extends AbstractPreferenc
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_TOGGLE_BLUETOOTH.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothSettings.class.getName(), null,
|
||||
R.string.bluetooth, null, new UserHandle(UserHandle.myUserId()));
|
||||
R.string.bluetooth, new UserHandle(UserHandle.myUserId()));
|
||||
return true;
|
||||
}
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
|
@@ -60,7 +60,7 @@ public class BluetoothPairingPreferenceController extends AbstractPreferenceCont
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_PAIRING.equals(preference.getKey())) {
|
||||
mActivity.startPreferencePanelAsUser(mFragment, BluetoothPairingDetail.class.getName(),
|
||||
null, R.string.bluetooth_pairing_page_title, null,
|
||||
null, R.string.bluetooth_pairing_page_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
return true;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SubSettings;
|
||||
@@ -102,8 +103,17 @@ public class SubSettingLauncher {
|
||||
mLaunched = true;
|
||||
final Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClass(mContext, SubSettings.class);
|
||||
|
||||
if (TextUtils.isEmpty(mLaunchRequest.destinationName)) {
|
||||
throw new IllegalArgumentException("Destination fragment must be set");
|
||||
}
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, mLaunchRequest.destinationName);
|
||||
|
||||
if (mLaunchRequest.sourceMetricsCategory <= 0) {
|
||||
throw new IllegalArgumentException("Source metrics category must be set");
|
||||
}
|
||||
intent.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
mLaunchRequest.sourceMetricsCategory);
|
||||
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, mLaunchRequest.arguments);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME,
|
||||
mLaunchRequest.titleResPackageName);
|
||||
@@ -112,8 +122,6 @@ public class SubSettingLauncher {
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, mLaunchRequest.title);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SHORTCUT,
|
||||
mLaunchRequest.isShortCut);
|
||||
intent.putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
mLaunchRequest.sourceMetricsCategory);
|
||||
intent.addFlags(mLaunchRequest.flags);
|
||||
|
||||
if (mLaunchRequest.userHandle != null
|
||||
@@ -150,7 +158,7 @@ public class SubSettingLauncher {
|
||||
String titleResPackageName;
|
||||
CharSequence title;
|
||||
boolean isShortCut;
|
||||
int sourceMetricsCategory;
|
||||
int sourceMetricsCategory = -100;
|
||||
int flags;
|
||||
Fragment mResultListener;
|
||||
int mRequestCode;
|
||||
|
@@ -45,20 +45,20 @@ import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyUtils;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settings.wrapper.DevicePolicyManagerWrapper;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -158,7 +158,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title, null,
|
||||
R.string.battery_details_title,
|
||||
new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper)));
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class AdvancedPowerUsageDetail extends DashboardFragment implements
|
||||
}
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, AdvancedPowerUsageDetail.class.getName(), args,
|
||||
R.string.battery_details_title, null, new UserHandle(UserHandle.myUserId()));
|
||||
R.string.battery_details_title, new UserHandle(UserHandle.myUserId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
@@ -69,8 +68,7 @@ public class PowerUsageAnomalyDetails extends DashboardFragment implements
|
||||
args.putParcelableList(EXTRA_ANOMALY_LIST, anomalies);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, PowerUsageAnomalyDetails.class.getName(), args,
|
||||
R.string.battery_abnormal_details_title, null,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
R.string.battery_abnormal_details_title, new UserHandle(UserHandle.myUserId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -66,7 +66,7 @@ public class RestrictedAppDetails extends DashboardFragment {
|
||||
args.putParcelableList(EXTRA_PACKAGE_OPS_LIST, packageOpsList);
|
||||
|
||||
caller.startPreferencePanelAsUser(fragment, RestrictedAppDetails.class.getName(), args,
|
||||
R.string.restricted_app_title, null /* titleText */,
|
||||
R.string.restricted_app_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
}
|
||||
|
||||
|
@@ -18,12 +18,10 @@ package com.android.settings.fuelgauge.batterytip.actions;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.UserHandle;
|
||||
import android.support.v14.preference.PreferenceFragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.fuelgauge.SmartBatterySettings;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class SmartBatteryAction extends BatteryTipAction {
|
||||
private SettingsActivity mSettingsActivity;
|
||||
@@ -42,7 +40,7 @@ public class SmartBatteryAction extends BatteryTipAction {
|
||||
public void handlePositiveAction() {
|
||||
mSettingsActivity.startPreferencePanelAsUser(mFragment,
|
||||
SmartBatterySettings.class.getName(), null /* args */,
|
||||
R.string.smart_battery_manager_title, null /* titleText */,
|
||||
R.string.smart_battery_manager_title,
|
||||
new UserHandle(UserHandle.myUserId()));
|
||||
}
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ public class RecentLocationRequestPreferenceController extends LocationBasePrefe
|
||||
((SettingsActivity) mFragment.getActivity()).startPreferencePanelAsUser(
|
||||
mFragment,
|
||||
AppInfoDashboardFragment.class.getName(), args,
|
||||
R.string.application_info_label, null, mUserHandle);
|
||||
R.string.application_info_label, mUserHandle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ import com.android.internal.net.VpnConfig;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
@@ -100,10 +100,15 @@ public class AppManagementFragment extends SettingsPreferenceFragment
|
||||
};
|
||||
|
||||
public static void show(Context context, AppPreference pref, int sourceMetricsCategory) {
|
||||
Bundle args = new Bundle();
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(ARG_PACKAGE_NAME, pref.getPackageName());
|
||||
Utils.startWithFragmentAsUser(context, AppManagementFragment.class.getName(), args, -1,
|
||||
pref.getLabel(), false, sourceMetricsCategory, new UserHandle(pref.getUserId()));
|
||||
new SubSettingLauncher(context)
|
||||
.setDestination(AppManagementFragment.class.getName())
|
||||
.setArguments(args)
|
||||
.setTitle(pref.getLabel())
|
||||
.setSourceMetricsCategory(sourceMetricsCategory)
|
||||
.setUserHandle(new UserHandle(pref.getUserId()))
|
||||
.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -26,7 +26,7 @@ import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.wrapper.WallpaperManagerWrapper;
|
||||
|
||||
public class WallpaperSuggestionActivity extends Activity {
|
||||
@@ -51,9 +51,12 @@ public class WallpaperSuggestionActivity extends Activity {
|
||||
@VisibleForTesting
|
||||
void startFallbackSuggestion() {
|
||||
// fall back to default wallpaper picker
|
||||
Utils.startWithFragment(this, WallpaperTypeSettings.class.getName(),
|
||||
R.string.wallpaper_suggestion_title, MetricsProto.MetricsEvent.DASHBOARD_SUMMARY,
|
||||
Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
new SubSettingLauncher(this)
|
||||
.setDestination(WallpaperTypeSettings.class.getName())
|
||||
.setTitle(R.string.wallpaper_suggestion_title)
|
||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.DASHBOARD_SUMMARY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
|
||||
.launch();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@@ -101,6 +101,6 @@ public class BluetoothPairingPreferenceControllerTest {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
verify(mSettingsActivity).startPreferencePanelAsUser(eq(mFragment), anyString(), any(),
|
||||
anyInt(), any(), any());
|
||||
anyInt(), any());
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import android.content.Intent;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -49,12 +50,28 @@ public class SubSettingLauncherTest {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void cannotReuseLauncher() {
|
||||
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext));
|
||||
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
|
||||
.setDestination(SubSettingLauncherTest.class.getName())
|
||||
.setSourceMetricsCategory(123);
|
||||
doNothing().when(launcher).launch(any(Intent.class));
|
||||
launcher.launch();
|
||||
launcher.launch();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void launch_noSourceMetricsCategory_shouldCrash() {
|
||||
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
|
||||
.setDestination(SubSettingLauncherTest.class.getName());
|
||||
launcher.launch();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void launch_noDestination_shouldCrash() {
|
||||
final SubSettingLauncher launcher = spy(new SubSettingLauncher(mContext))
|
||||
.setSourceMetricsCategory(123);
|
||||
launcher.launch();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launch_shouldIncludeAllParams() {
|
||||
final ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
|
||||
@@ -62,6 +79,7 @@ public class SubSettingLauncherTest {
|
||||
launcher.setTitle("123")
|
||||
.setDestination(SubSettingLauncherTest.class.getName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.setSourceMetricsCategory(123)
|
||||
.launch();
|
||||
doNothing().when(launcher).launch(any(Intent.class));
|
||||
verify(launcher).launch(intentArgumentCaptor.capture());
|
||||
@@ -72,5 +90,7 @@ public class SubSettingLauncherTest {
|
||||
assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
|
||||
.isEqualTo(SubSettingLauncherTest.class.getName());
|
||||
assertThat(intent.getFlags()).isEqualTo(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
assertThat(intent.getIntExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY, -1))
|
||||
.isEqualTo(123);
|
||||
}
|
||||
}
|
||||
|
@@ -210,7 +210,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
};
|
||||
doAnswer(callable).when(mTestActivity).startPreferencePanelAsUser(
|
||||
nullable(Fragment.class), nullable(String.class), captor.capture(), anyInt(),
|
||||
nullable(CharSequence.class), nullable(UserHandle.class));
|
||||
nullable(UserHandle.class));
|
||||
|
||||
mForegroundPreference = new Preference(mContext);
|
||||
mBackgroundPreference = new Preference(mContext);
|
||||
@@ -345,7 +345,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
|
||||
verify(mTestActivity).startPreferencePanelAsUser(
|
||||
nullable(Fragment.class), nullable(String.class), nullable(Bundle.class), anyInt(),
|
||||
nullable(CharSequence.class), eq(new UserHandle(10)));
|
||||
eq(new UserHandle(10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -361,7 +361,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
|
||||
verify(mTestActivity).startPreferencePanelAsUser(
|
||||
nullable(Fragment.class), nullable(String.class), nullable(Bundle.class), anyInt(),
|
||||
nullable(CharSequence.class), eq(new UserHandle(currentUser)));
|
||||
eq(new UserHandle(currentUser)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -372,7 +372,7 @@ public class AdvancedPowerUsageDetailTest {
|
||||
return null;
|
||||
};
|
||||
doAnswer(callable).when(mTestActivity).startPreferencePanelAsUser(nullable(Fragment.class),
|
||||
nullable(String.class), captor.capture(), anyInt(), nullable(CharSequence.class),
|
||||
nullable(String.class), captor.capture(), anyInt(),
|
||||
nullable(UserHandle.class));
|
||||
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(mTestActivity, null, PACKAGE_NAME[0]);
|
||||
|
@@ -17,8 +17,6 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
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.anyString;
|
||||
@@ -26,7 +24,6 @@ import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
@@ -40,9 +37,9 @@ import android.support.v7.preference.PreferenceManager;
|
||||
import android.util.IconDrawableFactory;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -188,8 +185,7 @@ public class PowerUsageAnomalyDetailsTest {
|
||||
}
|
||||
};
|
||||
doAnswer(bundleCallable).when(mSettingsActivity).startPreferencePanelAsUser(any(),
|
||||
anyString(),
|
||||
bundleCaptor.capture(), anyInt(), any(), any());
|
||||
anyString(), bundleCaptor.capture(), anyInt(), any());
|
||||
|
||||
PowerUsageAnomalyDetails.startBatteryAbnormalPage(mSettingsActivity, mFragment,
|
||||
mAnomalyList);
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -112,7 +111,7 @@ public class RestrictAppPreferenceControllerTest {
|
||||
|
||||
verify(mSettingsActivity).startPreferencePanelAsUser(eq(mFragment),
|
||||
eq(RestrictedAppDetails.class.getName()), any(), eq(R.string.restricted_app_title),
|
||||
any(), any());
|
||||
any());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -178,7 +178,7 @@ public class RecentLocationRequestPreferenceControllerTest {
|
||||
|
||||
verify(activity).startPreferencePanelAsUser(any(),
|
||||
eq(AppInfoDashboardFragment.class.getName()),
|
||||
any(Bundle.class), anyInt(), any(), any());
|
||||
any(Bundle.class), anyInt(), any());
|
||||
}
|
||||
|
||||
private static ArgumentMatcher<Preference> titleMatches(String expected) {
|
||||
|
Reference in New Issue
Block a user