android.content.pm.ProviderInfo Java Examples
The following examples show how to use
android.content.pm.ProviderInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IPackageManagerHookHandle.java From DroidPlugin with GNU Lesser General Public License v3.0 | 6 votes |
@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); }
Example #2
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException { final int userId = getUserId(); try { ProviderInfo pi = mPM.getProviderInfo(className, updateFlagsForComponent(flags, userId, null), userId); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); }
Example #3
Source File: PackageInfoAssembler.java From under-the-hood with Apache License 2.0 | 6 votes |
/** * Lists all defined providers with additional meta-data * * @param packageInfo from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_PROVIDERS} flag * @return entries */ public static List<PageEntry<?>> createPmProviderInfo(@NonNull PackageInfo packageInfo) { List<PageEntry<?>> entries = new ArrayList<>(); if (packageInfo.providers != null) { for (ProviderInfo provider : packageInfo.providers) { if (provider != null) { entries.add(Hood.get().createPropertyEntry(provider.name, "exported: " + provider.exported + "\n" + "enabled: " + provider.enabled + "\n" + "authorities: " + provider.authority + "\n" + "multi-process: " + provider.multiprocess + "\n" + "read-perm: " + provider.readPermission + "\n" + "write-perm: " + provider.writePermission + "\n", true)); } } } return entries; }
Example #4
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private void installContentProviders( Context context, List<ProviderInfo> providers) { final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>(); for (ProviderInfo cpi : providers) { StringBuilder buf = new StringBuilder(128); buf.append("Pub "); buf.append(cpi.authority); buf.append(": "); buf.append(cpi.name); Log.i(TAG, buf.toString()); IActivityManager.ContentProviderHolder cph = installProvider(context, null, cpi, false /*noisy*/, true /*noReleaseNeeded*/, true /*stable*/); if (cph != null) { cph.noReleaseNeeded = true; results.add(cph); } } try { ActivityManagerNative.getDefault().publishContentProviders( getApplicationThread(), results); } catch (RemoteException ex) { } }
Example #5
Source File: ContentProviderProxy.java From GPT with Apache License 2.0 | 6 votes |
/** * 安装阶段调用,把package对应的provider存入sp中。 * * @param hostContext Context * @param providers ProviderInfo[] */ public static void addProviders(Context hostContext, ProviderInfo[] providers) { if (hostContext == null || providers == null || providers.length == 0) { return; } SharedPreferences sp = hostContext.getSharedPreferences(SP_FILENAME, Context.MODE_PRIVATE); Editor editor = sp.edit(); for (ProviderInfo provider : providers) { String packageName = provider.packageName; String authority = provider.authority; if (sp.contains(authority)) { if (Constants.DEBUG) { Log.e("ContentProviderProxy", packageName + "的provider: " + authority + " 已经存在 , replace it."); } } editor.putString(authority, packageName); } editor.commit(); }
Example #6
Source File: FileProvider.java From V.FlyoutTest with MIT License | 5 votes |
/** * After the FileProvider is instantiated, this method is called to provide the system with * information about the provider. * * @param context A {@link Context} for the current component. * @param info A {@link ProviderInfo} for the new provider. */ @Override public void attachInfo(Context context, ProviderInfo info) { super.attachInfo(context, info); // Sanity check our security if (info.exported) { throw new SecurityException("Provider must not be exported"); } if (!info.grantUriPermissions) { throw new SecurityException("Provider must grant uri permissions"); } mStrategy = getPathStrategy(context, info.authority); }
Example #7
Source File: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private PackageParser.Package getDefaultProviderAuthorityPackage( String authority, int userId) { ProviderInfo provider = mServiceInternal.resolveContentProvider(authority, DEFAULT_FLAGS, userId); if (provider != null) { return getSystemPackage(provider.packageName); } return null; }
Example #8
Source File: DynamicActivityThread.java From Android-plugin-support with MIT License | 5 votes |
private List<ProviderInfo> generateProviderInfos(List<DynamicApkParser.Provider> providers) { List<ProviderInfo> providerInfos = new ArrayList<>(); for (DynamicApkParser.Provider p : providers) { p.info.packageName = getHostPackageName(); p.info.applicationInfo.packageName = getHostPackageName(); providerInfos.add(p.info); } return providerInfos; }
Example #9
Source File: FileProvider.java From AndPermission with Apache License 2.0 | 5 votes |
@Override public void attachInfo(Context context, ProviderInfo info) { super.attachInfo(context, info); if (info.exported) { throw new SecurityException("Provider must not be exported"); } if (!info.grantUriPermissions) { throw new SecurityException("Provider must grant uri permissions"); } mStrategy = getPathStrategy(context, info.authority); }
Example #10
Source File: QueryContentProviders.java From container with GNU General Public License v3.0 | 5 votes |
@Override public Object call(Object who, Method method, Object... args) throws Throwable { String processName = (String) args[0]; int flags = (int) args[2]; List<ProviderInfo> infos = VPackageManager.get().queryContentProviders(processName, flags, 0); if (ParceledListSliceCompat.isReturnParceledListSlice(method)) { return ParceledListSliceCompat.create(infos); } return infos; }
Example #11
Source File: ApplicationPackageManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException { try { ProviderInfo pi = mPM.getProviderInfo(className, flags, mContext.getUserId()); if (pi != null) { return pi; } } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } throw new NameNotFoundException(className.toString()); }
Example #12
Source File: ContentProviderHolder.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private ContentProviderHolder(Parcel source) { info = ProviderInfo.CREATOR.createFromParcel(source); provider = ContentProviderNative.asInterface( source.readStrongBinder()); connection = source.readStrongBinder(); noReleaseNeeded = source.readInt() != 0; }
Example #13
Source File: FileManager.java From DeviceConnect-Android with MIT License | 5 votes |
/** * コンストラクタ. * * @param context コンテキスト * @param fileProvider FileProviderクラス名 */ public FileManager(final Context context, final String fileProvider) { mContext = context; mFileProviderClassName = fileProvider; File dir = getBasePath(); if (!dir.exists()) { if (!dir.mkdirs()) { mLogger.warning("Cannot create a folder."); } } PackageManager pkgMgr = context.getPackageManager(); try { PackageInfo packageInfo = pkgMgr.getPackageInfo(context.getPackageName(), PackageManager.GET_PROVIDERS); ProviderInfo[] providers = packageInfo.providers; if (providers != null) { for (ProviderInfo provider : providers) { if (mFileProviderClassName.equals(provider.name)) { mAuthority = provider.authority; } } } if (mAuthority == null) { throw new RuntimeException("Cannot found provider."); } } catch (NameNotFoundException e) { throw new RuntimeException("Cannot found provider."); } mWorkerThread = new HandlerThread(getClass().getSimpleName()); mWorkerThread.start(); mHandler = new Handler(mWorkerThread.getLooper()); }
Example #14
Source File: SentryInitProvider.java From sentry-android with MIT License | 5 votes |
@Override public void attachInfo(Context context, ProviderInfo info) { // applicationId is expected to be prepended. See AndroidManifest.xml if (SentryInitProvider.class.getName().equals(info.authority)) { throw new IllegalStateException( "An applicationId is required to fulfill the manifest placeholder."); } super.attachInfo(context, info); }
Example #15
Source File: IntentMatcher.java From DroidPlugin with GNU Lesser General Public License v3.0 | 5 votes |
@TargetApi(VERSION_CODES.KITKAT) private static ResolveInfo newResolveInfo(ProviderInfo providerInfo, IntentFilter intentFilter) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.providerInfo = providerInfo; resolveInfo.filter = intentFilter; resolveInfo.resolvePackageName = providerInfo.packageName; resolveInfo.labelRes = providerInfo.labelRes; resolveInfo.icon = providerInfo.icon; resolveInfo.specificIndex = 1; // 默认就是false,不用再设置了。 // resolveInfo.system = false; resolveInfo.priority = intentFilter.getPriority(); resolveInfo.preferredOrder = 0; return resolveInfo; }
Example #16
Source File: AbstractContentProviderStub.java From letv with Apache License 2.0 | 5 votes |
private String getMyAuthority() throws NameNotFoundException, IllegalAccessException { if (VERSION.SDK_INT >= 21) { return (String) FieldUtils.readField((Object) this, "mAuthority"); } Context context = getContext(); PackageInfo pkgInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 8); 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; }
Example #17
Source File: CrashReporterInitProvider.java From CrashReporter with Apache License 2.0 | 5 votes |
@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); }
Example #18
Source File: IconUtils.java From FireFiles with Apache License 2.0 | 5 votes |
public static Drawable loadPackageIcon(Context context, String authority, int icon) { if (icon != 0) { if (authority != null) { final PackageManager pm = context.getPackageManager(); final ProviderInfo info = pm.resolveContentProvider(authority, 0); if (info != null) { return pm.getDrawable(info.packageName, icon, info.applicationInfo); } } else { return ContextCompat.getDrawable(context, icon); } } return null; }
Example #19
Source File: ChuckContentProvider.java From chuck with Apache License 2.0 | 5 votes |
@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); }
Example #20
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags, String metaDataKey) { try { ParceledListSlice<ProviderInfo> slice = mPM.queryContentProviders(processName, uid, flags, metaDataKey); return slice != null ? slice.getList() : Collections.<ProviderInfo>emptyList(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } }
Example #21
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
/** @hide **/ @Override public ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId) { try { return mPM.resolveContentProvider(name, flags, userId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } }
Example #22
Source File: DisallowedProviders.java From SafeContentResolver with Apache License 2.0 | 5 votes |
private Set<String> findDisallowedContentProviderAuthorities() { ProviderInfo[] providers = getProviderInfo(context); Set<String> disallowedAuthorities = new HashSet<>(providers.length); for (ProviderInfo providerInfo : providers) { if (!isContentProviderAllowed(providerInfo)) { String[] authorities = providerInfo.authority.split(";"); Collections.addAll(disallowedAuthorities, authorities); } } return disallowedAuthorities; }
Example #23
Source File: OurFileProvider.java From secrecy with Apache License 2.0 | 5 votes |
@Override public void attachInfo(Context context, ProviderInfo info) { super.attachInfo(context, info); // Sanity check our security if (info.exported) { throw new SecurityException("Provider must not be exported"); } if (!info.grantUriPermissions) { throw new SecurityException("Provider must grant uri permissions"); } mStrategy = getPathStrategy(context, info.authority); }
Example #24
Source File: LoadedPlugin.java From VirtualAPK with Apache License 2.0 | 5 votes |
@Override public ProviderInfo getProviderInfo(ComponentName component, int flags) throws NameNotFoundException { LoadedPlugin plugin = mPluginManager.getLoadedPlugin(component); if (null != plugin) { return plugin.mProviderInfos.get(component); } return this.mHostPackageManager.getProviderInfo(component, flags); }
Example #25
Source File: PluginDelegateContentProviderImpl.java From AndroidPlugin with MIT License | 5 votes |
private void initializeContentProviderInfo() { PackageInfo packageInfo = mPluginClient.mClientPackageInfo; if ((packageInfo.providers != null) && (packageInfo.providers.length > 0)) { if (TextUtils.isEmpty(mPluginClientContentProviderClass)) { mPluginClientContentProviderClass = packageInfo.providers[0].name; } for (ProviderInfo a : packageInfo.providers) { if (a.name.equals(mPluginClientContentProviderClass)) { mProviderInfo = a; } } } }
Example #26
Source File: FileProvider.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
@Override public void attachInfo(Context context, ProviderInfo info) { super.attachInfo(context, info); // Sanity check our security if (info.exported) { throw new SecurityException("Provider must not be exported"); } if (!info.grantUriPermissions) { throw new SecurityException("Provider must grant uri permissions"); } mStrategy = getPathStrategy(context, info.authority); }
Example #27
Source File: CondomProcess.java From condom with Apache License 2.0 | 5 votes |
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 }
Example #28
Source File: PackageDetail.java From Inspeckage with Apache License 2.0 | 5 votes |
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(); }
Example #29
Source File: ApplicationPackageManager.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
@Override public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException { try { ProviderInfo pi = mPM.getProviderInfo(className, flags); if (pi != null) { return pi; } } catch (RemoteException e) { throw new RuntimeException("Package manager has died", e); } throw new NameNotFoundException(className.toString()); }
Example #30
Source File: DocumentsProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** {@hide} */ @Override public void attachInfoForTesting(Context context, ProviderInfo info) { registerAuthority(info.authority); super.attachInfoForTesting(context, info); }