Merge "MediaSessionService: Leave log for any session creation failure" into rvc-dev am: 0d2eacc86e

Change-Id: I4d341f4cd314ec1cb734b9d0fa77a31834695c0e
This commit is contained in:
TreeHugger Robot
2020-05-18 09:12:00 +00:00
committed by Automerger Merge Worker

View File

@@ -1134,8 +1134,19 @@ public class MediaSessionService extends SystemService implements Monitor {
if (cb == null) {
throw new IllegalArgumentException("Controller callback cannot be null");
}
return createSessionInternal(pid, uid, resolvedUserId, packageName, cb, tag,
sessionInfo).getSessionBinder();
MediaSessionRecord session = createSessionInternal(
pid, uid, resolvedUserId, packageName, cb, tag, sessionInfo);
if (session == null) {
throw new IllegalStateException("Failed to create a new session record");
}
ISession sessionBinder = session.getSessionBinder();
if (sessionBinder == null) {
throw new IllegalStateException("Invalid session record");
}
return sessionBinder;
} catch (Exception e) {
Slog.w(TAG, "Exception in creating a new session", e);
throw e;
} finally {
Binder.restoreCallingIdentity(token);
}