Search in sources :

Example 91 with ProviderInfo

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);
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) PackageInfo(android.content.pm.PackageInfo) Uri(android.net.Uri)

Example 92 with ProviderInfo

use of android.content.pm.ProviderInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountSyncSettings method addSyncStateSwitch.

private void addSyncStateSwitch(Account account, String authority, String packageName, int uid) {
    SyncStateSwitchPreference item = (SyncStateSwitchPreference) getCachedPreference(authority);
    if (item == null) {
        item = new SyncStateSwitchPreference(getPrefContext(), account, authority, packageName, uid);
        getPreferenceScreen().addPreference(item);
    } else {
        item.setup(account, authority, packageName, uid);
    }
    final PackageManager packageManager = getPackageManager();
    item.setPersistent(false);
    final ProviderInfo providerInfo = packageManager.resolveContentProviderAsUser(authority, 0, mUserHandle.getIdentifier());
    if (providerInfo == null) {
        return;
    }
    final CharSequence providerLabel = providerInfo.loadLabel(packageManager);
    if (TextUtils.isEmpty(providerLabel)) {
        Log.e(TAG, "Provider needs a label for authority '" + authority + "'");
        return;
    }
    item.setTitle(providerLabel);
    item.setKey(authority);
}
Also used : PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo)

Example 93 with ProviderInfo

use of android.content.pm.ProviderInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RunningServiceDetails method addProcessDetailsView.

void addProcessDetailsView(RunningState.ProcessItem pi, boolean isMain) {
    addProcessesHeader();
    ActiveDetail detail = new ActiveDetail();
    View root = mInflater.inflate(R.layout.running_service_details_process, mAllDetails, false);
    mAllDetails.addView(root);
    detail.mRootView = root;
    detail.mViewHolder = new RunningProcessesView.ViewHolder(root);
    detail.mActiveItem = detail.mViewHolder.bind(mState, pi, mBuilder);
    TextView description = (TextView) root.findViewById(R.id.comp_description);
    if (pi.mUserId != UserHandle.myUserId()) {
        // Processes for another user are all shown batched together; there is
        // no reason to have a description.
        description.setVisibility(View.GONE);
    } else if (isMain) {
        description.setText(R.string.main_running_process_description);
    } else {
        int textid = 0;
        CharSequence label = null;
        ActivityManager.RunningAppProcessInfo rpi = pi.mRunningProcessInfo;
        final ComponentName comp = rpi.importanceReasonComponent;
        // + " pid=" + rpi.importanceReasonPid + " comp=" + comp);
        switch(rpi.importanceReasonCode) {
            case ActivityManager.RunningAppProcessInfo.REASON_PROVIDER_IN_USE:
                textid = R.string.process_provider_in_use_description;
                if (rpi.importanceReasonComponent != null) {
                    try {
                        ProviderInfo prov = getActivity().getPackageManager().getProviderInfo(rpi.importanceReasonComponent, 0);
                        label = RunningState.makeLabel(getActivity().getPackageManager(), prov.name, prov);
                    } catch (NameNotFoundException e) {
                    }
                }
                break;
            case ActivityManager.RunningAppProcessInfo.REASON_SERVICE_IN_USE:
                textid = R.string.process_service_in_use_description;
                if (rpi.importanceReasonComponent != null) {
                    try {
                        ServiceInfo serv = getActivity().getPackageManager().getServiceInfo(rpi.importanceReasonComponent, 0);
                        label = RunningState.makeLabel(getActivity().getPackageManager(), serv.name, serv);
                    } catch (NameNotFoundException e) {
                    }
                }
                break;
        }
        if (textid != 0 && label != null) {
            description.setText(getActivity().getString(textid, label));
        }
    }
    mActiveDetails.add(detail);
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) ProviderInfo(android.content.pm.ProviderInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) TextView(android.widget.TextView) ComponentName(android.content.ComponentName) View(android.view.View) TextView(android.widget.TextView)

Example 94 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualApp by asLody.

the class ResolveContentProvider method call.

@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    String name = (String) args[0];
    int flags = (int) args[1];
    int userId = VUserHandle.myUserId();
    ProviderInfo info = VPackageManager.get().resolveContentProvider(name, flags, userId);
    if (info == null) {
        if (name.equals("settings")) {
            info = (ProviderInfo) method.invoke(who, args);
        }
    }
    return info;
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 95 with ProviderInfo

use of android.content.pm.ProviderInfo in project platform_frameworks_base by android.

the class ActivityThread method installContentProviders.

private void installContentProviders(Context context, List<ProviderInfo> providers) {
    final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>();
    for (ProviderInfo cpi : providers) {
        if (DEBUG_PROVIDER) {
            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);
        if (cph != null) {
            cph.noReleaseNeeded = true;
            results.add(cph);
        }
    }
    try {
        ActivityManagerNative.getDefault().publishContentProviders(getApplicationThread(), results);
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException)

Aggregations

ProviderInfo (android.content.pm.ProviderInfo)200 ComponentName (android.content.ComponentName)43 RemoteException (android.os.RemoteException)36 ArrayList (java.util.ArrayList)33 PackageManager (android.content.pm.PackageManager)27 ResolveInfo (android.content.pm.ResolveInfo)23 ApplicationInfo (android.content.pm.ApplicationInfo)22 ServiceInfo (android.content.pm.ServiceInfo)16 Point (android.graphics.Point)16 VPackage (com.lody.virtual.server.pm.parser.VPackage)15 PackageInfo (android.content.pm.PackageInfo)14 Map (java.util.Map)14 Test (org.junit.Test)14 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)13 Uri (android.net.Uri)13 File (java.io.File)13 IPackageManager (android.content.pm.IPackageManager)12 ActivityInfo (android.content.pm.ActivityInfo)10 Before (org.junit.Before)10 Intent (android.content.Intent)8