Revert "Remove InputContentInfo#requestPermission()"

This reverts commit c4b8f36de5523366e354fc01b6cba81ad72f6423.

Having InputContentInfo#requestPermission() should not hurt developers,
but we can polish the behavior in a subsequent CL without changing
the API.

Bug: 29450031
Bug: 29892936
Change-Id: I1b43c19417b643d0c269af860db2d309b73a90d5
diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java
index 15422b6..9a09dcc 100644
--- a/core/java/com/android/internal/view/InputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/InputConnectionWrapper.java
@@ -517,22 +517,20 @@
 
     public boolean commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts) {
         boolean result = false;
-        final boolean grantUriPermission =
-                (flags & InputConnection.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0;
         if (isMethodMissing(MissingMethodFlags.COMMIT_CONTENT)) {
             // This method is not implemented.
             return false;
         }
         try {
-            if (grantUriPermission) {
+            if ((flags & InputConnection.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
                 final AbstractInputMethodService inputMethodService = mInputMethodService.get();
                 if (inputMethodService == null) {
                     // This basically should not happen, because it's the the caller of this method.
                     return false;
                 }
-                // Temporarily grant URI permission.
                 inputMethodService.exposeContent(inputContentInfo, this);
             }
+
             InputContextCallback callback = InputContextCallback.getInstance();
             mIInputContext.commitContent(inputContentInfo, flags, opts, callback.mSeq, callback);
             synchronized (callback) {
@@ -542,10 +540,6 @@
                 }
             }
             callback.dispose();
-            // If this request is not handled, then there is no reason to keep the URI permission.
-            if (grantUriPermission && !result) {
-                inputContentInfo.releasePermission();
-            }
         } catch (RemoteException e) {
             return false;
         }