Search in sources :

Example 51 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_packages_apps_Settings by DirtyUnicorns.

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 52 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class AppStorageSettings method refreshGrantedUriPermissions.

private void refreshGrantedUriPermissions() {
    // Clear UI first (in case the activity has been resumed)
    removeUriPermissionsFromUi();
    // Gets all URI permissions from am.
    ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
    List<UriPermission> perms = am.getGrantedUriPermissions(mAppEntry.info.packageName).getList();
    if (perms.isEmpty()) {
        mClearUriButton.setVisibility(View.GONE);
        return;
    }
    PackageManager pm = getActivity().getPackageManager();
    // Group number of URIs by app.
    Map<CharSequence, MutableInt> uriCounters = new TreeMap<>();
    for (UriPermission perm : perms) {
        String authority = perm.getUri().getAuthority();
        ProviderInfo provider = pm.resolveContentProvider(authority, 0);
        CharSequence app = provider.applicationInfo.loadLabel(pm);
        MutableInt count = uriCounters.get(app);
        if (count == null) {
            uriCounters.put(app, new MutableInt(1));
        } else {
            count.value++;
        }
    }
    // Dynamically add the preferences, one per app.
    int order = 0;
    for (Map.Entry<CharSequence, MutableInt> entry : uriCounters.entrySet()) {
        int numberResources = entry.getValue().value;
        Preference pref = new Preference(getPrefContext());
        pref.setTitle(entry.getKey());
        pref.setSummary(getPrefContext().getResources().getQuantityString(R.plurals.uri_permissions_text, numberResources, numberResources));
        pref.setSelectable(false);
        pref.setLayoutResource(R.layout.horizontal_preference);
        pref.setOrder(order);
        Log.v(TAG, "Adding preference '" + pref + "' at order " + order);
        mUri.addPreference(pref);
    }
    if (mAppsControlDisallowedBySystem) {
        mClearUriButton.setEnabled(false);
    }
    mClearUri.setOrder(order);
    mClearUriButton.setVisibility(View.VISIBLE);
}
Also used : ActivityManager(android.app.ActivityManager) TreeMap(java.util.TreeMap) PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) Preference(android.support.v7.preference.Preference) MutableInt(android.util.MutableInt) UriPermission(android.content.UriPermission) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 53 with ProviderInfo

use of android.content.pm.ProviderInfo in project android_packages_apps_Settings by DirtyUnicorns.

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);
    }
    item.setPersistent(false);
    final ProviderInfo providerInfo = getPackageManager().resolveContentProviderAsUser(authority, 0, mUserHandle.getIdentifier());
    if (providerInfo == null) {
        return;
    }
    CharSequence providerLabel = providerInfo.loadLabel(getPackageManager());
    if (TextUtils.isEmpty(providerLabel)) {
        Log.e(TAG, "Provider needs a label for authority '" + authority + "'");
        return;
    }
    String title = getString(R.string.sync_item_title, providerLabel);
    item.setTitle(title);
    item.setKey(authority);
}
Also used : ProviderInfo(android.content.pm.ProviderInfo)

Example 54 with ProviderInfo

use of android.content.pm.ProviderInfo in project VirtualAPK by didi.

the class RemoteContentProvider method getContentProvider.

private ContentProvider getContentProvider(final Uri uri) {
    final PluginManager pluginManager = PluginManager.getInstance(getContext());
    Uri pluginUri = Uri.parse(uri.getQueryParameter(KEY_URI));
    final String auth = pluginUri.getAuthority();
    ContentProvider cachedProvider = sCachedProviders.get(auth);
    if (cachedProvider != null) {
        return cachedProvider;
    }
    synchronized (sCachedProviders) {
        LoadedPlugin plugin = pluginManager.getLoadedPlugin(uri.getQueryParameter(KEY_PKG));
        if (plugin == null) {
            try {
                pluginManager.loadPlugin(new File(uri.getQueryParameter(KEY_PLUGIN)));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        final ProviderInfo providerInfo = pluginManager.resolveContentProvider(auth, 0);
        if (providerInfo != null) {
            RunUtil.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    try {
                        LoadedPlugin loadedPlugin = pluginManager.getLoadedPlugin(uri.getQueryParameter(KEY_PKG));
                        ContentProvider contentProvider = (ContentProvider) Class.forName(providerInfo.name).newInstance();
                        contentProvider.attachInfo(loadedPlugin.getPluginContext(), providerInfo);
                        sCachedProviders.put(auth, contentProvider);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, true);
            return sCachedProviders.get(auth);
        }
    }
    return null;
}
Also used : PluginManager(com.didi.virtualapk.PluginManager) LoadedPlugin(com.didi.virtualapk.internal.LoadedPlugin) ProviderInfo(android.content.pm.ProviderInfo) ContentProvider(android.content.ContentProvider) Uri(android.net.Uri) File(java.io.File) OperationApplicationException(android.content.OperationApplicationException)

Example 55 with ProviderInfo

use of android.content.pm.ProviderInfo in project AnExplorer by 1hakr.

the class IconUtils method loadPackageIcon.

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

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