From: Marcus Comstedt Date: Wed, 7 Dec 2016 20:24:47 +0000 (+0100) Subject: Include the device filter XML in the AAR X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f0d3cf4b0c86b1cd4e0e28122f8167b02fb1acdb;p=sigrok-androidutils.git Include the device filter XML in the AAR Also add a convenience method for creating a UsbSupplicant from it. --- diff --git a/AndroidManifest.xml.in b/AndroidManifest.xml.in index 1256ec4..e6b25f6 100644 --- a/AndroidManifest.xml.in +++ b/AndroidManifest.xml.in @@ -29,6 +29,7 @@ + diff --git a/build.xml b/build.xml index 04496cd..e4af70a 100644 --- a/build.xml +++ b/build.xml @@ -95,6 +95,7 @@ ]]> + diff --git a/src/org/sigrok/androidutils/SigrokApplication.java b/src/org/sigrok/androidutils/SigrokApplication.java index 5a68792..8406693 100644 --- a/src/org/sigrok/androidutils/SigrokApplication.java +++ b/src/org/sigrok/androidutils/SigrokApplication.java @@ -29,6 +29,8 @@ public class SigrokApplication extends Application { private static final String JNI_LIBS_RESOURCE_ID_META = "org.sigrok.androidutils.jni_libs_resource_id"; + private static final String DEVICE_FILTER_RESOURCE_ID_META = + "org.sigrok.androidutils.device_filter_resource_id"; public SigrokApplication() { @@ -57,6 +59,24 @@ public class SigrokApplication extends Application { } } + public static UsbSupplicant createUsbSupplicant(Context context) + { + ApplicationInfo appInfo = context.getApplicationInfo(); + try { + appInfo = context.getPackageManager(). + getApplicationInfo(context.getPackageName(), + PackageManager.GET_META_DATA); + } catch (PackageManager.NameNotFoundException exc) { + } + if (appInfo.metaData != null && + appInfo.metaData.containsKey(DEVICE_FILTER_RESOURCE_ID_META)) { + int resId = appInfo.metaData.getInt(DEVICE_FILTER_RESOURCE_ID_META); + return new UsbSupplicant(context, resId); + } + Log.e("SigrokApplication", "Can't create UsbSupplicant (resource ID missing)"); + return null; + } + @Override public void onCreate() {