Search in sources :

Example 51 with SettingsActivity

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);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Example 52 with SettingsActivity

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();
    }
}
Also used : AnomalySummaryPreferenceController(com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController) SettingsActivity(com.android.settings.SettingsActivity)

Example 53 with SettingsActivity

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);
    }
}
Also used : Bundle(android.os.Bundle) SettingsActivity(com.android.settings.SettingsActivity)

Example 54 with SettingsActivity

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);
}
Also used : SettingsActivity(com.android.settings.SettingsActivity)

Example 55 with SettingsActivity

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());
}
Also used : AppOpsManager(android.app.AppOpsManager) Bundle(android.os.Bundle) SettingsRobolectricTestRunner(com.android.settings.testutils.SettingsRobolectricTestRunner) PackageManager(android.content.pm.PackageManager) ArgumentMatchers.nullable(org.mockito.ArgumentMatchers.nullable) Drawable(android.graphics.drawable.Drawable) MockitoAnnotations(org.mockito.MockitoAnnotations) ReflectionHelpers(org.robolectric.util.ReflectionHelpers) AppUtils(com.android.settingslib.applications.AppUtils) Matchers.eq(org.mockito.Matchers.eq) Mockito.doAnswer(org.mockito.Mockito.doAnswer) After(org.junit.After) Matchers.anyInt(org.mockito.Matchers.anyInt) Mockito.doReturn(org.mockito.Mockito.doReturn) R(com.android.settings.R) Anomaly(com.android.settings.fuelgauge.anomaly.Anomaly) BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper) RuntimeEnvironment(org.robolectric.RuntimeEnvironment) Matchers.any(org.mockito.Matchers.any) List(java.util.List) SettingsActivity(com.android.settings.SettingsActivity) EntityHeaderController(com.android.settings.widget.EntityHeaderController) ApplicationInfo(android.content.pm.ApplicationInfo) ShadowEntityHeaderController(com.android.settings.testutils.shadow.ShadowEntityHeaderController) Mockito.mock(org.mockito.Mockito.mock) Context(android.content.Context) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) UserHandle(android.os.UserHandle) Matchers.anyLong(org.mockito.Matchers.anyLong) LayoutPreference(com.android.settings.applications.LayoutPreference) LoaderManager(android.app.LoaderManager) Before(org.junit.Before) Fragment(android.app.Fragment) Answers(org.mockito.Answers) AnomalySummaryPreferenceController(com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController) Test(org.junit.Test) ApplicationsState(com.android.settingslib.applications.ApplicationsState) Truth.assertThat(com.google.common.truth.Truth.assertThat) InstantAppDataProvider(com.android.settingslib.applications.instantapps.InstantAppDataProvider) Mockito.verify(org.mockito.Mockito.verify) Preference(android.support.v7.preference.Preference) RecyclerView(android.support.v7.widget.RecyclerView) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) BatterySipper(com.android.internal.os.BatterySipper) BatteryStats(android.os.BatteryStats) Activity(android.app.Activity) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Bundle(android.os.Bundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Drawable(android.graphics.drawable.Drawable) ApplicationInfo(android.content.pm.ApplicationInfo) Fragment(android.app.Fragment) LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference) UserHandle(android.os.UserHandle) RecyclerView(android.support.v7.widget.RecyclerView) SettingsActivity(com.android.settings.SettingsActivity) Before(org.junit.Before)

Aggregations

SettingsActivity (com.android.settings.SettingsActivity)246 Bundle (android.os.Bundle)71 Intent (android.content.Intent)37 ArrayList (java.util.ArrayList)27 Preference (android.support.v7.preference.Preference)25 AnomalySummaryPreferenceController (com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController)18 SwitchBarController (com.android.settings.widget.SwitchBarController)16 ContentResolver (android.content.ContentResolver)15 TextView (android.widget.TextView)15 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)15 Test (org.junit.Test)15 Context (android.content.Context)14 View (android.view.View)14 LinkifyUtils (com.android.settings.LinkifyUtils)14 RemoteException (android.os.RemoteException)13 EngineInfo (android.speech.tts.TextToSpeech.EngineInfo)13 PreferenceScreen (android.support.v7.preference.PreferenceScreen)13 RecyclerView (android.support.v7.widget.RecyclerView)12 LayoutPreference (com.android.settings.applications.LayoutPreference)12 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)11