Fields Summary |
---|
private static final String | TAG |
public static final int | STRENGTH_NONE |
public static final int | STRENGTH_OWNED |
public static final int | STRENGTH_GLOBAL |
public static final int | STRENGTH_PERSISTABLE |
final int | targetUserId |
final String | sourcePkg |
final String | targetPkg |
final int | targetUidCached UID of {@link #targetPkg}; should not be persisted |
final com.android.server.am.ActivityManagerService.GrantUri | uri |
int | modeFlagsAllowed modes. All permission enforcement should use this field. Must
always be a combination of {@link #ownedModeFlags},
{@link #globalModeFlags}, {@link #persistableModeFlags}, and
{@link #persistedModeFlags}. Mutations must only be performed by
the owning class. |
int | ownedModeFlagsAllowed modes with active owner. |
int | globalModeFlagsAllowed modes without explicit owner. |
int | persistableModeFlagsAllowed modes that have been offered for possible persisting. |
int | persistedModeFlagsAllowed modes that should be persisted across device boots. |
long | persistedCreateTimeTimestamp when {@link #persistedModeFlags} was first defined in
{@link System#currentTimeMillis()} time base. |
private static final long | INVALID_TIME |
private android.util.ArraySet | mReadOwners |
private android.util.ArraySet | mWriteOwners |
private String | stringName |
Methods Summary |
---|
private void | addReadOwner(UriPermissionOwner owner)
if (mReadOwners == null) {
mReadOwners = Sets.newArraySet();
ownedModeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION;
updateModeFlags();
}
if (mReadOwners.add(owner)) {
owner.addReadPermission(this);
}
|
private void | addWriteOwner(UriPermissionOwner owner)
if (mWriteOwners == null) {
mWriteOwners = Sets.newArraySet();
ownedModeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
updateModeFlags();
}
if (mWriteOwners.add(owner)) {
owner.addWritePermission(this);
}
|
public android.content.UriPermission | buildPersistedPublicApiObject()
return new android.content.UriPermission(uri.uri, persistedModeFlags, persistedCreateTime);
|
void | dump(java.io.PrintWriter pw, java.lang.String prefix)
pw.print(prefix);
pw.print("targetUserId=" + targetUserId);
pw.print(" sourcePkg=" + sourcePkg);
pw.println(" targetPkg=" + targetPkg);
pw.print(prefix);
pw.print("mode=0x" + Integer.toHexString(modeFlags));
pw.print(" owned=0x" + Integer.toHexString(ownedModeFlags));
pw.print(" global=0x" + Integer.toHexString(globalModeFlags));
pw.print(" persistable=0x" + Integer.toHexString(persistableModeFlags));
pw.print(" persisted=0x" + Integer.toHexString(persistedModeFlags));
if (persistedCreateTime != INVALID_TIME) {
pw.print(" persistedCreate=" + persistedCreateTime);
}
pw.println();
if (mReadOwners != null) {
pw.print(prefix);
pw.println("readOwners:");
for (UriPermissionOwner owner : mReadOwners) {
pw.print(prefix);
pw.println(" * " + owner);
}
}
if (mWriteOwners != null) {
pw.print(prefix);
pw.println("writeOwners:");
for (UriPermissionOwner owner : mReadOwners) {
pw.print(prefix);
pw.println(" * " + owner);
}
}
|
public int | getStrength(int modeFlags)Return strength of this permission grant for the given flags.
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if ((persistableModeFlags & modeFlags) == modeFlags) {
return STRENGTH_PERSISTABLE;
} else if ((globalModeFlags & modeFlags) == modeFlags) {
return STRENGTH_GLOBAL;
} else if ((ownedModeFlags & modeFlags) == modeFlags) {
return STRENGTH_OWNED;
} else {
return STRENGTH_NONE;
}
|
void | grantModes(int modeFlags, UriPermissionOwner owner)
final boolean persistable = (modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0;
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if (persistable) {
persistableModeFlags |= modeFlags;
}
if (owner == null) {
globalModeFlags |= modeFlags;
} else {
if ((modeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) {
addReadOwner(owner);
}
if ((modeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) {
addWriteOwner(owner);
}
}
updateModeFlags();
|
void | initPersistedModes(int modeFlags, long createdTime)Initialize persisted modes as read from file. This doesn't issue any
global or owner grants.
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
persistableModeFlags = modeFlags;
persistedModeFlags = modeFlags;
persistedCreateTime = createdTime;
updateModeFlags();
|
boolean | releasePersistableModes(int modeFlags)
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
final int before = persistedModeFlags;
persistableModeFlags &= ~modeFlags;
persistedModeFlags &= ~modeFlags;
if (persistedModeFlags == 0) {
persistedCreateTime = INVALID_TIME;
}
updateModeFlags();
return persistedModeFlags != before;
|
void | removeReadOwner(UriPermissionOwner owner)Remove given read owner, updating {@Link #modeFlags} as needed.
if (!mReadOwners.remove(owner)) {
Slog.wtf(TAG, "Unknown read owner " + owner + " in " + this);
}
if (mReadOwners.size() == 0) {
mReadOwners = null;
ownedModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
updateModeFlags();
}
|
void | removeWriteOwner(UriPermissionOwner owner)Remove given write owner, updating {@Link #modeFlags} as needed.
if (!mWriteOwners.remove(owner)) {
Slog.wtf(TAG, "Unknown write owner " + owner + " in " + this);
}
if (mWriteOwners.size() == 0) {
mWriteOwners = null;
ownedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
updateModeFlags();
}
|
boolean | revokeModes(int modeFlags, boolean includingOwners)
final boolean persistable = (modeFlags & Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION) != 0;
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
final int before = persistedModeFlags;
if ((modeFlags & Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) {
if (persistable) {
persistableModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
persistedModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
}
globalModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
if (mReadOwners != null && includingOwners) {
ownedModeFlags &= ~Intent.FLAG_GRANT_READ_URI_PERMISSION;
for (UriPermissionOwner r : mReadOwners) {
r.removeReadPermission(this);
}
mReadOwners = null;
}
}
if ((modeFlags & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) {
if (persistable) {
persistableModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
persistedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
}
globalModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
if (mWriteOwners != null && includingOwners) {
ownedModeFlags &= ~Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
for (UriPermissionOwner r : mWriteOwners) {
r.removeWritePermission(this);
}
mWriteOwners = null;
}
}
if (persistedModeFlags == 0) {
persistedCreateTime = INVALID_TIME;
}
updateModeFlags();
return persistedModeFlags != before;
|
public com.android.server.am.UriPermission$Snapshot | snapshot()
return new Snapshot(this);
|
boolean | takePersistableModes(int modeFlags)
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if ((modeFlags & persistableModeFlags) != modeFlags) {
Slog.w(TAG, "Requested flags 0x"
+ Integer.toHexString(modeFlags) + ", but only 0x"
+ Integer.toHexString(persistableModeFlags) + " are allowed");
return false;
}
final int before = persistedModeFlags;
persistedModeFlags |= (persistableModeFlags & modeFlags);
if (persistedModeFlags != 0) {
persistedCreateTime = System.currentTimeMillis();
}
updateModeFlags();
return persistedModeFlags != before;
|
public java.lang.String | toString()
if (stringName != null) {
return stringName;
}
StringBuilder sb = new StringBuilder(128);
sb.append("UriPermission{");
sb.append(Integer.toHexString(System.identityHashCode(this)));
sb.append(' ");
sb.append(uri);
sb.append('}");
return stringName = sb.toString();
|
private void | updateModeFlags()
modeFlags = ownedModeFlags | globalModeFlags | persistableModeFlags | persistedModeFlags;
|