Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev
am: bc26d925c6
* commit 'bc26d925c62968c0728a524a45c6e60f2b8fb781':
Fixed connectivity state in some power saving scenarios.
Change-Id: I7ebe3864657d2147034ffae400312e94deb5ef35
This commit is contained in:
@@ -33,6 +33,7 @@ import static android.net.NetworkPolicyManager.RULE_ALLOW_METERED;
|
||||
import static android.net.NetworkPolicyManager.MASK_METERED_NETWORKS;
|
||||
import static android.net.NetworkPolicyManager.MASK_ALL_NETWORKS;
|
||||
import static android.net.NetworkPolicyManager.RULE_NONE;
|
||||
import static android.net.NetworkPolicyManager.RULE_REJECT_ALL;
|
||||
import static android.net.NetworkPolicyManager.RULE_REJECT_METERED;
|
||||
import static android.net.NetworkPolicyManager.RULE_TEMPORARY_ALLOW_METERED;
|
||||
import static android.net.NetworkPolicyManager.uidRulesToString;
|
||||
@@ -218,9 +219,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
/** Flag indicating if background data is restricted. */
|
||||
@GuardedBy("mRulesLock")
|
||||
private boolean mRestrictBackground;
|
||||
/** Flag indicating if background data is restricted due to battery savings. */
|
||||
@GuardedBy("mRulesLock")
|
||||
private boolean mRestrictPower;
|
||||
|
||||
final private Context mContext;
|
||||
private int mNetworkPreference;
|
||||
@@ -669,7 +667,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
try {
|
||||
mPolicyManager.setConnectivityListener(mPolicyListener);
|
||||
mRestrictBackground = mPolicyManager.getRestrictBackground();
|
||||
mRestrictPower = mPolicyManager.getRestrictPower();
|
||||
} catch (RemoteException e) {
|
||||
// ouch, no rules updates means some processes may never get network
|
||||
loge("unable to register INetworkPolicyListener" + e);
|
||||
@@ -942,13 +939,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
+ ": " + allowed);
|
||||
}
|
||||
}
|
||||
// ...then Battery Saver Mode.
|
||||
if (allowed && mRestrictPower) {
|
||||
allowed = (uidRules & RULE_ALLOW_ALL) != 0;
|
||||
// ...then power restrictions.
|
||||
if (allowed) {
|
||||
allowed = (uidRules & RULE_REJECT_ALL) == 0;
|
||||
if (LOGD_RULES) Log.d(TAG, "allowed status for uid " + uid + " when"
|
||||
+ " mRestrictPower=" + mRestrictPower
|
||||
+ ", whitelisted=" + ((uidRules & RULE_ALLOW_ALL) != 0)
|
||||
+ ": " + allowed);
|
||||
+ " rule is " + uidRulesToString(uidRules) + ": " + allowed);
|
||||
}
|
||||
return !allowed;
|
||||
}
|
||||
@@ -1400,8 +1395,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
final int oldRules = mUidRules.get(uid, RULE_NONE);
|
||||
if (oldRules == uidRules) return;
|
||||
|
||||
if (uidRules == RULE_NONE) {
|
||||
mUidRules.delete(uid);
|
||||
} else {
|
||||
mUidRules.put(uid, uidRules);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: notify UID when it has requested targeted updates
|
||||
}
|
||||
@@ -1438,18 +1437,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestrictPowerChanged(boolean restrictPower) {
|
||||
// caller is NPMS, since we only register with them
|
||||
if (LOGD_RULES) {
|
||||
log("onRestrictPowerChanged(restrictPower=" + restrictPower + ")");
|
||||
}
|
||||
|
||||
synchronized (mRulesLock) {
|
||||
mRestrictPower = restrictPower;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestrictBackgroundWhitelistChanged(int uid, boolean whitelisted) {
|
||||
if (LOGD_RULES) {
|
||||
@@ -1891,10 +1878,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
pw.println(mRestrictBackground);
|
||||
pw.println();
|
||||
|
||||
pw.print("Restrict power: ");
|
||||
pw.println(mRestrictPower);
|
||||
pw.println();
|
||||
|
||||
pw.println("Status for known UIDs:");
|
||||
pw.increaseIndent();
|
||||
final int size = mUidRules.size();
|
||||
|
||||
Reference in New Issue
Block a user