Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4b8f36d authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove InputContentInfo#requestPermission()

It turns out that requiring editor authors to call
InputContentInfo#requestPermission() as needed is just confusing and can
cause compatibility issues, because if an editor author forgot to call
that method then there would be no way for IME developers to prevent
permission denial except for relaxing the default permission of the
ContentProvider just because of such an application. This is not what we
want to see.

My conclusion is that the system should automatically call
InputContentInfo#requestPermission() (or do any equivalent operation)
when InputConnection#INPUT_CONTENT_GRANT_READ_URI_PERMISSION is
specified, like we have done in Context#startActivity().

With this CL, the system automatically grants a temporary URI permission
to the target application when the IME calls
InputConnection#commitContent() with
InputConnection#INPUT_CONTENT_GRANT_READ_URI_PERMISSION, and the
temporary permission will be revoked by any of the following events:
 - InputContentInfo#releasePermission() is explicitly called by the
   target application.
 - The target application returned false in
   InputConnection#commitContent().
 - All the InputContentInfo instances copied from the original one are
   GC-ed.

Bug: 29450031
Bug: 29892936
Change-Id: I37fb744e4d3d1c59177fb0a9be4ef5c325c9a39f
parent 8e3b57aa
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -44921,7 +44921,6 @@ package android.view.inputmethod {
    method public android.content.ClipDescription getDescription();
    method public android.net.Uri getLinkUri();
    method public void releasePermission();
    method public void requestPermission();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.inputmethod.InputContentInfo> CREATOR;
  }
+0 −1
Original line number Diff line number Diff line
@@ -48049,7 +48049,6 @@ package android.view.inputmethod {
    method public android.content.ClipDescription getDescription();
    method public android.net.Uri getLinkUri();
    method public void releasePermission();
    method public void requestPermission();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.inputmethod.InputContentInfo> CREATOR;
  }
+0 −1
Original line number Diff line number Diff line
@@ -45001,7 +45001,6 @@ package android.view.inputmethod {
    method public android.content.ClipDescription getDescription();
    method public android.net.Uri getLinkUri();
    method public void releasePermission();
    method public void requestPermission();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.view.inputmethod.InputContentInfo> CREATOR;
  }
+5 −4
Original line number Diff line number Diff line
@@ -840,15 +840,16 @@ public interface InputConnection {
    public void closeConnection();

    /**
     * When this flag is used, the editor will be able to request read access to the content URI
     * contained in the {@link InputContentInfo} object.
     * When this flag is used in {@link #commitContent(InputContentInfo, int, Bundle)}, the editor
     * will be able to request read access to the content URI contained in the
     * {@link InputContentInfo} object.
     *
     * <p>Make sure that the content provider owning the Uri sets the
     * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
     * grantUriPermissions} attribute in its manifest or included the
     * {@link android.R.styleable#AndroidManifestGrantUriPermission
     * &lt;grant-uri-permissions&gt;} tag. Otherwise {@link InputContentInfo#requestPermission()}
     * can fail.</p>
     * &lt;grant-uri-permissions&gt;} tag. Otherwise
     * {@link #commitContent(InputContentInfo, int, Bundle)} can fail.</p>
     *
     * <p>Although calling this API is allowed only for the IME that is currently selected, the
     * client is able to request a temporary read-only access even after the current IME is switched
+0 −16
Original line number Diff line number Diff line
@@ -162,22 +162,6 @@ public final class InputContentInfo implements Parcelable {
        mUriToken = token;
    }

    /**
     * Requests a temporary read-only access permission for content URI associated with this object.
     *
     * <p>Does nothing if the temporary permission is already granted.</p>
     */
    public void requestPermission() {
        if (mUriToken == null) {
            return;
        }
        try {
            mUriToken.take();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * Releases a temporary read-only access permission for content URI associated with this object.
     *
Loading