Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a140c067 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Cleanup else blocks on security checks."

parents e89454ed e9052a3c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+9 −9
Original line number Diff line number Diff line
@@ -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. */