* commit 'e261ede827664bdb0f115edb5af25e590a36557e': Add UserHandle to BeamShareData
This commit is contained in:
@@ -3,6 +3,7 @@ package android.nfc;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to IPC data to be shared over Android Beam.
|
* Class to IPC data to be shared over Android Beam.
|
||||||
@@ -14,11 +15,13 @@ import android.os.Parcelable;
|
|||||||
public final class BeamShareData implements Parcelable {
|
public final class BeamShareData implements Parcelable {
|
||||||
public final NdefMessage ndefMessage;
|
public final NdefMessage ndefMessage;
|
||||||
public final Uri[] uris;
|
public final Uri[] uris;
|
||||||
|
public final UserHandle userHandle;
|
||||||
public final int flags;
|
public final int flags;
|
||||||
|
|
||||||
public BeamShareData(NdefMessage msg, Uri[] uris, int flags) {
|
public BeamShareData(NdefMessage msg, Uri[] uris, UserHandle userHandle, int flags) {
|
||||||
this.ndefMessage = msg;
|
this.ndefMessage = msg;
|
||||||
this.uris = uris;
|
this.uris = uris;
|
||||||
|
this.userHandle = userHandle;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +38,7 @@ public final class BeamShareData implements Parcelable {
|
|||||||
if (urisLength > 0) {
|
if (urisLength > 0) {
|
||||||
dest.writeTypedArray(uris, 0);
|
dest.writeTypedArray(uris, 0);
|
||||||
}
|
}
|
||||||
|
dest.writeParcelable(userHandle, 0);
|
||||||
dest.writeInt(this.flags);
|
dest.writeInt(this.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,9 +53,10 @@ public final class BeamShareData implements Parcelable {
|
|||||||
uris = new Uri[numUris];
|
uris = new Uri[numUris];
|
||||||
source.readTypedArray(uris, Uri.CREATOR);
|
source.readTypedArray(uris, Uri.CREATOR);
|
||||||
}
|
}
|
||||||
|
UserHandle userHandle = source.readParcelable(UserHandle.class.getClassLoader());
|
||||||
int flags = source.readInt();
|
int flags = source.readInt();
|
||||||
|
|
||||||
return new BeamShareData(msg, uris, flags);
|
return new BeamShareData(msg, uris, userHandle, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ package android.nfc;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.ContentProvider;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.nfc.NfcAdapter.ReaderCallback;
|
import android.nfc.NfcAdapter.ReaderCallback;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -350,19 +352,24 @@ public final class NfcActivityManager extends IAppCallback.Stub
|
|||||||
if (urisCallback != null) {
|
if (urisCallback != null) {
|
||||||
uris = urisCallback.createBeamUris(mDefaultEvent);
|
uris = urisCallback.createBeamUris(mDefaultEvent);
|
||||||
if (uris != null) {
|
if (uris != null) {
|
||||||
|
ArrayList<Uri> validUris = new ArrayList<Uri>();
|
||||||
for (Uri uri : uris) {
|
for (Uri uri : uris) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
Log.e(TAG, "Uri not allowed to be null.");
|
Log.e(TAG, "Uri not allowed to be null.");
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
String scheme = uri.getScheme();
|
String scheme = uri.getScheme();
|
||||||
if (scheme == null || (!scheme.equalsIgnoreCase("file") &&
|
if (scheme == null || (!scheme.equalsIgnoreCase("file") &&
|
||||||
!scheme.equalsIgnoreCase("content"))) {
|
!scheme.equalsIgnoreCase("content"))) {
|
||||||
Log.e(TAG, "Uri needs to have " +
|
Log.e(TAG, "Uri needs to have " +
|
||||||
"either scheme file or scheme content");
|
"either scheme file or scheme content");
|
||||||
return null;
|
continue;
|
||||||
}
|
}
|
||||||
|
uri = ContentProvider.maybeAddUserId(uri, UserHandle.myUserId());
|
||||||
|
validUris.add(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uris = validUris.toArray(new Uri[validUris.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uris != null && uris.length > 0) {
|
if (uris != null && uris.length > 0) {
|
||||||
@@ -372,7 +379,7 @@ public final class NfcActivityManager extends IAppCallback.Stub
|
|||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new BeamShareData(message, uris, flags);
|
return new BeamShareData(message, uris, UserHandle.CURRENT, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Callback from NFC service, usually on binder thread */
|
/** Callback from NFC service, usually on binder thread */
|
||||||
|
|||||||
Reference in New Issue
Block a user