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

Commit 1fdd6265 authored by Zoey Chen's avatar Zoey Chen
Browse files

[ToA] Check CHANGE_CONFIGURATION permission if the caller is not system

Bug: 328345585
Test: manual
Change-Id: I273d7286ef3bf915350fe9f8956d62ce02c48a97
parent 260d9c9e
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.");
        }
    }