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

Commit d1937e6d authored by Haofan Wang's avatar Haofan Wang
Browse files

Fix permission check

The permission check compares profile name with package name which is
incorrect. Fix it to compare the packageNameForUid to package name of
the profile.

Test: Gambit
Bug: 425593849
Flag: EXEMPT bugfix
Change-Id: I7d515f88c9529c63cab7f85e478894b9f62f5e1a
parent 9dd52325
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -317,6 +317,9 @@ public class MediaQualityService extends SystemService {
                                    : pp.getPackageName(),
                            pp.getInputId(), pp.getParameters());

                    if (DEBUG) {
                        Slog.d(TAG, "insert " + pp.getName() + " to database");
                    }
                    // id is auto-generated by SQLite upon successful insertion of row
                    Long id = db.insert(
                            mMediaQualityDbHelper.PICTURE_QUALITY_TABLE_NAME, null, values);
@@ -484,7 +487,7 @@ public class MediaQualityService extends SystemService {

        private boolean hasPermissionToRemovePictureProfile(PictureProfile toDelete, int uid) {
            if (toDelete != null) {
                return toDelete.getName().equalsIgnoreCase(getPackageOfUid(uid));
                return toDelete.getPackageName().equalsIgnoreCase(getPackageOfUid(uid));
            }
            return false;
        }
@@ -971,7 +974,7 @@ public class MediaQualityService extends SystemService {
            return fromDb.getProfileType() == sp.getProfileType()
                    && fromDb.getPackageName().equals(sp.getPackageName())
                    && fromDb.getName().equals(sp.getName())
                    && fromDb.getName().equals(getPackageOfUid(uid));
                    && fromDb.getPackageName().equals(getPackageOfUid(uid));
        }

        @GuardedBy("mSoundProfileLock")
@@ -1015,7 +1018,7 @@ public class MediaQualityService extends SystemService {

        private boolean hasPermissionToRemoveSoundProfile(SoundProfile toDelete, int uid) {
            if (toDelete != null) {
                return toDelete.getName().equalsIgnoreCase(getPackageOfUid(uid));
                return toDelete.getPackageName().equalsIgnoreCase(getPackageOfUid(uid));
            }
            return false;
        }