Remove CursorAnchorInfoRequest and related stuff

This CL removes CursorAnchorInfoRequest and related stuff
in favor of InputConnection.requestUpdateCursorAnchorInfo,
which is more easy to understand. This CL also deprecates
InputMethodManager#updateCursor and related stuff.

Rationale:
1. The spec of #updateCursor says that it provides the cursor
   position in local coordinates, while the input method
   requires it in the screen coordinates.
2. #updateCursor has never been enabled in AOSP, because
   InputMethodManager#isWatchingCursor always returned false.
3. There has been no way to let
   InputMethodManager#isWatchingCursor return true.
4. In L, InputMethodManager#updateCursorAnchorInfo is
   introduced to address all the issues above.

Given that we no longer need to support #updateCursor,
CursorAnchorInfoRequest is overkill when we need to convey
just a couple of parameters.

BUG: 17185263
BUG: 17182367

Change-Id: I4a577bfd02b37b9e56c80b8b41bb25afa95dd8ef
diff --git a/core/java/com/android/internal/view/IInputConnectionWrapper.java b/core/java/com/android/internal/view/IInputConnectionWrapper.java
index 897381d..b1f5d90 100644
--- a/core/java/com/android/internal/view/IInputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/IInputConnectionWrapper.java
@@ -25,7 +25,6 @@
 import android.view.KeyEvent;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
 import android.view.inputmethod.ExtractedTextRequest;
 import android.view.inputmethod.InputConnection;
 
@@ -55,7 +54,7 @@
     private static final int DO_REPORT_FULLSCREEN_MODE = 100;
     private static final int DO_PERFORM_PRIVATE_COMMAND = 120;
     private static final int DO_CLEAR_META_KEY_STATES = 130;
-    private static final int DO_REQUEST_CURSOR_ANCHOR_INFO = 140;
+    private static final int DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO = 140;
 
     private WeakReference<InputConnection> mInputConnection;
 
@@ -177,9 +176,10 @@
         dispatchMessage(obtainMessageOO(DO_PERFORM_PRIVATE_COMMAND, action, data));
     }
 
-    public void requestCursorAnchorInfo(CursorAnchorInfoRequest request, int seq,
+    public void requestUpdateCursorAnchorInfo(int cursorUpdateMode, int seq,
             IInputContextCallback callback) {
-        dispatchMessage(obtainMessageOSC(DO_REQUEST_CURSOR_ANCHOR_INFO, request, seq, callback));
+        dispatchMessage(obtainMessageISC(DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO, cursorUpdateMode,
+                seq, callback));
     }
 
     void dispatchMessage(Message msg) {
@@ -427,18 +427,17 @@
                         (Bundle)args.arg2);
                 return;
             }
-            case DO_REQUEST_CURSOR_ANCHOR_INFO: {
+            case DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 try {
                     InputConnection ic = mInputConnection.get();
                     if (ic == null || !isActive()) {
                         Log.w(TAG, "requestCursorAnchorInfo on inactive InputConnection");
-                        args.callback.setRequestCursorAnchorInfoResult(0, args.seq);
+                        args.callback.setRequestUpdateCursorAnchorInfoResult(false, args.seq);
                         return;
                     }
-                    args.callback.setRequestCursorAnchorInfoResult(
-                            ic.requestCursorAnchorInfo((CursorAnchorInfoRequest)args.arg1),
-                            args.seq);
+                    args.callback.setRequestUpdateCursorAnchorInfoResult(
+                            ic.requestUpdateCursorAnchorInfo(msg.arg1), args.seq);
                 } catch (RemoteException e) {
                     Log.w(TAG, "Got RemoteException calling requestCursorAnchorInfo", e);
                 }
diff --git a/core/java/com/android/internal/view/IInputContext.aidl b/core/java/com/android/internal/view/IInputContext.aidl
index c06596a..fd2b513 100644
--- a/core/java/com/android/internal/view/IInputContext.aidl
+++ b/core/java/com/android/internal/view/IInputContext.aidl
@@ -20,7 +20,6 @@
 import android.view.KeyEvent;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
 import android.view.inputmethod.ExtractedTextRequest;
 
 import com.android.internal.view.IInputContextCallback;
@@ -74,6 +73,6 @@
 
     void getSelectedText(int flags, int seq, IInputContextCallback callback);
 
-    void requestCursorAnchorInfo(in CursorAnchorInfoRequest request, int seq,
+    void requestUpdateCursorAnchorInfo(in int cursorUpdateMode, int seq,
             IInputContextCallback callback);
 }
diff --git a/core/java/com/android/internal/view/IInputContextCallback.aidl b/core/java/com/android/internal/view/IInputContextCallback.aidl
index ab2fbdc..54ea306 100644
--- a/core/java/com/android/internal/view/IInputContextCallback.aidl
+++ b/core/java/com/android/internal/view/IInputContextCallback.aidl
@@ -27,5 +27,5 @@
     void setCursorCapsMode(int capsMode, int seq);
     void setExtractedText(in ExtractedText extractedText, int seq);
     void setSelectedText(CharSequence selectedText, int seq);
-    void setRequestCursorAnchorInfoResult(int result, int seq);
+    void setRequestUpdateCursorAnchorInfoResult(boolean result, int seq);
 }
diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java
index 8535a98..a8526c8 100644
--- a/core/java/com/android/internal/view/InputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/InputConnectionWrapper.java
@@ -23,7 +23,6 @@
 import android.view.KeyEvent;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
 import android.view.inputmethod.ExtractedText;
 import android.view.inputmethod.ExtractedTextRequest;
 import android.view.inputmethod.InputConnection;
@@ -41,7 +40,7 @@
         public CharSequence mSelectedText;
         public ExtractedText mExtractedText;
         public int mCursorCapsMode;
-        public int mCursorAnchorInfoRequestResult;
+        public boolean mRequestUpdateCursorAnchorInfoResult;
         
         // A 'pool' of one InputContextCallback.  Each ICW request will attempt to gain
         // exclusive access to this object.
@@ -155,10 +154,10 @@
             }
         }
 
-        public void setRequestCursorAnchorInfoResult(int result, int seq) {
+        public void setRequestUpdateCursorAnchorInfoResult(boolean result, int seq) {
             synchronized (this) {
                 if (seq == mSeq) {
-                    mCursorAnchorInfoRequestResult = result;
+                    mRequestUpdateCursorAnchorInfoResult = result;
                     mHaveValue = true;
                     notifyAll();
                 } else {
@@ -429,21 +428,21 @@
         }
     }
 
-    public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
-        int value = CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+    public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+        boolean result = false;
         try {
             InputContextCallback callback = InputContextCallback.getInstance();
-            mIInputContext.requestCursorAnchorInfo(request, callback.mSeq, callback);
+            mIInputContext.requestUpdateCursorAnchorInfo(cursorUpdateMode, callback.mSeq, callback);
             synchronized (callback) {
                 callback.waitForResultLocked();
                 if (callback.mHaveValue) {
-                    value = callback.mCursorAnchorInfoRequestResult;
+                    result = callback.mRequestUpdateCursorAnchorInfoResult;
                 }
             }
             callback.dispose();
         } catch (RemoteException e) {
-            return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+            return false;
         }
-        return value;
+        return result;
     }
 }
diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java
index bfe0090..2967938 100644
--- a/core/java/com/android/internal/widget/EditableInputConnection.java
+++ b/core/java/com/android/internal/widget/EditableInputConnection.java
@@ -25,9 +25,9 @@
 import android.view.inputmethod.BaseInputConnection;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
 import android.view.inputmethod.ExtractedText;
 import android.view.inputmethod.ExtractedTextRequest;
+import android.view.inputmethod.InputConnection;
 import android.widget.TextView;
 
 public class EditableInputConnection extends BaseInputConnection {
@@ -188,24 +188,17 @@
     }
 
     @Override
-    public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
-        if (DEBUG) Log.v(TAG, "requestCursorAnchorInfo " + request);
+    public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+        if (DEBUG) Log.v(TAG, "requestUpdateCursorAnchorInfo " + cursorUpdateMode);
 
-        // This implementation supports TYPE_CURSOR_ANCHOR_INFO only. Other events will be
-        // delegated to the super class.
-        if (request == null ||
-                request.getRequestType() != CursorAnchorInfoRequest.TYPE_CURSOR_ANCHOR_INFO) {
-            return super.requestCursorAnchorInfo(request);
-        }
         if (mIMM == null) {
             // In this case, TYPE_CURSOR_ANCHOR_INFO is not handled.
-            // TODO: Return some notification code for the input method that indicates
+            // TODO: Return some notification code rather than false to indicate method that
             // CursorAnchorInfo is temporarily unavailable.
-            return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+            return false;
         }
-        final int flags = request.getRequestFlags();
-        mIMM.setCursorAnchorInfoMonitorMode(flags);
-        if ((flags & CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0) {
+        mIMM.setUpdateCursorAnchorInfoMode(cursorUpdateMode);
+        if ((cursorUpdateMode & InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE) != 0) {
             if (mTextView == null) {
                 // In this case, FLAG_CURSOR_ANCHOR_INFO_IMMEDIATE is silently ignored.
                 // TODO: Return some notification code for the input method that indicates
@@ -220,6 +213,6 @@
                 mTextView.requestLayout();
             }
         }
-        return CursorAnchorInfoRequest.RESULT_SCHEDULED;
+        return true;
     }
 }