Loading core/java/android/view/inputmethod/InputMethodManager.java +18 −5 Original line number Diff line number Diff line Loading @@ -1430,8 +1430,13 @@ public final class InputMethodManager { public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { try { return mService.getEnabledInputMethodSubtypeList( imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes); final Completable.InputMethodSubtypeList value = Completable.createInputMethodSubtypeList(); mService.getEnabledInputMethodSubtypeList( imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes, ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -2970,7 +2975,9 @@ public final class InputMethodManager { */ public InputMethodSubtype getCurrentInputMethodSubtype() { try { return mService.getCurrentInputMethodSubtype(); final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); mService.getCurrentInputMethodSubtype(ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -3019,7 +3026,11 @@ public final class InputMethodManager { } final List<InputMethodSubtype> enabledSubtypes; try { enabledSubtypes = mService.getEnabledInputMethodSubtypeList(imeId, true); final Completable.InputMethodSubtypeList value = Completable.createInputMethodSubtypeList(); mService.getEnabledInputMethodSubtypeList( imeId, true, ResultCallbacks.of(value)); enabledSubtypes = Completable.getResult(value); } catch (RemoteException e) { return false; } Loading Loading @@ -3214,7 +3225,9 @@ public final class InputMethodManager { public InputMethodSubtype getLastInputMethodSubtype() { try { return mService.getLastInputMethodSubtype(); final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); mService.getLastInputMethodSubtype(ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/com/android/internal/inputmethod/CallbackUtils.java +57 −1 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package com.android.internal.inputmethod; import android.annotation.AnyThread; import android.annotation.NonNull; import android.os.RemoteException; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.view.InputBindResult; import java.util.List; import java.util.function.BooleanSupplier; import java.util.function.Supplier; Loading Loading @@ -67,7 +69,7 @@ public final class CallbackUtils { /** * A utility method using given {@link IBooleanResultCallback} to callback the result. * * @param callback {@link IInputBindResultResultCallback} to be called back. * @param callback {@link IBooleanResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IBooleanResultCallback callback, Loading @@ -89,4 +91,58 @@ public final class CallbackUtils { callback.onResult(result); } catch (RemoteException ignored) { } } /** * A utility method using given {@link IInputMethodSubtypeResultCallback} to callback the * result. * * @param callback {@link IInputMethodSubtypeResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IInputMethodSubtypeResultCallback callback, @NonNull Supplier<InputMethodSubtype> resultSupplier) { InputMethodSubtype result = null; Throwable exception = null; try { result = resultSupplier.get(); } catch (Throwable throwable) { exception = throwable; } try { if (exception != null) { callback.onError(ThrowableHolder.of(exception)); return; } callback.onResult(result); } catch (RemoteException ignored) { } } /** * A utility method using given {@link IInputMethodSubtypeListResultCallback} to callback the * result. * * @param callback {@link IInputMethodSubtypeListResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IInputMethodSubtypeListResultCallback callback, @NonNull Supplier<List<InputMethodSubtype>> resultSupplier) { List<InputMethodSubtype> result = null; Throwable exception = null; try { result = resultSupplier.get(); } catch (Throwable throwable) { exception = throwable; } try { if (exception != null) { callback.onError(ThrowableHolder.of(exception)); return; } callback.onResult(result); } catch (RemoteException ignored) { } } } core/java/com/android/internal/inputmethod/Completable.java +28 −0 Original line number Diff line number Diff line Loading @@ -23,10 +23,12 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.annotations.GuardedBy; import java.lang.annotation.Retention; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; Loading Loading @@ -372,6 +374,20 @@ public final class Completable { return new Completable.InputBindResult(); } /** * @return an instance of {@link Completable.InputMethodSubtype}. */ public static Completable.InputMethodSubtype createInputMethodSubtype() { return new Completable.InputMethodSubtype(); } /** * @return an instance of {@link Completable.InputMethodSubtypeList}. */ public static Completable.InputMethodSubtypeList createInputMethodSubtypeList() { return new Completable.InputMethodSubtypeList(); } /** * Completable object of {@link java.lang.Boolean}. */ Loading Loading @@ -400,6 +416,18 @@ public final class Completable { public static final class InputBindResult extends Values<com.android.internal.view.InputBindResult> { } /** * Completable object of {@link android.view.inputmethod.InputMethodSubtype}. */ public static final class InputMethodSubtype extends Values<android.view.inputmethod.InputMethodSubtype> { } /** * Completable object of {@link List<android.view.inputmethod.InputMethodSubtype>}. */ public static final class InputMethodSubtypeList extends Values<List<android.view.inputmethod.InputMethodSubtype>> { } /** * Await the result by the {@link Completable.Values}. * Loading core/java/com/android/internal/inputmethod/IInputMethodSubtypeListResultCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 com.android.internal.inputmethod; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.inputmethod.ThrowableHolder; oneway interface IInputMethodSubtypeListResultCallback { void onResult(in List<InputMethodSubtype> result); void onError(in ThrowableHolder exception); } No newline at end of file core/java/com/android/internal/inputmethod/IInputMethodSubtypeResultCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 com.android.internal.inputmethod; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.inputmethod.ThrowableHolder; oneway interface IInputMethodSubtypeResultCallback { void onResult(in InputMethodSubtype result); void onError(in ThrowableHolder exception); } No newline at end of file Loading
core/java/android/view/inputmethod/InputMethodManager.java +18 −5 Original line number Diff line number Diff line Loading @@ -1430,8 +1430,13 @@ public final class InputMethodManager { public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi, boolean allowsImplicitlySelectedSubtypes) { try { return mService.getEnabledInputMethodSubtypeList( imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes); final Completable.InputMethodSubtypeList value = Completable.createInputMethodSubtypeList(); mService.getEnabledInputMethodSubtypeList( imi == null ? null : imi.getId(), allowsImplicitlySelectedSubtypes, ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -2970,7 +2975,9 @@ public final class InputMethodManager { */ public InputMethodSubtype getCurrentInputMethodSubtype() { try { return mService.getCurrentInputMethodSubtype(); final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); mService.getCurrentInputMethodSubtype(ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -3019,7 +3026,11 @@ public final class InputMethodManager { } final List<InputMethodSubtype> enabledSubtypes; try { enabledSubtypes = mService.getEnabledInputMethodSubtypeList(imeId, true); final Completable.InputMethodSubtypeList value = Completable.createInputMethodSubtypeList(); mService.getEnabledInputMethodSubtypeList( imeId, true, ResultCallbacks.of(value)); enabledSubtypes = Completable.getResult(value); } catch (RemoteException e) { return false; } Loading Loading @@ -3214,7 +3225,9 @@ public final class InputMethodManager { public InputMethodSubtype getLastInputMethodSubtype() { try { return mService.getLastInputMethodSubtype(); final Completable.InputMethodSubtype value = Completable.createInputMethodSubtype(); mService.getLastInputMethodSubtype(ResultCallbacks.of(value)); return Completable.getResult(value); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/com/android/internal/inputmethod/CallbackUtils.java +57 −1 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package com.android.internal.inputmethod; import android.annotation.AnyThread; import android.annotation.NonNull; import android.os.RemoteException; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.view.InputBindResult; import java.util.List; import java.util.function.BooleanSupplier; import java.util.function.Supplier; Loading Loading @@ -67,7 +69,7 @@ public final class CallbackUtils { /** * A utility method using given {@link IBooleanResultCallback} to callback the result. * * @param callback {@link IInputBindResultResultCallback} to be called back. * @param callback {@link IBooleanResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IBooleanResultCallback callback, Loading @@ -89,4 +91,58 @@ public final class CallbackUtils { callback.onResult(result); } catch (RemoteException ignored) { } } /** * A utility method using given {@link IInputMethodSubtypeResultCallback} to callback the * result. * * @param callback {@link IInputMethodSubtypeResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IInputMethodSubtypeResultCallback callback, @NonNull Supplier<InputMethodSubtype> resultSupplier) { InputMethodSubtype result = null; Throwable exception = null; try { result = resultSupplier.get(); } catch (Throwable throwable) { exception = throwable; } try { if (exception != null) { callback.onError(ThrowableHolder.of(exception)); return; } callback.onResult(result); } catch (RemoteException ignored) { } } /** * A utility method using given {@link IInputMethodSubtypeListResultCallback} to callback the * result. * * @param callback {@link IInputMethodSubtypeListResultCallback} to be called back. * @param resultSupplier the supplier from which the result is provided. */ public static void onResult(@NonNull IInputMethodSubtypeListResultCallback callback, @NonNull Supplier<List<InputMethodSubtype>> resultSupplier) { List<InputMethodSubtype> result = null; Throwable exception = null; try { result = resultSupplier.get(); } catch (Throwable throwable) { exception = throwable; } try { if (exception != null) { callback.onError(ThrowableHolder.of(exception)); return; } callback.onResult(result); } catch (RemoteException ignored) { } } }
core/java/com/android/internal/inputmethod/Completable.java +28 −0 Original line number Diff line number Diff line Loading @@ -23,10 +23,12 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.annotations.GuardedBy; import java.lang.annotation.Retention; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; Loading Loading @@ -372,6 +374,20 @@ public final class Completable { return new Completable.InputBindResult(); } /** * @return an instance of {@link Completable.InputMethodSubtype}. */ public static Completable.InputMethodSubtype createInputMethodSubtype() { return new Completable.InputMethodSubtype(); } /** * @return an instance of {@link Completable.InputMethodSubtypeList}. */ public static Completable.InputMethodSubtypeList createInputMethodSubtypeList() { return new Completable.InputMethodSubtypeList(); } /** * Completable object of {@link java.lang.Boolean}. */ Loading Loading @@ -400,6 +416,18 @@ public final class Completable { public static final class InputBindResult extends Values<com.android.internal.view.InputBindResult> { } /** * Completable object of {@link android.view.inputmethod.InputMethodSubtype}. */ public static final class InputMethodSubtype extends Values<android.view.inputmethod.InputMethodSubtype> { } /** * Completable object of {@link List<android.view.inputmethod.InputMethodSubtype>}. */ public static final class InputMethodSubtypeList extends Values<List<android.view.inputmethod.InputMethodSubtype>> { } /** * Await the result by the {@link Completable.Values}. * Loading
core/java/com/android/internal/inputmethod/IInputMethodSubtypeListResultCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 com.android.internal.inputmethod; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.inputmethod.ThrowableHolder; oneway interface IInputMethodSubtypeListResultCallback { void onResult(in List<InputMethodSubtype> result); void onError(in ThrowableHolder exception); } No newline at end of file
core/java/com/android/internal/inputmethod/IInputMethodSubtypeResultCallback.aidl 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 com.android.internal.inputmethod; import android.view.inputmethod.InputMethodSubtype; import com.android.internal.inputmethod.ThrowableHolder; oneway interface IInputMethodSubtypeResultCallback { void onResult(in InputMethodSubtype result); void onError(in ThrowableHolder exception); } No newline at end of file