use of org.awesomeapp.messenger.plugin.ImPluginInfo in project Zom-Android by zom.
the class ImPluginHelper method loadAvailablePlugins.
public void loadAvailablePlugins() {
if (mLoaded) {
return;
}
List<ResolveInfo> plugins = getPlugins();
for (ResolveInfo info : plugins) {
Log.d(TAG, "Found plugin " + info);
ServiceInfo serviceInfo = info.serviceInfo;
if (serviceInfo == null) {
Log.e(TAG, "Ignore bad IM plugin: " + info);
continue;
}
String providerName = null;
String providerFullName = null;
String signUpUrl = null;
Bundle metaData = serviceInfo.metaData;
if (metaData != null) {
providerName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_NAME);
providerFullName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_FULL_NAME);
signUpUrl = metaData.getString(ImPluginConstants.METADATA_SIGN_UP_URL);
}
if (TextUtils.isEmpty(providerName) || TextUtils.isEmpty(providerFullName)) {
Log.e(TAG, "Ignore bad IM plugin: " + info + ". Lack of required meta data");
continue;
}
if (isPluginDuplicated(providerName)) {
Log.e(TAG, "Ignore duplicated IM plugin: " + info);
continue;
}
if (!serviceInfo.packageName.equals(mContext.getPackageName())) {
Log.e(TAG, "Ignore plugin in package: " + serviceInfo.packageName);
continue;
}
ImPluginInfo pluginInfo = new ImPluginInfo(providerName, serviceInfo.packageName, serviceInfo.name, serviceInfo.applicationInfo.sourceDir);
ImPlugin plugin = loadPlugin(pluginInfo);
if (plugin == null) {
Log.e(TAG, "Ignore bad IM plugin");
continue;
}
try {
updateProviderDb(plugin, pluginInfo, providerFullName, signUpUrl);
} catch (SQLiteFullException e) {
Log.e(TAG, "Storage full", e);
return;
}
mPluginsInfo.add(pluginInfo);
mPluginObjects.add(plugin);
}
mLoaded = true;
}
use of org.awesomeapp.messenger.plugin.ImPluginInfo in project Zom-Android by zom.
the class ImPluginHelper method createAdditionalProvider.
public long createAdditionalProvider(String name) {
List<ResolveInfo> plugins = getPlugins();
ResolveInfo info = null;
ServiceInfo serviceInfo = null;
Bundle metaData = null;
long providerId = -1;
for (ResolveInfo _info : plugins) {
serviceInfo = _info.serviceInfo;
if (serviceInfo == null) {
Log.e(TAG, "Ignore bad IM plugin: " + _info);
continue;
}
if (serviceInfo.metaData == null) {
Log.e(TAG, "Ignore bad IM plugin: " + _info);
continue;
}
metaData = serviceInfo.metaData;
if (name.equals(metaData.getString(ImPluginConstants.METADATA_PROVIDER_NAME))) {
info = _info;
break;
}
}
if (info == null) {
Log.e(TAG, "Did not find plugin " + name);
return -1;
}
String providerName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_NAME);
String providerFullName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_FULL_NAME);
String signUpUrl = metaData.getString(ImPluginConstants.METADATA_SIGN_UP_URL);
if (TextUtils.isEmpty(providerName) || TextUtils.isEmpty(providerFullName)) {
Log.e(TAG, "Ignore bad IM plugin: " + info + ". Lack of required meta data");
return -1;
}
/*
if (!serviceInfo.packageName.equals(mContext.getPackageName())) {
Log.e(TAG, "Ignore plugin in package: " + serviceInfo.packageName);
return -1;
}*/
ImPluginInfo pluginInfo = new ImPluginInfo(providerName, serviceInfo.packageName, serviceInfo.name, serviceInfo.applicationInfo.sourceDir);
ImPlugin plugin = loadPlugin(pluginInfo);
if (plugin == null) {
Log.e(TAG, "Ignore bad IM plugin");
return -1;
}
try {
providerId = insertProviderDb(plugin, pluginInfo, providerFullName, signUpUrl);
} catch (SQLiteFullException e) {
Log.e(TAG, "Storage full", e);
return -1;
}
mPluginsInfo.add(pluginInfo);
mPluginObjects.add(plugin);
return providerId;
}
Aggregations