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

Commit 7676e823 authored by Zoey Chen's avatar Zoey Chen Committed by Android (Google) Code Review
Browse files

Merge "[ToA] Check CHANGE_CONFIGURATION permission if the caller is not system" into main

parents cb2fd331 1fdd6265
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public class GrammaticalInflectionService extends SystemService {

        @Override
        public void setSystemWideGrammaticalGender(int grammaticalGender, int userId) {
            checkCallerIsSystem();
            isCallerAllowed();
            GrammaticalInflectionService.this.setSystemWideGrammaticalGender(grammaticalGender,
                    userId);
        }
@@ -154,7 +154,7 @@ public class GrammaticalInflectionService extends SystemService {
        @Override
        @Nullable
        public byte[] getBackupPayload(int userId) {
            checkCallerIsSystem();
            isCallerAllowed();
            return mBackupHelper.getBackupPayload(userId);
        }

@@ -333,11 +333,13 @@ public class GrammaticalInflectionService extends SystemService {
        return GRAMMATICAL_GENDER_NOT_SPECIFIED;
    }

    private void checkCallerIsSystem() {
    private void isCallerAllowed() {
        int callingUid = Binder.getCallingUid();
        if (callingUid != Process.SYSTEM_UID && callingUid != Process.SHELL_UID
                && callingUid != Process.ROOT_UID) {
            throw new SecurityException("Caller is not system, shell and root.");
            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.CHANGE_CONFIGURATION,
                    "Caller must be system, shell, root or has CHANGE_CONFIGURATION permission.");
        }
    }