android.content.Context.checkCallingOrSelfUriPermission()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中android.content.Context.checkCallingOrSelfUriPermission()方法的一些代码示例,展示了Context.checkCallingOrSelfUriPermission()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.checkCallingOrSelfUriPermission()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:checkCallingOrSelfUriPermission

Context.checkCallingOrSelfUriPermission介绍

暂无

代码示例

代码示例来源:origin: oasisfeng/condom

@Override public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) {
  return mBase.checkCallingOrSelfUriPermission(uri, modeFlags);
}

代码示例来源:origin: Trumeet/MiPushFramework

@Override public int checkCallingOrSelfUriPermission(Uri uri, int modeFlags) {
  return mBase.checkCallingOrSelfUriPermission(uri, modeFlags);
}

代码示例来源:origin: gigabytedevelopers/FireFiles

private static int getCallingOrSelfUriPermissionModeFlags(Context context, Uri uri) {
  // TODO: move this to a direct AMS call
  int modeFlags = 0;
  if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
      == PackageManager.PERMISSION_GRANTED) {
    modeFlags |= Intent.FLAG_GRANT_READ_URI_PERMISSION;
  }
  if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      == PackageManager.PERMISSION_GRANTED) {
    modeFlags |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
  }
  if (context.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION
      | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      == PackageManager.PERMISSION_GRANTED) {
    modeFlags |= Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION;
  }
  return modeFlags;
}

代码示例来源:origin: gigabytedevelopers/FireFiles

public static boolean canRead(Context context, Uri self) {
  // Ignore if grant doesn't allow read
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_READ_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  // Ignore documents without MIME
  if (TextUtils.isEmpty(getRawType(context, self))) {
    return false;
  }
  return true;
}

代码示例来源:origin: gigabytedevelopers/FireFiles

public static boolean canRead(Context context, Uri self) {
  // Ignore if grant doesn't allow read
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_READ_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  // Ignore documents without MIME
  if (TextUtils.isEmpty(getRawType(context, self))) {
    return false;
  }
  return true;
}

代码示例来源:origin: kingargyle/adt-leanback-support

public static boolean canRead(Context context, Uri self) {
  // Ignore if grant doesn't allow read
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_READ_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  // Ignore documents without MIME
  if (TextUtils.isEmpty(getRawType(context, self))) {
    return false;
  }
  return true;
}

代码示例来源:origin: gigabytedevelopers/FireFiles

public static boolean canWrite(Context context, Uri self) {
  // Ignore if grant doesn't allow write
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  final String type = getRawType(context, self);
  final int flags = queryForInt(context, self, DocumentsContract.Document.COLUMN_FLAGS, 0);
  // Ignore documents without MIME
  if (TextUtils.isEmpty(type)) {
    return false;
  }
  // Deletable documents considered writable
  if ((flags & DocumentsContract.Document.FLAG_SUPPORTS_DELETE) != 0) {
    return true;
  }
  if (DocumentsContract.Document.MIME_TYPE_DIR.equals(type)
      && (flags & DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE) != 0) {
    // Directories that allow create considered writable
    return true;
  } else if (!TextUtils.isEmpty(type)
      && (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0) {
    // Writable normal files considered writable
    return true;
  }
  return false;
}

代码示例来源:origin: gigabytedevelopers/FireFiles

public static boolean canWrite(Context context, Uri self) {
  // Ignore if grant doesn't allow write
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  final String type = getRawType(context, self);
  final int flags = queryForInt(context, self, DocumentsContract.Document.COLUMN_FLAGS, 0);
  // Ignore documents without MIME
  if (TextUtils.isEmpty(type)) {
    return false;
  }
  // Deletable documents considered writable
  if ((flags & DocumentsContract.Document.FLAG_SUPPORTS_DELETE) != 0) {
    return true;
  }
  if (DocumentsContract.Document.MIME_TYPE_DIR.equals(type)
      && (flags & DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE) != 0) {
    // Directories that allow create considered writable
    return true;
  } else if (!TextUtils.isEmpty(type)
      && (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0) {
    // Writable normal files considered writable
    return true;
  }
  return false;
}

代码示例来源:origin: kingargyle/adt-leanback-support

public static boolean canWrite(Context context, Uri self) {
  // Ignore if grant doesn't allow write
  if (context.checkCallingOrSelfUriPermission(self, Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      != PackageManager.PERMISSION_GRANTED) {
    return false;
  }
  final String type = getRawType(context, self);
  final int flags = queryForInt(context, self, DocumentsContract.Document.COLUMN_FLAGS, 0);
  // Ignore documents without MIME
  if (TextUtils.isEmpty(type)) {
    return false;
  }
  // Deletable documents considered writable
  if ((flags & DocumentsContract.Document.FLAG_SUPPORTS_DELETE) != 0) {
    return true;
  }
  if (DocumentsContract.Document.MIME_TYPE_DIR.equals(type)
      && (flags & DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE) != 0) {
    // Directories that allow create considered writable
    return true;
  } else if (!TextUtils.isEmpty(type)
      && (flags & DocumentsContract.Document.FLAG_SUPPORTS_WRITE) != 0) {
    // Writable normal files considered writable
    return true;
  }
  return false;
}

相关文章

Context类方法