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

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

Merge "[MediaQuality] Change from Enum to IntDef" into main

parents ac044964 ab2ec4b1
Loading
Loading
Loading
Loading
+37 −33
Original line number Diff line number Diff line
@@ -72,6 +72,8 @@ import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -1067,35 +1069,37 @@ public class MediaQualityService extends SystemService {
            }
        }

        enum Mode {
            ADD,
            UPDATE,
            REMOVE,
            ERROR
        /** @hide */
        @Retention(RetentionPolicy.SOURCE)
        private @interface ProfileModes {
            int ADD = 1;
            int UPDATE = 2;
            int REMOVE = 3;
            int ERROR = 4;
        }

        private void notifyOnPictureProfileAdded(String profileId, PictureProfile profile,
                int uid, int pid) {
            notifyPictureProfileHelper(Mode.ADD, profileId, profile, null, uid, pid);
            notifyPictureProfileHelper(ProfileModes.ADD, profileId, profile, null, uid, pid);
        }

        private void notifyOnPictureProfileUpdated(String profileId, PictureProfile profile,
                int uid, int pid) {
            notifyPictureProfileHelper(Mode.UPDATE, profileId, profile, null, uid, pid);
            notifyPictureProfileHelper(ProfileModes.UPDATE, profileId, profile, null, uid, pid);
        }

        private void notifyOnPictureProfileRemoved(String profileId, PictureProfile profile,
                int uid, int pid) {
            notifyPictureProfileHelper(Mode.REMOVE, profileId, profile, null, uid, pid);
            notifyPictureProfileHelper(ProfileModes.REMOVE, profileId, profile, null, uid, pid);
        }

        private void notifyOnPictureProfileError(String profileId, int errorCode,
                int uid, int pid) {
            notifyPictureProfileHelper(Mode.ERROR, profileId, null, errorCode, uid, pid);
            notifyPictureProfileHelper(ProfileModes.ERROR, profileId, null, errorCode, uid, pid);
        }

        private void notifyPictureProfileHelper(Mode mode, String profileId, PictureProfile profile,
                Integer errorCode, int uid, int pid) {
        private void notifyPictureProfileHelper(int mode, String profileId,
                PictureProfile profile, Integer errorCode, int uid, int pid) {
            UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM);
            int n = userState.mPictureProfileCallbacks.beginBroadcast();

@@ -1107,28 +1111,28 @@ public class MediaQualityService extends SystemService {
                            .get(callback);

                    if (pidUid.first == pid && pidUid.second == uid) {
                        if (mode == Mode.ADD) {
                        if (mode == ProfileModes.ADD) {
                            userState.mPictureProfileCallbacks.getBroadcastItem(i)
                                    .onPictureProfileAdded(profileId, profile);
                        } else if (mode == Mode.UPDATE) {
                        } else if (mode == ProfileModes.UPDATE) {
                            userState.mPictureProfileCallbacks.getBroadcastItem(i)
                                    .onPictureProfileUpdated(profileId, profile);
                        } else if (mode == Mode.REMOVE) {
                        } else if (mode == ProfileModes.REMOVE) {
                            userState.mPictureProfileCallbacks.getBroadcastItem(i)
                                    .onPictureProfileRemoved(profileId, profile);
                        } else if (mode == Mode.ERROR) {
                        } else if (mode == ProfileModes.ERROR) {
                            userState.mPictureProfileCallbacks.getBroadcastItem(i)
                                    .onError(profileId, errorCode);
                        }
                    }
                } catch (RemoteException e) {
                    if (mode == Mode.ADD) {
                    if (mode == ProfileModes.ADD) {
                        Slog.e(TAG, "Failed to report added picture profile to callback", e);
                    } else if (mode == Mode.UPDATE) {
                    } else if (mode == ProfileModes.UPDATE) {
                        Slog.e(TAG, "Failed to report updated picture profile to callback", e);
                    } else if (mode == Mode.REMOVE) {
                    } else if (mode == ProfileModes.REMOVE) {
                        Slog.e(TAG, "Failed to report removed picture profile to callback", e);
                    } else if (mode == Mode.ERROR) {
                    } else if (mode == ProfileModes.ERROR) {
                        Slog.e(TAG, "Failed to report picture profile error to callback", e);
                    }
                }
@@ -1138,25 +1142,25 @@ public class MediaQualityService extends SystemService {

        private void notifyOnSoundProfileAdded(String profileId, SoundProfile profile,
                int uid, int pid) {
            notifySoundProfileHelper(Mode.ADD, profileId, profile, null, uid, pid);
            notifySoundProfileHelper(ProfileModes.ADD, profileId, profile, null, uid, pid);
        }

        private void notifyOnSoundProfileUpdated(String profileId, SoundProfile profile,
                int uid, int pid) {
            notifySoundProfileHelper(Mode.UPDATE, profileId, profile, null, uid, pid);
            notifySoundProfileHelper(ProfileModes.UPDATE, profileId, profile, null, uid, pid);
        }

        private void notifyOnSoundProfileRemoved(String profileId, SoundProfile profile,
                int uid, int pid) {
            notifySoundProfileHelper(Mode.REMOVE, profileId, profile, null, uid, pid);
            notifySoundProfileHelper(ProfileModes.REMOVE, profileId, profile, null, uid, pid);
        }

        private void notifyOnSoundProfileError(String profileId, int errorCode, int uid, int pid) {
            notifySoundProfileHelper(Mode.ERROR, profileId, null, errorCode, uid, pid);
            notifySoundProfileHelper(ProfileModes.ERROR, profileId, null, errorCode, uid, pid);
        }

        private void notifySoundProfileHelper(Mode mode, String profileId, SoundProfile profile,
                Integer errorCode, int uid, int pid) {
        private void notifySoundProfileHelper(int mode, String profileId,
                SoundProfile profile, Integer errorCode, int uid, int pid) {
            UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM);
            int n = userState.mSoundProfileCallbacks.beginBroadcast();

@@ -1168,28 +1172,28 @@ public class MediaQualityService extends SystemService {
                            .get(callback);

                    if (pidUid.first == pid && pidUid.second == uid) {
                        if (mode == Mode.ADD) {
                        if (mode == ProfileModes.ADD) {
                            userState.mSoundProfileCallbacks.getBroadcastItem(i)
                                    .onSoundProfileAdded(profileId, profile);
                        } else if (mode == Mode.UPDATE) {
                        } else if (mode == ProfileModes.UPDATE) {
                            userState.mSoundProfileCallbacks.getBroadcastItem(i)
                                    .onSoundProfileUpdated(profileId, profile);
                        } else if (mode == Mode.REMOVE) {
                        } else if (mode == ProfileModes.REMOVE) {
                            userState.mSoundProfileCallbacks.getBroadcastItem(i)
                                    .onSoundProfileRemoved(profileId, profile);
                        } else if (mode == Mode.ERROR) {
                        } else if (mode == ProfileModes.ERROR) {
                            userState.mSoundProfileCallbacks.getBroadcastItem(i)
                                    .onError(profileId, errorCode);
                        }
                    }
                } catch (RemoteException e) {
                    if (mode == Mode.ADD) {
                    if (mode == ProfileModes.ADD) {
                        Slog.e(TAG, "Failed to report added sound profile to callback", e);
                    } else if (mode == Mode.UPDATE) {
                    } else if (mode == ProfileModes.UPDATE) {
                        Slog.e(TAG, "Failed to report updated sound profile to callback", e);
                    } else if (mode == Mode.REMOVE) {
                    } else if (mode == ProfileModes.REMOVE) {
                        Slog.e(TAG, "Failed to report removed sound profile to callback", e);
                    } else if (mode == Mode.ERROR) {
                    } else if (mode == ProfileModes.ERROR) {
                        Slog.e(TAG, "Failed to report sound profile error to callback", e);
                    }
                }