Merge "Fix for NetworkStats/Telephony deadlock"
am: 0d4445f1e0
Change-Id: I4436ada416d0c643b226656e4c4b6b87572b4730
This commit is contained in:
@ -3462,9 +3462,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
/**
|
/**
|
||||||
* Process state of UID changed; if needed, will trigger
|
* Process state of UID changed; if needed, will trigger
|
||||||
* {@link #updateRulesForDataUsageRestrictionsUL(int)} and
|
* {@link #updateRulesForDataUsageRestrictionsUL(int)} and
|
||||||
* {@link #updateRulesForPowerRestrictionsUL(int)}
|
* {@link #updateRulesForPowerRestrictionsUL(int)}. Returns true if the state was updated.
|
||||||
*/
|
*/
|
||||||
private void updateUidStateUL(int uid, int uidState) {
|
private boolean updateUidStateUL(int uid, int uidState) {
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateUidStateUL");
|
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateUidStateUL");
|
||||||
try {
|
try {
|
||||||
final int oldUidState = mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY);
|
final int oldUidState = mUidState.get(uid, ActivityManager.PROCESS_STATE_CACHED_EMPTY);
|
||||||
@ -3483,14 +3483,15 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
updateRulesForPowerRestrictionsUL(uid);
|
updateRulesForPowerRestrictionsUL(uid);
|
||||||
}
|
}
|
||||||
updateNetworkStats(uid, isUidStateForeground(uidState));
|
return true;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeUidStateUL(int uid) {
|
private boolean removeUidStateUL(int uid) {
|
||||||
final int index = mUidState.indexOfKey(uid);
|
final int index = mUidState.indexOfKey(uid);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
final int oldUidState = mUidState.valueAt(index);
|
final int oldUidState = mUidState.valueAt(index);
|
||||||
@ -3505,9 +3506,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
updateRuleForRestrictPowerUL(uid);
|
updateRuleForRestrictPowerUL(uid);
|
||||||
}
|
}
|
||||||
updateRulesForPowerRestrictionsUL(uid);
|
updateRulesForPowerRestrictionsUL(uid);
|
||||||
updateNetworkStats(uid, false);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust stats accounting based on foreground status
|
// adjust stats accounting based on foreground status
|
||||||
@ -4419,21 +4421,26 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleUidChanged(int uid, int procState, long procStateSeq) {
|
void handleUidChanged(int uid, int procState, long procStateSeq) {
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidStateChanged");
|
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidStateChanged");
|
||||||
try {
|
try {
|
||||||
|
boolean updated;
|
||||||
synchronized (mUidRulesFirstLock) {
|
synchronized (mUidRulesFirstLock) {
|
||||||
// We received a uid state change callback, add it to the history so that it
|
// We received a uid state change callback, add it to the history so that it
|
||||||
// will be useful for debugging.
|
// will be useful for debugging.
|
||||||
mLogger.uidStateChanged(uid, procState, procStateSeq);
|
mLogger.uidStateChanged(uid, procState, procStateSeq);
|
||||||
// Now update the network policy rules as per the updated uid state.
|
// Now update the network policy rules as per the updated uid state.
|
||||||
updateUidStateUL(uid, procState);
|
updated = updateUidStateUL(uid, procState);
|
||||||
// Updating the network rules is done, so notify AMS about this.
|
// Updating the network rules is done, so notify AMS about this.
|
||||||
mActivityManagerInternal.notifyNetworkPolicyRulesUpdated(uid, procStateSeq);
|
mActivityManagerInternal.notifyNetworkPolicyRulesUpdated(uid, procStateSeq);
|
||||||
}
|
}
|
||||||
|
// Do this without the lock held. handleUidChanged() and handleUidGone() are
|
||||||
|
// called from the handler, so there's no multi-threading issue.
|
||||||
|
if (updated) {
|
||||||
|
updateNetworkStats(uid, isUidStateForeground(procState));
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
||||||
}
|
}
|
||||||
@ -4442,8 +4449,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
void handleUidGone(int uid) {
|
void handleUidGone(int uid) {
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidGone");
|
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "onUidGone");
|
||||||
try {
|
try {
|
||||||
|
boolean updated;
|
||||||
synchronized (mUidRulesFirstLock) {
|
synchronized (mUidRulesFirstLock) {
|
||||||
removeUidStateUL(uid);
|
updated = removeUidStateUL(uid);
|
||||||
|
}
|
||||||
|
// Do this without the lock held. handleUidChanged() and handleUidGone() are
|
||||||
|
// called from the handler, so there's no multi-threading issue.
|
||||||
|
if (updated) {
|
||||||
|
updateNetworkStats(uid, false);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
Trace.traceEnd(Trace.TRACE_TAG_NETWORK);
|
||||||
|
Reference in New Issue
Block a user