Loading core/java/com/android/internal/inputmethod/IInputMethodManagerGlobal.java→core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java +13 −10 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.internal.inputmethod; package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.NonNull; Loading @@ -36,8 +36,11 @@ import java.util.function.Consumer; * * <p>All public methods are guaranteed to do nothing when {@link IInputMethodManager} is * unavailable.</p> * * <p>If you want to use any of this method outside of {@code android.view.inputmethod}, create * a wrapper method in {@link InputMethodManagerGlobal} instead of making this class public.</p> */ public final class IInputMethodManagerGlobal { final class IInputMethodManagerGlobalInvoker { @Nullable private static volatile IInputMethodManager sServiceCache = null; Loading @@ -45,7 +48,7 @@ public final class IInputMethodManagerGlobal { * @return {@code true} if {@link IInputMethodManager} is available. */ @AnyThread public static boolean isAvailable() { static boolean isAvailable() { return getService() != null; } Loading Loading @@ -79,14 +82,14 @@ public final class IInputMethodManagerGlobal { * * @param protoDump client or service side information to be stored by the server * @param source where the information is coming from, refer to * {@link ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link ImeTracing#IME_TRACING_FROM_IMS} * {@link com.android.internal.inputmethod.ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link com.android.internal.inputmethod.ImeTracing#IME_TRACING_FROM_IMS} * @param where where the information is coming from. * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresNoPermission @AnyThread public static void startProtoDump(byte[] protoDump, int source, String where, static void startProtoDump(byte[] protoDump, int source, String where, @Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { Loading @@ -106,7 +109,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading @@ -125,7 +128,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading @@ -144,7 +147,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresNoPermission @AnyThread public static boolean isImeTraceEnabled() { static boolean isImeTraceEnabled() { final IInputMethodManager service = getService(); if (service == null) { return false; Loading @@ -161,7 +164,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) @AnyThread public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading core/java/android/view/inputmethod/InputMethodManagerGlobal.java 0 → 100644 +104 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.Nullable; import android.annotation.RequiresNoPermission; import android.annotation.RequiresPermission; import android.os.RemoteException; import com.android.internal.inputmethod.ImeTracing; import com.android.internal.view.IInputMethodManager; import java.util.function.Consumer; /** * Defines a set of static methods that can be used globally by framework classes. * * @hide */ public class InputMethodManagerGlobal { /** * @return {@code true} if IME tracing is currently is available. */ @AnyThread public static boolean isImeTraceAvailable() { return IInputMethodManagerGlobalInvoker.isAvailable(); } /** * Invokes {@link IInputMethodManager#startProtoDump(byte[], int, String)}. * * @param protoDump client or service side information to be stored by the server * @param source where the information is coming from, refer to * {@link ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link ImeTracing#IME_TRACING_FROM_IMS} * @param where where the information is coming from. * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresNoPermission @AnyThread public static void startProtoDump(byte[] protoDump, int source, String where, @Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.startProtoDump(protoDump, source, where, exceptionHandler); } /** * Invokes {@link IInputMethodManager#startImeTrace()}. * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.startImeTrace(exceptionHandler); } /** * Invokes {@link IInputMethodManager#stopImeTrace()}. * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.stopImeTrace(exceptionHandler); } /** * Invokes {@link IInputMethodManager#isImeTraceEnabled()}. * * @return The return value of {@link IInputMethodManager#isImeTraceEnabled()}. */ @RequiresNoPermission @AnyThread public static boolean isImeTraceEnabled() { return IInputMethodManagerGlobalInvoker.isImeTraceEnabled(); } /** * Invokes {@link IInputMethodManager#removeImeSurface()} * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) @AnyThread public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.removeImeSurface(exceptionHandler); } } core/java/com/android/internal/inputmethod/ImeTracing.java +5 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.ActivityThread; import android.util.Log; import android.util.proto.ProtoOutputStream; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManagerGlobal; import java.io.PrintWriter; Loading @@ -44,7 +45,7 @@ public abstract class ImeTracing { private static ImeTracing sInstance; static boolean sEnabled = false; private final boolean mIsAvailable = IInputMethodManagerGlobal.isAvailable(); private final boolean mIsAvailable = InputMethodManagerGlobal.isImeTraceAvailable(); protected boolean mDumpInProgress; protected final Object mDumpInProgressLock = new Object(); Loading Loading @@ -81,7 +82,7 @@ public abstract class ImeTracing { * @param where */ public void sendToService(byte[] protoDump, int source, String where) { IInputMethodManagerGlobal.startProtoDump(protoDump, source, where, InputMethodManagerGlobal.startProtoDump(protoDump, source, where, e -> Log.e(TAG, "Exception while sending ime-related dump to server", e)); } Loading @@ -90,7 +91,7 @@ public abstract class ImeTracing { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) public final void startImeTrace() { IInputMethodManagerGlobal.startImeTrace(e -> Log.e(TAG, "Could not start ime trace.", e)); InputMethodManagerGlobal.startImeTrace(e -> Log.e(TAG, "Could not start ime trace.", e)); } /** Loading @@ -98,7 +99,7 @@ public abstract class ImeTracing { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) public final void stopImeTrace() { IInputMethodManagerGlobal.stopImeTrace(e -> Log.e(TAG, "Could not stop ime trace.", e)); InputMethodManagerGlobal.stopImeTrace(e -> Log.e(TAG, "Could not stop ime trace.", e)); } /** Loading core/java/com/android/internal/inputmethod/ImeTracingClientImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManagerGlobal; import java.io.PrintWriter; Loading @@ -28,7 +29,7 @@ import java.io.PrintWriter; */ class ImeTracingClientImpl extends ImeTracing { ImeTracingClientImpl() { sEnabled = IInputMethodManagerGlobal.isImeTraceEnabled(); sEnabled = InputMethodManagerGlobal.isImeTraceEnabled(); } @Override Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java +2 −2 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ import android.view.WindowInsets; import android.view.WindowInsets.Type.InsetsType; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import android.view.inputmethod.InputMethodManagerGlobal; import androidx.annotation.VisibleForTesting; import com.android.internal.inputmethod.IInputMethodManagerGlobal; import com.android.wm.shell.sysui.ShellInit; import java.util.ArrayList; Loading Loading @@ -515,7 +515,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged void removeImeSurface() { // Remove the IME surface to make the insets invisible for // non-client controlled insets. IInputMethodManagerGlobal.removeImeSurface( InputMethodManagerGlobal.removeImeSurface( e -> Slog.e(TAG, "Failed to remove IME surface.", e)); } Loading Loading
core/java/com/android/internal/inputmethod/IInputMethodManagerGlobal.java→core/java/android/view/inputmethod/IInputMethodManagerGlobalInvoker.java +13 −10 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ package com.android.internal.inputmethod; package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.NonNull; Loading @@ -36,8 +36,11 @@ import java.util.function.Consumer; * * <p>All public methods are guaranteed to do nothing when {@link IInputMethodManager} is * unavailable.</p> * * <p>If you want to use any of this method outside of {@code android.view.inputmethod}, create * a wrapper method in {@link InputMethodManagerGlobal} instead of making this class public.</p> */ public final class IInputMethodManagerGlobal { final class IInputMethodManagerGlobalInvoker { @Nullable private static volatile IInputMethodManager sServiceCache = null; Loading @@ -45,7 +48,7 @@ public final class IInputMethodManagerGlobal { * @return {@code true} if {@link IInputMethodManager} is available. */ @AnyThread public static boolean isAvailable() { static boolean isAvailable() { return getService() != null; } Loading Loading @@ -79,14 +82,14 @@ public final class IInputMethodManagerGlobal { * * @param protoDump client or service side information to be stored by the server * @param source where the information is coming from, refer to * {@link ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link ImeTracing#IME_TRACING_FROM_IMS} * {@link com.android.internal.inputmethod.ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link com.android.internal.inputmethod.ImeTracing#IME_TRACING_FROM_IMS} * @param where where the information is coming from. * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresNoPermission @AnyThread public static void startProtoDump(byte[] protoDump, int source, String where, static void startProtoDump(byte[] protoDump, int source, String where, @Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { Loading @@ -106,7 +109,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading @@ -125,7 +128,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading @@ -144,7 +147,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresNoPermission @AnyThread public static boolean isImeTraceEnabled() { static boolean isImeTraceEnabled() { final IInputMethodManager service = getService(); if (service == null) { return false; Loading @@ -161,7 +164,7 @@ public final class IInputMethodManagerGlobal { */ @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) @AnyThread public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { final IInputMethodManager service = getService(); if (service == null) { return; Loading
core/java/android/view/inputmethod/InputMethodManagerGlobal.java 0 → 100644 +104 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view.inputmethod; import android.annotation.AnyThread; import android.annotation.Nullable; import android.annotation.RequiresNoPermission; import android.annotation.RequiresPermission; import android.os.RemoteException; import com.android.internal.inputmethod.ImeTracing; import com.android.internal.view.IInputMethodManager; import java.util.function.Consumer; /** * Defines a set of static methods that can be used globally by framework classes. * * @hide */ public class InputMethodManagerGlobal { /** * @return {@code true} if IME tracing is currently is available. */ @AnyThread public static boolean isImeTraceAvailable() { return IInputMethodManagerGlobalInvoker.isAvailable(); } /** * Invokes {@link IInputMethodManager#startProtoDump(byte[], int, String)}. * * @param protoDump client or service side information to be stored by the server * @param source where the information is coming from, refer to * {@link ImeTracing#IME_TRACING_FROM_CLIENT} and * {@link ImeTracing#IME_TRACING_FROM_IMS} * @param where where the information is coming from. * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresNoPermission @AnyThread public static void startProtoDump(byte[] protoDump, int source, String where, @Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.startProtoDump(protoDump, source, where, exceptionHandler); } /** * Invokes {@link IInputMethodManager#startImeTrace()}. * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void startImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.startImeTrace(exceptionHandler); } /** * Invokes {@link IInputMethodManager#stopImeTrace()}. * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) @AnyThread public static void stopImeTrace(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.stopImeTrace(exceptionHandler); } /** * Invokes {@link IInputMethodManager#isImeTraceEnabled()}. * * @return The return value of {@link IInputMethodManager#isImeTraceEnabled()}. */ @RequiresNoPermission @AnyThread public static boolean isImeTraceEnabled() { return IInputMethodManagerGlobalInvoker.isImeTraceEnabled(); } /** * Invokes {@link IInputMethodManager#removeImeSurface()} * * @param exceptionHandler an optional {@link RemoteException} handler. */ @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) @AnyThread public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) { IInputMethodManagerGlobalInvoker.removeImeSurface(exceptionHandler); } }
core/java/com/android/internal/inputmethod/ImeTracing.java +5 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.app.ActivityThread; import android.util.Log; import android.util.proto.ProtoOutputStream; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManagerGlobal; import java.io.PrintWriter; Loading @@ -44,7 +45,7 @@ public abstract class ImeTracing { private static ImeTracing sInstance; static boolean sEnabled = false; private final boolean mIsAvailable = IInputMethodManagerGlobal.isAvailable(); private final boolean mIsAvailable = InputMethodManagerGlobal.isImeTraceAvailable(); protected boolean mDumpInProgress; protected final Object mDumpInProgressLock = new Object(); Loading Loading @@ -81,7 +82,7 @@ public abstract class ImeTracing { * @param where */ public void sendToService(byte[] protoDump, int source, String where) { IInputMethodManagerGlobal.startProtoDump(protoDump, source, where, InputMethodManagerGlobal.startProtoDump(protoDump, source, where, e -> Log.e(TAG, "Exception while sending ime-related dump to server", e)); } Loading @@ -90,7 +91,7 @@ public abstract class ImeTracing { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) public final void startImeTrace() { IInputMethodManagerGlobal.startImeTrace(e -> Log.e(TAG, "Could not start ime trace.", e)); InputMethodManagerGlobal.startImeTrace(e -> Log.e(TAG, "Could not start ime trace.", e)); } /** Loading @@ -98,7 +99,7 @@ public abstract class ImeTracing { */ @RequiresPermission(android.Manifest.permission.CONTROL_UI_TRACING) public final void stopImeTrace() { IInputMethodManagerGlobal.stopImeTrace(e -> Log.e(TAG, "Could not stop ime trace.", e)); InputMethodManagerGlobal.stopImeTrace(e -> Log.e(TAG, "Could not stop ime trace.", e)); } /** Loading
core/java/com/android/internal/inputmethod/ImeTracingClientImpl.java +2 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManagerGlobal; import java.io.PrintWriter; Loading @@ -28,7 +29,7 @@ import java.io.PrintWriter; */ class ImeTracingClientImpl extends ImeTracing { ImeTracingClientImpl() { sEnabled = IInputMethodManagerGlobal.isImeTraceEnabled(); sEnabled = InputMethodManagerGlobal.isImeTraceEnabled(); } @Override Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java +2 −2 Original line number Diff line number Diff line Loading @@ -38,10 +38,10 @@ import android.view.WindowInsets; import android.view.WindowInsets.Type.InsetsType; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import android.view.inputmethod.InputMethodManagerGlobal; import androidx.annotation.VisibleForTesting; import com.android.internal.inputmethod.IInputMethodManagerGlobal; import com.android.wm.shell.sysui.ShellInit; import java.util.ArrayList; Loading Loading @@ -515,7 +515,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged void removeImeSurface() { // Remove the IME surface to make the insets invisible for // non-client controlled insets. IInputMethodManagerGlobal.removeImeSurface( InputMethodManagerGlobal.removeImeSurface( e -> Slog.e(TAG, "Failed to remove IME surface.", e)); } Loading