Java Code Examples for android.content.pm.PackageManagerInternal#setSyncAdapterPackagesprovider()
The following examples show how to use
android.content.pm.PackageManagerInternal#setSyncAdapterPackagesprovider() .
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: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
ContentService(Context context, boolean factoryTest) { mContext = context; mFactoryTest = factoryTest; // Let the package manager query for the sync adapters for a given authority // as we grant default permissions to sync adapters for specific authorities. PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal.class); packageManagerInternal.setSyncAdapterPackagesprovider( new PackageManagerInternal.SyncAdapterPackagesProvider() { @Override public String[] getPackages(String authority, int userId) { return getSyncAdapterPackagesForAuthorityAsUser(authority, userId); } }); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED); packageFilter.addDataScheme("package"); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, packageFilter, null, null); final IntentFilter localeFilter = new IntentFilter(); localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, localeFilter, null, null); }
Example 2
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
ContentService(Context context, boolean factoryTest) { mContext = context; mFactoryTest = factoryTest; // Let the package manager query for the sync adapters for a given authority // as we grant default permissions to sync adapters for specific authorities. PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal.class); packageManagerInternal.setSyncAdapterPackagesprovider( new PackageManagerInternal.SyncAdapterPackagesProvider() { @Override public String[] getPackages(String authority, int userId) { return getSyncAdapterPackagesForAuthorityAsUser(authority, userId); } }); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED); packageFilter.addDataScheme("package"); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, packageFilter, null, null); final IntentFilter localeFilter = new IntentFilter(); localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, localeFilter, null, null); }
Example 3
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
ContentService(Context context, boolean factoryTest) { mContext = context; mFactoryTest = factoryTest; // Let the package manager query for the sync adapters for a given authority // as we grant default permissions to sync adapters for specific authorities. PackageManagerInternal packageManagerInternal = LocalServices.getService( PackageManagerInternal.class); packageManagerInternal.setSyncAdapterPackagesprovider( new PackageManagerInternal.SyncAdapterPackagesProvider() { @Override public String[] getPackages(String authority, int userId) { return getSyncAdapterPackagesForAuthorityAsUser(authority, userId); } }); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED); packageFilter.addDataScheme("package"); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, packageFilter, null, null); final IntentFilter localeFilter = new IntentFilter(); localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiverAsUser(mCacheReceiver, UserHandle.ALL, localeFilter, null, null); }