summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2016-12-22 00:29:21 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-12-22 00:29:24 +0000
commitfa83dea8a28dd706a59bc4c63f507e9d24fcdd8c (patch)
tree56b4354c3ff46c1109315db6c78d26ed05d6ba00
parent9dc0bdeffdf1994cb4b7fbec79ab21df6e8c257c (diff)
parent86c2a5ecb523d50d2cd93360d0f9a5cc65c8191b (diff)
Merge "Cleanup the evaluateBinding() method."
-rw-r--r--services/core/java/com/android/server/NetworkScoreService.java56
1 files changed, 29 insertions, 27 deletions
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index 496d5d032d96..fe815368b756 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -146,37 +146,39 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
}
private void evaluateBinding(String scorerPackageName, boolean forceUnbind) {
- if (mPackagesToWatch.contains(scorerPackageName)) {
+ if (!mPackagesToWatch.contains(scorerPackageName)) {
+ // Early exit when we don't care about the package that has changed.
+ return;
+ }
+
+ if (DBG) {
+ Log.d(TAG, "Evaluating binding for: " + scorerPackageName
+ + ", forceUnbind=" + forceUnbind);
+ }
+ final NetworkScorerAppData activeScorer = mNetworkScorerAppManager.getActiveScorer();
+ if (activeScorer == null) {
+ // Package change has invalidated a scorer, this will also unbind any service
+ // connection.
+ if (DBG) Log.d(TAG, "No active scorers available.");
+ unbindFromScoringServiceIfNeeded();
+ } else if (activeScorer.packageName.equals(scorerPackageName)) {
+ // The active scoring service changed in some way.
if (DBG) {
- Log.d(TAG, "Evaluating binding for: " + scorerPackageName
- + ", forceUnbind=" + forceUnbind);
+ Log.d(TAG, "Possible change to the active scorer: "
+ + activeScorer.packageName);
}
- final NetworkScorerAppData activeScorer =
- mNetworkScorerAppManager.getActiveScorer();
- if (activeScorer == null) {
- // Package change has invalidated a scorer, this will also unbind any service
- // connection.
- if (DBG) Log.d(TAG, "No active scorers available.");
+ if (forceUnbind) {
unbindFromScoringServiceIfNeeded();
- } else if (activeScorer.packageName.equals(scorerPackageName)) {
- // The active scoring service changed in some way.
- if (DBG) {
- Log.d(TAG, "Possible change to the active scorer: "
- + activeScorer.packageName);
- }
- if (forceUnbind) {
- unbindFromScoringServiceIfNeeded();
- }
- bindToScoringServiceIfNeeded(activeScorer);
- } else {
- // One of the scoring apps on the device has changed and we may no longer be
- // bound to the correct scoring app. The logic in bindToScoringServiceIfNeeded()
- // will sort that out to leave us bound to the most recent active scorer.
- if (DBG) {
- Log.d(TAG, "Binding to " + activeScorer.packageName + " if needed.");
- }
- bindToScoringServiceIfNeeded(activeScorer);
}
+ bindToScoringServiceIfNeeded(activeScorer);
+ } else {
+ // One of the scoring apps on the device has changed and we may no longer be
+ // bound to the correct scoring app. The logic in bindToScoringServiceIfNeeded()
+ // will sort that out to leave us bound to the most recent active scorer.
+ if (DBG) {
+ Log.d(TAG, "Binding to " + activeScorer.packageName + " if needed.");
+ }
+ bindToScoringServiceIfNeeded(activeScorer);
}
}
}