Search in sources :

Example 16 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ProcessStatsBase method launchMemoryDetail.

public static void launchMemoryDetail(SettingsActivity activity, MemInfo memInfo, ProcStatsPackageEntry entry, boolean includeAppInfo) {
    Bundle args = new Bundle();
    args.putParcelable(ProcessStatsDetail.EXTRA_PACKAGE_ENTRY, entry);
    args.putDouble(ProcessStatsDetail.EXTRA_WEIGHT_TO_RAM, memInfo.weightToRam);
    args.putLong(ProcessStatsDetail.EXTRA_TOTAL_TIME, memInfo.memTotalTime);
    args.putDouble(ProcessStatsDetail.EXTRA_MAX_MEMORY_USAGE, memInfo.usedWeight * memInfo.weightToRam);
    args.putDouble(ProcessStatsDetail.EXTRA_TOTAL_SCALE, memInfo.totalScale);
    new SubSettingLauncher(activity).setDestination(ProcessStatsDetail.class.getName()).setTitleRes(R.string.memory_usage).setArguments(args).setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN).launch();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle)

Example 17 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsageSummaryPreference method launchWifiDataUsage.

@VisibleForTesting
static void launchWifiDataUsage(Context context) {
    final Bundle args = new Bundle(1);
    args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, NetworkTemplate.buildTemplateWifiWildcard());
    args.putInt(DataUsageList.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_WIFI);
    final SubSettingLauncher launcher = new SubSettingLauncher(context).setArguments(args).setDestination(DataUsageList.class.getName()).setSourceMetricsCategory(SettingsEnums.PAGE_UNKNOWN);
    launcher.setTitleRes(R.string.wifi_data_usage);
    launcher.launch();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 18 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AdvancedPowerUsageDetail method startBatteryDetailPage.

@VisibleForTesting
static void startBatteryDetailPage(Activity caller, BatteryUtils batteryUtils, InstrumentedPreferenceFragment fragment, BatteryStatsHelper helper, int which, BatteryEntry entry, String usagePercent) {
    // Initialize mStats if necessary.
    helper.getStats();
    final Bundle args = new Bundle();
    final BatterySipper sipper = entry.sipper;
    final BatteryStats.Uid uid = sipper.uidObj;
    final boolean isTypeApp = sipper.drainType == BatterySipper.DrainType.APP;
    final long foregroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(BatteryUtils.StatusType.FOREGROUND, uid, which) : sipper.usageTimeMs;
    final long backgroundTimeMs = isTypeApp ? batteryUtils.getProcessTimeMs(BatteryUtils.StatusType.BACKGROUND, uid, which) : 0;
    if (ArrayUtils.isEmpty(sipper.mPackages)) {
        // populate data for system app
        args.putString(EXTRA_LABEL, entry.getLabel());
        args.putInt(EXTRA_ICON_ID, entry.iconId);
        args.putString(EXTRA_PACKAGE_NAME, null);
    } else {
        // populate data for normal app
        args.putString(EXTRA_PACKAGE_NAME, entry.defaultPackageName != null ? entry.defaultPackageName : sipper.mPackages[0]);
    }
    args.putInt(EXTRA_UID, sipper.getUid());
    args.putLong(EXTRA_BACKGROUND_TIME, backgroundTimeMs);
    args.putLong(EXTRA_FOREGROUND_TIME, foregroundTimeMs);
    args.putString(EXTRA_POWER_USAGE_PERCENT, usagePercent);
    args.putInt(EXTRA_POWER_USAGE_AMOUNT, (int) sipper.totalPowerMah);
    new SubSettingLauncher(caller).setDestination(AdvancedPowerUsageDetail.class.getName()).setTitleRes(R.string.battery_details_title).setArguments(args).setSourceMetricsCategory(fragment.getMetricsCategory()).setUserHandle(new UserHandle(getUserIdToLaunchAdvancePowerUsageDetail(sipper))).launch();
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) BatteryStats(android.os.BatteryStats) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 19 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeAllBypassingAppsPreferenceController method updateNotificationChannelList.

