Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35496c27 authored by Hall Liu's avatar Hall Liu
Browse files

Add null checks to EMBMS AIDL impls

Add null checks for things that the user passes in so that they don't
inadvertently cause NPEs for the middleware later on.

Change-Id: I09392a2ac9adec494fcbeeba889ce7fca6708323
Fixes: 67785040
Test: manual
parent 26817938
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -113,6 +113,10 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
    @Override
    public final int initialize(final int subscriptionId,
            final IMbmsDownloadSessionCallback callback) throws RemoteException {
        if (callback == null) {
            throw new NullPointerException("Callback must not be null");
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override
@@ -240,6 +244,13 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
    public final int registerStateCallback(final DownloadRequest downloadRequest,
            final IDownloadStateCallback callback, int flags) throws RemoteException {
        final int uid = Binder.getCallingUid();
        if (downloadRequest == null) {
            throw new NullPointerException("Download request must not be null");
        }
        if (callback == null) {
            throw new NullPointerException("Callback must not be null");
        }

        DeathRecipient deathRecipient = new DeathRecipient() {
            @Override
            public void binderDied() {
@@ -292,6 +303,13 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
    public final int unregisterStateCallback(
            final DownloadRequest downloadRequest, final IDownloadStateCallback callback)
            throws RemoteException {
        if (downloadRequest == null) {
            throw new NullPointerException("Download request must not be null");
        }
        if (callback == null) {
            throw new NullPointerException("Callback must not be null");
        }

        DeathRecipient deathRecipient =
                mDownloadCallbackDeathRecipients.remove(callback.asBinder());
        if (deathRecipient == null) {
+8 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
    @Override
    public final int initialize(final IMbmsStreamingSessionCallback callback,
            final int subscriptionId) throws RemoteException {
        if (callback == null) {
            throw new NullPointerException("Callback must not be null");
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override
@@ -152,6 +156,10 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
    @Override
    public int startStreaming(final int subscriptionId, String serviceId,
            final IStreamingServiceCallback callback) throws RemoteException {
        if (callback == null) {
            throw new NullPointerException("Callback must not be null");
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override