Revoke drag and drop related grants on client crash
Add a token on the client side, linkToDeath to it on the server
side.
Bug: 29586254
Change-Id: I41ef6dd58352514035c95a4ec9e49c92ea240661
diff --git a/core/java/android/view/DragAndDropPermissions.java b/core/java/android/view/DragAndDropPermissions.java
index 71afaaa..c198e1f 100644
--- a/core/java/android/view/DragAndDropPermissions.java
+++ b/core/java/android/view/DragAndDropPermissions.java
@@ -17,7 +17,7 @@
package android.view;
import android.app.Activity;
-import android.app.ActivityManagerNative;
+import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
@@ -54,7 +54,7 @@
private final IDragAndDropPermissions mDragAndDropPermissions;
- private IBinder mPermissionOwnerToken;
+ private IBinder mTransientToken;
/**
* Create a new {@link DragAndDropPermissions} object to control the access permissions for
@@ -98,9 +98,8 @@
*/
public boolean takeTransient() {
try {
- mPermissionOwnerToken = ActivityManagerNative.getDefault().
- newUriPermissionOwner("drop");
- mDragAndDropPermissions.takeTransient(mPermissionOwnerToken);
+ mTransientToken = new Binder();
+ mDragAndDropPermissions.takeTransient(mTransientToken);
} catch (RemoteException e) {
return false;
}
@@ -113,7 +112,7 @@
public void release() {
try {
mDragAndDropPermissions.release();
- mPermissionOwnerToken = null;
+ mTransientToken = null;
} catch (RemoteException e) {
}
}
@@ -139,11 +138,11 @@
@Override
public void writeToParcel(Parcel destination, int flags) {
destination.writeStrongInterface(mDragAndDropPermissions);
- destination.writeStrongBinder(mPermissionOwnerToken);
+ destination.writeStrongBinder(mTransientToken);
}
private DragAndDropPermissions(Parcel in) {
mDragAndDropPermissions = IDragAndDropPermissions.Stub.asInterface(in.readStrongBinder());
- mPermissionOwnerToken = in.readStrongBinder();
+ mTransientToken = in.readStrongBinder();
}
}