Java 类android.content.pm.ProviderInfo 实例源码
项目:CP-Tester
文件:MainActivity.java
private Observable<List<ProviderInfo>> getProviders(){
return Observable.fromCallable(new Callable<List<ProviderInfo>>() {
@Override public List<ProviderInfo> call() throws Exception {
List<ProviderInfo> info = new ArrayList<>();
for (PackageInfo providerInfo :getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)){
if (providerInfo.providers != null){
for (ProviderInfo provider : providerInfo.providers) {
if (provider.authority != null) {
if (sp.getBoolean("need_filter",false)){
info.add(provider);
}else if(provider.readPermission!=null){
info.add(provider);
}
}
}
}
}
return info;
}
});
}
项目:MovieGuide
文件:TestProvider.java
@Test
public void testProviderRegistry() {
Context appContext = InstrumentationRegistry.getTargetContext();
PackageManager pm = appContext.getPackageManager();
// We define the component name based on the package name from the context and the
// Provider class.
ComponentName componentName = new ComponentName(appContext.getPackageName(),
FavoritesProvider.class.getName());
try {
// Fetch the provider info using the component name from the PackageManager
// This throws an exception if the provider isn't registered.
ProviderInfo providerInfo = pm.getProviderInfo(componentName, 0);
// Make sure that the registered authority matches the authority from the Contract.
assertEquals("Error: FavoritesProvider registered with authority: " + providerInfo.authority
+ " instead of authority: " + FavoritesContract.AUTHORITY,
providerInfo.authority, FavoritesContract.AUTHORITY);
} catch (PackageManager.NameNotFoundException e) {
// I guess the provider isn't registered correctly.
assertTrue("Error: FavoritesProvider not registered at " + appContext.getPackageName(),
false);
}
}
项目:TPlayer
文件:ProviderIntentResolver.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected ResolveInfo newResult(VPackage.ProviderIntentInfo filter, int match, int userId) {
final VPackage.ProviderComponent provider = filter.provider;
PackageSetting ps = (PackageSetting) provider.owner.mExtras;
ProviderInfo pi = PackageParserEx.generateProviderInfo(provider, mFlags, ps.readUserState(userId), userId);
if (pi == null) {
return null;
}
final ResolveInfo res = new ResolveInfo();
res.providerInfo = pi;
if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
res.filter = filter.filter;
}
res.priority = filter.filter.getPriority();
res.preferredOrder = provider.owner.mPreferredOrder;
res.match = match;
res.isDefault = filter.hasDefault;
res.labelRes = filter.labelRes;
res.nonLocalizedLabel = filter.nonLocalizedLabel;
res.icon = filter.icon;
return res;
}
项目:DroidPlugin
文件:RunningProcesList.java
private void addProviderInfo(String stubAuthority, ProviderInfo info) {
if (!targetProviderInfos.containsKey(info.authority)) {
targetProviderInfos.put(info.authority, info);
if (!pkgs.contains(info.packageName)) {
pkgs.add(info.packageName);
}
//stub map to activity info
Set<ProviderInfo> list = providerInfosMap.get(stubAuthority);
if (list == null) {
list = new TreeSet<ProviderInfo>(sProviderInfoComparator);
list.add(info);
providerInfosMap.put(stubAuthority, list);
} else {
list.add(info);
}
}
}
项目:CodeWatch
文件:TestProvider.java
public void testProviderRegistry() {
PackageManager pm = mContext.getPackageManager();
ComponentName componentName = new ComponentName(mContext.getPackageName(),
LeaderProvider.class.getName());
try {
// Fetch the provider info using the component name from the PackageManager
// This throws an exception if the provider isn't registered.
ProviderInfo providerInfo = pm.getProviderInfo(componentName, 0);
// Make sure that the registered authority matches the authority from the Contract.
assertEquals("Error: LeaderProvider registered with authority: " + providerInfo.authority +
" instead of authority: " + LeaderContract.CONTENT_AUTHORITY,
providerInfo.authority, LeaderContract.CONTENT_AUTHORITY);
} catch (PackageManager.NameNotFoundException e) {
assertTrue("Error: LeaderProvider not registered at " + mContext.getPackageName(),
false);
}
}
项目:TPlayer
文件:VActivityManagerService.java
@Override
public IBinder acquireProviderClient(int userId, ProviderInfo info) {
ProcessRecord callerApp;
synchronized (mPidsSelfLocked) {
callerApp = findProcessLocked(VBinder.getCallingPid());
}
if (callerApp == null) {
throw new SecurityException("Who are you?");
}
String processName = info.processName;
ProcessRecord r;
synchronized (this) {
r = startProcessIfNeedLocked(processName, userId, info.packageName);
}
if (r != null && r.client.asBinder().isBinderAlive()) {
try {
return r.client.acquireProviderClient(info);
} catch (RemoteException e) {
e.printStackTrace();
}
}
return null;
}
项目:easyfilemanager
文件:RootsCache.java
private void handleDocumentsProvider(ProviderInfo info) {
// Ignore stopped packages for now; we might query them
// later during UI interaction.
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
mTaskStoppedAuthorities.add(info.authority);
return;
}
// Try using cached roots if filtering
boolean cacheHit = false;
if (mAuthority != null && !mAuthority.equals(info.authority)) {
synchronized (mLock) {
if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
cacheHit = true;
}
}
}
// Cache miss, or loading everything
if (!cacheHit) {
mTaskRoots.putAll(info.authority,
loadRootsForAuthority(mContext.getContentResolver(), info.authority));
}
}
项目:DroidPlugin
文件:RunningProcesList.java
void addProviderInfo(int pid, int uid, ProviderInfo stubInfo, ProviderInfo targetInfo) {
ProcessItem item = items.get(pid);
if (TextUtils.isEmpty(targetInfo.processName)) {
targetInfo.processName = targetInfo.packageName;
}
if (item == null) {
item = new ProcessItem();
item.pid = pid;
item.uid = uid;
items.put(pid, item);
}
item.stubProcessName = stubInfo.processName;
if (!item.pkgs.contains(targetInfo.packageName)) {
item.pkgs.add(targetInfo.packageName);
}
item.targetProcessName = targetInfo.processName;
item.addProviderInfo(stubInfo.authority, targetInfo);
}
项目:VirtualHook
文件:VPackageManagerService.java
@Override
public VParceledListSlice<ProviderInfo> queryContentProviders(String processName, int vuid, int flags) {
int userId = VUserHandle.getUserId(vuid);
checkUserId(userId);
flags = updateFlagsNought(flags);
ArrayList<ProviderInfo> finalList = new ArrayList<>(3);
// reader
synchronized (mPackages) {
for (VPackage.ProviderComponent p : mProvidersByComponent.values()) {
PackageSetting ps = (PackageSetting) p.owner.mExtras;
if (processName == null || ps.appId == VUserHandle.getAppId(vuid) && p.info.processName.equals(processName)) {
ProviderInfo providerInfo = PackageParserEx.generateProviderInfo(p, flags, ps.readUserState(userId), userId);
finalList.add(providerInfo);
}
}
}
if (!finalList.isEmpty()) {
Collections.sort(finalList, sProviderInitOrderSorter);
}
return new VParceledListSlice<>(finalList);
}
项目:VirtualHook
文件:VPackageManagerService.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
checkUserId(userId);
flags = updateFlagsNought(flags);
ComponentName comp = intent.getComponent();
if (comp == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
if (intent.getSelector() != null) {
intent = intent.getSelector();
comp = intent.getComponent();
}
}
}
if (comp != null) {
final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
final ProviderInfo pi = getProviderInfo(comp, flags, userId);
if (pi != null) {
final ResolveInfo ri = new ResolveInfo();
ri.providerInfo = pi;
list.add(ri);
}
return list;
}
// reader
synchronized (mPackages) {
String pkgName = intent.getPackage();
if (pkgName == null) {
return mProviders.queryIntent(intent, resolvedType, flags, userId);
}
final VPackage pkg = mPackages.get(pkgName);
if (pkg != null) {
return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
}
return Collections.emptyList();
}
}
项目:TPlayer
文件:PackageParserEx.java
public static ProviderInfo generateProviderInfo(VPackage.ProviderComponent p, int flags,
PackageUserState state, int userId) {
if (p == null) return null;
if (!checkUseInstalledOrHidden(state, flags)) {
return null;
}
// Make shallow copies so we can store the metadata safely
ProviderInfo pi = new ProviderInfo(p.info);
if ((flags & PackageManager.GET_META_DATA) != 0
&& (p.metaData != null)) {
pi.metaData = p.metaData;
}
if ((flags & PackageManager.GET_URI_PERMISSION_PATTERNS) == 0) {
pi.uriPermissionPatterns = null;
}
pi.applicationInfo = generateApplicationInfo(p.owner, flags, state, userId);
return pi;
}
项目:FireFiles
文件:RootsCache.java
private void handleDocumentsProvider(ProviderInfo info) {
// Ignore stopped packages for now; we might query them
// later during UI interaction.
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
mTaskStoppedAuthorities.add(info.authority);
return;
}
// Try using cached roots if filtering
boolean cacheHit = false;
if (mAuthority != null && !mAuthority.equals(info.authority)) {
synchronized (mLock) {
if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
cacheHit = true;
}
}
}
// Cache miss, or loading everything
if (!cacheHit) {
mTaskRoots.putAll(info.authority,
loadRootsForAuthority(mContext.getContentResolver(), info.authority));
}
}
项目:DroidPlugin
文件:AbstractContentProviderStub.java
private String getMyAuthority() throws PackageManager.NameNotFoundException, IllegalAccessException {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
return (String) FieldUtils.readField(this, "mAuthority");
} else {
Context context = getContext();
PackageInfo pkgInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PROVIDERS);
if (pkgInfo != null && pkgInfo.providers != null && pkgInfo.providers.length > 0) {
for (ProviderInfo info : pkgInfo.providers) {
if (TextUtils.equals(info.name, getClass().getName())) {
return info.authority;
}
}
}
}
return null;
}
项目:letv
文件:IApkManagerImpl.java
public ProviderInfo resolveContentProvider(String name, int flags) throws RemoteException {
waitForReadyInner();
try {
enforcePluginFileExists();
if (shouldNotBlockOtherInfo()) {
for (PluginPackageParser pluginPackageParser : this.mPluginCache.values()) {
for (ProviderInfo providerInfo : pluginPackageParser.getProviders()) {
if (TextUtils.equals(providerInfo.authority, name)) {
return providerInfo;
}
}
}
}
List<String> pkgs = this.mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
for (PluginPackageParser pluginPackageParser2 : this.mPluginCache.values()) {
for (ProviderInfo providerInfo2 : pluginPackageParser2.getProviders()) {
if (TextUtils.equals(providerInfo2.authority, name) && pkgs.contains(providerInfo2.packageName)) {
return providerInfo2;
}
}
}
} catch (Exception e) {
handleException(e);
}
return null;
}
项目:letv
文件:ApkManager.java
public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException, RemoteException {
ProviderInfo providerInfo = null;
if (className != null) {
try {
if (!(this.mApkManager == null || className == null)) {
providerInfo = this.mApkManager.getProviderInfo(className, flags);
}
} catch (RemoteException e) {
JLog.log("wuxinrong", "获取Provider信息 失败 e=" + e.getMessage());
throw e;
} catch (Exception e2) {
JLog.log("wuxinrong", "获取Provider信息 失败 e=" + e2.getMessage());
}
}
return providerInfo;
}
项目:letv
文件:UIs.java
private static String getAuthorityFromPermission(String permission) {
List<PackageInfo> packs = BaseApplication.getInstance().getPackageManager().getInstalledPackages(8);
if (packs != null) {
for (PackageInfo pack : packs) {
ProviderInfo[] providers = pack.providers;
if (!BaseTypeUtils.isArrayEmpty(providers)) {
for (ProviderInfo provider : providers) {
String readPermission = provider.readPermission;
if (readPermission != null && permission.equals(readPermission)) {
return provider.authority;
}
}
continue;
}
}
}
return null;
}
项目:DroidPlugin
文件:IPackageManagerHookHandle.java
@Override
protected void afterInvoke(Object receiver, Method method, Object[] args, Object invokeResult) throws Throwable {
if (args != null) {
if (invokeResult == null) {
final int index0 = 0, index1 = 1;
if (args.length >= 2 && args[index0] instanceof String && args[index1] instanceof Integer) {
String name = (String) args[index0];
Integer flags = (Integer) args[index1];
ProviderInfo info = PluginManager.getInstance().resolveContentProvider(name, flags);
if (info != null) {
setFakedResult(info);
}
}
}
}
super.afterInvoke(receiver, method, args, invokeResult);
}
项目:container
文件:ProviderIntentResolver.java
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected ResolveInfo newResult(PackageParser.ProviderIntentInfo filter, int match) {
final PackageParser.Provider provider = filter.provider;
ProviderInfo pi = PackageParserCompat.generateProviderInfo(provider, mFlags);
if (pi == null) {
return null;
}
final ResolveInfo res = new ResolveInfo();
res.providerInfo = pi;
if ((mFlags & PackageManager.GET_RESOLVED_FILTER) != 0) {
res.filter = filter;
}
res.priority = filter.getPriority();
res.preferredOrder = provider.owner.mPreferredOrder;
res.match = match;
res.isDefault = filter.hasDefault;
res.labelRes = filter.labelRes;
res.nonLocalizedLabel = filter.nonLocalizedLabel;
res.icon = filter.icon;
return res;
}
项目:VirtualHook
文件:VActivityManagerService.java
@Override
public IBinder acquireProviderClient(int userId, ProviderInfo info) {
ProcessRecord callerApp;
synchronized (mPidsSelfLocked) {
callerApp = findProcessLocked(VBinder.getCallingPid());
}
if (callerApp == null) {
throw new SecurityException("Who are you?");
}
String processName = info.processName;
ProcessRecord r;
synchronized (this) {
r = startProcessIfNeedLocked(processName, userId, info.packageName);
}
if (r != null && r.client.asBinder().isBinderAlive()) {
try {
return r.client.acquireProviderClient(info);
} catch (RemoteException e) {
e.printStackTrace();
}
}
return null;
}
项目:LaunchEnr
文件:ImportDataTask.java
/**
* Performs data import if possible.
* @return true on successful data import, false if it was not available
* @throws Exception if the import failed
*/
public static boolean performImportIfPossible(Context context) throws Exception {
SharedPreferences devicePrefs = getDevicePrefs(context);
String sourcePackage = devicePrefs.getString(KEY_DATA_IMPORT_SRC_PKG, "");
String sourceAuthority = devicePrefs.getString(KEY_DATA_IMPORT_SRC_AUTHORITY, "");
if (TextUtils.isEmpty(sourcePackage) || TextUtils.isEmpty(sourceAuthority)) {
return false;
}
// Synchronously clear the migration flags. This ensures that we do not try migration
// again and thus prevents potential crash loops due to migration failure.
devicePrefs.edit().remove(KEY_DATA_IMPORT_SRC_PKG).remove(KEY_DATA_IMPORT_SRC_AUTHORITY).apply();
if (!Settings.call(context.getContentResolver(), Settings.METHOD_WAS_EMPTY_DB_CREATED)
.getBoolean(Settings.EXTRA_VALUE, false)) {
// Only migration if a new DB was created.
return false;
}
for (ProviderInfo info : context.getPackageManager().queryContentProviders(
null, context.getApplicationInfo().uid, 0)) {
if (sourcePackage.equals(info.packageName)) {
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// Only migrate if the source launcher is also on system image.
return false;
}
// Wait until we found a provider with matching authority.
if (sourceAuthority.equals(info.authority)) {
if (TextUtils.isEmpty(info.readPermission) ||
context.checkPermission(info.readPermission, Process.myPid(),
Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
// All checks passed, run the import task.
return new ImportDataTask(context, sourceAuthority).importWorkspace();
}
}
}
}
return false;
}
项目:CP-Tester
文件:QueryFragment.java
public static QueryFragment newInstance(ProviderInfo provider) {
QueryFragment fragment = new QueryFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_PROVIDER, provider);
fragment.setArguments(args);
return fragment;
}
项目:VirtualHook
文件:PackageParserCompat.java
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {
if (API_LEVEL >= M) {
return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= LOLLIPOP_MR1) {
return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= LOLLIPOP) {
return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= JELLY_BEAN_MR1) {
return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= JELLY_BEAN) {
return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);
} else {
return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
}
}
项目:CP-Tester
文件:SchemaFragment.java
public static SchemaFragment newInstance(ProviderInfo provider) {
SchemaFragment fragment = new SchemaFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_PROVIDER, provider);
fragment.setArguments(args);
return fragment;
}
项目:Phial
文件:FileProvider.java
/**
* Parse and return {@link PathStrategy} for given authority as defined in
* {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
*
* @see #getPathStrategy(Context, String)
*/
private static PathStrategy parsePathStrategy(Context context, String authority)
throws IOException, XmlPullParserException {
final SimplePathStrategy strat = new SimplePathStrategy(authority);
final ProviderInfo info = context.getPackageManager()
.resolveContentProvider(authority, PackageManager.GET_META_DATA);
final XmlResourceParser in = info.loadXmlMetaData(
context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
if (in == null) {
throw new IllegalArgumentException(
"Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
}
int type;
while ((type = in.next()) != END_DOCUMENT) {
if (type == START_TAG) {
final String tag = in.getName();
final String name = in.getAttributeValue(null, ATTR_NAME);
String path = in.getAttributeValue(null, ATTR_PATH);
File target = null;
if (TAG_ROOT_PATH.equals(tag)) {
target = DEVICE_ROOT;
} else if (TAG_FILES_PATH.equals(tag)) {
target = context.getFilesDir();
} else if (TAG_CACHE_PATH.equals(tag)) {
target = context.getCacheDir();
} else if (TAG_EXTERNAL.equals(tag)) {
target = Environment.getExternalStorageDirectory();
} else if (TAG_EXTERNAL_FILES.equals(tag)) {
File[] externalFilesDirs = getExternalFilesDirs(context, null);
if (externalFilesDirs.length > 0) {
target = externalFilesDirs[0];
}
} else if (TAG_EXTERNAL_CACHE.equals(tag)) {
File[] externalCacheDirs = getExternalCacheDirs(context);
if (externalCacheDirs.length > 0) {
target = externalCacheDirs[0];
}
}
if (target != null) {
strat.addRoot(name, buildPath(target, path));
}
}
}
return strat;
}
项目:container
文件:VPackageManager.java
public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
try {
// noinspection unchecked
return getInterface().queryContentProviders(processName, uid, flags).getList();
} catch (RemoteException e) {
return VirtualRuntime.crash(e);
}
}
项目:simple-share-android
文件:DocumentsProvider.java
/**
* Implementation is provided by the parent class.
*/
@Override
public void attachInfo(Context context, ProviderInfo info) {
mAuthority = info.authority;
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mMatcher.addURI(mAuthority, "root", MATCH_ROOTS);
mMatcher.addURI(mAuthority, "root/*", MATCH_ROOT);
mMatcher.addURI(mAuthority, "root/*/recent", MATCH_RECENT);
mMatcher.addURI(mAuthority, "root/*/search", MATCH_SEARCH);
mMatcher.addURI(mAuthority, "document/*", MATCH_DOCUMENT);
mMatcher.addURI(mAuthority, "document/*/children", MATCH_CHILDREN);
mMatcher.addURI(mAuthority, "tree/*/document/*", MATCH_DOCUMENT_TREE);
mMatcher.addURI(mAuthority, "tree/*/document/*/children", MATCH_CHILDREN_TREE);
// Sanity check our setup
if (!info.exported) {
throw new SecurityException("Provider must be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grantUriPermissions");
}
/* if (!android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.readPermission)
|| !android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.writePermission)) {
throw new SecurityException("Provider must be protected by MANAGE_DOCUMENTS");
}
*/
super.attachInfo(context, info);
}
项目:VirtualHook
文件:VPackageManager.java
public ProviderInfo getProviderInfo(ComponentName componentName, int flags, int userId) {
try {
return getInterface().getProviderInfo(componentName, flags, userId);
} catch (RemoteException e) {
return VirtualRuntime.crash(e);
}
}
项目:container
文件:VPackageManagerService.java
@Override
public ProviderInfo resolveContentProvider(String name, int flags, int userId) {
checkUserId(userId);
synchronized (mPackages) {
final PackageParser.Provider provider = mProvidersByAuthority.get(name);
if (provider != null) {
ProviderInfo providerInfo = PackageParserCompat.generateProviderInfo(provider, flags);
PackageParser.Package p = mPackages.get(providerInfo.packageName);
AppSetting settings = (AppSetting) p.mExtras;
ComponentFixer.fixComponentInfo(settings, providerInfo, userId);
return providerInfo;
}
}
return null;
}
项目:CrashReporter
文件:CrashReporterInitProvider.java
@Override
public void attachInfo(Context context, ProviderInfo providerInfo) {
if (providerInfo == null) {
throw new NullPointerException("CrashReporterInitProvider ProviderInfo cannot be null.");
}
// So if the authorities equal the library internal ones, the developer forgot to set his applicationId
if ("com.balsikandar.crashreporter.CrashReporterInitProvider".equals(providerInfo.authority)) {
throw new IllegalStateException("Incorrect provider authority in manifest. Most likely due to a "
+ "missing applicationId variable in application\'s build.gradle.");
}
super.attachInfo(context, providerInfo);
}
项目:VirtualHook
文件:VPackageManager.java
public ProviderInfo resolveContentProvider(String name, int flags, int userId) {
try {
return getInterface().resolveContentProvider(name, flags, userId);
} catch (RemoteException e) {
return VirtualRuntime.crash(e);
}
}
项目:easyfilemanager
文件:DocumentsProvider.java
/**
* Implementation is provided by the parent class.
*/
@Override
public void attachInfo(Context context, ProviderInfo info) {
mAuthority = info.authority;
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
mMatcher.addURI(mAuthority, "root", MATCH_ROOTS);
mMatcher.addURI(mAuthority, "root/*", MATCH_ROOT);
mMatcher.addURI(mAuthority, "root/*/recent", MATCH_RECENT);
mMatcher.addURI(mAuthority, "root/*/search", MATCH_SEARCH);
mMatcher.addURI(mAuthority, "document/*", MATCH_DOCUMENT);
mMatcher.addURI(mAuthority, "document/*/children", MATCH_CHILDREN);
mMatcher.addURI(mAuthority, "tree/*/document/*", MATCH_DOCUMENT_TREE);
mMatcher.addURI(mAuthority, "tree/*/document/*/children", MATCH_CHILDREN_TREE);
// Sanity check our setup
if (!info.exported) {
throw new SecurityException("Provider must be exported");
}
if (!info.grantUriPermissions) {
throw new SecurityException("Provider must grantUriPermissions");
}
/* if (!android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.readPermission)
|| !android.Manifest.permission.MANAGE_DOCUMENTS.equals(info.writePermission)) {
throw new SecurityException("Provider must be protected by MANAGE_DOCUMENTS");
}
*/
super.attachInfo(context, info);
}
项目:MiPushFramework
文件:CondomProcess.java
private static void doValidateProcessNames(final Application app, final String[] process_names) {
try {
final PackageInfo info = app.getPackageManager().getPackageInfo(app.getPackageName(),
GET_ACTIVITIES | GET_SERVICES | GET_RECEIVERS | GET_PROVIDERS);
final Set<String> defined_process_names = new HashSet<>();
if (info.activities != null) for (final ActivityInfo activity : info.activities) defined_process_names.add(activity.processName);
if (info.services != null) for (final ServiceInfo service : info.services) defined_process_names.add(service.processName);
if (info.receivers != null) for (final ActivityInfo receiver : info.receivers) defined_process_names.add(receiver.processName);
if (info.providers != null) for (final ProviderInfo provider : info.providers) defined_process_names.add(provider.processName);
for (final String process_name : process_names)
if (! defined_process_names.contains(getFullProcessName(app, process_name)))
throw new IllegalArgumentException("Process name \"" + process_name + "\" is not used by any component in AndroidManifest.xml");
} catch (final PackageManager.NameNotFoundException ignored) {} // Should never happen
}
项目:ObjectBoxDebugBrowser
文件:DebugDBInitProvider.java
@Override
public void attachInfo(Context context, ProviderInfo providerInfo) {
if (providerInfo == null) {
throw new NullPointerException("DebugDBInitProvider ProviderInfo cannot be null.");
}
// So if the authorities equal the library internal ones, the developer forgot to set his applicationId
if ("com.amitshekhar.DebugDBInitProvider".equals(providerInfo.authority)) {
throw new IllegalStateException("Incorrect provider authority in manifest. Most likely due to a "
+ "missing applicationId variable in application\'s build.gradle.");
}
super.attachInfo(context, providerInfo);
}
项目:android-apkbox
文件:ApkLoader.java
/**
* parseProviders
*
* @param apkPath apkPath
* @return providers
*/
public static List<ProviderInfo> parseProviders(String apkPath) {
List<ProviderInfo> ret = new ArrayList<>();
File apkFile = new File(apkPath);
if (apkFile.exists()) {
try {
Class<?> packageParserClass = Class.forName("android.content.pm.PackageParser");
Method parsePackageMethod = packageParserClass.getDeclaredMethod("parsePackage", File.class, int.class);
Object packageParser = packageParserClass.newInstance();
Object packageObj = parsePackageMethod.invoke(packageParser, apkFile, PackageManager.GET_PROVIDERS);
Field providersField = packageObj.getClass().getDeclaredField("providers");
List providers = (List) providersField.get(packageObj);
Class<?> packageParser$ProviderClass = Class.forName("android.content.pm.PackageParser$Provider");
Class<?> packageUserStateClass = Class.forName("android.content.pm.PackageUserState");
Class<?> userHandler = Class.forName("android.os.UserHandle");
Method getCallingUserIdMethod = userHandler.getDeclaredMethod("getCallingUserId");
int userId = (Integer) getCallingUserIdMethod.invoke(null);
Object defaultUserState = packageUserStateClass.newInstance();
Method generateProviderInfo = packageParserClass.getDeclaredMethod("generateProviderInfo",
packageParser$ProviderClass, int.class, packageUserStateClass, int.class);
for (Object service : providers) {
ProviderInfo info = (ProviderInfo) generateProviderInfo.invoke(packageParser, service, 0, defaultUserState, userId);
ret.add(info);
}
} catch (Exception e) {
}
}
return ret;
}
项目:SimpleUILauncher
文件:ImportDataTask.java
/**
* Performs data import if possible.
* @return true on successful data import, false if it was not available
* @throws Exception if the import failed
*/
public static boolean performImportIfPossible(Context context) throws Exception {
SharedPreferences devicePrefs = getDevicePrefs(context);
String sourcePackage = devicePrefs.getString(KEY_DATA_IMPORT_SRC_PKG, "");
String sourceAuthority = devicePrefs.getString(KEY_DATA_IMPORT_SRC_AUTHORITY, "");
if (TextUtils.isEmpty(sourcePackage) || TextUtils.isEmpty(sourceAuthority)) {
return false;
}
// Synchronously clear the migration flags. This ensures that we do not try migration
// again and thus prevents potential crash loops due to migration failure.
devicePrefs.edit().remove(KEY_DATA_IMPORT_SRC_PKG).remove(KEY_DATA_IMPORT_SRC_AUTHORITY).commit();
if (!Settings.call(context.getContentResolver(), Settings.METHOD_WAS_EMPTY_DB_CREATED)
.getBoolean(Settings.EXTRA_VALUE, false)) {
// Only migration if a new DB was created.
return false;
}
for (ProviderInfo info : context.getPackageManager().queryContentProviders(
null, context.getApplicationInfo().uid, 0)) {
if (sourcePackage.equals(info.packageName)) {
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
// Only migrate if the source launcher is also on system image.
return false;
}
// Wait until we found a provider with matching authority.
if (sourceAuthority.equals(info.authority)) {
if (TextUtils.isEmpty(info.readPermission) ||
context.checkPermission(info.readPermission, Process.myPid(),
Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
// All checks passed, run the import task.
return new ImportDataTask(context, sourceAuthority).importWorkspace();
}
}
}
}
return false;
}
项目:TPlayer
文件:PackageParserCompat.java
public static ProviderInfo generateProviderInfo(Provider provider, int flags) {
if (API_LEVEL >= M) {
return PackageParserMarshmallow.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= LOLLIPOP_MR1) {
return PackageParserLollipop22.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= LOLLIPOP) {
return PackageParserLollipop.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= JELLY_BEAN_MR1) {
return PackageParserJellyBean17.generateProviderInfo.call(provider, flags, sUserState, myUserId);
} else if (API_LEVEL >= JELLY_BEAN) {
return PackageParserJellyBean.generateProviderInfo.call(provider, flags, false, 1, myUserId);
} else {
return mirror.android.content.pm.PackageParser.generateProviderInfo.call(provider, flags);
}
}
项目:atlas
文件:ContentProviderBridge.java
public static Object getContentProvider(ProviderInfo info){
String targetProcessName = info.processName!=null ? info.processName : RuntimeVariables.androidApplication.getPackageName();
String currentProcessName = RuntimeVariables.getProcessName(RuntimeVariables.androidApplication);
if(info.multiprocess || targetProcessName.equals(RuntimeVariables.getProcessName(RuntimeVariables.androidApplication))){
return transactProviderInstall(currentProcessName,info);
}else{
return transactProviderInstall(info.processName,info);
}
}
项目:atlas
文件:ContentProviderBridge.java
private static Object transactProviderInstall(String processName,ProviderInfo info){
Bundle extras = new Bundle();
extras.putParcelable(PROVIDER_INFO_KEY,info);
ContentResolver contentResolver = RuntimeVariables.androidApplication.getContentResolver();
Bundle bundle = contentResolver.call(accquireRemoteBridgeToken(processName),METHOD_INSTALLPROVIDER,"",extras);
Object holder = bundle.getParcelable(PROVIDER_HOLDER_KEY);
return holder;
}
项目:DroidPlugin
文件:StaticProcessList.java
private void addProviderInfo(ProviderInfo info) {
if (TextUtils.isEmpty(info.processName)) {
info.processName = info.packageName;
}
ProcessItem item = items.get(info.processName);
if (item == null) {
item = new ProcessItem();
item.name = info.processName;
items.put(info.processName, item);
}
item.addProviderInfo(info);
}
项目:chuck
文件:ChuckContentProvider.java
@Override
public void attachInfo(Context context, ProviderInfo info) {
super.attachInfo(context, info);
TRANSACTION_URI = Uri.parse("content://" + info.authority + "/transaction");
matcher.addURI(info.authority, "transaction/#", TRANSACTION);
matcher.addURI(info.authority, "transaction", TRANSACTIONS);
}