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

Commit 11dc30d3 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Move clearCallingIdentity to priviliged operations

This moves the clearCallingIdentity blocks into the caller methods from
InputMethodPriviligedOperationsImpl.

Flag: EXEMPT refactor
Test: presubmit
Bug: 355154964
Change-Id: I7a2cc49ec1d29fa3b00204a745aeddc5c0acc3ee
parent 88016bb6
Loading
Loading
Loading
Loading
+61 −61
Original line number Original line Diff line number Diff line
@@ -2581,8 +2581,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
        if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
            return;
            return;
        }
        }
        final long ident = Binder.clearCallingIdentity();
        try {
        if (iconId == 0) {
        if (iconId == 0) {
            if (DEBUG) Slog.d(TAG, "hide the small icon for the input method");
            if (DEBUG) Slog.d(TAG, "hide the small icon for the input method");
            hideStatusBarIconLocked(userId);
            hideStatusBarIconLocked(userId);
@@ -2606,9 +2604,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                mStatusBarManagerInternal.setIconVisibility(mSlotIme, true);
                mStatusBarManagerInternal.setIconVisibility(mSlotIme, true);
            }
            }
        }
        }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }
    }


    @GuardedBy("ImfLock.class")
    @GuardedBy("ImfLock.class")
@@ -4792,9 +4787,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @InputMethodManager.HideFlags int flags, @SoftInputShowHideReason int reason,
            @InputMethodManager.HideFlags int flags, @SoftInputShowHideReason int reason,
            @NonNull UserData userData) {
            @NonNull UserData userData) {
        final int userId = userData.mUserId;
        final int userId = userData.mUserId;
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideMySoftInputLocked");
        final long ident = Binder.clearCallingIdentity();
        try {
        if (Flags.refactorInsetsController()) {
        if (Flags.refactorInsetsController()) {
            userData.mCurClient.mClient.setImeVisibility(false, statsToken);
            userData.mCurClient.mClient.setImeVisibility(false, statsToken);
            // TODO we will loose the flags here
            // TODO we will loose the flags here
@@ -4804,10 +4796,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            hideCurrentInputLocked(visibilityStateComputer.getLastImeTargetWindow(),
            hideCurrentInputLocked(visibilityStateComputer.getLastImeTargetWindow(),
                    statsToken, flags, null /* resultReceiver */, reason, userId);
                    statsToken, flags, null /* resultReceiver */, reason, userId);
        }
        }
        } finally {
            Binder.restoreCallingIdentity(ident);
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
    }
    }


    @BinderThread
    @BinderThread
@@ -4816,9 +4804,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            @InputMethodManager.ShowFlags int flags, @SoftInputShowHideReason int reason,
            @InputMethodManager.ShowFlags int flags, @SoftInputShowHideReason int reason,
            @NonNull UserData userData) {
            @NonNull UserData userData) {
        final int userId = userData.mUserId;
        final int userId = userData.mUserId;
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showMySoftInputLocked");
        final long ident = Binder.clearCallingIdentity();
        try {
        if (Flags.refactorInsetsController()) {
        if (Flags.refactorInsetsController()) {
            userData.mCurClient.mClient.setImeVisibility(true, statsToken);
            userData.mCurClient.mClient.setImeVisibility(true, statsToken);
            setImeVisibilityOnFocusedWindowClient(true, userData, statsToken);
            setImeVisibilityOnFocusedWindowClient(true, userData, statsToken);
@@ -4828,10 +4813,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN,
                    statsToken, flags, MotionEvent.TOOL_TYPE_UNKNOWN,
                    null /* resultReceiver */, reason, userId);
                    null /* resultReceiver */, reason, userId);
        }
        }
        } finally {
            Binder.restoreCallingIdentity(ident);
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
    }
    }


    @GuardedBy("ImfLock.class")
    @GuardedBy("ImfLock.class")
@@ -6915,8 +6896,15 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    }
                    }
                    ImeTracker.forLogging().onProgress(statsToken,
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_SERVER_CURRENT_ACTIVE_IME);
                            ImeTracker.PHASE_SERVER_CURRENT_ACTIVE_IME);
                    Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideMySoftInput");
                    final long ident = Binder.clearCallingIdentity();
                    try {
                        mImms.hideMySoftInputLocked(statsToken, flags, reason, mUserData);
                        mImms.hideMySoftInputLocked(statsToken, flags, reason, mUserData);
                        typedFuture.complete(null);
                        typedFuture.complete(null);
                    } finally {
                        Binder.restoreCallingIdentity(ident);
                        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                    }
                }
                }
            } catch (Throwable e) {
            } catch (Throwable e) {
                typedFuture.completeExceptionally(e);
                typedFuture.completeExceptionally(e);
@@ -6939,8 +6927,15 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    }
                    }
                    ImeTracker.forLogging().onProgress(statsToken,
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_SERVER_CURRENT_ACTIVE_IME);
                            ImeTracker.PHASE_SERVER_CURRENT_ACTIVE_IME);
                    Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.showMySoftInput");
                    final long ident = Binder.clearCallingIdentity();
                    try {
                        mImms.showMySoftInputLocked(statsToken, flags, reason, mUserData);
                        mImms.showMySoftInputLocked(statsToken, flags, reason, mUserData);
                        typedFuture.complete(null);
                        typedFuture.complete(null);
                    } finally {
                        Binder.restoreCallingIdentity(ident);
                        Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                    }
                }
                }
            } catch (Throwable e) {
            } catch (Throwable e) {
                typedFuture.completeExceptionally(e);
                typedFuture.completeExceptionally(e);
@@ -6954,7 +6949,12 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                if (!calledWithValidTokenLocked(mToken, mUserData)) {
                if (!calledWithValidTokenLocked(mToken, mUserData)) {
                    return;
                    return;
                }
                }
                final long ident = Binder.clearCallingIdentity();
                try {
                    mImms.updateStatusIconLocked(packageName, iconId, mUserData);
                    mImms.updateStatusIconLocked(packageName, iconId, mUserData);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
            }
            }
        }
        }