Merge "Make IInputMethodManager to oneway (10/N)" into sc-dev am: 299897e9ba
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13410419 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I58254b02602f6cd0b34329d4cb1a850bdc01adac
This commit is contained in:
@@ -2307,7 +2307,9 @@ public final class InputMethodManager {
|
|||||||
public void removeImeSurface(IBinder windowToken) {
|
public void removeImeSurface(IBinder windowToken) {
|
||||||
synchronized (mH) {
|
synchronized (mH) {
|
||||||
try {
|
try {
|
||||||
mService.removeImeSurfaceFromWindow(windowToken);
|
final Completable.Void value = Completable.createVoid();
|
||||||
|
mService.removeImeSurfaceFromWindow(windowToken, ResultCallbacks.of(value));
|
||||||
|
Completable.getResult(value);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
@@ -3239,7 +3241,9 @@ public final class InputMethodManager {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
|
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
|
||||||
try {
|
try {
|
||||||
mService.setAdditionalInputMethodSubtypes(imiId, subtypes);
|
final Completable.Void value = Completable.createVoid();
|
||||||
|
mService.setAdditionalInputMethodSubtypes(imiId, subtypes, ResultCallbacks.of(value));
|
||||||
|
Completable.getResult(value);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,22 +41,24 @@ interface IInputMethodManager {
|
|||||||
int untrustedDisplayId);
|
int untrustedDisplayId);
|
||||||
|
|
||||||
// TODO: Use ParceledListSlice instead
|
// TODO: Use ParceledListSlice instead
|
||||||
void getInputMethodList(int userId, in IInputMethodInfoListResultCallback resultCallback);
|
oneway void getInputMethodList(int userId,
|
||||||
// TODO: Use ParceledListSlice instead
|
|
||||||
void getEnabledInputMethodList(int userId,
|
|
||||||
in IInputMethodInfoListResultCallback resultCallback);
|
in IInputMethodInfoListResultCallback resultCallback);
|
||||||
void getEnabledInputMethodSubtypeList(in String imiId, boolean allowsImplicitlySelectedSubtypes,
|
// TODO: Use ParceledListSlice instead
|
||||||
|
oneway void getEnabledInputMethodList(int userId,
|
||||||
|
in IInputMethodInfoListResultCallback resultCallback);
|
||||||
|
oneway void getEnabledInputMethodSubtypeList(in String imiId,
|
||||||
|
boolean allowsImplicitlySelectedSubtypes,
|
||||||
in IInputMethodSubtypeListResultCallback resultCallback);
|
in IInputMethodSubtypeListResultCallback resultCallback);
|
||||||
void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
|
oneway void getLastInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
|
||||||
|
|
||||||
void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
|
oneway void showSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
|
||||||
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
|
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
|
||||||
void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
|
oneway void hideSoftInput(in IInputMethodClient client, IBinder windowToken, int flags,
|
||||||
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
|
in ResultReceiver resultReceiver, in IBooleanResultCallback resultCallback);
|
||||||
// If windowToken is null, this just does startInput(). Otherwise this reports that a window
|
// If windowToken is null, this just does startInput(). Otherwise this reports that a window
|
||||||
// has gained focus, and if 'attribute' is non-null then also does startInput.
|
// has gained focus, and if 'attribute' is non-null then also does startInput.
|
||||||
// @NonNull
|
// @NonNull
|
||||||
void startInputOrWindowGainedFocus(
|
oneway void startInputOrWindowGainedFocus(
|
||||||
/* @StartInputReason */ int startInputReason,
|
/* @StartInputReason */ int startInputReason,
|
||||||
in IInputMethodClient client, in IBinder windowToken,
|
in IInputMethodClient client, in IBinder windowToken,
|
||||||
/* @StartInputFlags */ int startInputFlags,
|
/* @StartInputFlags */ int startInputFlags,
|
||||||
@@ -66,29 +68,31 @@ interface IInputMethodManager {
|
|||||||
int unverifiedTargetSdkVersion,
|
int unverifiedTargetSdkVersion,
|
||||||
in IInputBindResultResultCallback inputBindResult);
|
in IInputBindResultResultCallback inputBindResult);
|
||||||
|
|
||||||
void showInputMethodPickerFromClient(in IInputMethodClient client,
|
oneway void showInputMethodPickerFromClient(in IInputMethodClient client,
|
||||||
int auxiliarySubtypeMode, in IVoidResultCallback resultCallback);
|
int auxiliarySubtypeMode, in IVoidResultCallback resultCallback);
|
||||||
void showInputMethodPickerFromSystem(in IInputMethodClient client, int auxiliarySubtypeMode,
|
oneway void showInputMethodPickerFromSystem(in IInputMethodClient client,
|
||||||
int displayId, in IVoidResultCallback resultCallback);
|
int auxiliarySubtypeMode, int displayId, in IVoidResultCallback resultCallback);
|
||||||
void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client, String topId,
|
oneway void showInputMethodAndSubtypeEnablerFromClient(in IInputMethodClient client,
|
||||||
|
String topId, in IVoidResultCallback resultCallback);
|
||||||
|
oneway void isInputMethodPickerShownForTest(in IBooleanResultCallback resultCallback);
|
||||||
|
oneway void getCurrentInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
|
||||||
|
oneway void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes,
|
||||||
in IVoidResultCallback resultCallback);
|
in IVoidResultCallback resultCallback);
|
||||||
void isInputMethodPickerShownForTest(in IBooleanResultCallback resultCallback);
|
|
||||||
void getCurrentInputMethodSubtype(in IInputMethodSubtypeResultCallback resultCallback);
|
|
||||||
void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes);
|
|
||||||
// This is kept due to @UnsupportedAppUsage.
|
// This is kept due to @UnsupportedAppUsage.
|
||||||
// TODO(Bug 113914148): Consider removing this.
|
// TODO(Bug 113914148): Consider removing this.
|
||||||
void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback);
|
oneway void getInputMethodWindowVisibleHeight(IIntResultCallback resultCallback);
|
||||||
|
|
||||||
void reportActivityView(in IInputMethodClient parentClient, int childDisplayId,
|
oneway void reportActivityView(in IInputMethodClient parentClient, int childDisplayId,
|
||||||
in float[] matrixValues, in IVoidResultCallback resultCallback);
|
in float[] matrixValues, in IVoidResultCallback resultCallback);
|
||||||
|
|
||||||
oneway void reportPerceptible(in IBinder windowToken, boolean perceptible);
|
oneway void reportPerceptible(in IBinder windowToken, boolean perceptible);
|
||||||
/** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */
|
/** Remove the IME surface. Requires INTERNAL_SYSTEM_WINDOW permission. */
|
||||||
void removeImeSurface();
|
oneway void removeImeSurface(in IVoidResultCallback resultCallback);
|
||||||
/** Remove the IME surface. Requires passing the currently focused window. */
|
/** Remove the IME surface. Requires passing the currently focused window. */
|
||||||
void removeImeSurfaceFromWindow(in IBinder windowToken);
|
oneway void removeImeSurfaceFromWindow(in IBinder windowToken,
|
||||||
|
in IVoidResultCallback resultCallback);
|
||||||
void startProtoDump(in byte[] protoDump, int source, String where);
|
void startProtoDump(in byte[] protoDump, int source, String where);
|
||||||
void isImeTraceEnabled(in IBooleanResultCallback resultCallback);
|
oneway void isImeTraceEnabled(in IBooleanResultCallback resultCallback);
|
||||||
|
|
||||||
// Starts an ime trace.
|
// Starts an ime trace.
|
||||||
void startImeTrace();
|
void startImeTrace();
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ import android.view.animation.PathInterpolator;
|
|||||||
import androidx.annotation.BinderThread;
|
import androidx.annotation.BinderThread;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import com.android.internal.inputmethod.Completable;
|
||||||
|
import com.android.internal.inputmethod.ResultCallbacks;
|
||||||
import com.android.internal.view.IInputMethodManager;
|
import com.android.internal.view.IInputMethodManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -506,7 +508,9 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
|||||||
try {
|
try {
|
||||||
// Remove the IME surface to make the insets invisible for
|
// Remove the IME surface to make the insets invisible for
|
||||||
// non-client controlled insets.
|
// non-client controlled insets.
|
||||||
imms.removeImeSurface();
|
final Completable.Void value = Completable.createVoid();
|
||||||
|
imms.removeImeSurface(ResultCallbacks.of(value));
|
||||||
|
Completable.getResult(value);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Failed to remove IME surface.", e);
|
Slog.e(TAG, "Failed to remove IME surface.", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public class DisplayImeControllerTest {
|
|||||||
public IInputMethodManager getImms() {
|
public IInputMethodManager getImms() {
|
||||||
return mMock;
|
return mMock;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
void removeImeSurface() { }
|
||||||
}.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);
|
}.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3947,58 +3947,61 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
|
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes,
|
||||||
// By this IPC call, only a process which shares the same uid with the IME can add
|
IVoidResultCallback resultCallback) {
|
||||||
// additional input method subtypes to the IME.
|
CallbackUtils.onResult(resultCallback, () -> {
|
||||||
if (TextUtils.isEmpty(imiId) || subtypes == null) return;
|
// By this IPC call, only a process which shares the same uid with the IME can add
|
||||||
final ArrayList<InputMethodSubtype> toBeAdded = new ArrayList<>();
|
// additional input method subtypes to the IME.
|
||||||
for (InputMethodSubtype subtype : subtypes) {
|
if (TextUtils.isEmpty(imiId) || subtypes == null) return;
|
||||||
if (!toBeAdded.contains(subtype)) {
|
final ArrayList<InputMethodSubtype> toBeAdded = new ArrayList<>();
|
||||||
toBeAdded.add(subtype);
|
for (InputMethodSubtype subtype : subtypes) {
|
||||||
} else {
|
if (!toBeAdded.contains(subtype)) {
|
||||||
Slog.w(TAG, "Duplicated subtype definition found: "
|
toBeAdded.add(subtype);
|
||||||
+ subtype.getLocale() + ", " + subtype.getMode());
|
} else {
|
||||||
|
Slog.w(TAG, "Duplicated subtype definition found: "
|
||||||
|
+ subtype.getLocale() + ", " + subtype.getMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
synchronized (mMethodMap) {
|
||||||
synchronized (mMethodMap) {
|
if (!calledFromValidUserLocked()) {
|
||||||
if (!calledFromValidUserLocked()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (!mSystemReady) {
|
||||||
if (!mSystemReady) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
final InputMethodInfo imi = mMethodMap.get(imiId);
|
||||||
final InputMethodInfo imi = mMethodMap.get(imiId);
|
if (imi == null) return;
|
||||||
if (imi == null) return;
|
final String[] packageInfos;
|
||||||
final String[] packageInfos;
|
try {
|
||||||
try {
|
packageInfos = mIPackageManager.getPackagesForUid(Binder.getCallingUid());
|
||||||
packageInfos = mIPackageManager.getPackagesForUid(Binder.getCallingUid());
|
} catch (RemoteException e) {
|
||||||
} catch (RemoteException e) {
|
Slog.e(TAG, "Failed to get package infos");
|
||||||
Slog.e(TAG, "Failed to get package infos");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (packageInfos != null) {
|
||||||
if (packageInfos != null) {
|
final int packageNum = packageInfos.length;
|
||||||
final int packageNum = packageInfos.length;
|
for (int i = 0; i < packageNum; ++i) {
|
||||||
for (int i = 0; i < packageNum; ++i) {
|
if (packageInfos[i].equals(imi.getPackageName())) {
|
||||||
if (packageInfos[i].equals(imi.getPackageName())) {
|
if (subtypes.length > 0) {
|
||||||
if (subtypes.length > 0) {
|
mAdditionalSubtypeMap.put(imi.getId(), toBeAdded);
|
||||||
mAdditionalSubtypeMap.put(imi.getId(), toBeAdded);
|
} else {
|
||||||
} else {
|
mAdditionalSubtypeMap.remove(imi.getId());
|
||||||
mAdditionalSubtypeMap.remove(imi.getId());
|
}
|
||||||
|
AdditionalSubtypeUtils.save(mAdditionalSubtypeMap, mMethodMap,
|
||||||
|
mSettings.getCurrentUserId());
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
AdditionalSubtypeUtils.save(mAdditionalSubtypeMap, mMethodMap,
|
|
||||||
mSettings.getCurrentUserId());
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(ident);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return;
|
||||||
return;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4103,16 +4106,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeImeSurface() {
|
public void removeImeSurface(IVoidResultCallback resultCallback) {
|
||||||
mContext.enforceCallingPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW, null);
|
CallbackUtils.onResult(resultCallback, () -> {
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE));
|
mContext.enforceCallingPermission(Manifest.permission.INTERNAL_SYSTEM_WINDOW, null);
|
||||||
|
mHandler.sendMessage(mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeImeSurfaceFromWindow(IBinder windowToken) {
|
public void removeImeSurfaceFromWindow(IBinder windowToken,
|
||||||
// No permission check, because we'll only execute the request if the calling window is
|
IVoidResultCallback resultCallback) {
|
||||||
// also the current IME client.
|
CallbackUtils.onResult(resultCallback, () -> {
|
||||||
mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE_FROM_WINDOW, windowToken).sendToTarget();
|
// No permission check, because we'll only execute the request if the calling window is
|
||||||
|
// also the current IME client.
|
||||||
|
mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE_FROM_WINDOW, windowToken).sendToTarget();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1502,14 +1502,17 @@ public final class MultiClientInputMethodManagerService {
|
|||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
@Override
|
@Override
|
||||||
public void removeImeSurface() {
|
public void removeImeSurface(IVoidResultCallback resultCallback) {
|
||||||
reportNotSupported();
|
reportNotSupported();
|
||||||
|
CallbackUtils.onResult(resultCallback, () -> { });
|
||||||
}
|
}
|
||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
@Override
|
@Override
|
||||||
public void removeImeSurfaceFromWindow(IBinder windowToken) {
|
public void removeImeSurfaceFromWindow(IBinder windowToken,
|
||||||
|
IVoidResultCallback resultCallback) {
|
||||||
reportNotSupported();
|
reportNotSupported();
|
||||||
|
CallbackUtils.onResult(resultCallback, () -> { });
|
||||||
}
|
}
|
||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
@@ -1815,8 +1818,10 @@ public final class MultiClientInputMethodManagerService {
|
|||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
@Override
|
@Override
|
||||||
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes) {
|
public void setAdditionalInputMethodSubtypes(String imiId, InputMethodSubtype[] subtypes,
|
||||||
|
IVoidResultCallback resultCallback) {
|
||||||
reportNotSupported();
|
reportNotSupported();
|
||||||
|
CallbackUtils.onResult(resultCallback, () -> { });
|
||||||
}
|
}
|
||||||
|
|
||||||
@BinderThread
|
@BinderThread
|
||||||
|
|||||||
Reference in New Issue
Block a user