summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-02-28 22:49:57 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-02-28 22:50:00 +0000
commita140c067c2881120ebc0df2d5dc6982d36f18cb3 (patch)
treeceeb147c2c6004b22942ccb5eac8586de6e5a536
parente89454ed8426f50522b0a4cbb49046ab2874401e (diff)
parente9052a3cbc1d8580f48548927a108d7d8262911a (diff)
Merge "Cleanup else blocks on security checks."
-rw-r--r--core/java/android/net/NetworkScoreManager.java4
-rw-r--r--services/core/java/com/android/server/NetworkScoreService.java18
2 files changed, 11 insertions, 11 deletions
diff --git a/core/java/android/net/NetworkScoreManager.java b/core/java/android/net/NetworkScoreManager.java
index 815d4807a39e..f0bea5b8e0ad 100644
--- a/core/java/android/net/NetworkScoreManager.java
+++ b/core/java/android/net/NetworkScoreManager.java
@@ -265,8 +265,8 @@ public class NetworkScoreManager {
* the {@link #ACTION_CHANGE_ACTIVE} broadcast, or using a custom configuration activity.
*
* @return true if the operation succeeded, or false if the new package is not a valid scorer.
- * @throws SecurityException if the caller does not hold the
- * {@link android.Manifest.permission#SCORE_NETWORKS} permission.
+ * @throws SecurityException if the caller is not a system process or does not hold the
+ * {@link android.Manifest.permission#REQUEST_NETWORK_SCORES} permission
* @hide
*/
@SystemApi
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index d54ebaafb5bb..b83dbd686ae5 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -663,12 +663,12 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
@Override
public boolean setActiveScorer(String packageName) {
// Only the system can set the active scorer
- if (isCallerSystemProcess(getCallingUid()) || callerCanRequestScores()) {
- return mNetworkScorerAppManager.setActiveScorer(packageName);
- } else {
+ if (!isCallerSystemProcess(getCallingUid()) || !callerCanRequestScores()) {
throw new SecurityException(
"Caller is neither the system process nor a score requester.");
}
+
+ return mNetworkScorerAppManager.setActiveScorer(packageName);
}
/**
@@ -732,23 +732,23 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
@Override
public List<NetworkScorerAppData> getAllValidScorers() {
// Only the system can access this data.
- if (isCallerSystemProcess(getCallingUid()) || callerCanRequestScores()) {
- return mNetworkScorerAppManager.getAllValidScorers();
- } else {
+ if (!isCallerSystemProcess(getCallingUid()) || !callerCanRequestScores()) {
throw new SecurityException(
"Caller is neither the system process nor a score requester.");
}
+
+ return mNetworkScorerAppManager.getAllValidScorers();
}
@Override
public void disableScoring() {
// Only the active scorer or the system should be allowed to disable scoring.
- if (isCallerActiveScorer(getCallingUid()) || callerCanRequestScores()) {
- // no-op for now but we could write to the setting if needed.
- } else {
+ if (!isCallerActiveScorer(getCallingUid()) || !callerCanRequestScores()) {
throw new SecurityException(
"Caller is neither the active scorer nor the scorer manager.");
}
+
+ // no-op for now but we could write to the setting if needed.
}
/** Clear scores. Callers are responsible for checking permissions as appropriate. */