Merge "Add null pointer check for callback in HotwordDetectionConnection." into sc-dev
This commit is contained in:
@@ -103,6 +103,7 @@ final class HotwordDetectionConnection {
|
|||||||
private final AtomicBoolean mUpdateStateAfterStartFinished = new AtomicBoolean(false);
|
private final AtomicBoolean mUpdateStateAfterStartFinished = new AtomicBoolean(false);
|
||||||
private final IBinder.DeathRecipient mAudioServerDeathRecipient = this::audioServerDied;
|
private final IBinder.DeathRecipient mAudioServerDeathRecipient = this::audioServerDied;
|
||||||
private final @NonNull ServiceConnectionFactory mServiceConnectionFactory;
|
private final @NonNull ServiceConnectionFactory mServiceConnectionFactory;
|
||||||
|
private final IHotwordRecognitionStatusCallback mCallback;
|
||||||
|
|
||||||
final Object mLock;
|
final Object mLock;
|
||||||
final int mVoiceInteractionServiceUid;
|
final int mVoiceInteractionServiceUid;
|
||||||
@@ -110,7 +111,6 @@ final class HotwordDetectionConnection {
|
|||||||
final int mUser;
|
final int mUser;
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
volatile HotwordDetectionServiceIdentity mIdentity;
|
volatile HotwordDetectionServiceIdentity mIdentity;
|
||||||
private IHotwordRecognitionStatusCallback mCallback;
|
|
||||||
private IMicrophoneHotwordDetectionVoiceInteractionCallback mSoftwareCallback;
|
private IMicrophoneHotwordDetectionVoiceInteractionCallback mSoftwareCallback;
|
||||||
private Instant mLastRestartInstant;
|
private Instant mLastRestartInstant;
|
||||||
|
|
||||||
@@ -132,13 +132,19 @@ final class HotwordDetectionConnection {
|
|||||||
HotwordDetectionConnection(Object lock, Context context, int voiceInteractionServiceUid,
|
HotwordDetectionConnection(Object lock, Context context, int voiceInteractionServiceUid,
|
||||||
Identity voiceInteractorIdentity, ComponentName serviceName, int userId,
|
Identity voiceInteractorIdentity, ComponentName serviceName, int userId,
|
||||||
boolean bindInstantServiceAllowed, @Nullable PersistableBundle options,
|
boolean bindInstantServiceAllowed, @Nullable PersistableBundle options,
|
||||||
@Nullable SharedMemory sharedMemory, IHotwordRecognitionStatusCallback callback) {
|
@Nullable SharedMemory sharedMemory,
|
||||||
|
@NonNull IHotwordRecognitionStatusCallback callback) {
|
||||||
|
if (callback == null) {
|
||||||
|
Slog.w(TAG, "Callback is null while creating connection");
|
||||||
|
throw new IllegalArgumentException("Callback is null while creating connection");
|
||||||
|
}
|
||||||
mLock = lock;
|
mLock = lock;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mVoiceInteractionServiceUid = voiceInteractionServiceUid;
|
mVoiceInteractionServiceUid = voiceInteractionServiceUid;
|
||||||
mVoiceInteractorIdentity = voiceInteractorIdentity;
|
mVoiceInteractorIdentity = voiceInteractorIdentity;
|
||||||
mDetectionComponentName = serviceName;
|
mDetectionComponentName = serviceName;
|
||||||
mUser = userId;
|
mUser = userId;
|
||||||
|
mCallback = callback;
|
||||||
final Intent intent = new Intent(HotwordDetectionService.SERVICE_INTERFACE);
|
final Intent intent = new Intent(HotwordDetectionService.SERVICE_INTERFACE);
|
||||||
intent.setComponent(mDetectionComponentName);
|
intent.setComponent(mDetectionComponentName);
|
||||||
initAudioFlingerLocked();
|
initAudioFlingerLocked();
|
||||||
@@ -147,12 +153,6 @@ final class HotwordDetectionConnection {
|
|||||||
|
|
||||||
mRemoteHotwordDetectionService = mServiceConnectionFactory.createLocked();
|
mRemoteHotwordDetectionService = mServiceConnectionFactory.createLocked();
|
||||||
|
|
||||||
if (callback == null) {
|
|
||||||
updateStateLocked(options, sharedMemory);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mCallback = callback;
|
|
||||||
|
|
||||||
mLastRestartInstant = Instant.now();
|
mLastRestartInstant = Instant.now();
|
||||||
updateStateAfterProcessStart(options, sharedMemory);
|
updateStateAfterProcessStart(options, sharedMemory);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user