mirror of
https://github.com/samsonjs/media.git
synced 2026-04-18 13:25:47 +00:00
Avoid NPE in onStartCommand when action factory isn't instantiated
PiperOrigin-RevId: 431969914
This commit is contained in:
parent
6c6e256cfb
commit
88cedf010c
1 changed files with 12 additions and 8 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue