java类android.content.pm.ProviderInfo的实例源码

MainActivity.java 文件源码 项目:CP-Tester 阅读 35 收藏 0 点赞 0 评论 0
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;
        }
    });
}
TestProvider.java 文件源码 项目:MovieGuide 阅读 44 收藏 0 点赞 0 评论 0
@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);
    }
}
ProviderIntentResolver.java 文件源码 项目:TPlayer 阅读 45 收藏 0 点赞 0 评论 0
@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;
}
RunningProcesList.java 文件源码 项目:DroidPlugin 阅读 37 收藏 0 点赞 0 评论 0
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);
        }
    }
}
TestProvider.java 文件源码 项目:CodeWatch 阅读 31 收藏 0 点赞 0 评论 0
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);
    }
}
VActivityManagerService.java 文件源码 项目:TPlayer 阅读 41 收藏 0 点赞 0 评论 0
@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;
}
RootsCache.java 文件源码 项目:easyfilemanager 阅读 37 收藏 0 点赞 0 评论 0
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));
    }
}
RunningProcesList.java 文件源码 项目:DroidPlugin 阅读 40 收藏 0 点赞 0 评论 0
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);
}
VPackageManagerService.java 文件源码 项目:VirtualHook 阅读 37 收藏 0 点赞 0 评论 0
@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);
}
VPackageManagerService.java 文件源码 项目:VirtualHook 阅读 38 收藏 0 点赞 0 评论 0
@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();
    }
}
PackageParserEx.java 文件源码 项目:TPlayer 阅读 49 收藏 0 点赞 0 评论 0
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;
}
RootsCache.java 文件源码 项目:FireFiles 阅读 31 收藏 0 点赞 0 评论 0
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));
    }
}
AbstractContentProviderStub.java 文件源码 项目:DroidPlugin 阅读 45 收藏 0 点赞 0 评论 0
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;
}
IApkManagerImpl.java 文件源码 项目:letv 阅读 41 收藏 0 点赞 0 评论 0
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;
}
ApkManager.java 文件源码 项目:letv 阅读 47 收藏 0 点赞 0 评论 0
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;
}
UIs.java 文件源码 项目:letv 阅读 42 收藏 0 点赞 0 评论 0
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;
}
IPackageManagerHookHandle.java 文件源码 项目:DroidPlugin 阅读 37 收藏 0 点赞 0 评论 0
@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);
}
ProviderIntentResolver.java 文件源码 项目:container 阅读 46 收藏 0 点赞 0 评论 0
@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;
}
VActivityManagerService.java 文件源码 项目:VirtualHook 阅读 40 收藏 0 点赞 0 评论 0
@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;
}
ImportDataTask.java 文件源码 项目:LaunchEnr 阅读 40 收藏 0 点赞 0 评论 0
/**
 * 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;
}
QueryFragment.java 文件源码 项目:CP-Tester 阅读 42 收藏 0 点赞 0 评论 0
public static QueryFragment newInstance(ProviderInfo provider) {
    QueryFragment fragment = new QueryFragment();
    Bundle args = new Bundle();
    args.putParcelable(ARG_PROVIDER, provider);
    fragment.setArguments(args);
    return fragment;
}
PackageParserCompat.java 文件源码 项目:VirtualHook 阅读 47 收藏 0 点赞 0 评论 0
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);
    }
}
SchemaFragment.java 文件源码 项目:CP-Tester 阅读 26 收藏 0 点赞 0 评论 0
public static SchemaFragment newInstance(ProviderInfo provider) {
    SchemaFragment fragment = new SchemaFragment();
    Bundle args = new Bundle();
    args.putParcelable(ARG_PROVIDER, provider);
    fragment.setArguments(args);
    return fragment;
}
FileProvider.java 文件源码 项目:Phial 阅读 41 收藏 0 点赞 0 评论 0
/**
 * 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;
}
VPackageManager.java 文件源码 项目:container 阅读 40 收藏 0 点赞 0 评论 0
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);
    }
}
DocumentsProvider.java 文件源码 项目:simple-share-android 阅读 44 收藏 0 点赞 0 评论 0
/**
     * 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);
    }
VPackageManager.java 文件源码 项目:VirtualHook 阅读 39 收藏 0 点赞 0 评论 0
public ProviderInfo getProviderInfo(ComponentName componentName, int flags, int userId) {
    try {
        return getInterface().getProviderInfo(componentName, flags, userId);
    } catch (RemoteException e) {
        return VirtualRuntime.crash(e);
    }
}
VPackageManagerService.java 文件源码 项目:container 阅读 46 收藏 0 点赞 0 评论 0
@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;
}
CrashReporterInitProvider.java 文件源码 项目:CrashReporter 阅读 37 收藏 0 点赞 0 评论 0
@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);
}
VPackageManager.java 文件源码 项目:VirtualHook 阅读 42 收藏 0 点赞 0 评论 0
public ProviderInfo resolveContentProvider(String name, int flags, int userId) {
    try {
        return getInterface().resolveContentProvider(name, flags, userId);
    } catch (RemoteException e) {
        return VirtualRuntime.crash(e);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号