Merge "Remove multi-client IME"

This commit is contained in:
Wilson Wu
2021-06-30 01:34:37 +00:00
committed by Android (Google) Code Review
14 changed files with 2 additions and 3664 deletions

View File

@@ -1,26 +0,0 @@
/*
* Copyright (C) 2018 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.os.IBinder;
import com.android.internal.inputmethod.IMultiClientInputMethodPrivilegedOperations;
oneway interface IMultiClientInputMethod {
void initialize(in IMultiClientInputMethodPrivilegedOperations privOps);
void addClient(int clientId, int uid, int pid, int selfReportedDisplayId);
void removeClient(int clientId);
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright (C) 2018 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.InputChannel;
import com.android.internal.view.IInputMethodSession;
import com.android.internal.inputmethod.IMultiClientInputMethodSession;
/**
* Defines priviledged operations that only the current MSIMS is allowed to call.
* Actual operations are implemented and handled by MultiClientInputMethodManagerService.
*/
interface IMultiClientInputMethodPrivilegedOperations {
IBinder createInputMethodWindowToken(int displayId);
void deleteInputMethodWindowToken(IBinder token);
void acceptClient(int clientId, in IInputMethodSession session,
in IMultiClientInputMethodSession multiClientSession, in InputChannel writeChannel);
void reportImeWindowTarget(int clientId, int targetWindowHandle, in IBinder imeWindowToken);
boolean isUidAllowedOnDisplay(int displayId, int uid);
void setActive(int clientId, boolean active);
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright (C) 2018 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.os.ResultReceiver;
import android.view.inputmethod.EditorInfo;
import com.android.internal.view.IInputContext;
oneway interface IMultiClientInputMethodSession {
void startInputOrWindowGainedFocus(
in IInputContext inputContext, int missingMethods, in EditorInfo attribute,
int controlFlags, int softInputMode, int targetWindowHandle);
void showSoftInput(int flags, in ResultReceiver resultReceiver);
void hideSoftInput(int flags, in ResultReceiver resultReceiver);
}

View File

@@ -1,232 +0,0 @@
/*
* Copyright (C) 2018 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.annotation.AnyThread;
import android.annotation.Nullable;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.InputChannel;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.view.IInputMethodSession;
/**
* A utility class to take care of boilerplate code around IPCs.
*
* <p>Note: All public methods are designed to be thread-safe.</p>
*/
public class MultiClientInputMethodPrivilegedOperations {
private static final String TAG = "MultiClientInputMethodPrivilegedOperations";
private static final class OpsHolder {
@Nullable
@GuardedBy("this")
private IMultiClientInputMethodPrivilegedOperations mPrivOps;
/**
* Sets {@link IMultiClientInputMethodPrivilegedOperations}.
*
* <p>This method can be called only once.</p>
*
* @param privOps Binder interface to be set.
*/
@AnyThread
public synchronized void set(IMultiClientInputMethodPrivilegedOperations privOps) {
if (mPrivOps != null) {
throw new IllegalStateException(
"IMultiClientInputMethodPrivilegedOperations must be set at most once."
+ " privOps=" + privOps);
}
mPrivOps = privOps;
}
/**
* A simplified version of {@link android.os.Debug#getCaller()}.
*
* @return method name of the caller.
*/
@AnyThread
private static String getCallerMethodName() {
final StackTraceElement[] callStack = Thread.currentThread().getStackTrace();
if (callStack.length <= 4) {
return "<bottom of call stack>";
}
return callStack[4].getMethodName();
}
@AnyThread
public synchronized void dispose() {
mPrivOps = null;
}
@AnyThread
@Nullable
public synchronized IMultiClientInputMethodPrivilegedOperations getAndWarnIfNull() {
if (mPrivOps == null) {
Log.e(TAG, getCallerMethodName() + " is ignored."
+ " Call it within attachToken() and InputMethodService.onDestroy()");
}
return mPrivOps;
}
}
private final OpsHolder mOps = new OpsHolder();
/**
* Sets {@link IMultiClientInputMethodPrivilegedOperations}.
*
* <p>This method can be called only once.</p>
*
* @param privOps Binder interface to be set.
*/
@AnyThread
public void set(IMultiClientInputMethodPrivilegedOperations privOps) {
mOps.set(privOps);
}
/**
* Disposes internal Binder proxy so that the real Binder object can be garbage collected.
*/
@AnyThread
public void dispose() {
mOps.dispose();
}
/**
* Calls {@link IMultiClientInputMethodPrivilegedOperations#createInputMethodWindowToken(int)}.
*
* @param displayId display ID on which the IME window will be shown.
* @return Window token to be specified to the IME window.
*/
@AnyThread
public IBinder createInputMethodWindowToken(int displayId) {
IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return null;
}
try {
return ops.createInputMethodWindowToken(displayId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Calls {@link
* IMultiClientInputMethodPrivilegedOperations#deleteInputMethodWindowToken(IBinder)}.
*
* @param token Window token that is to be deleted.
*/
@AnyThread
public void deleteInputMethodWindowToken(IBinder token) {
IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return;
}
try {
ops.deleteInputMethodWindowToken(token);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Calls {@link IMultiClientInputMethodPrivilegedOperations#acceptClient(int,
* IInputMethodSession, IMultiClientInputMethodSession, InputChannel)}.
*
* @param clientId client ID to be accepted.
* @param session {@link IInputMethodSession} that is also used for traditional IME protocol.
* @param multiClientSession {@link IMultiClientInputMethodSession} that defines new callbacks
* for multi-client scenarios.
* @param writeChannel {@link InputChannel} that is also used for traditional IME protocol.
*/
@AnyThread
public void acceptClient(int clientId, IInputMethodSession session,
IMultiClientInputMethodSession multiClientSession, InputChannel writeChannel) {
final IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return;
}
try {
ops.acceptClient(clientId, session, multiClientSession, writeChannel);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Calls {@link IMultiClientInputMethodPrivilegedOperations#reportImeWindowTarget(int, int,
* IBinder)}.
*
* @param clientId client ID about which new IME target window is reported.
* @param targetWindowHandle integer handle of the target window.
* @param imeWindowToken {@link IBinder} window token of the IME window.
*/
@AnyThread
public void reportImeWindowTarget(int clientId, int targetWindowHandle,
IBinder imeWindowToken) {
final IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return;
}
try {
ops.reportImeWindowTarget(clientId, targetWindowHandle, imeWindowToken);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Calls {@link IMultiClientInputMethodPrivilegedOperations#isUidAllowedOnDisplay(int, int)}.
*
* @param displayId display ID to be verified.
* @param uid UID to be verified.
* @return {@code true} when {@code uid} is allowed to access to {@code displayId}.
*/
@AnyThread
public boolean isUidAllowedOnDisplay(int displayId, int uid) {
final IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return false;
}
try {
return ops.isUidAllowedOnDisplay(displayId, uid);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Calls {@link IMultiClientInputMethodPrivilegedOperations#setActive(int, boolean)}.
* @param clientId client ID to be set active/inactive
* @param active {@code true} set set active.
*/
@AnyThread
public void setActive(int clientId, boolean active) {
final IMultiClientInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
if (ops == null) {
return;
}
try {
ops.setActive(clientId, active);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}

View File

@@ -53,8 +53,7 @@ public final class InputBindResult implements Parcelable {
ResultCode.ERROR_NOT_IME_TARGET_WINDOW,
ResultCode.ERROR_NO_EDITOR,
ResultCode.ERROR_DISPLAY_ID_MISMATCH,
ResultCode.ERROR_INVALID_DISPLAY_ID,
ResultCode.ERROR_INVALID_CLIENT,
ResultCode.ERROR_INVALID_DISPLAY_ID
})
public @interface ResultCode {
/**
@@ -168,10 +167,6 @@ public final class InputBindResult implements Parcelable {
* display.
*/
int ERROR_INVALID_DISPLAY_ID = 15;
/**
* Indicates that the client is not recognized by the system.
*/
int ERROR_INVALID_CLIENT = 16;
}
@ResultCode
@@ -310,8 +305,6 @@ public final class InputBindResult implements Parcelable {
return "ERROR_DISPLAY_ID_MISMATCH";
case ResultCode.ERROR_INVALID_DISPLAY_ID:
return "ERROR_INVALID_DISPLAY_ID";
case ResultCode.ERROR_INVALID_CLIENT:
return "ERROR_INVALID_CLIENT";
default:
return "Unknown(" + result + ")";
}
@@ -369,11 +362,6 @@ public final class InputBindResult implements Parcelable {
public static final InputBindResult INVALID_DISPLAY_ID =
error(ResultCode.ERROR_INVALID_DISPLAY_ID);
/**
* Predefined error object for {@link ResultCode#ERROR_INVALID_CLIENT}.
*/
public static final InputBindResult INVALID_CLIENT = error(ResultCode.ERROR_INVALID_CLIENT);
/**
* Predefined <strong>success</strong> object for
* {@link ResultCode#SUCCESS_WAITING_USER_SWITCHING}.