Loading services/core/java/com/android/server/media/quality/MediaQualityService.java +37 −33 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,8 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.JSONObject; import java.io.File; import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -1067,35 +1069,37 @@ public class MediaQualityService extends SystemService { } } } } enum Mode { /** @hide */ ADD, @Retention(RetentionPolicy.SOURCE) UPDATE, private @interface ProfileModes { REMOVE, int ADD = 1; ERROR int UPDATE = 2; int REMOVE = 3; int ERROR = 4; } } private void notifyOnPictureProfileAdded(String profileId, PictureProfile profile, private void notifyOnPictureProfileAdded(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileUpdated(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileRemoved(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileError(String profileId, int errorCode, int uid, int pid) { 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, private void notifyPictureProfileHelper(int mode, String profileId, Integer errorCode, int uid, int pid) { PictureProfile profile, Integer errorCode, int uid, int pid) { UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); int n = userState.mPictureProfileCallbacks.beginBroadcast(); int n = userState.mPictureProfileCallbacks.beginBroadcast(); Loading @@ -1107,28 +1111,28 @@ public class MediaQualityService extends SystemService { .get(callback); .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if (pidUid.first == pid && pidUid.second == uid) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileAdded(profileId, profile); .onPictureProfileAdded(profileId, profile); } else if (mode == Mode.UPDATE) { } else if (mode == ProfileModes.UPDATE) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileUpdated(profileId, profile); .onPictureProfileUpdated(profileId, profile); } else if (mode == Mode.REMOVE) { } else if (mode == ProfileModes.REMOVE) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileRemoved(profileId, profile); .onPictureProfileRemoved(profileId, profile); } else if (mode == Mode.ERROR) { } else if (mode == ProfileModes.ERROR) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onError(profileId, errorCode); .onError(profileId, errorCode); } } } } } catch (RemoteException e) { } catch (RemoteException e) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { Slog.e(TAG, "Failed to report added picture profile to callback", e); 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); 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); 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); Slog.e(TAG, "Failed to report picture profile error to callback", e); } } } } Loading @@ -1138,25 +1142,25 @@ public class MediaQualityService extends SystemService { private void notifyOnSoundProfileAdded(String profileId, SoundProfile profile, private void notifyOnSoundProfileAdded(String profileId, SoundProfile profile, int uid, int pid) { 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, private void notifyOnSoundProfileUpdated(String profileId, SoundProfile profile, int uid, int pid) { 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, private void notifyOnSoundProfileRemoved(String profileId, SoundProfile profile, int uid, int pid) { 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) { 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, private void notifySoundProfileHelper(int mode, String profileId, Integer errorCode, int uid, int pid) { SoundProfile profile, Integer errorCode, int uid, int pid) { UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); int n = userState.mSoundProfileCallbacks.beginBroadcast(); int n = userState.mSoundProfileCallbacks.beginBroadcast(); Loading @@ -1168,28 +1172,28 @@ public class MediaQualityService extends SystemService { .get(callback); .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if (pidUid.first == pid && pidUid.second == uid) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileAdded(profileId, profile); .onSoundProfileAdded(profileId, profile); } else if (mode == Mode.UPDATE) { } else if (mode == ProfileModes.UPDATE) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileUpdated(profileId, profile); .onSoundProfileUpdated(profileId, profile); } else if (mode == Mode.REMOVE) { } else if (mode == ProfileModes.REMOVE) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileRemoved(profileId, profile); .onSoundProfileRemoved(profileId, profile); } else if (mode == Mode.ERROR) { } else if (mode == ProfileModes.ERROR) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onError(profileId, errorCode); .onError(profileId, errorCode); } } } } } catch (RemoteException e) { } catch (RemoteException e) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { Slog.e(TAG, "Failed to report added sound profile to callback", e); 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); 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); 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); Slog.e(TAG, "Failed to report sound profile error to callback", e); } } } } Loading Loading
services/core/java/com/android/server/media/quality/MediaQualityService.java +37 −33 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,8 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.JSONObject; import java.io.File; import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.HashMap; import java.util.HashMap; Loading Loading @@ -1067,35 +1069,37 @@ public class MediaQualityService extends SystemService { } } } } enum Mode { /** @hide */ ADD, @Retention(RetentionPolicy.SOURCE) UPDATE, private @interface ProfileModes { REMOVE, int ADD = 1; ERROR int UPDATE = 2; int REMOVE = 3; int ERROR = 4; } } private void notifyOnPictureProfileAdded(String profileId, PictureProfile profile, private void notifyOnPictureProfileAdded(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileUpdated(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileRemoved(String profileId, PictureProfile profile, int uid, int pid) { 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, private void notifyOnPictureProfileError(String profileId, int errorCode, int uid, int pid) { 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, private void notifyPictureProfileHelper(int mode, String profileId, Integer errorCode, int uid, int pid) { PictureProfile profile, Integer errorCode, int uid, int pid) { UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); int n = userState.mPictureProfileCallbacks.beginBroadcast(); int n = userState.mPictureProfileCallbacks.beginBroadcast(); Loading @@ -1107,28 +1111,28 @@ public class MediaQualityService extends SystemService { .get(callback); .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if (pidUid.first == pid && pidUid.second == uid) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileAdded(profileId, profile); .onPictureProfileAdded(profileId, profile); } else if (mode == Mode.UPDATE) { } else if (mode == ProfileModes.UPDATE) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileUpdated(profileId, profile); .onPictureProfileUpdated(profileId, profile); } else if (mode == Mode.REMOVE) { } else if (mode == ProfileModes.REMOVE) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onPictureProfileRemoved(profileId, profile); .onPictureProfileRemoved(profileId, profile); } else if (mode == Mode.ERROR) { } else if (mode == ProfileModes.ERROR) { userState.mPictureProfileCallbacks.getBroadcastItem(i) userState.mPictureProfileCallbacks.getBroadcastItem(i) .onError(profileId, errorCode); .onError(profileId, errorCode); } } } } } catch (RemoteException e) { } catch (RemoteException e) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { Slog.e(TAG, "Failed to report added picture profile to callback", e); 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); 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); 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); Slog.e(TAG, "Failed to report picture profile error to callback", e); } } } } Loading @@ -1138,25 +1142,25 @@ public class MediaQualityService extends SystemService { private void notifyOnSoundProfileAdded(String profileId, SoundProfile profile, private void notifyOnSoundProfileAdded(String profileId, SoundProfile profile, int uid, int pid) { 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, private void notifyOnSoundProfileUpdated(String profileId, SoundProfile profile, int uid, int pid) { 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, private void notifyOnSoundProfileRemoved(String profileId, SoundProfile profile, int uid, int pid) { 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) { 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, private void notifySoundProfileHelper(int mode, String profileId, Integer errorCode, int uid, int pid) { SoundProfile profile, Integer errorCode, int uid, int pid) { UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); UserState userState = getOrCreateUserStateLocked(UserHandle.USER_SYSTEM); int n = userState.mSoundProfileCallbacks.beginBroadcast(); int n = userState.mSoundProfileCallbacks.beginBroadcast(); Loading @@ -1168,28 +1172,28 @@ public class MediaQualityService extends SystemService { .get(callback); .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if (pidUid.first == pid && pidUid.second == uid) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileAdded(profileId, profile); .onSoundProfileAdded(profileId, profile); } else if (mode == Mode.UPDATE) { } else if (mode == ProfileModes.UPDATE) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileUpdated(profileId, profile); .onSoundProfileUpdated(profileId, profile); } else if (mode == Mode.REMOVE) { } else if (mode == ProfileModes.REMOVE) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileRemoved(profileId, profile); .onSoundProfileRemoved(profileId, profile); } else if (mode == Mode.ERROR) { } else if (mode == ProfileModes.ERROR) { userState.mSoundProfileCallbacks.getBroadcastItem(i) userState.mSoundProfileCallbacks.getBroadcastItem(i) .onError(profileId, errorCode); .onError(profileId, errorCode); } } } } } catch (RemoteException e) { } catch (RemoteException e) { if (mode == Mode.ADD) { if (mode == ProfileModes.ADD) { Slog.e(TAG, "Failed to report added sound profile to callback", e); 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); 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); 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); Slog.e(TAG, "Failed to report sound profile error to callback", e); } } } } Loading