Merge "Configure handwriting window with the IME's pid and uid for ANRs" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
987c93ce3c
@@ -83,6 +83,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Process;
|
||||
import android.os.ResultReceiver;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
@@ -926,7 +927,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
mOnPreparedStylusHwCalled = true;
|
||||
}
|
||||
if (onStartStylusHandwriting()) {
|
||||
mPrivOps.onStylusHandwritingReady(requestId);
|
||||
mPrivOps.onStylusHandwritingReady(requestId, Process.myPid());
|
||||
} else {
|
||||
Log.i(TAG, "IME is not ready. Can't start Stylus Handwriting");
|
||||
// TODO(b/210039666): see if it's valuable to propagate this back to IMM.
|
||||
|
||||
@@ -42,6 +42,6 @@ oneway interface IInputMethodPrivilegedOperations {
|
||||
void shouldOfferSwitchingToNextInputMethod(in AndroidFuture future /* T=Boolean */);
|
||||
void notifyUserActionAsync();
|
||||
void applyImeVisibilityAsync(IBinder showOrHideInputToken, boolean setVisible);
|
||||
void onStylusHandwritingReady(int requestId);
|
||||
void onStylusHandwritingReady(int requestId, int pid);
|
||||
void finishStylusHandwriting(int requestId);
|
||||
}
|
||||
|
||||
@@ -396,16 +396,16 @@ public final class InputMethodPrivilegedOperations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link IInputMethodPrivilegedOperations#onStylusHandwritingReady()}
|
||||
* Calls {@link IInputMethodPrivilegedOperations#onStylusHandwritingReady(int, int)}
|
||||
*/
|
||||
@AnyThread
|
||||
public void onStylusHandwritingReady(int requestId) {
|
||||
public void onStylusHandwritingReady(int requestId, int pid) {
|
||||
final IInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
|
||||
if (ops == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ops.onStylusHandwritingReady(requestId);
|
||||
ops.onStylusHandwritingReady(requestId, pid);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -82,13 +82,14 @@ final class HandwritingEventReceiverSurface {
|
||||
mIsIntercepting = false;
|
||||
}
|
||||
|
||||
void startIntercepting() {
|
||||
// TODO(b/210978621): Update the spy window's PID and UID to be associated with the IME so
|
||||
// that ANRs are correctly attributed to the IME.
|
||||
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||
void startIntercepting(int imePid, int imeUid) {
|
||||
mWindowHandle.ownerPid = imePid;
|
||||
mWindowHandle.ownerUid = imeUid;
|
||||
mWindowHandle.inputFeatures &= ~WindowManager.LayoutParams.INPUT_FEATURE_SPY;
|
||||
t.setInputWindowInfo(mInputSurface, mWindowHandle);
|
||||
t.apply();
|
||||
|
||||
new SurfaceControl.Transaction()
|
||||
.setInputWindowInfo(mInputSurface, mWindowHandle)
|
||||
.apply();
|
||||
mIsIntercepting = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ final class HandwritingModeController {
|
||||
*/
|
||||
@UiThread
|
||||
@Nullable
|
||||
HandwritingSession startHandwritingSession(int requestId) {
|
||||
HandwritingSession startHandwritingSession(int requestId, int imePid, int imeUid) {
|
||||
if (mHandwritingSurface == null) {
|
||||
Slog.e(TAG, "Cannot start handwriting session: Handwriting was not initialized.");
|
||||
return null;
|
||||
@@ -160,7 +160,7 @@ final class HandwritingModeController {
|
||||
throw new IllegalStateException(
|
||||
"Handwriting surface should not be already intercepting.");
|
||||
}
|
||||
mHandwritingSurface.startIntercepting();
|
||||
mHandwritingSurface.startIntercepting(imePid, imeUid);
|
||||
|
||||
return new HandwritingSession(mCurrentRequestId, mHandwritingSurface.getInputChannel(),
|
||||
mHandwritingBuffer);
|
||||
|
||||
@@ -4702,7 +4702,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return true;
|
||||
}
|
||||
final HandwritingModeController.HandwritingSession session =
|
||||
mHwController.startHandwritingSession(msg.arg1);
|
||||
mHwController.startHandwritingSession(
|
||||
msg.arg1 /*requestId*/,
|
||||
msg.arg2 /*pid*/,
|
||||
mBindingController.getCurMethodUid());
|
||||
if (session == null) {
|
||||
Slog.e(TAG,
|
||||
"Failed to start handwriting session for requestId: " + msg.arg1);
|
||||
@@ -4722,8 +4725,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
private void onStylusHandwritingReady(int requestId) {
|
||||
mHandler.obtainMessage(MSG_START_HANDWRITING, requestId, 0 /* unused */).sendToTarget();
|
||||
private void onStylusHandwritingReady(int requestId, int pid) {
|
||||
mHandler.obtainMessage(MSG_START_HANDWRITING, requestId, pid).sendToTarget();
|
||||
}
|
||||
|
||||
private void handleSetInteractive(final boolean interactive) {
|
||||
@@ -6304,8 +6307,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void onStylusHandwritingReady(int requestId) {
|
||||
mImms.onStylusHandwritingReady(requestId);
|
||||
public void onStylusHandwritingReady(int requestId, int pid) {
|
||||
mImms.onStylusHandwritingReady(requestId, pid);
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
|
||||
Reference in New Issue
Block a user