use of com.android.settings.SettingsActivity in project android_packages_apps_Settings by crdroidandroid.
the class ToggleFeaturePreferenceFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mToggleSwitch = mSwitchBar.getSwitch();
onProcessArguments(getArguments());
// Show the "Settings" menu as if it were a preference screen
if (mSettingsTitle != null && mSettingsIntent != null) {
PreferenceScreen preferenceScreen = getPreferenceScreen();
Preference settingsPref = new Preference(preferenceScreen.getContext());
settingsPref.setTitle(mSettingsTitle);
settingsPref.setIconSpaceReserved(true);
settingsPref.setIntent(mSettingsIntent);
preferenceScreen.addPreference(settingsPref);
}
}
use of com.android.settings.SettingsActivity in project android_packages_apps_Settings by crdroidandroid.
the class AdvancedPowerUsageDetail method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mPackageName = getArguments().getString(EXTRA_PACKAGE_NAME);
mAnomalySummaryPreferenceController = new AnomalySummaryPreferenceController((SettingsActivity) getActivity(), this, MetricsEvent.FUELGAUGE_POWER_USAGE_DETAIL);
mForegroundPreference = findPreference(KEY_PREF_FOREGROUND);
mBackgroundPreference = findPreference(KEY_PREF_BACKGROUND);
mPowerUsagePreference = findPreference(KEY_PREF_POWER_USAGE);
mHeaderPreference = (LayoutPreference) findPreference(KEY_PREF_HEADER);
if (mPackageName != null) {
mAppEntry = mState.getEntry(mPackageName, UserHandle.myUserId());
initAnomalyInfo();
}
}
use of com.android.settings.SettingsActivity in project android_packages_apps_Settings by crdroidandroid.
the class RunningProcessesView method startServiceDetailsActivity.
// utility method used to start sub activity
private void startServiceDetailsActivity(RunningState.MergedItem mi) {
if (mOwner != null && mi != null) {
// start new fragment to display extended information
Bundle args = new Bundle();
if (mi.mProcess != null) {
args.putInt(RunningServiceDetails.KEY_UID, mi.mProcess.mUid);
args.putString(RunningServiceDetails.KEY_PROCESS, mi.mProcess.mProcessName);
}
args.putInt(RunningServiceDetails.KEY_USER_ID, mi.mUserId);
args.putBoolean(RunningServiceDetails.KEY_BACKGROUND, mAdapter.mShowBackground);
SettingsActivity sa = (SettingsActivity) mOwner.getActivity();
sa.startPreferencePanel(mOwner, RunningServiceDetails.class.getName(), args, R.string.runningservicedetails_settings_title, null, null, 0);
}
}
use of com.android.settings.SettingsActivity in project android_packages_apps_Settings by crdroidandroid.
the class ConvertToFbe method convert.
private void convert() {
SettingsActivity sa = (SettingsActivity) getActivity();
sa.startPreferencePanel(this, ConfirmConvertToFbe.class.getName(), null, R.string.convert_to_file_encryption, null, null, 0);
}
use of com.android.settings.SettingsActivity in project android_packages_apps_Settings by crdroidandroid.
the class AdvancedPowerUsageDetailTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
mFragment = spy(new AdvancedPowerUsageDetail());
doReturn(mContext).when(mFragment).getContext();
doReturn(mActivity).when(mFragment).getActivity();
doReturn(SUMMARY).when(mFragment).getString(anyInt());
doReturn(APP_LABEL).when(mBundle).getString(nullable(String.class));
doReturn(mBundle).when(mFragment).getArguments();
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
doReturn(mEntityHeaderController).when(mEntityHeaderController).setRecyclerView(nullable(RecyclerView.class), nullable(Lifecycle.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setButtonActions(anyInt(), anyInt());
doReturn(mEntityHeaderController).when(mEntityHeaderController).setIcon(nullable(Drawable.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setIcon(nullable(ApplicationsState.AppEntry.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(String.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(String.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(ApplicationsState.AppEntry.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setSummary(nullable(String.class));
doReturn(UID).when(mBatterySipper).getUid();
doReturn(APP_LABEL).when(mBatteryEntry).getLabel();
doReturn(BACKGROUND_TIME_US).when(mUid).getProcessStateTime(eq(BatteryStats.Uid.PROCESS_STATE_BACKGROUND), anyLong(), anyInt());
doReturn(PROCSTATE_TOP_TIME_US).when(mUid).getProcessStateTime(eq(BatteryStats.Uid.PROCESS_STATE_TOP), anyLong(), anyInt());
doReturn(mForegroundActivityTimer).when(mUid).getForegroundActivityTimer();
doReturn(FOREGROUND_ACTIVITY_TIME_US).when(mForegroundActivityTimer).getTotalTimeLocked(anyLong(), anyInt());
ReflectionHelpers.setField(mBatteryEntry, "sipper", mBatterySipper);
mBatteryEntry.iconId = ICON_ID;
mBatterySipper.uidObj = mUid;
mBatterySipper.drainType = BatterySipper.DrainType.APP;
mFragment.mHeaderPreference = mHeaderPreference;
mFragment.mState = mState;
mFragment.mBatteryUtils = new BatteryUtils(RuntimeEnvironment.application);
mAppEntry.info = mock(ApplicationInfo.class);
mTestActivity = spy(new SettingsActivity());
doReturn(mPackageManager).when(mTestActivity).getPackageManager();
doReturn(mAppOpsManager).when(mTestActivity).getSystemService(Context.APP_OPS_SERVICE);
mBatteryUtils = spy(BatteryUtils.getInstance(mTestActivity));
doReturn(FOREGROUND_SERVICE_TIME_US).when(mBatteryUtils).getForegroundServiceTotalTimeUs(any(BatteryStats.Uid.class), anyLong());
final ArgumentCaptor<Bundle> captor = ArgumentCaptor.forClass(Bundle.class);
Answer<Void> callable = invocation -> {
mBundle = captor.getValue();
return null;
};
doAnswer(callable).when(mTestActivity).startPreferencePanelAsUser(nullable(Fragment.class), nullable(String.class), captor.capture(), anyInt(), nullable(CharSequence.class), nullable(UserHandle.class));
mForegroundPreference = new Preference(mContext);
mBackgroundPreference = new Preference(mContext);
mPowerUsagePreference = new Preference(mContext);
mFragment.mForegroundPreference = mForegroundPreference;
mFragment.mBackgroundPreference = mBackgroundPreference;
mFragment.mPowerUsagePreference = mPowerUsagePreference;
mFragment.mAnomalySummaryPreferenceController = mAnomalySummaryPreferenceController;
mAnomalies = new ArrayList<>();
mAnomalies.add(new Anomaly.Builder().setUid(UID).setType(Anomaly.AnomalyType.WAKE_LOCK).build());
}
Aggregations