Java源码示例:android.content.pm.PathPermission
示例1
private static void printProviderInfo(ProviderInfo providerInfo, int i) {
String name = providerInfo.name;
String authority = providerInfo.authority;
String readPermission = providerInfo.readPermission;
String writePermission = providerInfo.writePermission;
boolean grantUriPermissions = providerInfo.grantUriPermissions;
boolean multiProcess = providerInfo.multiprocess;
int initOrder = providerInfo.initOrder;
PatternMatcher[] uriPermissionPatterns = providerInfo.uriPermissionPatterns;
PathPermission[] pathPermissions = providerInfo.pathPermissions;
Log.d(TAG, i + "==============");
Log.d(TAG, "name:" + name);
Log.d(TAG, "authority:" + authority);
Log.d(TAG, "readPermission:" + readPermission);
Log.d(TAG, "writePermission:" + writePermission);
Log.d(TAG, "grantUriPermissions:" + grantUriPermissions);
Log.d(TAG, "multiprocess:" + multiProcess);
Log.d(TAG, "initOrder:" + initOrder);
Log.d(TAG, "uriPermissionPatterns:" + Arrays.toString(uriPermissionPatterns));
Log.d(TAG, "pathPermissions:" + Arrays.toString(pathPermissions));
Log.d(TAG, "applicationInfo.packageName:" + providerInfo.applicationInfo.packageName);
Log.d(TAG, "applicationInfo.name:" + providerInfo.applicationInfo.name);
Log.d(TAG, i + "==============");
}
示例2
public String getExportedContentProvider() {
StringBuilder sb = new StringBuilder();
if (mPInfo.providers != null) {
for (ProviderInfo pi : mPInfo.providers) {
String piName = pi.name;
if (pi.exported) {
//Grant Uri Permissions
piName = piName + " GRANT: " + String.valueOf(pi.grantUriPermissions) + "|";
if (pi.authority != null) {
piName = piName + " AUTHORITY: " + pi.authority + "|";
}
if (pi.readPermission != null) {
piName = piName + " READ: " + pi.readPermission + "|";
}
if (pi.writePermission != null) {
piName = piName + " WRITE: " + pi.writePermission + "|";
}
PathPermission[] pp = pi.pathPermissions;
if (pp != null) {
for (PathPermission pathPermission : pp) {
piName = piName + " PATH: " + pathPermission.getPath() + "|";
piName = piName + " - READ: " + pathPermission.getReadPermission() + "|";
piName = piName + " - WRITE: " + pathPermission.getWritePermission() + "|";
}
}
sb.append(piName + "\n");
}
}
} else {
sb.append(" -- null");
}
return sb.toString();
}
示例3
public String getNonExportedContentProvider() {
StringBuilder sb = new StringBuilder();
if (mPInfo.providers != null) {
for (ProviderInfo pi : mPInfo.providers) {
String piName = pi.name;
if (!pi.exported) {
//Grant Uri Permissions
piName = piName + " GRANT: " + String.valueOf(pi.grantUriPermissions) + "|";
if (pi.authority != null) {
piName = piName + " AUTHORITY: " + pi.authority + "|";
}
if (pi.readPermission != null) {
piName = piName + " READ: " + pi.readPermission + "|";
}
if (pi.writePermission != null) {
piName = piName + " WRITE: " + pi.writePermission + "|";
}
PathPermission[] pp = pi.pathPermissions;
if (pp != null) {
for (PathPermission pathPermission : pp) {
piName = piName + " PATH: " + pathPermission.getPath() + "|";
piName = piName + " - READ: " + pathPermission.getReadPermission() + "|";
piName = piName + " - WRITE: " + pathPermission.getWritePermission() + "|";
}
}
sb.append(piName + "\n");
}
}
} else {
sb.append(" -- null");
}
return sb.toString();
}
示例4
/**
* Constructor just for mocking.
*
* @param context A Context object which should be some mock instance (like the
* instance of {@link android.test.mock.MockContext}).
* @param readPermission The read permision you want this instance should have in the
* test, which is available via {@link #getReadPermission()}.
* @param writePermission The write permission you want this instance should have
* in the test, which is available via {@link #getWritePermission()}.
* @param pathPermissions The PathPermissions you want this instance should have
* in the test, which is available via {@link #getPathPermissions()}.
* @hide
*/
public ContentProvider(
Context context,
String readPermission,
String writePermission,
PathPermission[] pathPermissions) {
mContext = context;
mReadPermission = readPermission;
mWritePermission = writePermission;
mPathPermissions = pathPermissions;
}
示例5
/**
* Constructor just for mocking.
*
* @param context A Context object which should be some mock instance (like the
* instance of {@link android.test.mock.MockContext}).
* @param readPermission The read permision you want this instance should have in the
* test, which is available via {@link #getReadPermission()}.
* @param writePermission The write permission you want this instance should have
* in the test, which is available via {@link #getWritePermission()}.
* @param pathPermissions The PathPermissions you want this instance should have
* in the test, which is available via {@link #getPathPermissions()}.
* @hide
*/
public ContentProvider(
Context context,
String readPermission,
String writePermission,
PathPermission[] pathPermissions) {
mContext = context;
mReadPermission = readPermission;
mWritePermission = writePermission;
mPathPermissions = pathPermissions;
}
示例6
/**
* Change the path-based permission required to read and/or write data in
* the content provider. This is normally set for you from its manifest
* information when the provider is first created.
*
* @param permissions Array of path permission descriptions.
*/
protected final void setPathPermissions(@Nullable PathPermission[] permissions) {
mPathPermissions = permissions;
}
示例7
/**
* Return the path-based permissions required for read and/or write access to
* this content provider. This method can be called from multiple
* threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*/
public final @Nullable PathPermission[] getPathPermissions() {
return mPathPermissions;
}
示例8
/**
* Change the path-based permission required to read and/or write data in
* the content provider. This is normally set for you from its manifest
* information when the provider is first created.
*
* @param permissions Array of path permission descriptions.
*/
protected final void setPathPermissions(@Nullable PathPermission[] permissions) {
mPathPermissions = permissions;
}
示例9
/**
* Return the path-based permissions required for read and/or write access to
* this content provider. This method can be called from multiple
* threads, as described in
* <a href="{@docRoot}guide/topics/fundamentals/processes-and-threads.html#Threads">Processes
* and Threads</a>.
*/
public final @Nullable PathPermission[] getPathPermissions() {
return mPathPermissions;
}