Merge "Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."" into main

This commit is contained in:
Junyu Lai 2023-10-25 01:59:12 +00:00 • committed by Gerrit Code Review
commit 0cfaea8d98

View file

@ -12586,6 +12586,20 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
@Override
public void setDataSaverEnabled(final boolean enable) {
enforceNetworkStackOrSettingsPermission();
try {
final boolean ret = mNetd.bandwidthEnableDataSaver(enable);
if (!ret) {
throw new IllegalStateException("Error when changing iptables: " + enable);
}
} catch (RemoteException e) {
// Lack of permission or binder errors.
throw new IllegalStateException(e);
}
}
@Override
public void updateMeteredNetworkAllowList(final int uid, final boolean add) {
enforceNetworkStackOrSettingsPermission();