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

Commit b6c4bc31 authored by Hall Liu's avatar Hall Liu Committed by Gerrit Code Review
Browse files

Merge "Check success before registering DeathRecipient"

parents 3c48bd72 8374e75d
Loading
Loading
Loading
Loading
+28 −20
Original line number Diff line number Diff line
@@ -118,14 +118,8 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override
            public void binderDied() {
                onAppCallbackDied(uid, subscriptionId);
            }
        }, 0);

        return initialize(subscriptionId, new MbmsDownloadSessionCallback() {
        int result = initialize(subscriptionId, new MbmsDownloadSessionCallback() {
            @Override
            public void onError(int errorCode, String message) {
                try {
@@ -153,6 +147,17 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
                }
            }
        });

        if (result == MbmsErrors.SUCCESS) {
            callback.asBinder().linkToDeath(new DeathRecipient() {
                @Override
                public void binderDied() {
                    onAppCallbackDied(uid, subscriptionId);
                }
            }, 0);
        }

        return result;
    }

    /**
@@ -251,6 +256,16 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
            throw new NullPointerException("Callback must not be null");
        }

        DownloadStateCallback exposedCallback = new FilteredDownloadStateCallback(callback, flags) {
            @Override
            protected void onRemoteException(RemoteException e) {
                onAppCallbackDied(uid, downloadRequest.getSubscriptionId());
            }
        };

        int result = registerStateCallback(downloadRequest, exposedCallback);

        if (result == MbmsErrors.SUCCESS) {
            DeathRecipient deathRecipient = new DeathRecipient() {
                @Override
                public void binderDied() {
@@ -261,17 +276,10 @@ public class MbmsDownloadServiceBase extends IMbmsDownloadService.Stub {
            };
            mDownloadCallbackDeathRecipients.put(callback.asBinder(), deathRecipient);
            callback.asBinder().linkToDeath(deathRecipient, 0);

        DownloadStateCallback exposedCallback = new FilteredDownloadStateCallback(callback, flags) {
            @Override
            protected void onRemoteException(RemoteException e) {
                onAppCallbackDied(uid, downloadRequest.getSubscriptionId());
            }
        };

            mDownloadCallbackBinderMap.put(callback.asBinder(), exposedCallback);
        }

        return registerStateCallback(downloadRequest, exposedCallback);
        return result;
    }

    /**
+24 −14
Original line number Diff line number Diff line
@@ -70,14 +70,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override
            public void binderDied() {
                onAppCallbackDied(uid, subscriptionId);
            }
        }, 0);

        return initialize(new MbmsStreamingSessionCallback() {
        int result = initialize(new MbmsStreamingSessionCallback() {
            @Override
            public void onError(final int errorCode, final String message) {
                try {
@@ -105,6 +99,17 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
                }
            }
        }, subscriptionId);

        if (result == MbmsErrors.SUCCESS) {
            callback.asBinder().linkToDeath(new DeathRecipient() {
                @Override
                public void binderDied() {
                    onAppCallbackDied(uid, subscriptionId);
                }
            }, 0);
        }

        return result;
    }


@@ -161,14 +166,8 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
        }

        final int uid = Binder.getCallingUid();
        callback.asBinder().linkToDeath(new DeathRecipient() {
            @Override
            public void binderDied() {
                onAppCallbackDied(uid, subscriptionId);
            }
        }, 0);

        return startStreaming(subscriptionId, serviceId, new StreamingServiceCallback() {
        int result = startStreaming(subscriptionId, serviceId, new StreamingServiceCallback() {
            @Override
            public void onError(final int errorCode, final String message) {
                try {
@@ -215,6 +214,17 @@ public class MbmsStreamingServiceBase extends IMbmsStreamingService.Stub {
                }
            }
        });

        if (result == MbmsErrors.SUCCESS) {
            callback.asBinder().linkToDeath(new DeathRecipient() {
                @Override
                public void binderDied() {
                    onAppCallbackDied(uid, subscriptionId);
                }
            }, 0);
        }

        return result;
    }

    /**