@VisibleForTesting
void updateNotificationChannelList(List<ApplicationsState.AppEntry> apps) {
    if (mPreferenceScreen == null || apps == null) {
        return;
    }
    List<Preference> channelsBypassingDnd = new ArrayList<>();
    for (ApplicationsState.AppEntry entry : apps) {
        String pkg = entry.info.packageName;
        mApplicationsState.ensureIcon(entry);
        for (NotificationChannel channel : mNotificationBackend.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
            Preference pref = new AppPreference(mPrefContext);
            pref.setKey(pkg + "|" + channel.getId());
            pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
            pref.setIcon(entry.icon);
            pref.setSummary(BidiFormatter.getInstance().unicodeWrap(channel.getName()));
            pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    Bundle args = new Bundle();
                    args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
                    args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
                    args.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
                    new SubSettingLauncher(mContext).setDestination(ChannelNotificationSettings.class.getName()).setArguments(args).setTitleRes(R.string.notification_channel_title).setResultListener(mHostFragment, 0).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP).launch();
                    return true;
                }
            });
            channelsBypassingDnd.add(pref);
        }
        mPreferenceScreen.removeAll();
        if (channelsBypassingDnd.size() > 0) {
            for (Preference prefToAdd : channelsBypassingDnd) {
                mPreferenceScreen.addPreference(prefToAdd);
            }
        }
    }
}
Also used : AppPreference(com.android.settingslib.widget.apppreference.AppPreference) ApplicationsState(com.android.settingslib.applications.ApplicationsState) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) NotificationChannel(android.app.NotificationChannel) AppPreference(com.android.settingslib.widget.apppreference.AppPreference) Preference(androidx.preference.Preference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 20 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenCustomRuleConfigSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mSummaryBuilder = new ZenModeSettings.SummaryBuilder(mContext);
    mCallsPreference = getPreferenceScreen().findPreference(CALLS_KEY);
    mCallsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new SubSettingLauncher(mContext).setDestination(ZenCustomRuleCallsSettings.class.getName()).setArguments(createZenRuleBundle()).setSourceMetricsCategory(SettingsEnums.ZEN_CUSTOM_RULE_CALLS).launch();
            return true;
        }
    });
    mMessagesPreference = getPreferenceScreen().findPreference(MESSAGES_KEY);
    mMessagesPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new SubSettingLauncher(mContext).setDestination(ZenCustomRuleMessagesSettings.class.getName()).setArguments(createZenRuleBundle()).setSourceMetricsCategory(SettingsEnums.ZEN_CUSTOM_RULE_MESSAGES).launch();
            return true;
        }
    });
    mNotificationsPreference = getPreferenceScreen().findPreference(NOTIFICATIONS_KEY);
    mNotificationsPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            new SubSettingLauncher(mContext).setDestination(ZenCustomRuleNotificationsSettings.class.getName()).setArguments(createZenRuleBundle()).setSourceMetricsCategory(SettingsEnums.ZEN_CUSTOM_RULE_NOTIFICATION_RESTRICTIONS).launch();
            return true;
        }
    });
    updateSummaries();
}
Also used : Preference(androidx.preference.Preference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher)

Aggregations

SubSettingLauncher (com.android.settings.core.SubSettingLauncher)135 Bundle (android.os.Bundle)116 Intent (android.content.Intent)24 VisibleForTesting (androidx.annotation.VisibleForTesting)16 Preference (androidx.preference.Preference)14 UserHandle (android.os.UserHandle)10 ManageApplications (com.android.settings.applications.manageapplications.ManageApplications)10 Context (android.content.Context)9 PendingIntent (android.app.PendingIntent)6 PackageManager (android.content.pm.PackageManager)5 ComponentName (android.content.ComponentName)4 PersistableBundle (android.os.PersistableBundle)4 ApplicationsState (com.android.settingslib.applications.ApplicationsState)4 UserManager (android.os.UserManager)3 View (android.view.View)3 NetworkSelectSettings (com.android.settings.network.telephony.NetworkSelectSettings)3 Activity (android.app.Activity)2 NotificationChannel (android.app.NotificationChannel)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2