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

Commit 8729846c authored by Pranav Madapurmath's avatar Pranav Madapurmath Committed by Android (Google) Code Review
Browse files

Merge "Resolve Telecom Binder#withCleanCallingIdentity usages" into main

parents 87b83a22 7938706e
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
@@ -1994,8 +1994,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;
            }

@@ -2243,7 +2247,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();
@@ -2256,7 +2261,9 @@ public class TelecomServiceImpl {
                        for (UserHandle userHandle : userHandles) {
                            mCallsManager.getInCallController().unbindFromServices(userHandle);
                        }
                    });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
@@ -2333,11 +2340,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();