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

Commit 2fda0778 authored by mtk81368's avatar mtk81368 Committed by Tyler Gunn
Browse files

telecom: Add null checks for service interface

This upstream patch is about telecom mainline.
Added null checks for mServiceInterface to prevent potential
NullPointerException during various telecom operations.
Ensures stability during connection handling and focus events.
Handling logs that contain sensitive information.

Bug: 404208222
Flag: NONE null checks and logging.
Test: monkey test
Test: Re-run CTS and unit tests.
(cherry picked from https://android-review.googlesource.com/q/commit:0e7f94ae752e739ddfc43cfabed9b3f43e3b1828)
Change-Id: Icb1eb7e1be6daecfdab79ffb35862fa57f0210bf

Change-Id: Ia862a1a323641c1b1373830f77f1f6f483f7ccb0
parent f9a03db0
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2462,7 +2462,16 @@ public class CallsManager extends Call.ListenerBase
            // CallScreeningService in order for it to potentially provide caller ID.
            dialerSelectPhoneAccountFuture.thenAcceptBothAsync(contactLookupFuture,
                    (callPhoneAccountHandlePair, uriCallerInfoPair) -> {
                        if (callPhoneAccountHandlePair == null) {
                            return;
                        }
                        Call theCall = callPhoneAccountHandlePair.first;
                        // Other branches building on dialerSelectPhoneAccountFuture do this, so
                        // we should early return here; if there is no call, then don't bother
                        // continuing.
                        if (theCall == null) {
                            return;
                        }
                        UserHandle userHandleForCallScreening = theCall.
                                getAssociatedUser();
                        boolean isInContacts = uriCallerInfoPair.second != null
+49 −36
Original line number Diff line number Diff line
@@ -910,7 +910,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    logIncoming("setAddress %s %s %d", callId, address, presentation);
                    logIncoming("setAddress %s %s %d", callId, Log.piiHandle(address),
                            presentation);
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.setHandle(address, presentation);
@@ -932,7 +933,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    logIncoming("setCallerDisplayName %s %s %d", callId, callerDisplayName,
                    logIncoming("setCallerDisplayName %s %s %d", callId, Log.pii(callerDisplayName),
                            presentation);
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
@@ -1887,6 +1888,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            Log.piiHandle(call.getHandle()));
                    try {
                        logOutgoing("createConnectionFailed %s", callId);
                        if (mServiceInterface != null) {
                            mServiceInterface.createConnectionFailed(
                                    call.getConnectionManagerPhoneAccount(),
                                    callId,
@@ -1901,6 +1903,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                                    Log.getExternalSession(TELECOM_ABBREVIATION));
                            call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED));
                            call.disconnect();
                        }
                    } catch (RemoteException e) {
                    }
                }
@@ -1974,6 +1977,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                    Log.addEvent(call, LogUtils.Events.HANDOVER_FAILED,
                            Log.piiHandle(call.getHandle()));
                    try {
                        if (mServiceInterface != null) {
                            mServiceInterface.handoverFailed(
                                    callId,
                                    new ConnectionRequest(
@@ -1985,6 +1989,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                                            false),
                                    reason,
                                    Log.getExternalSession(TELECOM_ABBREVIATION));
                        }
                    } catch (RemoteException e) {
                    }
                }
@@ -2010,9 +2015,11 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                // If still bound, tell the connection service create connection has failed.
                if (callId != null && isServiceValid("handoverComplete")) {
                    try {
                        if (mServiceInterface != null) {
                            mServiceInterface.handoverComplete(
                                    callId,
                                    Log.getExternalSession(TELECOM_ABBREVIATION));
                        }
                    } catch (RemoteException e) {
                    }
                }
@@ -2089,8 +2096,10 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("onCallAudioStateChanged")) {
            try {
                logOutgoing("onCallAudioStateChanged %s %s", callId, audioState);
                if (mServiceInterface != null) {
                    mServiceInterface.onCallAudioStateChanged(callId, audioState,
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                }
            } catch (RemoteException e) {
            }
        }
@@ -2566,8 +2575,10 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            public void onSuccess() {
                if (!isServiceValid("connectionServiceFocusLost")) return;
                try {
                    if (mServiceInterface != null) {
                        mServiceInterface.connectionServiceFocusLost(
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                    }
                } catch (RemoteException ignored) {
                    Log.d(this, "failed to inform the focus lost event");
                }
@@ -2586,8 +2597,10 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            public void onSuccess() {
                if (!isServiceValid("connectionServiceFocusGained")) return;
                try {
                    if (mServiceInterface != null) {
                        mServiceInterface.connectionServiceFocusGained(
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                    }
                } catch (RemoteException ignored) {
                    Log.d(this, "failed to inform the focus gained event");
                }