summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-02-07 12:05:43 -0800
committerJeff Sharkey <jsharkey@android.com>2012-02-07 12:08:58 -0800
commit1f8ea2dcd1ed3cde4b84fbb27b5a55b3fea7ff2a (patch)
tree21db818fc9acf4130663a138ea6816a1eb3aaacf /services
parent706498d387eaceb574cf4aa982fee3c288819dad (diff)
downloadframeworks_base-1f8ea2dcd1ed3cde4b84fbb27b5a55b3fea7ff2a.zip
frameworks_base-1f8ea2dcd1ed3cde4b84fbb27b5a55b3fea7ff2a.tar.gz
frameworks_base-1f8ea2dcd1ed3cde4b84fbb27b5a55b3fea7ff2a.tar.bz2
Send broadcast when changing restrict background.
When changing global restrict background status, send connectivity change broadcast, since it radically changes DISCONNECTED/BLOCKED status system-wide. Also reduce verbose stats logging. Bug: 5854466 Change-Id: I3b612c520f50cc3000a3a569b7e0ab5f691cc2bd
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/ConnectivityService.java29
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java18
-rw-r--r--services/java/com/android/server/net/NetworkStatsRecorder.java3
3 files changed, 43 insertions, 7 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index a372fb8..eab60a7 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1394,9 +1394,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
private INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() {
@Override
public void onUidRulesChanged(int uid, int uidRules) {
- // only someone like NPMS should only be calling us
- mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
-
+ // caller is NPMS, since we only register with them
if (LOGD_RULES) {
log("onUidRulesChanged(uid=" + uid + ", uidRules=" + uidRules + ")");
}
@@ -1415,9 +1413,7 @@ private NetworkStateTracker makeWimaxStateTracker() {
@Override
public void onMeteredIfacesChanged(String[] meteredIfaces) {
- // only someone like NPMS should only be calling us
- mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
-
+ // caller is NPMS, since we only register with them
if (LOGD_RULES) {
log("onMeteredIfacesChanged(ifaces=" + Arrays.toString(meteredIfaces) + ")");
}
@@ -1429,6 +1425,27 @@ private NetworkStateTracker makeWimaxStateTracker() {
}
}
}
+
+ @Override
+ public void onRestrictBackgroundChanged(boolean restrictBackground) {
+ // caller is NPMS, since we only register with them
+ if (LOGD_RULES) {
+ log("onRestrictBackgroundChanged(restrictBackground=" + restrictBackground + ")");
+ }
+
+ // kick off connectivity change broadcast for active network, since
+ // global background policy change is radical.
+ final int networkType = mActiveDefaultNetwork;
+ if (isNetworkTypeValid(networkType)) {
+ final NetworkStateTracker tracker = mNetTrackers[networkType];
+ if (tracker != null) {
+ final NetworkInfo info = tracker.getNetworkInfo();
+ if (info != null && info.isConnected()) {
+ sendConnectedBroadcast(info);
+ }
+ }
+ }
+ }
};
/**
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 9772d6a..a890068 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -195,6 +195,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final int MSG_FOREGROUND_ACTIVITIES_CHANGED = 3;
private static final int MSG_PROCESS_DIED = 4;
private static final int MSG_LIMIT_REACHED = 5;
+ private static final int MSG_RESTRICT_BACKGROUND_CHANGED = 6;
private final Context mContext;
private final IActivityManager mActivityManager;
@@ -1225,6 +1226,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
updateNotificationsLocked();
writePolicyLocked();
}
+
+ mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_CHANGED, restrictBackground ? 1 : 0, 0)
+ .sendToTarget();
}
@Override
@@ -1573,6 +1577,20 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
return true;
}
+ case MSG_RESTRICT_BACKGROUND_CHANGED: {
+ final boolean restrictBackground = msg.arg1 != 0;
+ final int length = mListeners.beginBroadcast();
+ for (int i = 0; i < length; i++) {
+ final INetworkPolicyListener listener = mListeners.getBroadcastItem(i);
+ if (listener != null) {
+ try {
+ listener.onRestrictBackgroundChanged(restrictBackground);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ mListeners.finishBroadcast();
+ }
default: {
return false;
}
diff --git a/services/java/com/android/server/net/NetworkStatsRecorder.java b/services/java/com/android/server/net/NetworkStatsRecorder.java
index e7ba358..240cc1c 100644
--- a/services/java/com/android/server/net/NetworkStatsRecorder.java
+++ b/services/java/com/android/server/net/NetworkStatsRecorder.java
@@ -51,6 +51,7 @@ import java.util.Map;
public class NetworkStatsRecorder {
private static final String TAG = "NetworkStatsRecorder";
private static final boolean LOGD = true;
+ private static final boolean LOGV = false;
private final FileRotator mRotator;
private final NonMonotonicObserver<String> mObserver;
@@ -170,7 +171,7 @@ public class NetworkStatsRecorder {
mLastSnapshot = snapshot;
- if (LOGD && unknownIfaces.size() > 0) {
+ if (LOGV && unknownIfaces.size() > 0) {
Slog.w(TAG, "unknown interfaces " + unknownIfaces + ", ignoring those stats");
}
}