use of android.content.pm.ProviderInfo in project DroidPlugin by DroidPluginTeam.
the class StaticProcessList method onCreate.
void onCreate(Context mHostContext) throws NameNotFoundException {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(CATEGORY_ACTIVITY_PROXY_STUB);
intent.setPackage(mHostContext.getPackageName());
PackageManager pm = mHostContext.getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
for (ResolveInfo activity : activities) {
addActivityInfo(activity.activityInfo);
}
List<ResolveInfo> services = pm.queryIntentServices(intent, 0);
for (ResolveInfo service : services) {
addServiceInfo(service.serviceInfo);
}
PackageInfo packageInfo = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_PROVIDERS);
if (packageInfo.providers != null && packageInfo.providers.length > 0) {
for (ProviderInfo providerInfo : packageInfo.providers) {
if (providerInfo.name != null && providerInfo.name.startsWith(ContentProviderStub.class.getName())) {
addProviderInfo(providerInfo);
}
}
}
mOtherProcessNames.clear();
PackageInfo packageInfo1 = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS | PackageManager.GET_SERVICES);
if (packageInfo1.activities != null) {
for (ActivityInfo info : packageInfo1.activities) {
if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
mOtherProcessNames.add(info.processName);
}
}
}
if (packageInfo1.receivers != null) {
for (ActivityInfo info : packageInfo1.receivers) {
if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
mOtherProcessNames.add(info.processName);
}
}
}
if (packageInfo1.providers != null) {
for (ProviderInfo info : packageInfo1.providers) {
if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
mOtherProcessNames.add(info.processName);
}
}
}
if (packageInfo1.services != null) {
for (ServiceInfo info : packageInfo1.services) {
if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
mOtherProcessNames.add(info.processName);
}
}
}
}
use of android.content.pm.ProviderInfo in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class DictionaryPackInstallBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
final PackageManager manager = context.getPackageManager();
// We need to reread the dictionary if a new dictionary package is installed.
if (action.equals(Intent.ACTION_PACKAGE_ADDED)) {
if (null == mService) {
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this " + "should never happen");
return;
}
final Uri packageUri = intent.getData();
// No package name : we can't do anything
if (null == packageUri)
return;
final String packageName = packageUri.getSchemeSpecificPart();
if (null == packageName)
return;
// TODO: do this in a more appropriate place
TargetPackageInfoGetterTask.removeCachedPackageInfo(packageName);
final PackageInfo packageInfo;
try {
packageInfo = manager.getPackageInfo(packageName, PackageManager.GET_PROVIDERS);
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
// No package info : we can't do anything
return;
}
final ProviderInfo[] providers = packageInfo.providers;
// No providers : it is not a dictionary.
if (null == providers)
return;
// Search for some dictionary pack in the just-installed package. If found, reread.
for (ProviderInfo info : providers) {
if (DictionaryPackConstants.AUTHORITY.equals(info.authority)) {
mService.resetSuggestMainDict();
return;
}
}
// We can exit safely.
return;
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED) && !intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
if (null == mService) {
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this " + "should never happen");
return;
}
// When the dictionary package is removed, we need to reread dictionary (to use the
// next-priority one, or stop using a dictionary at all if this was the only one,
// since this is the user request).
// If we are replacing the package, we will receive ADDED right away so no need to
// remove the dictionary at the moment, since we will do it when we receive the
// ADDED broadcast.
// TODO: Only reload dictionary on REMOVED when the removed package is the one we
// read dictionary from?
mService.resetSuggestMainDict();
} else if (action.equals(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION)) {
if (null == mService) {
Log.e(TAG, "Called with intent " + action + " but we don't know the service: this " + "should never happen");
return;
}
mService.resetSuggestMainDict();
} else if (action.equals(DictionaryPackConstants.UNKNOWN_DICTIONARY_PROVIDER_CLIENT)) {
if (null != mService) {
// Careful! This is returning if the service is NOT null. This is because we
// should come here instantiated by the framework in reaction to a broadcast of
// the above action, so we should gave gone through the no-args constructor.
Log.e(TAG, "Called with intent " + action + " but we have a reference to the " + "service: this should never happen");
return;
}
// The dictionary provider does not know about some client. We check that it's really
// us that it needs to know about, and if it's the case, we register with the provider.
final String wantedClientId = intent.getStringExtra(DictionaryPackConstants.DICTIONARY_PROVIDER_CLIENT_EXTRA);
final String myClientId = context.getString(R.string.dictionary_pack_client_id);
// Not for us
if (!wantedClientId.equals(myClientId))
return;
BinaryDictionaryFileDumper.initializeClientRecordHelper(context, myClientId);
}
}
use of android.content.pm.ProviderInfo in project DroidPlugin by DroidPluginTeam.
the class PluginPackageParser method getProviderInfo.
public ProviderInfo getProviderInfo(ComponentName className, int flags) throws Exception {
Object data;
synchronized (mProviderObjCache) {
data = mProviderObjCache.get(className);
}
if (data != null) {
ProviderInfo providerInfo = mParser.generateProviderInfo(data, flags);
fixApplicationInfo(providerInfo.applicationInfo);
if (TextUtils.isEmpty(providerInfo.processName)) {
providerInfo.processName = providerInfo.packageName;
}
return providerInfo;
}
return null;
}
use of android.content.pm.ProviderInfo in project AndroidChromium by JackyAndroid.
the class PartnerBrowserCustomizations method initializeAsync.
/**
* Constructs an async task that reads PartnerBrowserCustomization provider.
*
* @param context The current application context.
* @param timeoutMs If initializing takes more than this time, cancels it. The unit is ms.
*/
public static void initializeAsync(final Context context, long timeoutMs) {
sIsInitialized = false;
// Setup an initializing async task.
final AsyncTask<Void, Void, Void> initializeAsyncTask = new AsyncTask<Void, Void, Void>() {
private boolean mDisablePartnerBookmarksShim;
private boolean mHomepageUriChanged;
private void refreshHomepage() {
try {
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(buildQueryUri(PARTNER_HOMEPAGE_PATH), null, null, null, null);
if (cursor != null && cursor.moveToFirst() && cursor.getColumnCount() == 1 && !isCancelled()) {
if (TextUtils.isEmpty(sHomepage) || !sHomepage.equals(cursor.getString(0))) {
mHomepageUriChanged = true;
}
sHomepage = cursor.getString(0);
}
if (cursor != null)
cursor.close();
} catch (Exception e) {
Log.w(TAG, "Partner homepage provider URL read failed : ", e);
}
}
private void refreshIncognitoModeDisabled() {
try {
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(buildQueryUri(PARTNER_DISABLE_INCOGNITO_MODE_PATH), null, null, null, null);
if (cursor != null && cursor.moveToFirst() && cursor.getColumnCount() == 1 && !isCancelled()) {
sIncognitoModeDisabled = cursor.getInt(0) == 1;
}
if (cursor != null)
cursor.close();
} catch (Exception e) {
Log.w(TAG, "Partner disable incognito mode read failed : ", e);
}
}
private void refreshBookmarksEditingDisabled() {
try {
ContentResolver contentResolver = context.getContentResolver();
Cursor cursor = contentResolver.query(buildQueryUri(PARTNER_DISABLE_BOOKMARKS_EDITING_PATH), null, null, null, null);
if (cursor != null && cursor.moveToFirst() && cursor.getColumnCount() == 1 && !isCancelled()) {
boolean bookmarksEditingDisabled = cursor.getInt(0) == 1;
if (bookmarksEditingDisabled != sBookmarksEditingDisabled) {
mDisablePartnerBookmarksShim = true;
}
sBookmarksEditingDisabled = bookmarksEditingDisabled;
}
if (cursor != null)
cursor.close();
} catch (Exception e) {
Log.w(TAG, "Partner disable bookmarks editing read failed : ", e);
}
}
@Override
protected Void doInBackground(Void... params) {
try {
ProviderInfo providerInfo = context.getPackageManager().resolveContentProvider(sProviderAuthority, 0);
if (providerInfo == null)
return null;
if ((providerInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && !sIgnoreBrowserProviderSystemPackageCheck) {
Log.w("TAG", "Browser Cutomizations content provider package, " + providerInfo.packageName + ", is not a system package. " + "This could be a malicious attepment from a third party app, " + "so skip reading the browser content provider.");
return null;
}
if (isCancelled())
return null;
refreshIncognitoModeDisabled();
if (isCancelled())
return null;
refreshBookmarksEditingDisabled();
if (isCancelled())
return null;
refreshHomepage();
} catch (Exception e) {
Log.w(TAG, "Fetching partner customizations failed", e);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
onFinalized();
}
@Override
protected void onCancelled(Void result) {
onFinalized();
}
private void onFinalized() {
sIsInitialized = true;
for (Runnable callback : sInitializeAsyncCallbacks) {
callback.run();
}
sInitializeAsyncCallbacks.clear();
if (mHomepageUriChanged) {
HomepageManager.getInstance(context).notifyHomepageUpdated();
}
// Disable partner bookmarks editing if necessary.
if (mDisablePartnerBookmarksShim) {
PartnerBookmarksReader.disablePartnerBookmarksEditing();
}
}
};
initializeAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
// Cancel the initialization if it reaches timeout.
ThreadUtils.postOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
initializeAsyncTask.cancel(true);
}
}, timeoutMs);
}
use of android.content.pm.ProviderInfo in project OneSignal-Android-SDK by OneSignal.
the class SonyHomeBadger method sonyBadgeContentProviderExists.
/**
* Check if the latest Sony badge content provider exists .
*
* @param context the context to use
* @return true if Sony badge content provider exists, otherwise false.
*/
private static boolean sonyBadgeContentProviderExists(Context context) {
boolean exists = false;
ProviderInfo info = context.getPackageManager().resolveContentProvider(SONY_HOME_PROVIDER_NAME, 0);
if (info != null) {
exists = true;
}
return exists;
}
Aggregations