<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
- <intent-filter>
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.datausage.DataUsageSummary" />
</activity>
*/
package com.android.settings.applications;
-import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import com.android.settings.Utils;
import com.android.settings.applications.ProcStatsData.MemInfo;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.SummaryLoader;
public class ProcessStatsSummary extends ProcessStatsBase implements OnPreferenceClickListener {
}
return false;
}
-
- private static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader) {
- mContext = context;
- mSummaryLoader = summaryLoader;
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- ProcStatsData statsManager = new ProcStatsData(mContext, false);
- statsManager.setDuration(sDurations[0]);
- MemInfo memInfo = statsManager.getMemInfo();
- String usedResult = Formatter.formatShortFileSize(mContext,
- (long) memInfo.realUsedRam);
- String totalResult = Formatter.formatShortFileSize(mContext,
- (long) memInfo.realTotalRam);
- mSummaryLoader.setSummary(this, mContext.getString(R.string.memory_summary,
- usedResult, totalResult));
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
-
}
import com.android.settings.applications.AppStateUsageBridge.UsageState;
import com.android.settings.applications.AppStateWriteSettingsBridge;
import com.android.settings.applications.AppStorageSettings;
-import com.android.settings.applications.InstalledAppCounter;
import com.android.settings.applications.UsageAccessDetails;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.WriteSettingsDetails;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.fuelgauge.HighPowerDetail;
import com.android.settings.notification.AppNotificationSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
}
}
}
-
- private static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
- private final Context mContext;
- private final SummaryLoader mLoader;
-
- private SummaryProvider(Context context, SummaryLoader loader) {
- mContext = context;
- mLoader = loader;
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- new InstalledAppCounter(mContext, InstalledAppCounter.IGNORE_INSTALL_REASON,
- mContext.getPackageManager()) {
- @Override
- protected void onCountComplete(int num) {
- mLoader.setSummary(SummaryProvider.this,
- mContext.getString(R.string.apps_summary, num));
- }
- }.execute();
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
}
import android.os.Bundle;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.SubscriptionPlan;
import android.text.BidiFormatter;
import android.text.Spannable;
import android.text.SpannableString;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settingslib.NetworkPolicyEditor;
import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.net.DataUsageController;
import java.util.ArrayList;
import java.util.List;
updateState();
mSummaryController.updateState(mSummaryPreference);
}
-
- private static class SummaryProvider
- implements SummaryLoader.SummaryProvider {
-
- private final Activity mActivity;
- private final SummaryLoader mSummaryLoader;
- private final DataUsageController mDataController;
-
- public SummaryProvider(Activity activity, SummaryLoader summaryLoader) {
- mActivity = activity;
- mSummaryLoader = summaryLoader;
- mDataController = new DataUsageController(activity);
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- if (DataUsageUtils.hasSim(mActivity)) {
- mSummaryLoader.setSummary(this,
- mActivity.getString(R.string.data_usage_summary_format,
- formatUsedData()));
- } else {
- final DataUsageController.DataUsageInfo info =
- mDataController.getWifiDataUsageInfo();
-
- if (info == null) {
- mSummaryLoader.setSummary(this, null);
- } else {
- final CharSequence wifiFormat = mActivity
- .getText(R.string.data_usage_wifi_format);
- final CharSequence sizeText =
- DataUsageUtils.formatDataUsage(mActivity, info.usageLevel);
- mSummaryLoader.setSummary(this,
- TextUtils.expandTemplate(wifiFormat, sizeText));
- }
- }
- }
- }
-
- private CharSequence formatUsedData() {
- SubscriptionManager subscriptionManager = (SubscriptionManager) mActivity
- .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
- int defaultSubId = subscriptionManager.getDefaultSubscriptionId();
- if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return formatFallbackData();
- }
- SubscriptionPlan dfltPlan = DataUsageSummaryPreferenceController
- .getPrimaryPlan(subscriptionManager, defaultSubId);
- if (dfltPlan == null) {
- return formatFallbackData();
- }
- if (DataUsageSummaryPreferenceController.unlimited(dfltPlan.getDataLimitBytes())) {
- return DataUsageUtils.formatDataUsage(mActivity, dfltPlan.getDataUsageBytes());
- } else {
- return Utils.formatPercentage(dfltPlan.getDataUsageBytes(),
- dfltPlan.getDataLimitBytes());
- }
- }
-
- private CharSequence formatFallbackData() {
- DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
- if (info == null) {
- return DataUsageUtils.formatDataUsage(mActivity, 0);
- } else if (info.limitLevel <= 0) {
- return DataUsageUtils.formatDataUsage(mActivity, info.usageLevel);
- } else {
- return Utils.formatPercentage(info.usageLevel, info.limitLevel);
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = SummaryProvider::new;
}
import com.android.settings.SettingsActivity;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.datausage.DataUsageUtils;
import com.android.settings.location.ScanningSettings;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.SwitchBarController;
import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
import com.android.settings.wifi.dpp.WifiDppUtils;
}
};
- private static class SummaryProvider
- implements SummaryLoader.SummaryProvider, OnSummaryChangeListener {
-
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- @VisibleForTesting
- WifiSummaryUpdater mSummaryHelper;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader) {
- mContext = context;
- mSummaryLoader = summaryLoader;
- mSummaryHelper = new WifiSummaryUpdater(mContext, this);
- }
-
-
- @Override
- public void setListening(boolean listening) {
- mSummaryHelper.register(listening);
- }
-
- @Override
- public void onSummaryChanged(String summary) {
- mSummaryLoader.setSummary(this, summary);
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
-
private void handleConfigNetworkSubmitEvent(Intent data) {
final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
ConfigureAccessPointFragment.NETWORK_CONFIG_KEY);
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.SettingsActivity;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.datausage.DataUsageUtils;
import com.android.settings.location.ScanningSettings;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.SwitchBarController;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
return result;
}
};
-
- private static class SummaryProvider
- implements SummaryLoader.SummaryProvider, OnSummaryChangeListener {
-
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- @VisibleForTesting
- WifiSummaryUpdater mSummaryHelper;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader) {
- mContext = context;
- mSummaryLoader = summaryLoader;
- mSummaryHelper = new WifiSummaryUpdater(mContext, this);
- }
-
-
- @Override
- public void setListening(boolean listening) {
- mSummaryHelper.register(listening);
- }
-
- @Override
- public void onSummaryChanged(String summary) {
- mSummaryLoader.setSummary(this, summary);
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
- = new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
}
private TelephonyManager mTelephonyManager;
private Context mContext;
private FragmentActivity mActivity;
- private SummaryLoader.SummaryProvider mSummaryProvider;
/**
* This set up is contrived to get a passing test so that the build doesn't block without tests.
shadowTelephonyManager.setTelephonyManagerForSubscriptionId(1, mTelephonyManager);
mActivity = spy(Robolectric.buildActivity(FragmentActivity.class).get());
doReturn(mNetworkStatsManager).when(mActivity).getSystemService(NetworkStatsManager.class);
-
- mSummaryProvider = DataUsageSummary.SUMMARY_PROVIDER_FACTORY
- .createSummaryProvider(mActivity, mSummaryLoader);
}
@Test
}
@Test
- public void setListening_shouldBlankSummaryWithNoSim() {
- ShadowDataUsageUtils.HAS_SIM = false;
- mSummaryProvider.setListening(true);
- verify(mSummaryLoader).setSummary(mSummaryProvider, null);
- }
-
- @Test
- public void setListening_shouldSetSummaryWithSim() {
- ShadowDataUsageUtils.HAS_SIM = true;
- mSummaryProvider.setListening(true);
- verify(mSummaryLoader).setSummary(anyObject(), endsWith(" of data used"));
- }
-
- @Test
@Config(shadows = ShadowSubscriptionManager.class)
public void configuration_withSim_shouldShowMobileAndWifi() {
ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true;