Add InputMethodService#exposeContent()
This is a follow up CL to my previous CLs [1][2] that introduced
InputConnection#commitContent(InputContentInfo, Bundle) API to enable
IMEs to send a content to the target application.
With this CL, IME developers are able to temporarily expose
InputContentInfo object to the target package without permanently
granting URI permission. Although calling IMS#exposeContent() 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 to any other IME as long as the client keeps InputContentInfo
object.
Here is a sample code snippet about how to use this mechanism.
[IME]
InputContentInfo contentInfo = new InputContentInfo(
contentUri,
new ClipDescription(description, new String[]{mimeType}),
linkUrl);
exposeContent(contentInfo, getCurrentInputEditorInfo());
getCurrentInputConnection().commitContent(inputContentInfo, null);
[App]
try {
contentInfo.requestPermission();
// Load inputContentInfo.getContentUri() here.
} finally {
contentInfo.releasePermission();
}
[1]: Iaadf934a997ffcd6000a516cc3c1873db56e60ad
152944f490
[2]: Ica1ba3154795c1bf44e140dfe639b299f83cd8af
adebb52588
Bug: 29450031
Change-Id: I2772889ca01f2ecb2cdeed4e04a9319bdf7bc5a6
This commit is contained in:
@@ -318,6 +318,7 @@ LOCAL_SRC_FILES += \
|
||||
core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
|
||||
core/java/com/android/internal/backup/IBackupTransport.aidl \
|
||||
core/java/com/android/internal/backup/IObbBackupService.aidl \
|
||||
core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl \
|
||||
core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl \
|
||||
core/java/com/android/internal/policy/IKeyguardExitCallback.aidl \
|
||||
core/java/com/android/internal/policy/IKeyguardService.aidl \
|
||||
|
||||
Reference in New Issue
Block a user