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

Commit 7938706e authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Resolve Telecom Binder#withCleanCallingIdentity usages

As part of mainline prep, remove the use of
Binder#withCleanCallingIdentity usages from Telecom (as this is a hidden
API).

Bug: 307785735
Bug: 311773409
Test: m Telecom
Change-Id: Ib04c6648ee97eb0620d14be6d539934edcc52732
parent db88a8c2
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.ResultReceiver;
import android.os.UserHandle;
import android.telecom.CallEndpoint;
import android.telecom.Log;
import android.telecom.PhoneAccountHandle;
@@ -420,7 +421,8 @@ class InCallAdapter extends IInCallAdapter.Stub {
            Log.startSession(LogUtils.Sessions.ICA_ENTER_AUDIO_PROCESSING,
                    mOwnerPackageAbbreviation);
            // TODO: enforce the extra permission.
            Binder.withCleanCallingIdentity(() -> {
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
@@ -429,7 +431,9 @@ class InCallAdapter extends IInCallAdapter.Stub {
                        Log.w(this, "enterBackgroundAudioProcessing, unknown call id: %s", callId);
                    }
                }
            });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
@@ -440,7 +444,8 @@ class InCallAdapter extends IInCallAdapter.Stub {
        try {
            Log.startSession(LogUtils.Sessions.ICA_EXIT_AUDIO_PROCESSING,
                    mOwnerPackageAbbreviation);
            Binder.withCleanCallingIdentity(() -> {
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
@@ -450,7 +455,9 @@ class InCallAdapter extends IInCallAdapter.Stub {
                                "exitBackgroundAudioProcessing, unknown call id: %s", callId);
                    }
                }
            });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        } finally {
            Log.endSession();
        }
+16 −6
Original line number Diff line number Diff line
@@ -1986,8 +1986,12 @@ public class TelecomServiceImpl {

            if (args != null && args.length > 0 && Analytics.ANALYTICS_DUMPSYS_ARG.equals(
                    args[0])) {
                Binder.withCleanCallingIdentity(() ->
                        Analytics.dumpToEncodedProto(mContext, writer, args));
                long token = Binder.clearCallingIdentity();
                try {
                    Analytics.dumpToEncodedProto(mContext, writer, args);
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
                return;
            }

@@ -2235,7 +2239,8 @@ public class TelecomServiceImpl {
            try {
                synchronized (mLock) {
                    enforceShellOnly(Binder.getCallingUid(), "cleanupStuckCalls");
                    Binder.withCleanCallingIdentity(() -> {
                    long token = Binder.clearCallingIdentity();
                    try {
                        Set<UserHandle> userHandles = new HashSet<>();
                        for (Call call : mCallsManager.getCalls()) {
                            call.cleanup();
@@ -2248,7 +2253,9 @@ public class TelecomServiceImpl {
                        for (UserHandle userHandle : userHandles) {
                            mCallsManager.getInCallController().unbindFromServices(userHandle);
                        }
                    });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
@@ -2325,11 +2332,14 @@ public class TelecomServiceImpl {
            try {
                synchronized (mLock) {
                    enforceShellOnly(Binder.getCallingUid(), "resetCarMode");
                    Binder.withCleanCallingIdentity(() -> {
                    long token = Binder.clearCallingIdentity();
                    try {
                        UiModeManager uiModeManager =
                                mContext.getSystemService(UiModeManager.class);
                        uiModeManager.disableCarMode(UiModeManager.DISABLE_CAR_MODE_ALL_PRIORITIES);
                    });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();