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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations