Commit 88cedf01 by bachinger Committed by Ian Baker

Avoid NPE in onStartCommand when action factory isn't instantiated

PiperOrigin-RevId: 431969914
parent 6c6e256c
......@@ -321,11 +321,7 @@ public abstract class MediaSessionService extends Service {
return START_STICKY;
}
DefaultActionFactory actionFactory;
synchronized (lock) {
actionFactory = checkStateNotNull(this.actionFactory);
}
DefaultActionFactory actionFactory = getActionFactory();
@Nullable Uri uri = intent.getData();
@Nullable MediaSession session = uri != null ? MediaSession.getSession(uri) : null;
if (actionFactory.isMediaAction(intent)) {
......@@ -396,15 +392,23 @@ public abstract class MediaSessionService extends Service {
if (mediaNotificationProvider == null) {
mediaNotificationProvider = new DefaultMediaNotificationProvider(getApplicationContext());
}
actionFactory = new DefaultActionFactory(/* service= */ this);
mediaNotificationManager =
new MediaNotificationManager(
/* mediaSessionService= */ this, mediaNotificationProvider, actionFactory);
/* mediaSessionService= */ this, mediaNotificationProvider, getActionFactory());
}
return mediaNotificationManager;
}
}
private DefaultActionFactory getActionFactory() {
synchronized (lock) {
if (actionFactory == null) {
actionFactory = new DefaultActionFactory(/* service= */ this);
}
return actionFactory;
}
}
private static final class MediaSessionServiceStub extends IMediaSessionService.Stub {
private final WeakReference<MediaSessionService> serviceReference;
......@@ -469,7 +473,7 @@ public abstract class MediaSessionService extends Service {
remoteUserInfo,
/* controllerVersion= */ request.version,
isTrusted,
/* controllerCb= */ null,
/* cb= */ null,
request.connectionHints);
@Nullable MediaSession session;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment