use of com.android.launcher3.uioverrides.plugins.PluginManagerWrapper in project android_packages_apps_404Launcher by P-404.
the class DeveloperOptionsFragment method loadPluginPrefs.
private void loadPluginPrefs() {
if (mPluginsCategory != null) {
mPreferenceScreen.removePreference(mPluginsCategory);
}
if (!PluginManagerWrapper.hasPlugins(getActivity())) {
mPluginsCategory = null;
return;
}
mPluginsCategory = newCategory("Plugins");
PluginManagerWrapper manager = PluginManagerWrapper.INSTANCE.get(getContext());
Context prefContext = getContext();
PackageManager pm = getContext().getPackageManager();
Set<String> pluginActions = manager.getPluginActions();
ArrayMap<Pair<String, String>, ArrayList<Pair<String, ResolveInfo>>> plugins = new ArrayMap<>();
Set<String> pluginPermissionApps = pm.getPackagesHoldingPermissions(new String[] { PLUGIN_PERMISSION }, MATCH_DISABLED_COMPONENTS).stream().map(pi -> pi.packageName).collect(Collectors.toSet());
for (String action : pluginActions) {
String name = toName(action);
List<ResolveInfo> result = pm.queryIntentServices(new Intent(action), MATCH_DISABLED_COMPONENTS | GET_RESOLVED_FILTER);
for (ResolveInfo info : result) {
String packageName = info.serviceInfo.packageName;
if (!pluginPermissionApps.contains(packageName)) {
continue;
}
Pair<String, String> key = Pair.create(packageName, info.serviceInfo.processName);
if (!plugins.containsKey(key)) {
plugins.put(key, new ArrayList<>());
}
plugins.get(key).add(Pair.create(name, info));
}
}
PreferenceDataStore enabler = manager.getPluginEnabler();
plugins.forEach((key, si) -> {
String packageName = key.first;
List<ComponentName> componentNames = si.stream().map(p -> new ComponentName(packageName, p.second.serviceInfo.name)).collect(Collectors.toList());
if (!componentNames.isEmpty()) {
SwitchPreference pref = new PluginPreference(prefContext, si.get(0).second, enabler, componentNames);
pref.setSummary("Plugins: " + si.stream().map(p -> p.first).collect(Collectors.joining(", ")));
mPluginsCategory.addPreference(pref);
}
});
}
use of com.android.launcher3.uioverrides.plugins.PluginManagerWrapper in project android_packages_apps_Trebuchet by LineageOS.
the class DeveloperOptionsFragment method loadPluginPrefs.
private void loadPluginPrefs() {
if (mPluginsCategory != null) {
mPreferenceScreen.removePreference(mPluginsCategory);
}
if (!PluginManagerWrapper.hasPlugins(getActivity())) {
mPluginsCategory = null;
return;
}
mPluginsCategory = newCategory("Plugins");
PluginManagerWrapper manager = PluginManagerWrapper.INSTANCE.get(getContext());
Context prefContext = getContext();
PackageManager pm = getContext().getPackageManager();
Set<String> pluginActions = manager.getPluginActions();
ArrayMap<Pair<String, String>, ArrayList<Pair<String, ServiceInfo>>> plugins = new ArrayMap<>();
Set<String> pluginPermissionApps = pm.getPackagesHoldingPermissions(new String[] { PLUGIN_PERMISSION }, MATCH_DISABLED_COMPONENTS).stream().map(pi -> pi.packageName).collect(Collectors.toSet());
for (String action : pluginActions) {
String name = toName(action);
List<ResolveInfo> result = pm.queryIntentServices(new Intent(action), MATCH_DISABLED_COMPONENTS);
for (ResolveInfo info : result) {
String packageName = info.serviceInfo.packageName;
if (!pluginPermissionApps.contains(packageName)) {
continue;
}
Pair<String, String> key = Pair.create(packageName, info.serviceInfo.processName);
if (!plugins.containsKey(key)) {
plugins.put(key, new ArrayList<>());
}
plugins.get(key).add(Pair.create(name, info.serviceInfo));
}
}
PreferenceDataStore enabler = manager.getPluginEnabler();
plugins.forEach((key, si) -> {
String packageName = key.first;
List<ComponentName> componentNames = si.stream().map(p -> new ComponentName(packageName, p.second.name)).collect(Collectors.toList());
if (!componentNames.isEmpty()) {
SwitchPreference pref = new PluginPreference(prefContext, si.get(0).second.applicationInfo, enabler, componentNames);
pref.setSummary("Plugins: " + si.stream().map(p -> p.first).collect(Collectors.joining(", ")));
mPluginsCategory.addPreference(pref);
}
});
}
Aggregations