Handle exceptions from #requestPermission()
This is a follow up CL to my previous CL [1] that let
IInputConnectionWrapper to call InputContentInfo#requestPermission()
automatically so that temporary URI permissions can be granted
automatically on API 25+ devices whenever
INPUT_CONTENT_GRANT_READ_URI_PERMISSION is specified.
However, in that CL we forgot to handle exceptions thrown from
InputContentInfo#requestPermission(). This is problematic because it is
actually easy for IMEs to cause SecurityException by specifying a
content URI that does not allow grantUriPermission, e.g.:
inputConnection.commitContent(
new InputContentInfo(Uri.parse("content://call_log/test"),
new ClipDescription("test", new String[]{"image/gif"}));
As a result, IMEs can let the application crash at any time because
InputContentInfo#requestPermission() is automatically called inside the
Framework.
This CL makes sure that exceptions thrown from
InputContentInfo#requestPermission() can be handled gracefully.
[1]: Id955435dd2e72549ee7134f46b3c6951581694ad
f3806f57a5
Bug: 32162481
Change-Id: I08916a1f54518390d3b67ab1673dc901e3f9716a
This commit is contained in:
@@ -580,7 +580,13 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
|
||||
return;
|
||||
}
|
||||
if (grantUriPermission) {
|
||||
inputContentInfo.requestPermission();
|
||||
try {
|
||||
inputContentInfo.requestPermission();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "InputConnectionInfo.requestPermission() failed", e);
|
||||
args.callback.setCommitContentResult(false, args.seq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final boolean result =
|
||||
ic.commitContent(inputContentInfo, flags, (Bundle) args.arg2);
|
||||
|
||||
Reference in New Issue
Block a user