am f3882914: Merge "Make policy data enabled flag static." into ics-mr1

* commit 'f3882914e668501ee1dabd42207ed18348050c14':
  Make policy data enabled flag static.
This commit is contained in:
Jeff Sharkey
2011-11-09 14:36:53 +00:00
committed by Android Git Automerger
3 changed files with 12 additions and 20 deletions

View File

@ -225,8 +225,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
/** Set of currently active {@link Notification} tags. */
private HashSet<String> mActiveNotifs = Sets.newHashSet();
/** Current values from {@link #setPolicyDataEnable(int, boolean)}. */
private SparseBooleanArray mActiveNetworkEnabled = new SparseBooleanArray();
/** Foreground at both UID and PID granularity. */
private SparseBooleanArray mUidForeground = new SparseBooleanArray();
@ -1519,21 +1517,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
/**
* Control {@link IConnectivityManager#setPolicyDataEnable(int, boolean)},
* dispatching only when actually changed.
* Control {@link IConnectivityManager#setPolicyDataEnable(int, boolean)}.
*/
private void setPolicyDataEnable(int networkType, boolean enabled) {
synchronized (mActiveNetworkEnabled) {
final boolean prevEnabled = mActiveNetworkEnabled.get(networkType, true);
if (prevEnabled == enabled) return;
try {
mConnManager.setPolicyDataEnable(networkType, enabled);
} catch (RemoteException e) {
// ignored; service lives in system_server
}
mActiveNetworkEnabled.put(networkType, enabled);
try {
mConnManager.setPolicyDataEnable(networkType, enabled);
} catch (RemoteException e) {
// ignored; service lives in system_server
}
}

View File

@ -167,7 +167,9 @@ public abstract class DataConnectionTracker extends Handler {
// independent of mInternalDataEnabled and requests for APN access
// persisted
protected boolean mUserDataEnabled = true;
protected boolean mPolicyDataEnabled = true;
// TODO: move away from static state once 5587429 is fixed.
protected static boolean sPolicyDataEnabled = true;
private boolean[] dataEnabled = new boolean[APN_NUM_TYPES];
@ -766,7 +768,7 @@ public abstract class DataConnectionTracker extends Handler {
public boolean getAnyDataEnabled() {
final boolean result;
synchronized (mDataEnabledLock) {
result = (mInternalDataEnabled && mUserDataEnabled && mPolicyDataEnabled
result = (mInternalDataEnabled && mUserDataEnabled && sPolicyDataEnabled
&& (enabledCount != 0));
}
if (!result && DBG) log("getAnyDataEnabled " + result);
@ -1132,8 +1134,8 @@ public abstract class DataConnectionTracker extends Handler {
protected void onSetPolicyDataEnabled(boolean enabled) {
synchronized (mDataEnabledLock) {
final boolean prevEnabled = getAnyDataEnabled();
if (mPolicyDataEnabled != enabled) {
mPolicyDataEnabled = enabled;
if (sPolicyDataEnabled != enabled) {
sPolicyDataEnabled = enabled;
if (prevEnabled != getAnyDataEnabled()) {
if (!prevEnabled) {
resetAllRetryCounts();

View File

@ -549,7 +549,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
@Override
public boolean getAnyDataEnabled() {
synchronized (mDataEnabledLock) {
if (!(mInternalDataEnabled && mUserDataEnabled && mPolicyDataEnabled)) return false;
if (!(mInternalDataEnabled && mUserDataEnabled && sPolicyDataEnabled)) return false;
for (ApnContext apnContext : mApnContexts.values()) {
// Make sure we dont have a context that going down
// and is explicitly disabled.