From 32e90552a597f65c469d016e6354977c90549cba Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Tue, 12 Feb 2019 23:06:46 +0900 Subject: [PATCH] MediaSessionService: Replace Log.wtf() with Log.w() Log.wtf() should be used only if it's enough to restart system, so replace it with Log.w() when it's not. Bug: 118987354 Test: Build Change-Id: If40f5519d36c40873dba8f6eaae9fd5a7f92c753 --- .../server/media/MediaSessionServiceImpl.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/media/MediaSessionServiceImpl.java b/services/core/java/com/android/server/media/MediaSessionServiceImpl.java index 5c7317892f3f7..62d9b20b636d4 100644 --- a/services/core/java/com/android/server/media/MediaSessionServiceImpl.java +++ b/services/core/java/com/android/server/media/MediaSessionServiceImpl.java @@ -284,13 +284,16 @@ public class MediaSessionServiceImpl extends MediaSessionService.ServiceImpl { * Tells the system UI that volume has changed on an active remote session. */ public void notifyRemoteVolumeChanged(int flags, MediaSessionRecord session) { - if (mRvc == null || !session.isActive()) { - return; - } - try { - mRvc.remoteVolumeChanged(session.getSessionToken(), flags); - } catch (Exception e) { - Log.wtf(TAG, "Error sending volume change to system UI.", e); + synchronized (mLock) { + if (mRvc == null || !session.isActive()) { + return; + } + try { + mRvc.remoteVolumeChanged(session.getSessionToken(), flags); + } catch (Exception e) { + Log.w(TAG, "Error sending volume change to system UI.", e); + mRvc = null; + } } } @@ -563,7 +566,7 @@ public class MediaSessionServiceImpl extends MediaSessionService.ServiceImpl { String callerPackageName, SessionCallbackLink cb, String tag) { FullUserRecord user = getFullUserRecordLocked(userId); if (user == null) { - Log.wtf(TAG, "Request from invalid user: " + userId); + Log.w(TAG, "Request from invalid user: " + userId + ", pkg=" + callerPackageName); throw new RuntimeException("Session request from invalid user."); } @@ -643,7 +646,8 @@ public class MediaSessionServiceImpl extends MediaSessionService.ServiceImpl { MediaSessionRecord record = user.mPriorityStack.getDefaultRemoteSession(userId); mRvc.updateRemoteController(record == null ? null : record.getSessionToken()); } catch (RemoteException e) { - Log.wtf(TAG, "Error sending default remote volume to sys ui.", e); + Log.w(TAG, "Error sending default remote volume to sys ui.", e); + mRvc = null; } } } @@ -1661,7 +1665,9 @@ public class MediaSessionServiceImpl extends MediaSessionService.ServiceImpl { final long token = Binder.clearCallingIdentity(); try { enforceSystemUiPermission("listen for volume changes", pid, uid); - mRvc = rvc; + synchronized (mLock) { + mRvc = rvc; + } } finally { Binder.restoreCallingIdentity(token); }