Loading src/com/android/settings/datausage/AppDataUsage.java +19 −10 Original line number Original line Diff line number Diff line Loading @@ -236,9 +236,14 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen mRestrictBackground.setChecked(!getAppRestrictBackground()); mRestrictBackground.setChecked(!getAppRestrictBackground()); } } if (mUnrestrictedData != null) { if (mUnrestrictedData != null) { if (getAppRestrictBackground()) { mUnrestrictedData.setVisible(false); } else { mUnrestrictedData.setVisible(true); mUnrestrictedData.setChecked(mDataSaverBackend.isWhitelisted(mAppItem.key)); mUnrestrictedData.setChecked(mDataSaverBackend.isWhitelisted(mAppItem.key)); } } } } } private void addUid(int uid) { private void addUid(int uid) { String[] packages = getPackageManager().getPackagesForUid(uid); String[] packages = getPackageManager().getPackagesForUid(uid); Loading @@ -250,18 +255,21 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen } } private void bindData() { private void bindData() { final long backgroundBytes, foregroundBytes; if (mChartData == null || mStart == 0) { if (mChartData == null || mStart == 0) { return; backgroundBytes = foregroundBytes = 0; } mCycle.setVisible(false); final Context context = getContext(); } else { mCycle.setVisible(true); final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); NetworkStatsHistory.Entry entry = null; NetworkStatsHistory.Entry entry = null; entry = mChartData.detailDefault.getValues(mStart, mEnd, now, entry); entry = mChartData.detailDefault.getValues(mStart, mEnd, now, entry); final long backgroundBytes = entry.rxBytes + entry.txBytes; backgroundBytes = entry.rxBytes + entry.txBytes; entry = mChartData.detailForeground.getValues(mStart, mEnd, now, entry); entry = mChartData.detailForeground.getValues(mStart, mEnd, now, entry); final long foregroundBytes = entry.rxBytes + entry.txBytes; foregroundBytes = entry.rxBytes + entry.txBytes; } final long totalBytes = backgroundBytes + foregroundBytes; final long totalBytes = backgroundBytes + foregroundBytes; final Context context = getContext(); mTotalUsage.setSummary(Formatter.formatFileSize(context, totalBytes)); mTotalUsage.setSummary(Formatter.formatFileSize(context, totalBytes)); mForegroundUsage.setSummary(Formatter.formatFileSize(context, foregroundBytes)); mForegroundUsage.setSummary(Formatter.formatFileSize(context, foregroundBytes)); Loading @@ -278,6 +286,7 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen final int uid = mAppItem.key; final int uid = mAppItem.key; services.mPolicyManager.setUidPolicy( services.mPolicyManager.setUidPolicy( uid, restrictBackground ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE); uid, restrictBackground ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE); updatePrefs(); // TODO: should have been notified by NPMS instead } } @Override @Override Loading Loading
src/com/android/settings/datausage/AppDataUsage.java +19 −10 Original line number Original line Diff line number Diff line Loading @@ -236,9 +236,14 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen mRestrictBackground.setChecked(!getAppRestrictBackground()); mRestrictBackground.setChecked(!getAppRestrictBackground()); } } if (mUnrestrictedData != null) { if (mUnrestrictedData != null) { if (getAppRestrictBackground()) { mUnrestrictedData.setVisible(false); } else { mUnrestrictedData.setVisible(true); mUnrestrictedData.setChecked(mDataSaverBackend.isWhitelisted(mAppItem.key)); mUnrestrictedData.setChecked(mDataSaverBackend.isWhitelisted(mAppItem.key)); } } } } } private void addUid(int uid) { private void addUid(int uid) { String[] packages = getPackageManager().getPackagesForUid(uid); String[] packages = getPackageManager().getPackagesForUid(uid); Loading @@ -250,18 +255,21 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen } } private void bindData() { private void bindData() { final long backgroundBytes, foregroundBytes; if (mChartData == null || mStart == 0) { if (mChartData == null || mStart == 0) { return; backgroundBytes = foregroundBytes = 0; } mCycle.setVisible(false); final Context context = getContext(); } else { mCycle.setVisible(true); final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis(); NetworkStatsHistory.Entry entry = null; NetworkStatsHistory.Entry entry = null; entry = mChartData.detailDefault.getValues(mStart, mEnd, now, entry); entry = mChartData.detailDefault.getValues(mStart, mEnd, now, entry); final long backgroundBytes = entry.rxBytes + entry.txBytes; backgroundBytes = entry.rxBytes + entry.txBytes; entry = mChartData.detailForeground.getValues(mStart, mEnd, now, entry); entry = mChartData.detailForeground.getValues(mStart, mEnd, now, entry); final long foregroundBytes = entry.rxBytes + entry.txBytes; foregroundBytes = entry.rxBytes + entry.txBytes; } final long totalBytes = backgroundBytes + foregroundBytes; final long totalBytes = backgroundBytes + foregroundBytes; final Context context = getContext(); mTotalUsage.setSummary(Formatter.formatFileSize(context, totalBytes)); mTotalUsage.setSummary(Formatter.formatFileSize(context, totalBytes)); mForegroundUsage.setSummary(Formatter.formatFileSize(context, foregroundBytes)); mForegroundUsage.setSummary(Formatter.formatFileSize(context, foregroundBytes)); Loading @@ -278,6 +286,7 @@ public class AppDataUsage extends DataUsageBase implements Preference.OnPreferen final int uid = mAppItem.key; final int uid = mAppItem.key; services.mPolicyManager.setUidPolicy( services.mPolicyManager.setUidPolicy( uid, restrictBackground ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE); uid, restrictBackground ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE); updatePrefs(); // TODO: should have been notified by NPMS instead } } @Override @Override Loading