mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultActionFactory actionFactory;
|
DefaultActionFactory actionFactory = getActionFactory();
|
||||||
synchronized (lock) {
|
|
||||||
actionFactory = checkStateNotNull(this.actionFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable Uri uri = intent.getData();
|
@Nullable Uri uri = intent.getData();
|
||||||
@Nullable MediaSession session = uri != null ? MediaSession.getSession(uri) : null;
|
@Nullable MediaSession session = uri != null ? MediaSession.getSession(uri) : null;
|
||||||
if (actionFactory.isMediaAction(intent)) {
|
if (actionFactory.isMediaAction(intent)) {
|
||||||
|
|
@ -396,15 +392,23 @@ public abstract class MediaSessionService extends Service {
|
||||||
if (mediaNotificationProvider == null) {
|
if (mediaNotificationProvider == null) {
|
||||||
mediaNotificationProvider = new DefaultMediaNotificationProvider(getApplicationContext());
|
mediaNotificationProvider = new DefaultMediaNotificationProvider(getApplicationContext());
|
||||||
}
|
}
|
||||||
actionFactory = new DefaultActionFactory(/* service= */ this);
|
|
||||||
mediaNotificationManager =
|
mediaNotificationManager =
|
||||||
new MediaNotificationManager(
|
new MediaNotificationManager(
|
||||||
/* mediaSessionService= */ this, mediaNotificationProvider, actionFactory);
|
/* mediaSessionService= */ this, mediaNotificationProvider, getActionFactory());
|
||||||
}
|
}
|
||||||
return mediaNotificationManager;
|
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 static final class MediaSessionServiceStub extends IMediaSessionService.Stub {
|
||||||
|
|
||||||
private final WeakReference<MediaSessionService> serviceReference;
|
private final WeakReference<MediaSessionService> serviceReference;
|
||||||
|
|
@ -469,7 +473,7 @@ public abstract class MediaSessionService extends Service {
|
||||||
remoteUserInfo,
|
remoteUserInfo,
|
||||||
/* controllerVersion= */ request.version,
|
/* controllerVersion= */ request.version,
|
||||||
isTrusted,
|
isTrusted,
|
||||||
/* controllerCb= */ null,
|
/* cb= */ null,
|
||||||
request.connectionHints);
|
request.connectionHints);
|
||||||
|
|
||||||
@Nullable MediaSession session;
|
@Nullable MediaSession session;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue