Settings: Add support for allowing/disallowing apps on cellular, vpn and wifi networks
*) Add options to disable all cellular, vpn and wifi data in app data usage settings. *) Disable the existing background data and unrestricted data usage options when all cellular data access is disabled. *) The vpn data option can be selected independently from the Wi-Fi and cellular options. *) Prevent DataSaverBackend from overwriting uid policies This is a replacement for the appops menu based cell/wifi data restriction settings in cm-13.0: Author: Danesh M <daneshm90@gmail.com> Date: Mon Mar 7 15:17:59 2016 -0800 Settings : Add per app internet/data control CYAN-3976 CRACKLING-834 Change-Id: I13192df837c057b5cadde8f31532e12daaf3c1b0 Change-Id: Ic087c27a5ed0bdb84bb8f297c425c6bcbffec848 (cherry picked from commit d4a2eea698cbc4636a635d60f2a52ec1bbc36ba2)
This commit is contained in:
committed by
Michael Bestas
parent
0b57abfdec
commit
0017a2f638
@@ -63,6 +63,12 @@
|
|||||||
<!-- Per-app data restrictions -->
|
<!-- Per-app data restrictions -->
|
||||||
<string name="data_usage_app_restrict_all">Allow network access</string>
|
<string name="data_usage_app_restrict_all">Allow network access</string>
|
||||||
<string name="data_usage_app_restrict_all_summary">Enable network usage</string>
|
<string name="data_usage_app_restrict_all_summary">Enable network usage</string>
|
||||||
|
<string name="data_usage_app_restrict_mobile">Mobile data</string>
|
||||||
|
<string name="data_usage_app_restrict_mobile_summary">Enable usage of mobile data</string>
|
||||||
|
<string name="data_usage_app_restrict_vpn">VPN data</string>
|
||||||
|
<string name="data_usage_app_restrict_vpn_summary">Enable usage of VPN data</string>
|
||||||
|
<string name="data_usage_app_restrict_wifi">Wi\u2011Fi data</string>
|
||||||
|
<string name="data_usage_app_restrict_wifi_summary">Enable usage of Wi\u2011Fi data</string>
|
||||||
|
|
||||||
<!-- PIN scramble -->
|
<!-- PIN scramble -->
|
||||||
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
|
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
|
||||||
|
|||||||
@@ -47,6 +47,16 @@
|
|||||||
android:title="@string/data_usage_app_restrict_all"
|
android:title="@string/data_usage_app_restrict_all"
|
||||||
android:summary="@string/data_usage_app_restrict_all_summary" />
|
android:summary="@string/data_usage_app_restrict_all_summary" />
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
|
android:key="restrict_wifi"
|
||||||
|
android:title="@string/data_usage_app_restrict_wifi"
|
||||||
|
android:summary="@string/data_usage_app_restrict_wifi_summary" />
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
|
android:key="restrict_cellular"
|
||||||
|
android:title="@string/data_usage_app_restrict_mobile"
|
||||||
|
android:summary="@string/data_usage_app_restrict_mobile_summary" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="restrict_background"
|
android:key="restrict_background"
|
||||||
android:title="@string/data_usage_app_restrict_background"
|
android:title="@string/data_usage_app_restrict_background"
|
||||||
@@ -54,6 +64,11 @@
|
|||||||
settings:useAdditionalSummary="true"
|
settings:useAdditionalSummary="true"
|
||||||
settings:restrictedSwitchSummary="@string/disabled_by_admin" />
|
settings:restrictedSwitchSummary="@string/disabled_by_admin" />
|
||||||
|
|
||||||
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
|
android:key="restrict_vpn"
|
||||||
|
android:title="@string/data_usage_app_restrict_vpn"
|
||||||
|
android:summary="@string/data_usage_app_restrict_vpn_summary" />
|
||||||
|
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="unrestricted_data_saver"
|
android:key="unrestricted_data_saver"
|
||||||
android:title="@string/unrestricted_app_title"
|
android:title="@string/unrestricted_app_title"
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
package com.android.settings.datausage;
|
package com.android.settings.datausage;
|
||||||
|
|
||||||
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
|
import static android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND;
|
||||||
|
import static android.net.NetworkPolicyManager.POLICY_REJECT_CELLULAR;
|
||||||
|
import static android.net.NetworkPolicyManager.POLICY_REJECT_VPN;
|
||||||
|
import static android.net.NetworkPolicyManager.POLICY_REJECT_WIFI;
|
||||||
|
|
||||||
import static com.android.settings.datausage.lib.AppDataUsageRepository.getAppUid;
|
import static com.android.settings.datausage.lib.AppDataUsageRepository.getAppUid;
|
||||||
import static com.android.settings.datausage.lib.AppDataUsageRepository.getAppUidList;
|
import static com.android.settings.datausage.lib.AppDataUsageRepository.getAppUidList;
|
||||||
@@ -27,6 +30,7 @@ import android.content.pm.ApplicationInfo;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.ConnectivitySettingsManager;
|
import android.net.ConnectivitySettingsManager;
|
||||||
|
import android.net.NetworkPolicyManager;
|
||||||
import android.net.NetworkTemplate;
|
import android.net.NetworkTemplate;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -77,12 +81,18 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
|
|
||||||
private static final String KEY_RESTRICT_ALL = "restrict_all";
|
private static final String KEY_RESTRICT_ALL = "restrict_all";
|
||||||
private static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
|
private static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
|
||||||
|
private static final String KEY_RESTRICT_CELLULAR = "restrict_cellular";
|
||||||
|
private static final String KEY_RESTRICT_VPN = "restrict_vpn";
|
||||||
|
private static final String KEY_RESTRICT_WIFI = "restrict_wifi";
|
||||||
private static final String KEY_UNRESTRICTED_DATA = "unrestricted_data_saver";
|
private static final String KEY_UNRESTRICTED_DATA = "unrestricted_data_saver";
|
||||||
|
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
private final ArraySet<String> mPackages = new ArraySet<>();
|
private final ArraySet<String> mPackages = new ArraySet<>();
|
||||||
private RestrictedSwitchPreference mRestrictAll;
|
private RestrictedSwitchPreference mRestrictAll;
|
||||||
private RestrictedSwitchPreference mRestrictBackground;
|
private RestrictedSwitchPreference mRestrictBackground;
|
||||||
|
private RestrictedSwitchPreference mRestrictCellular;
|
||||||
|
private RestrictedSwitchPreference mRestrictVpn;
|
||||||
|
private RestrictedSwitchPreference mRestrictWifi;
|
||||||
|
|
||||||
private Drawable mIcon;
|
private Drawable mIcon;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -153,6 +163,9 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
removePreference(KEY_UNRESTRICTED_DATA);
|
removePreference(KEY_UNRESTRICTED_DATA);
|
||||||
removePreference(KEY_RESTRICT_ALL);
|
removePreference(KEY_RESTRICT_ALL);
|
||||||
removePreference(KEY_RESTRICT_BACKGROUND);
|
removePreference(KEY_RESTRICT_BACKGROUND);
|
||||||
|
removePreference(KEY_RESTRICT_CELLULAR);
|
||||||
|
removePreference(KEY_RESTRICT_VPN);
|
||||||
|
removePreference(KEY_RESTRICT_WIFI);
|
||||||
} else {
|
} else {
|
||||||
if (mPackages.size() != 0) {
|
if (mPackages.size() != 0) {
|
||||||
int userId = UserHandle.getUserId(mAppItem.key);
|
int userId = UserHandle.getUserId(mAppItem.key);
|
||||||
@@ -170,6 +183,12 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
mRestrictAll.setOnPreferenceChangeListener(this);
|
mRestrictAll.setOnPreferenceChangeListener(this);
|
||||||
mRestrictBackground = findPreference(KEY_RESTRICT_BACKGROUND);
|
mRestrictBackground = findPreference(KEY_RESTRICT_BACKGROUND);
|
||||||
mRestrictBackground.setOnPreferenceChangeListener(this);
|
mRestrictBackground.setOnPreferenceChangeListener(this);
|
||||||
|
mRestrictCellular = findPreference(KEY_RESTRICT_CELLULAR);
|
||||||
|
mRestrictCellular.setOnPreferenceChangeListener(this);
|
||||||
|
mRestrictVpn = findPreference(KEY_RESTRICT_VPN);
|
||||||
|
mRestrictVpn.setOnPreferenceChangeListener(this);
|
||||||
|
mRestrictWifi = findPreference(KEY_RESTRICT_WIFI);
|
||||||
|
mRestrictWifi.setOnPreferenceChangeListener(this);
|
||||||
mUnrestrictedData = findPreference(KEY_UNRESTRICTED_DATA);
|
mUnrestrictedData = findPreference(KEY_UNRESTRICTED_DATA);
|
||||||
mUnrestrictedData.setOnPreferenceChangeListener(this);
|
mUnrestrictedData.setOnPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
@@ -186,6 +205,9 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
removePreference(KEY_UNRESTRICTED_DATA);
|
removePreference(KEY_UNRESTRICTED_DATA);
|
||||||
removePreference(KEY_RESTRICT_ALL);
|
removePreference(KEY_RESTRICT_ALL);
|
||||||
removePreference(KEY_RESTRICT_BACKGROUND);
|
removePreference(KEY_RESTRICT_BACKGROUND);
|
||||||
|
removePreference(KEY_RESTRICT_CELLULAR);
|
||||||
|
removePreference(KEY_RESTRICT_VPN);
|
||||||
|
removePreference(KEY_RESTRICT_WIFI);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupIntroPreference();
|
setupIntroPreference();
|
||||||
@@ -238,6 +260,18 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
ConnectivitySettingsManager.setUidsAllowedOnRestrictedNetworks(mContext, uids);
|
ConnectivitySettingsManager.setUidsAllowedOnRestrictedNetworks(mContext, uids);
|
||||||
updatePrefs();
|
updatePrefs();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (preference == mRestrictCellular) {
|
||||||
|
setAppRestrictCellular(!(Boolean) newValue);
|
||||||
|
updatePrefs();
|
||||||
|
return true;
|
||||||
|
} else if (preference == mRestrictVpn) {
|
||||||
|
setAppRestrictVpn(!(Boolean) newValue);
|
||||||
|
updatePrefs();
|
||||||
|
return true;
|
||||||
|
} else if (preference == mRestrictWifi) {
|
||||||
|
setAppRestrictWifi(!(Boolean) newValue);
|
||||||
|
updatePrefs();
|
||||||
|
return true;
|
||||||
} else if (preference == mUnrestrictedData) {
|
} else if (preference == mUnrestrictedData) {
|
||||||
mDataSaverBackend.setIsAllowlisted(mAppItem.key, mPackageName, (Boolean) newValue);
|
mDataSaverBackend.setIsAllowlisted(mAppItem.key, mPackageName, (Boolean) newValue);
|
||||||
return true;
|
return true;
|
||||||
@@ -257,7 +291,8 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void updatePrefs() {
|
void updatePrefs() {
|
||||||
updatePrefs(getAppRestrictBackground(), getUnrestrictData(), getAppRestrictAll());
|
updatePrefs(getAppRestrictBackground(), getUnrestrictData(), getAppRestrictAll(),
|
||||||
|
getAppRestrictCellular(), getAppRestrictVpn(), getAppRestrictWifi());
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -299,7 +334,8 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePrefs(boolean restrictBackground, boolean unrestrictData,
|
private void updatePrefs(boolean restrictBackground, boolean unrestrictData,
|
||||||
boolean restrictAll) {
|
boolean restrictAll, boolean restrictCellular, boolean restrictVpn,
|
||||||
|
boolean restrictWifi) {
|
||||||
if (!isSimHardwareVisible(mContext)) {
|
if (!isSimHardwareVisible(mContext)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -312,15 +348,29 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
}
|
}
|
||||||
if (mRestrictBackground != null) {
|
if (mRestrictBackground != null) {
|
||||||
mRestrictBackground.setDisabledByAdmin(admin);
|
mRestrictBackground.setDisabledByAdmin(admin);
|
||||||
mRestrictBackground.setEnabled(!mRestrictBackground.isDisabledByAdmin() &&
|
mRestrictBackground.setEnabled(!mRestrictBackground.isDisabledByAdmin() && !restrictAll
|
||||||
!restrictAll);
|
&& !restrictCellular);
|
||||||
mRestrictBackground.setChecked(!restrictBackground && !restrictAll);
|
mRestrictBackground.setChecked(!restrictBackground && !restrictAll &&
|
||||||
|
!restrictCellular);
|
||||||
|
}
|
||||||
|
if (mRestrictCellular != null) {
|
||||||
|
mRestrictCellular.setEnabled(!restrictAll);
|
||||||
|
mRestrictCellular.setChecked(!restrictAll && !restrictCellular);
|
||||||
|
}
|
||||||
|
if (mRestrictVpn != null) {
|
||||||
|
mRestrictVpn.setEnabled(!restrictAll);
|
||||||
|
mRestrictVpn.setChecked(!restrictAll && !restrictVpn);
|
||||||
|
}
|
||||||
|
if (mRestrictWifi != null) {
|
||||||
|
mRestrictWifi.setEnabled(!restrictAll);
|
||||||
|
mRestrictWifi.setChecked(!restrictAll && !restrictWifi);
|
||||||
}
|
}
|
||||||
if (mUnrestrictedData != null) {
|
if (mUnrestrictedData != null) {
|
||||||
mUnrestrictedData.setDisabledByAdmin(admin);
|
mUnrestrictedData.setDisabledByAdmin(admin);
|
||||||
mUnrestrictedData.setEnabled(!mUnrestrictedData.isDisabledByAdmin() &&
|
mUnrestrictedData.setEnabled(!mUnrestrictedData.isDisabledByAdmin() &&
|
||||||
!restrictBackground && !restrictAll);
|
!restrictBackground && !restrictAll && !restrictCellular);
|
||||||
mUnrestrictedData.setChecked(unrestrictData && !restrictBackground && !restrictAll);
|
mUnrestrictedData.setChecked(unrestrictData && !restrictBackground && !restrictAll
|
||||||
|
&& !restrictCellular);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,10 +382,19 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean getAppRestrictBackground() {
|
private boolean getAppRestrictBackground() {
|
||||||
final int uid = mAppItem.key;
|
return getAppRestriction(POLICY_REJECT_METERED_BACKGROUND);
|
||||||
final int uidPolicy = services.mPolicyManager.getUidPolicy(uid);
|
}
|
||||||
return (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0
|
|
||||||
&& DynamicDenylistManager.getInstance(mContext).isInManualDenylist(uid);
|
private boolean getAppRestrictCellular() {
|
||||||
|
return getAppRestriction(POLICY_REJECT_CELLULAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getAppRestrictVpn() {
|
||||||
|
return getAppRestriction(POLICY_REJECT_VPN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getAppRestrictWifi() {
|
||||||
|
return getAppRestriction(POLICY_REJECT_WIFI);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getAppRestrictAll() {
|
private boolean getAppRestrictAll() {
|
||||||
@@ -350,6 +409,33 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean getAppRestriction(int policy) {
|
||||||
|
final int uid = mAppItem.key;
|
||||||
|
final int uidPolicy = services.mPolicyManager.getUidPolicy(uid);
|
||||||
|
return (uidPolicy & policy) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAppRestrictCellular(boolean restrict) {
|
||||||
|
setAppRestriction(POLICY_REJECT_CELLULAR, restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAppRestrictVpn(boolean restrict) {
|
||||||
|
setAppRestriction(POLICY_REJECT_VPN, restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAppRestrictWifi(boolean restrict) {
|
||||||
|
setAppRestriction(POLICY_REJECT_WIFI, restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAppRestriction(int policy, boolean restrict) {
|
||||||
|
final int uid = mAppItem.key;
|
||||||
|
if (restrict) {
|
||||||
|
services.mPolicyManager.addUidPolicy(uid, policy);
|
||||||
|
} else {
|
||||||
|
services.mPolicyManager.removeUidPolicy(uid, policy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setupIntroPreference() {
|
void setupIntroPreference() {
|
||||||
final Preference pref = getPreferenceScreen().findPreference(ARG_APP_HEADER);
|
final Preference pref = getPreferenceScreen().findPreference(ARG_APP_HEADER);
|
||||||
@@ -392,14 +478,16 @@ public class AppDataUsage extends DataUsageBaseFragment implements OnPreferenceC
|
|||||||
@Override
|
@Override
|
||||||
public void onAllowlistStatusChanged(int uid, boolean isAllowlisted) {
|
public void onAllowlistStatusChanged(int uid, boolean isAllowlisted) {
|
||||||
if (mAppItem.uids.get(uid, false)) {
|
if (mAppItem.uids.get(uid, false)) {
|
||||||
updatePrefs(getAppRestrictBackground(), isAllowlisted, getAppRestrictAll());
|
updatePrefs(getAppRestrictBackground(), isAllowlisted, getAppRestrictAll(),
|
||||||
|
getAppRestrictCellular(), getAppRestrictVpn(), getAppRestrictWifi());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDenylistStatusChanged(int uid, boolean isDenylisted) {
|
public void onDenylistStatusChanged(int uid, boolean isDenylisted) {
|
||||||
if (mAppItem.uids.get(uid, false)) {
|
if (mAppItem.uids.get(uid, false)) {
|
||||||
updatePrefs(isDenylisted, getUnrestrictData(), getAppRestrictAll());
|
updatePrefs(isDenylisted, getUnrestrictData(), getAppRestrictAll(),
|
||||||
|
getAppRestrictCellular(), getAppRestrictVpn(), getAppRestrictWifi());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,12 +86,15 @@ public class DataSaverBackend {
|
|||||||
|
|
||||||
public void setIsAllowlisted(int uid, String packageName, boolean allowlisted) {
|
public void setIsAllowlisted(int uid, String packageName, boolean allowlisted) {
|
||||||
final int policy = allowlisted ? POLICY_ALLOW_METERED_BACKGROUND : POLICY_NONE;
|
final int policy = allowlisted ? POLICY_ALLOW_METERED_BACKGROUND : POLICY_NONE;
|
||||||
mDynamicDenylistManager.setUidPolicyLocked(uid, policy);
|
|
||||||
mUidPolicies.put(uid, policy);
|
mUidPolicies.put(uid, policy);
|
||||||
if (allowlisted) {
|
if (allowlisted) {
|
||||||
|
mPolicyManager.addUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
mContext, SettingsEnums.ACTION_DATA_SAVER_WHITELIST, packageName);
|
mContext, SettingsEnums.ACTION_DATA_SAVER_WHITELIST, packageName);
|
||||||
|
} else {
|
||||||
|
mPolicyManager.removeUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
mPolicyManager.removeUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowlisted(int uid) {
|
public boolean isAllowlisted(int uid) {
|
||||||
@@ -116,12 +119,15 @@ public class DataSaverBackend {
|
|||||||
|
|
||||||
public void setIsDenylisted(int uid, String packageName, boolean denylisted) {
|
public void setIsDenylisted(int uid, String packageName, boolean denylisted) {
|
||||||
final int policy = denylisted ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE;
|
final int policy = denylisted ? POLICY_REJECT_METERED_BACKGROUND : POLICY_NONE;
|
||||||
mDynamicDenylistManager.setUidPolicyLocked(uid, policy);
|
|
||||||
mUidPolicies.put(uid, policy);
|
mUidPolicies.put(uid, policy);
|
||||||
if (denylisted) {
|
if (denylisted) {
|
||||||
|
mPolicyManager.addUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
|
||||||
mMetricsFeatureProvider.action(
|
mMetricsFeatureProvider.action(
|
||||||
mContext, SettingsEnums.ACTION_DATA_SAVER_BLACKLIST, packageName);
|
mContext, SettingsEnums.ACTION_DATA_SAVER_BLACKLIST, packageName);
|
||||||
|
} else {
|
||||||
|
mPolicyManager.removeUidPolicy(uid, POLICY_REJECT_METERED_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
mPolicyManager.removeUidPolicy(uid, POLICY_ALLOW_METERED_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDenylisted(int uid) {
|
public boolean isDenylisted(int uid) {
|
||||||
@@ -162,6 +168,9 @@ public class DataSaverBackend {
|
|||||||
loadAllowlist();
|
loadAllowlist();
|
||||||
loadDenylist();
|
loadDenylist();
|
||||||
|
|
||||||
|
// We only care about allow/reject metered background policy here.
|
||||||
|
newPolicy &= POLICY_ALLOW_METERED_BACKGROUND | POLICY_REJECT_METERED_BACKGROUND;
|
||||||
|
|
||||||
final int oldPolicy = mUidPolicies.get(uid, POLICY_NONE);
|
final int oldPolicy = mUidPolicies.get(uid, POLICY_NONE);
|
||||||
if (newPolicy == POLICY_NONE) {
|
if (newPolicy == POLICY_NONE) {
|
||||||
mUidPolicies.delete(uid);
|
mUidPolicies.delete(uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user