From 499edaf8948de7337248d65f7fe46d79b541bb60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 12 Aug 2013 13:32:19 +0200 Subject: [PATCH 1/9] Adding AndroidDeviceReporter java implementation source code --- .../AndroidDeviceReporter.java | 11 + .../AndroidDeviceReporterImpl.java | 715 ++++++++++++++++++ 2 files changed, 726 insertions(+) create mode 100644 platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java create mode 100644 platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java diff --git a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java new file mode 100644 index 0000000..7253eb5 --- /dev/null +++ b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java @@ -0,0 +1,11 @@ +package net.gpii; + +import org.meshpoint.anode.bridge.Env; +import org.meshpoint.anode.java.Base; + +public abstract class AndroidDeviceReporter extends Base { + private static short classId = Env.getInterfaceId(AndroidDeviceReporter.class +); + public AndroidDeviceReporter() { super(classId); } + public abstract String getJSONOutput(); +} diff --git a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java new file mode 100644 index 0000000..341dac6 --- /dev/null +++ b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java @@ -0,0 +1,715 @@ +package net.gpii; + +/* + +DeviceReporterEngine +This class explores hardware and software on the device to make the Device reporter results list. + + Copyright (c) 2013, Technosite R&D + All rights reserved. +The research leading to these results has received funding from the European Union's Seventh Framework Programme (FP7/2007-2013) under grant agreement n° 289016 + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this +   list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, +   this list of conditions and the following disclaimer in the documentation +   and/or other materials provided with the distribution. + * Neither the name of Technosite R&D nor the names of its contributors may +   be used to endorse or promote products derived from this software without +   specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import android.annotation.SuppressLint; +import android.bluetooth.BluetoothAdapter; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Point; +import android.hardware.Camera; +import android.hardware.Camera.CameraInfo; +import android.hardware.Sensor; +import android.hardware.SensorManager; +import android.hardware.usb.UsbDevice; +import android.hardware.usb.UsbManager; +import android.media.AudioManager; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.nfc.NfcAdapter; +import android.nfc.NfcManager; +import android.os.BatteryManager; +import android.os.Build; +import android.os.Environment; +import android.speech.tts.TextToSpeech; +import android.telephony.TelephonyManager; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.Display; +import android.view.WindowManager; + +import org.meshpoint.anode.AndroidContext; +import org.meshpoint.anode.module.IModule; +import org.meshpoint.anode.module.IModuleContext; +import org.json.JSONObject; + +public class AndroidDeviceReporterImpl extends AndroidDeviceReporter implements IModule { + private static final String TAG = "net.gpii.AndroidDeviceReporterImpl"; + + IModuleContext ctx; + private Context androidContext; + + private HashMapresults = new HashMap(); + + public Map getResults() { + return (Map) this.results; + } + + @Override + public Object startModule(IModuleContext ctx) { + Log.v(TAG, "AndroidDeviceReporterImpl.startModule()"); + this.ctx = ctx; + this.androidContext = ((AndroidContext) ctx).getAndroidContext(); + + return this; + } + + @Override + public void stopModule() { + Log.v(TAG, "AndroidDeviceReporterImpl.stopModule()"); + } + + @Override + public String getJSONOutput() { + + getDataAboutDevice(); + getDataAboutOperatingSystem(androidContext); + getDataAboutHardware(androidContext); + getDataAboutSensors(androidContext); + //getDataAboutSound(androidContext); + //getDataAboutScreen(androidContext); + + JSONObject output = new JSONObject(results); + + return output.toString(); + } + + // *** Device reporter getters + + // ** Software + + private void getDataAboutDevice() { + results.put("Device" , android.os.Build.DEVICE); + results.put("Model" , android.os.Build.MODEL); + results.put("Manufacturer" , android.os.Build.MANUFACTURER); + results.put("Product" , android.os.Build.PRODUCT); + results.put("Brand" , android.os.Build.BRAND); + results.put("CPU" , android.os.Build.CPU_ABI); + results.put("CPU2" , android.os.Build.CPU_ABI2); + if (isDeviceRooted()) { + results.put("rootAccess", "yes"); + } else { + results.put("rootAccess", "no"); + } + } + + private void getDataAboutOperatingSystem(Context ct) { + results.put("OS Version", "Android " + android.os.Build.VERSION.RELEASE ); + results.put("Build name" , android.os.Build.FINGERPRINT); + results.put("Kernel Version", System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")"); + results.put("OS API Level" , String.valueOf(android.os.Build.VERSION.SDK_INT)); + + // Services + PackageManager packageManager = ct.getPackageManager(); + List applicationList = packageManager.getInstalledApplications (0); + if (applicationList.size()>0) + for (int i=0; i packageList = packageManager.getInstalledPackages (PackageManager.GET_SERVICES); + for (int i=0; i=12) { + HashMap deviceList = usb.getDeviceList(); + Iterator> it = deviceList.entrySet().iterator(); + int c = 1; + if (it.hasNext()) { + while (it.hasNext()) { + Map.Entry e = (Map.Entry) it.next(); + results.put("USB attached device " + String.valueOf(c), e.getKey()); + c++; + } + } else results.put("USB attached device", "None"); + } + } else results.put("USB", "Not supported"); + } catch (Exception e) { + results.put("USB", "Not supported\nError:" + e.toString()); + } + + // Keyboard + results.put("System board" , android.os.Build.BOARD); + boolean keyboardPresent = (ct.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); + results.put("Keyboard hardware" , String.valueOf(keyboardPresent)); + + switch (ct.getResources().getConfiguration().keyboard ) { + case Configuration.KEYBOARD_12KEY : + results.put("Keyboard type", "Numeric"); + break; + case Configuration.KEYBOARD_QWERTY : + results.put("Keyboard type", "Qwerty"); + break; + case Configuration.KEYBOARD_NOKEYS : + results.put("Keyboard type", "No keys"); + break; + default : + results.put("Keyboard type", "UNKNOWN"); + break; + } + + // Navigation mode + switch (ct.getResources().getConfiguration().navigation) { + case Configuration.NAVIGATION_TRACKBALL : + results.put("Navigator mode", "Trackball"); + break; + case Configuration.NAVIGATION_WHEEL : + results.put("Navigator mode", "Wheel"); + break; + case Configuration.NAVIGATION_DPAD : + results.put("Navigator mode", "DPad"); + break; + case Configuration.NAVIGATION_NONAV : + results.put("Navigator mode", "None"); + break; + case Configuration.NAVIGATION_UNDEFINED : + results.put("Navigator mode", "Unknown"); + break; + } + + // Battery + try + { + IntentFilter batIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + Intent battery = ct.registerReceiver(null, batIntentFilter); + int batteryLevel = battery.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); + int batteryStatus = battery.getIntExtra(BatteryManager.EXTRA_STATUS, -1); + int chargePlug = battery.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); + boolean isCharging = (batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING || batteryStatus == BatteryManager.BATTERY_STATUS_FULL); + boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB; + boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC; + results.put("Battery level", String.valueOf(batteryLevel)); + results.put("Battery charging", String.valueOf(isCharging)); + if (isCharging) { + if (usbCharge ) results.put("Battery charging mode", "USB"); + else if (acCharge) results.put("Battery charging mode", "AC "); + else results.put("Battery charging mode", "UNKNOWN"); + } + } + catch (Exception e) + { + results.put("Battery level", "UNKNOWN"); + } + } + + @SuppressLint("NewApi") + private void getDataAboutSensors(Context ct) { + // Wifi + try { + WifiManager wifi = (WifiManager) ct.getSystemService(Context.WIFI_SERVICE); + if (wifi!=null) { + results.put("Wifi", "Supported"); + if (wifi.isWifiEnabled()) { + results.put("Wifi state", "Enabled"); + WifiInfo info = wifi.getConnectionInfo(); + results.put("Wifi SSID", info.getSSID()); + results.put("Wifi BSSID", info.getBSSID()); + results.put("Wifi Mac address", info.getMacAddress()); + results.put("Wifi network Id", String.valueOf(info.getNetworkId() )); + results.put("Wifi IP address", String.valueOf(info.getIpAddress() )); + results.put("Wifi link speed", String.valueOf(info.getLinkSpeed() )); + results.put("Wifi Rssi", String.valueOf(info.getRssi() )); + } else results.put("Wifi state", "Disabled"); + } else results.put("Wifi", "Not supported"); + } catch (Exception e) { + results.put("Wifi", "Not supported\nError:" + e.toString()); + } + + // Bluetooth + try { + BluetoothAdapter bluetoothLocalAdapter = BluetoothAdapter.getDefaultAdapter(); + if (bluetoothLocalAdapter!= null) { + results.put("Bluetooth", "Supported"); + results.put("Bluetooth address", bluetoothLocalAdapter.getAddress()); + results.put("Bluetooth name", bluetoothLocalAdapter.getName()); + switch (bluetoothLocalAdapter.getState()) { + case android.bluetooth.BluetoothAdapter.STATE_OFF : + results.put("Bluetooth state", "Off"); + break; + case android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF : + results.put("Bluetooth state", "Turning off"); + break; + case android.bluetooth.BluetoothAdapter.STATE_ON : + results.put("Bluetooth state", "On"); + break; + case android.bluetooth.BluetoothAdapter.STATE_TURNING_ON : + results.put("Bluetooth state", "Turning on"); + break; + case android.bluetooth.BluetoothAdapter.STATE_CONNECTED : + results.put("Bluetooth state", "Connected"); + break; + case android.bluetooth.BluetoothAdapter.STATE_CONNECTING : + results.put("Bluetooth state", "Connecting"); + break; + case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTED : + results.put("Bluetooth state", "Disconnected"); + break; + case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTING : + results.put("Bluetooth state", "Disconnecting"); + break; + } + } else { + results.put("Bluetooth", "Not supported"); + } + } catch (Exception e) { + results.put("Bluetooth", "Not supported\nError:" + e.toString()); + } + + // NFC + NfcManager nfcManager = (NfcManager) ct.getSystemService(Context.NFC_SERVICE); + NfcAdapter nfc = nfcManager.getDefaultAdapter(); + if (nfc != null) { + results.put("NFC", "Supported"); + results.put("NFC enabled", String.valueOf(nfc.isEnabled() )); + if (Build.VERSION.SDK_INT>=16) results.put("NFC NDefPush enabled", String.valueOf(nfc.isNdefPushEnabled() )); + } else results.put("NFC", "Not supported"); + + // Camera + int numCameras = android.hardware.Camera.getNumberOfCameras(); + if (numCameras > 0 ) { + results.put("Cameras", String.valueOf(numCameras)); + for (int i=0;i sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); + for (int i=0;i=14) { + + mTts.shutdown(); + } + } + } catch (Exception e) { + results.put("TTS supported", "No:\n Error:" + e.toString()); + } + + + // Sound device + AudioManager audioManager = (AudioManager) ct.getSystemService(Context.AUDIO_SERVICE); + if (audioManager != null) { + results.put("Sound system volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM))); + results.put("Sound music volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC))); + results.put("Sound alarm volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_ALARM))); + results.put("Sound ring volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_RING))); + results.put("Sound voice call volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL ))); + results.put("Sound notification volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION))); + results.put("Sound DTMF volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_DTMF))); + results.put("Max sound system volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM))); + results.put("Max sound music volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))); + results.put("Max sound alarm volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM))); + results.put("Max sound ring volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING))); + results.put("Max sound voice call volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL ))); + results.put("Max sound notification volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION))); + results.put("Max sound DTMF volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_DTMF))); + + int audioStatus = audioManager.getMode(); + switch (audioStatus) { + case AudioManager.MODE_NORMAL : + results.put("Audio mode", "Normal"); + break; + case AudioManager.MODE_RINGTONE : + results.put("Audio mode", "Ringtone"); + break; + case AudioManager.MODE_IN_CALL : + results.put("Audio mode", "In call"); + break; + case AudioManager.MODE_IN_COMMUNICATION : + results.put("Audio mode", "In communication"); + break; + case AudioManager.MODE_INVALID : + results.put("Audio mode", "Invalid"); + break; + } + // Sound flags + results.put("Wired eadsets", String.valueOf(audioManager.isWiredHeadsetOn())); + results.put("Bluetooth Sco", String.valueOf(audioManager.isBluetoothScoOn())); + results.put("Bluetooth Sco available off call", String.valueOf(audioManager.isBluetoothScoAvailableOffCall())); + results.put("Microphone muted", String.valueOf(audioManager.isMicrophoneMute())); + results.put("Music active", String.valueOf(audioManager.isMusicActive())); + results.put("Speaker phone", String.valueOf(audioManager.isSpeakerphoneOn())); + results.put("Bluetooth A2dp speaker", String.valueOf(audioManager.isBluetoothA2dpOn())); + } else { // Errors getting info about Sound device + results.put("Sound volume", "UNKNOWN"); + } + } + + @SuppressLint("NewApi") + private void getDataAboutScreen(Context ct) { + WindowManager wm = (WindowManager) ct.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + + if (Build.VERSION.SDK_INT<=16){ // Android 4.0 and lowers + if (Build.VERSION.SDK_INT>13){ + Point size = new Point(); + display.getSize(size); + results.put("Screen width", String.valueOf(size.x)); + results.put("Screen height", String.valueOf(size.y)); + } else { + try { + Method mGetRawH = Display.class.getMethod("getRawHeight"); + Method mGetRawW = Display.class.getMethod("getRawWidth"); + results.put("Screen width",String.valueOf((Integer) mGetRawW.invoke(display))); + results.put("Screen height", String.valueOf((Integer) mGetRawH.invoke(display))); + } catch (Exception e) { + Log.d("Error", "\n Error accessing to video data."); + results.put("Screen width", "UNKNOWN"); + results.put("Screen height", "UNKNOWN"); + } + } + } else { // Android 4.1 or highers + DisplayMetrics displayMetrics = new DisplayMetrics(); + display.getRealMetrics(displayMetrics); + results.put("Screen width", String.valueOf(displayMetrics.widthPixels)); + results.put("Screen height", String.valueOf(displayMetrics.heightPixels)); + } + results.put("Density DPI" , String.valueOf(ct.getResources().getConfiguration().densityDpi)); + results.put("Font scale" , String.valueOf(ct.getResources().getConfiguration().fontScale)); + //Screen orientation)) + switch (ct.getResources().getConfiguration().orientation) { + case Configuration.ORIENTATION_LANDSCAPE : + results.put("Screen orientation", "Landscape"); + break; + case Configuration.ORIENTATION_PORTRAIT : + results.put("Screen orientation", "Portrait"); + break; + } + // Type of Touch screen + results.put("Touch screen", String.valueOf((ct.getResources().getConfiguration().touchscreen != Configuration. + TOUCHSCREEN_NOTOUCH))); + } + + + // CheckForRoot management + + private static String LOG_TAG = AndroidDeviceReporterImpl.class.getName(); + + public static enum SHELL_CMD { + check_su_binary(new String[] { "su", "-c", "ls /" }), ; + + String[] command; + + SHELL_CMD(String[] command) { + this.command = command; + } + } + + /* + * Three method to check the root permissions + */ + public boolean isDeviceRooted() { + if (checkRootMethod1()) { + Log.d(LOG_TAG, "method 1: true"); + return true; + } + if (checkRootMethod2()) { + Log.d(LOG_TAG, "method 2: true"); + return true; + } + if (checkRootMethod3()) { + Log.d(LOG_TAG, "method 3: true"); + return true; + } + return false; + } + + /* + * Method 1, check the SO builds Tags, Usually don't response with the + * correct answer + */ + public boolean checkRootMethod1() { + String buildTags = android.os.Build.TAGS; + + if (buildTags != null && buildTags.contains("test-keys")) { + return true; + } + return false; + } + + /* + * Method 2, If exists Superuser.apk, you can access as SuperUser. Usually, + * if the device is root, this method return true. + */ + public boolean checkRootMethod2() { + try { + File file = new File("/system/app/Superuser.apk"); + if (file.exists()) { + return true; + } + } catch (Exception e) { + } + + return false; + } + + /* + * Method 2, check thought the shell. If you can exec su, the device is + * root. + */ + public boolean checkRootMethod3() { + if (executeCommand(SHELL_CMD.check_su_binary) != null) { + return true; + } else { + return false; + } + } + + public ArrayList executeCommand(SHELL_CMD shellCmd) { + String line = null; + ArrayList fullResponse = new ArrayList(); + Process localProcess = null; + + try { + localProcess = Runtime.getRuntime().exec(shellCmd.command); + } catch (Exception e) { + + e.printStackTrace(); + return null; + } + + BufferedWriter out = new BufferedWriter(new OutputStreamWriter( + localProcess.getOutputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader( + localProcess.getInputStream())); + + try { + while ((line = in.readLine()) != null) { + Log.d(LOG_TAG, "--> Line received: " + line); + fullResponse.add(line); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Log.d(LOG_TAG, "--> Full response was: " + fullResponse); + + return fullResponse; + } + + + + +} From b7973f3787000b72737c5c6c53f9b1735d17c712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 12 Aug 2013 13:34:05 +0200 Subject: [PATCH 2/9] Adding device reporter source directory into ant.properties --- platform/app/ant.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/app/ant.properties b/platform/app/ant.properties index d530201..0c1e2ef 100644 --- a/platform/app/ant.properties +++ b/platform/app/ant.properties @@ -16,4 +16,4 @@ # The password will be asked during the build when you use the 'release' target. #source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src -source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src;../androidSettings/src;../audioManager/src;../persistentconfig/src;libs +source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src;../androidSettings/src;../audioManager/src;../persistentconfig/src;../devicereporter/src;libs From 1ead9944573319e156f7fced9cc9873267aa82f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 12 Aug 2013 13:35:57 +0200 Subject: [PATCH 3/9] Adding device reporter stub - Adding the initial stub - Adding required bits to create the stub into makestubs.sh --- .../platform/Net_gpii_AndroidDeviceReporter.java | 15 +++++++++++++++ platform/makestubs.sh | 1 + 2 files changed, 16 insertions(+) create mode 100644 platform/devicereporter/src/org/meshpoint/anode/stub/gen/platform/Net_gpii_AndroidDeviceReporter.java diff --git a/platform/devicereporter/src/org/meshpoint/anode/stub/gen/platform/Net_gpii_AndroidDeviceReporter.java b/platform/devicereporter/src/org/meshpoint/anode/stub/gen/platform/Net_gpii_AndroidDeviceReporter.java new file mode 100644 index 0000000..b66d3aa --- /dev/null +++ b/platform/devicereporter/src/org/meshpoint/anode/stub/gen/platform/Net_gpii_AndroidDeviceReporter.java @@ -0,0 +1,15 @@ +/* This file has been automatically generated; do not edit */ + +package org.meshpoint.anode.stub.gen.platform; + +public final class Net_gpii_AndroidDeviceReporter { + + private static Object[] __args = new Object[0]; + + public static Object[] __getArgs() { return __args; } + + static Object __invoke(net.gpii.AndroidDeviceReporter inst, int opIdx, Object[] args) { + return inst.getJSONOutput(); + } + +} diff --git a/platform/makestubs.sh b/platform/makestubs.sh index 76b66c4..3759e14 100644 --- a/platform/makestubs.sh +++ b/platform/makestubs.sh @@ -6,3 +6,4 @@ java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./androidSettings/s java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./androidSettings/src --classpath ./app/bin/classes net.gpii.AndroidSettings java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./audioManager/src --classpath ./app/bin/classes net.gpii.AndroidAudioManager java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./persistentconfig/src --classpath ./app/bin/classes net.gpii.AndroidPersistentConfiguration +java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./devicereporter/src --classpath ./app/bin/classes net.gpii.AndroidDeviceReporter From a4763bb7eae57fdfabf01424e5386f094558a63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 12 Aug 2013 13:37:48 +0200 Subject: [PATCH 4/9] Adding basic test.js to show how to use the DeviceReporter module --- test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 test.js diff --git a/test.js b/test.js new file mode 100755 index 0000000..8f80dca --- /dev/null +++ b/test.js @@ -0,0 +1,19 @@ +/*! +GPII Linux Personalization Framework Node.js Bootstrap + +Copyright 2012 OCAD University + +Licensed under the New BSD license. You may not use this file except in +compliance with this License. + +You may obtain a copy of the License at +https://github.com/gpii/universal/LICENSE.txt +*/ +thatall = this; + +var bridge = require("bridge"); + +var deviceReporter = bridge.load("net.gpii.AndroidDeviceReporterImpl", this); +var output = deviceReporter.getJSONOutput(); + +console.log("deviceReporter output: " + output); From 77752ede51cb02f4231636e6b8448b43068b2701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Jun 2014 11:19:03 +0200 Subject: [PATCH 5/9] GPII-779: Updating AndroidDeviceReporter Java code - Create a useful JSON output - Disable some parts of the device reporting - Code clean up --- .../AndroidDeviceReporter.java | 3 +- .../AndroidDeviceReporterImpl.java | 1276 +++++++++-------- 2 files changed, 648 insertions(+), 631 deletions(-) diff --git a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java index 7253eb5..ffe8510 100644 --- a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java +++ b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporter.java @@ -4,8 +4,7 @@ import org.meshpoint.anode.java.Base; public abstract class AndroidDeviceReporter extends Base { - private static short classId = Env.getInterfaceId(AndroidDeviceReporter.class -); + private static short classId = Env.getInterfaceId(AndroidDeviceReporter.class); public AndroidDeviceReporter() { super(classId); } public abstract String getJSONOutput(); } diff --git a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java index 341dac6..5b66ae6 100644 --- a/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java +++ b/platform/devicereporter/src/net/gpii/AndroidDeviceReporter/AndroidDeviceReporterImpl.java @@ -3,10 +3,10 @@ /* DeviceReporterEngine -This class explores hardware and software on the device to make the Device reporter results list. +This class explores hardware and software on the device to make the Device reporter results list. - Copyright (c) 2013, Technosite R&D - All rights reserved. + Copyright (c) 2013, Technosite R&D + All rights reserved. The research leading to these results has received funding from the European Union's Seventh Framework Programme (FP7/2007-2013) under grant agreement n° 289016 Redistribution and use in source and binary forms, with or without @@ -82,634 +82,652 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import org.meshpoint.anode.module.IModule; import org.meshpoint.anode.module.IModuleContext; import org.json.JSONObject; +import org.json.JSONException; public class AndroidDeviceReporterImpl extends AndroidDeviceReporter implements IModule { - private static final String TAG = "net.gpii.AndroidDeviceReporterImpl"; - - IModuleContext ctx; - private Context androidContext; - - private HashMapresults = new HashMap(); - - public Map getResults() { - return (Map) this.results; - } - - @Override - public Object startModule(IModuleContext ctx) { - Log.v(TAG, "AndroidDeviceReporterImpl.startModule()"); - this.ctx = ctx; - this.androidContext = ((AndroidContext) ctx).getAndroidContext(); - - return this; - } - - @Override - public void stopModule() { - Log.v(TAG, "AndroidDeviceReporterImpl.stopModule()"); - } - - @Override - public String getJSONOutput() { - - getDataAboutDevice(); - getDataAboutOperatingSystem(androidContext); - getDataAboutHardware(androidContext); - getDataAboutSensors(androidContext); - //getDataAboutSound(androidContext); - //getDataAboutScreen(androidContext); - - JSONObject output = new JSONObject(results); - - return output.toString(); + private static final String TAG = "net.gpii.AndroidDeviceReporterImpl"; + + IModuleContext ctx; + private Context androidContext; + + private JSONObject jsonResults = new JSONObject(); + + private HashMapresults = new HashMap(); + + public Map getResults() { + return (Map) this.results; + } + + @Override + public Object startModule(IModuleContext ctx) { + Log.v(TAG, "AndroidDeviceReporterImpl.startModule()"); + this.ctx = ctx; + this.androidContext = ((AndroidContext) ctx).getAndroidContext(); + + return this; + } + + @Override + public void stopModule() { + Log.v(TAG, "AndroidDeviceReporterImpl.stopModule()"); + } + + @Override + public String getJSONOutput() { + getDataAboutDevice(); + getDataAboutOperatingSystem(androidContext); + //getDataAboutHardware(androidContext); + //getDataAboutSensors(androidContext); + //getDataAboutSound(androidContext); + //getDataAboutScreen(androidContext); + + //JSONObject output = new JSONObject(results); + + return jsonResults.toString(); + } + + // *** Device reporter getters + + // ** Software + + private void getDataAboutDevice() { + try { + jsonResults.put("Device" , android.os.Build.DEVICE); + jsonResults.put("Model" , android.os.Build.MODEL); + jsonResults.put("Manufacturer" , android.os.Build.MANUFACTURER); + jsonResults.put("Product" , android.os.Build.PRODUCT); + jsonResults.put("Brand" , android.os.Build.BRAND); + jsonResults.put("CPU" , android.os.Build.CPU_ABI); + jsonResults.accumulate("CPU", android.os.Build.CPU_ABI2); + + if (isDeviceRooted()) { + jsonResults.put("rootAccess", "yes"); + } else { + jsonResults.put("rootAccess", "no"); + } + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + private void getDataAboutOperatingSystem(Context ct) { + try { + jsonResults.put("OS Version", "Android " + android.os.Build.VERSION.RELEASE ); + jsonResults.put("Build name" , android.os.Build.FINGERPRINT); + jsonResults.put("Kernel Version", System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")"); + jsonResults.put("OS API Level" , String.valueOf(android.os.Build.VERSION.SDK_INT)); + + // Services and Installed Applications + // + PackageManager packageManager = ct.getPackageManager(); + List applicationList = packageManager.getInstalledApplications (0); + if (applicationList.size()>0) { + for (int i=0; i applicationList = packageManager.getInstalledApplications (0); - if (applicationList.size()>0) - for (int i=0; i packageList = packageManager.getInstalledPackages (PackageManager.GET_SERVICES); - for (int i=0; i=12) { - HashMap deviceList = usb.getDeviceList(); - Iterator> it = deviceList.entrySet().iterator(); - int c = 1; - if (it.hasNext()) { - while (it.hasNext()) { - Map.Entry e = (Map.Entry) it.next(); - results.put("USB attached device " + String.valueOf(c), e.getKey()); - c++; - } - } else results.put("USB attached device", "None"); - } - } else results.put("USB", "Not supported"); - } catch (Exception e) { - results.put("USB", "Not supported\nError:" + e.toString()); - } - - // Keyboard - results.put("System board" , android.os.Build.BOARD); - boolean keyboardPresent = (ct.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); - results.put("Keyboard hardware" , String.valueOf(keyboardPresent)); - - switch (ct.getResources().getConfiguration().keyboard ) { - case Configuration.KEYBOARD_12KEY : - results.put("Keyboard type", "Numeric"); - break; - case Configuration.KEYBOARD_QWERTY : - results.put("Keyboard type", "Qwerty"); - break; - case Configuration.KEYBOARD_NOKEYS : - results.put("Keyboard type", "No keys"); - break; - default : - results.put("Keyboard type", "UNKNOWN"); - break; - } - - // Navigation mode - switch (ct.getResources().getConfiguration().navigation) { - case Configuration.NAVIGATION_TRACKBALL : - results.put("Navigator mode", "Trackball"); - break; - case Configuration.NAVIGATION_WHEEL : - results.put("Navigator mode", "Wheel"); - break; - case Configuration.NAVIGATION_DPAD : - results.put("Navigator mode", "DPad"); - break; - case Configuration.NAVIGATION_NONAV : - results.put("Navigator mode", "None"); - break; - case Configuration.NAVIGATION_UNDEFINED : - results.put("Navigator mode", "Unknown"); - break; - } - - // Battery - try - { - IntentFilter batIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); - Intent battery = ct.registerReceiver(null, batIntentFilter); - int batteryLevel = battery.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); - int batteryStatus = battery.getIntExtra(BatteryManager.EXTRA_STATUS, -1); - int chargePlug = battery.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); - boolean isCharging = (batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING || batteryStatus == BatteryManager.BATTERY_STATUS_FULL); - boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB; - boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC; - results.put("Battery level", String.valueOf(batteryLevel)); - results.put("Battery charging", String.valueOf(isCharging)); - if (isCharging) { - if (usbCharge ) results.put("Battery charging mode", "USB"); - else if (acCharge) results.put("Battery charging mode", "AC "); - else results.put("Battery charging mode", "UNKNOWN"); - } - } - catch (Exception e) - { - results.put("Battery level", "UNKNOWN"); - } - } - - @SuppressLint("NewApi") - private void getDataAboutSensors(Context ct) { - // Wifi - try { - WifiManager wifi = (WifiManager) ct.getSystemService(Context.WIFI_SERVICE); - if (wifi!=null) { - results.put("Wifi", "Supported"); - if (wifi.isWifiEnabled()) { - results.put("Wifi state", "Enabled"); - WifiInfo info = wifi.getConnectionInfo(); - results.put("Wifi SSID", info.getSSID()); - results.put("Wifi BSSID", info.getBSSID()); - results.put("Wifi Mac address", info.getMacAddress()); - results.put("Wifi network Id", String.valueOf(info.getNetworkId() )); - results.put("Wifi IP address", String.valueOf(info.getIpAddress() )); - results.put("Wifi link speed", String.valueOf(info.getLinkSpeed() )); - results.put("Wifi Rssi", String.valueOf(info.getRssi() )); - } else results.put("Wifi state", "Disabled"); - } else results.put("Wifi", "Not supported"); - } catch (Exception e) { - results.put("Wifi", "Not supported\nError:" + e.toString()); - } - - // Bluetooth - try { - BluetoothAdapter bluetoothLocalAdapter = BluetoothAdapter.getDefaultAdapter(); - if (bluetoothLocalAdapter!= null) { - results.put("Bluetooth", "Supported"); - results.put("Bluetooth address", bluetoothLocalAdapter.getAddress()); - results.put("Bluetooth name", bluetoothLocalAdapter.getName()); - switch (bluetoothLocalAdapter.getState()) { - case android.bluetooth.BluetoothAdapter.STATE_OFF : - results.put("Bluetooth state", "Off"); - break; - case android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF : - results.put("Bluetooth state", "Turning off"); - break; - case android.bluetooth.BluetoothAdapter.STATE_ON : - results.put("Bluetooth state", "On"); - break; - case android.bluetooth.BluetoothAdapter.STATE_TURNING_ON : - results.put("Bluetooth state", "Turning on"); - break; - case android.bluetooth.BluetoothAdapter.STATE_CONNECTED : - results.put("Bluetooth state", "Connected"); - break; - case android.bluetooth.BluetoothAdapter.STATE_CONNECTING : - results.put("Bluetooth state", "Connecting"); - break; - case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTED : - results.put("Bluetooth state", "Disconnected"); - break; - case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTING : - results.put("Bluetooth state", "Disconnecting"); - break; - } - } else { - results.put("Bluetooth", "Not supported"); - } - } catch (Exception e) { - results.put("Bluetooth", "Not supported\nError:" + e.toString()); - } - - // NFC - NfcManager nfcManager = (NfcManager) ct.getSystemService(Context.NFC_SERVICE); - NfcAdapter nfc = nfcManager.getDefaultAdapter(); - if (nfc != null) { - results.put("NFC", "Supported"); - results.put("NFC enabled", String.valueOf(nfc.isEnabled() )); - if (Build.VERSION.SDK_INT>=16) results.put("NFC NDefPush enabled", String.valueOf(nfc.isNdefPushEnabled() )); - } else results.put("NFC", "Not supported"); - - // Camera - int numCameras = android.hardware.Camera.getNumberOfCameras(); - if (numCameras > 0 ) { - results.put("Cameras", String.valueOf(numCameras)); - for (int i=0;i sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); - for (int i=0;i=14) { - - mTts.shutdown(); - } - } - } catch (Exception e) { - results.put("TTS supported", "No:\n Error:" + e.toString()); - } - - - // Sound device - AudioManager audioManager = (AudioManager) ct.getSystemService(Context.AUDIO_SERVICE); - if (audioManager != null) { - results.put("Sound system volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM))); - results.put("Sound music volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC))); - results.put("Sound alarm volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_ALARM))); - results.put("Sound ring volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_RING))); - results.put("Sound voice call volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL ))); - results.put("Sound notification volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION))); - results.put("Sound DTMF volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_DTMF))); - results.put("Max sound system volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM))); - results.put("Max sound music volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))); - results.put("Max sound alarm volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM))); - results.put("Max sound ring volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING))); - results.put("Max sound voice call volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL ))); - results.put("Max sound notification volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION))); - results.put("Max sound DTMF volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_DTMF))); - - int audioStatus = audioManager.getMode(); - switch (audioStatus) { - case AudioManager.MODE_NORMAL : - results.put("Audio mode", "Normal"); - break; - case AudioManager.MODE_RINGTONE : - results.put("Audio mode", "Ringtone"); - break; - case AudioManager.MODE_IN_CALL : - results.put("Audio mode", "In call"); - break; - case AudioManager.MODE_IN_COMMUNICATION : - results.put("Audio mode", "In communication"); - break; - case AudioManager.MODE_INVALID : - results.put("Audio mode", "Invalid"); - break; - } - // Sound flags - results.put("Wired eadsets", String.valueOf(audioManager.isWiredHeadsetOn())); - results.put("Bluetooth Sco", String.valueOf(audioManager.isBluetoothScoOn())); - results.put("Bluetooth Sco available off call", String.valueOf(audioManager.isBluetoothScoAvailableOffCall())); - results.put("Microphone muted", String.valueOf(audioManager.isMicrophoneMute())); - results.put("Music active", String.valueOf(audioManager.isMusicActive())); - results.put("Speaker phone", String.valueOf(audioManager.isSpeakerphoneOn())); - results.put("Bluetooth A2dp speaker", String.valueOf(audioManager.isBluetoothA2dpOn())); - } else { // Errors getting info about Sound device - results.put("Sound volume", "UNKNOWN"); - } - } - - @SuppressLint("NewApi") - private void getDataAboutScreen(Context ct) { - WindowManager wm = (WindowManager) ct.getSystemService(Context.WINDOW_SERVICE); - Display display = wm.getDefaultDisplay(); - - if (Build.VERSION.SDK_INT<=16){ // Android 4.0 and lowers - if (Build.VERSION.SDK_INT>13){ - Point size = new Point(); - display.getSize(size); - results.put("Screen width", String.valueOf(size.x)); - results.put("Screen height", String.valueOf(size.y)); - } else { - try { - Method mGetRawH = Display.class.getMethod("getRawHeight"); - Method mGetRawW = Display.class.getMethod("getRawWidth"); - results.put("Screen width",String.valueOf((Integer) mGetRawW.invoke(display))); - results.put("Screen height", String.valueOf((Integer) mGetRawH.invoke(display))); - } catch (Exception e) { - Log.d("Error", "\n Error accessing to video data."); - results.put("Screen width", "UNKNOWN"); - results.put("Screen height", "UNKNOWN"); - } - } - } else { // Android 4.1 or highers - DisplayMetrics displayMetrics = new DisplayMetrics(); - display.getRealMetrics(displayMetrics); - results.put("Screen width", String.valueOf(displayMetrics.widthPixels)); - results.put("Screen height", String.valueOf(displayMetrics.heightPixels)); - } - results.put("Density DPI" , String.valueOf(ct.getResources().getConfiguration().densityDpi)); - results.put("Font scale" , String.valueOf(ct.getResources().getConfiguration().fontScale)); - //Screen orientation)) - switch (ct.getResources().getConfiguration().orientation) { - case Configuration.ORIENTATION_LANDSCAPE : - results.put("Screen orientation", "Landscape"); - break; - case Configuration.ORIENTATION_PORTRAIT : - results.put("Screen orientation", "Portrait"); - break; - } - // Type of Touch screen - results.put("Touch screen", String.valueOf((ct.getResources().getConfiguration().touchscreen != Configuration. - TOUCHSCREEN_NOTOUCH))); - } - - - // CheckForRoot management - - private static String LOG_TAG = AndroidDeviceReporterImpl.class.getName(); - - public static enum SHELL_CMD { - check_su_binary(new String[] { "su", "-c", "ls /" }), ; - - String[] command; - - SHELL_CMD(String[] command) { - this.command = command; - } - } - - /* - * Three method to check the root permissions - */ - public boolean isDeviceRooted() { - if (checkRootMethod1()) { - Log.d(LOG_TAG, "method 1: true"); - return true; - } - if (checkRootMethod2()) { - Log.d(LOG_TAG, "method 2: true"); - return true; - } - if (checkRootMethod3()) { - Log.d(LOG_TAG, "method 3: true"); - return true; - } - return false; - } - - /* - * Method 1, check the SO builds Tags, Usually don't response with the - * correct answer - */ - public boolean checkRootMethod1() { - String buildTags = android.os.Build.TAGS; - - if (buildTags != null && buildTags.contains("test-keys")) { - return true; - } - return false; - } - - /* - * Method 2, If exists Superuser.apk, you can access as SuperUser. Usually, - * if the device is root, this method return true. - */ - public boolean checkRootMethod2() { - try { - File file = new File("/system/app/Superuser.apk"); - if (file.exists()) { - return true; - } - } catch (Exception e) { - } - - return false; - } - - /* - * Method 2, check thought the shell. If you can exec su, the device is - * root. - */ - public boolean checkRootMethod3() { - if (executeCommand(SHELL_CMD.check_su_binary) != null) { - return true; - } else { - return false; - } - } - - public ArrayList executeCommand(SHELL_CMD shellCmd) { - String line = null; - ArrayList fullResponse = new ArrayList(); - Process localProcess = null; - - try { - localProcess = Runtime.getRuntime().exec(shellCmd.command); - } catch (Exception e) { - - e.printStackTrace(); - return null; - } - - BufferedWriter out = new BufferedWriter(new OutputStreamWriter( - localProcess.getOutputStream())); - BufferedReader in = new BufferedReader(new InputStreamReader( - localProcess.getInputStream())); - - try { - while ((line = in.readLine()) != null) { - Log.d(LOG_TAG, "--> Line received: " + line); - fullResponse.add(line); - } - } catch (Exception e) { - e.printStackTrace(); - } - - Log.d(LOG_TAG, "--> Full response was: " + fullResponse); - - return fullResponse; - } - - - + } + + List packageList = packageManager.getInstalledPackages (PackageManager.GET_SERVICES); + for (int i=0; i=12) { + HashMap deviceList = usb.getDeviceList(); + Iterator> it = deviceList.entrySet().iterator(); + int c = 1; + if (it.hasNext()) { + while (it.hasNext()) { + Map.Entry e = (Map.Entry) it.next(); + results.put("USB attached device " + String.valueOf(c), e.getKey()); + c++; + } + } else results.put("USB attached device", "None"); + } + } else results.put("USB", "Not supported"); + } catch (Exception e) { + results.put("USB", "Not supported\nError:" + e.toString()); + } + + // Keyboard + results.put("System board" , android.os.Build.BOARD); + boolean keyboardPresent = (ct.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS); + results.put("Keyboard hardware" , String.valueOf(keyboardPresent)); + + switch (ct.getResources().getConfiguration().keyboard ) { + case Configuration.KEYBOARD_12KEY : + results.put("Keyboard type", "Numeric"); + break; + case Configuration.KEYBOARD_QWERTY : + results.put("Keyboard type", "Qwerty"); + break; + case Configuration.KEYBOARD_NOKEYS : + results.put("Keyboard type", "No keys"); + break; + default : + results.put("Keyboard type", "UNKNOWN"); + break; + } + + // Navigation mode + switch (ct.getResources().getConfiguration().navigation) { + case Configuration.NAVIGATION_TRACKBALL : + results.put("Navigator mode", "Trackball"); + break; + case Configuration.NAVIGATION_WHEEL : + results.put("Navigator mode", "Wheel"); + break; + case Configuration.NAVIGATION_DPAD : + results.put("Navigator mode", "DPad"); + break; + case Configuration.NAVIGATION_NONAV : + results.put("Navigator mode", "None"); + break; + case Configuration.NAVIGATION_UNDEFINED : + results.put("Navigator mode", "Unknown"); + break; + } + + // Battery + try + { + IntentFilter batIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + Intent battery = ct.registerReceiver(null, batIntentFilter); + int batteryLevel = battery.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); + int batteryStatus = battery.getIntExtra(BatteryManager.EXTRA_STATUS, -1); + int chargePlug = battery.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); + boolean isCharging = (batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING || batteryStatus == BatteryManager.BATTERY_STATUS_FULL); + boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB; + boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC; + results.put("Battery level", String.valueOf(batteryLevel)); + results.put("Battery charging", String.valueOf(isCharging)); + if (isCharging) { + if (usbCharge ) results.put("Battery charging mode", "USB"); + else if (acCharge) results.put("Battery charging mode", "AC "); + else results.put("Battery charging mode", "UNKNOWN"); + } + } + catch (Exception e) + { + results.put("Battery level", "UNKNOWN"); + } + } + + @SuppressLint("NewApi") + private void getDataAboutSensors(Context ct) { + // Wifi + try { + WifiManager wifi = (WifiManager) ct.getSystemService(Context.WIFI_SERVICE); + if (wifi!=null) { + results.put("Wifi", "Supported"); + if (wifi.isWifiEnabled()) { + results.put("Wifi state", "Enabled"); + WifiInfo info = wifi.getConnectionInfo(); + results.put("Wifi SSID", info.getSSID()); + results.put("Wifi BSSID", info.getBSSID()); + results.put("Wifi Mac address", info.getMacAddress()); + results.put("Wifi network Id", String.valueOf(info.getNetworkId() )); + results.put("Wifi IP address", String.valueOf(info.getIpAddress() )); + results.put("Wifi link speed", String.valueOf(info.getLinkSpeed() )); + results.put("Wifi Rssi", String.valueOf(info.getRssi() )); + } else results.put("Wifi state", "Disabled"); + } else results.put("Wifi", "Not supported"); + } catch (Exception e) { + results.put("Wifi", "Not supported\nError:" + e.toString()); + } + + // Bluetooth + try { + BluetoothAdapter bluetoothLocalAdapter = BluetoothAdapter.getDefaultAdapter(); + if (bluetoothLocalAdapter!= null) { + results.put("Bluetooth", "Supported"); + results.put("Bluetooth address", bluetoothLocalAdapter.getAddress()); + results.put("Bluetooth name", bluetoothLocalAdapter.getName()); + switch (bluetoothLocalAdapter.getState()) { + case android.bluetooth.BluetoothAdapter.STATE_OFF : + results.put("Bluetooth state", "Off"); + break; + case android.bluetooth.BluetoothAdapter.STATE_TURNING_OFF : + results.put("Bluetooth state", "Turning off"); + break; + case android.bluetooth.BluetoothAdapter.STATE_ON : + results.put("Bluetooth state", "On"); + break; + case android.bluetooth.BluetoothAdapter.STATE_TURNING_ON : + results.put("Bluetooth state", "Turning on"); + break; + case android.bluetooth.BluetoothAdapter.STATE_CONNECTED : + results.put("Bluetooth state", "Connected"); + break; + case android.bluetooth.BluetoothAdapter.STATE_CONNECTING : + results.put("Bluetooth state", "Connecting"); + break; + case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTED : + results.put("Bluetooth state", "Disconnected"); + break; + case android.bluetooth.BluetoothAdapter.STATE_DISCONNECTING : + results.put("Bluetooth state", "Disconnecting"); + break; + } + } else { + results.put("Bluetooth", "Not supported"); + } + } catch (Exception e) { + results.put("Bluetooth", "Not supported\nError:" + e.toString()); + } + + // NFC + NfcManager nfcManager = (NfcManager) ct.getSystemService(Context.NFC_SERVICE); + NfcAdapter nfc = nfcManager.getDefaultAdapter(); + if (nfc != null) { + results.put("NFC", "Supported"); + results.put("NFC enabled", String.valueOf(nfc.isEnabled() )); + if (Build.VERSION.SDK_INT>=16) results.put("NFC NDefPush enabled", String.valueOf(nfc.isNdefPushEnabled() )); + } else results.put("NFC", "Not supported"); + + // Camera + int numCameras = android.hardware.Camera.getNumberOfCameras(); + if (numCameras > 0 ) { + results.put("Cameras", String.valueOf(numCameras)); + for (int i=0;i sensorList = sensorManager.getSensorList(Sensor.TYPE_ALL); + for (int i=0;i=14) { + mTts.shutdown(); + } + } + } catch (Exception e) { + results.put("TTS supported", "No:\n Error:" + e.toString()); + } + + + // Sound device + AudioManager audioManager = (AudioManager) ct.getSystemService(Context.AUDIO_SERVICE); + if (audioManager != null) { + results.put("Sound system volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM))); + results.put("Sound music volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC))); + results.put("Sound alarm volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_ALARM))); + results.put("Sound ring volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_RING))); + results.put("Sound voice call volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL ))); + results.put("Sound notification volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION))); + results.put("Sound DTMF volume", String.valueOf(audioManager.getStreamVolume(AudioManager.STREAM_DTMF))); + results.put("Max sound system volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM))); + results.put("Max sound music volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))); + results.put("Max sound alarm volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM))); + results.put("Max sound ring volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING))); + results.put("Max sound voice call volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL ))); + results.put("Max sound notification volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION))); + results.put("Max sound DTMF volume", String.valueOf(audioManager.getStreamMaxVolume(AudioManager.STREAM_DTMF))); + + int audioStatus = audioManager.getMode(); + switch (audioStatus) { + case AudioManager.MODE_NORMAL : + results.put("Audio mode", "Normal"); + break; + case AudioManager.MODE_RINGTONE : + results.put("Audio mode", "Ringtone"); + break; + case AudioManager.MODE_IN_CALL : + results.put("Audio mode", "In call"); + break; + case AudioManager.MODE_IN_COMMUNICATION : + results.put("Audio mode", "In communication"); + break; + case AudioManager.MODE_INVALID : + results.put("Audio mode", "Invalid"); + break; + } + // Sound flags + results.put("Wired eadsets", String.valueOf(audioManager.isWiredHeadsetOn())); + results.put("Bluetooth Sco", String.valueOf(audioManager.isBluetoothScoOn())); + results.put("Bluetooth Sco available off call", String.valueOf(audioManager.isBluetoothScoAvailableOffCall())); + results.put("Microphone muted", String.valueOf(audioManager.isMicrophoneMute())); + results.put("Music active", String.valueOf(audioManager.isMusicActive())); + results.put("Speaker phone", String.valueOf(audioManager.isSpeakerphoneOn())); + results.put("Bluetooth A2dp speaker", String.valueOf(audioManager.isBluetoothA2dpOn())); + } else { // Errors getting info about Sound device + results.put("Sound volume", "UNKNOWN"); + } + } + + @SuppressLint("NewApi") + private void getDataAboutScreen(Context ct) { + WindowManager wm = (WindowManager) ct.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + + if (Build.VERSION.SDK_INT<=16){ // Android 4.0 and lowers + if (Build.VERSION.SDK_INT>13){ + Point size = new Point(); + display.getSize(size); + results.put("Screen width", String.valueOf(size.x)); + results.put("Screen height", String.valueOf(size.y)); + } else { + try { + Method mGetRawH = Display.class.getMethod("getRawHeight"); + Method mGetRawW = Display.class.getMethod("getRawWidth"); + results.put("Screen width",String.valueOf((Integer) mGetRawW.invoke(display))); + results.put("Screen height", String.valueOf((Integer) mGetRawH.invoke(display))); + } catch (Exception e) { + Log.d("Error", "\n Error accessing to video data."); + results.put("Screen width", "UNKNOWN"); + results.put("Screen height", "UNKNOWN"); + } + } + } else { // Android 4.1 or highers + DisplayMetrics displayMetrics = new DisplayMetrics(); + display.getRealMetrics(displayMetrics); + results.put("Screen width", String.valueOf(displayMetrics.widthPixels)); + results.put("Screen height", String.valueOf(displayMetrics.heightPixels)); + } + results.put("Density DPI" , String.valueOf(ct.getResources().getConfiguration().densityDpi)); + results.put("Font scale" , String.valueOf(ct.getResources().getConfiguration().fontScale)); + //Screen orientation)) + switch (ct.getResources().getConfiguration().orientation) { + case Configuration.ORIENTATION_LANDSCAPE : + results.put("Screen orientation", "Landscape"); + break; + case Configuration.ORIENTATION_PORTRAIT : + results.put("Screen orientation", "Portrait"); + break; + } + // Type of Touch screen + results.put("Touch screen", String.valueOf((ct.getResources().getConfiguration().touchscreen != Configuration. + TOUCHSCREEN_NOTOUCH))); + } + + // CheckForRoot management + + private static String LOG_TAG = AndroidDeviceReporterImpl.class.getName(); + + public static enum SHELL_CMD { + check_su_binary(new String[] { "su", "-c", "ls /" }), ; + + String[] command; + + SHELL_CMD(String[] command) { + this.command = command; + } + } + + /* + * Three method to check the root permissions + */ + public boolean isDeviceRooted() { + if (checkRootMethod1()) { + Log.d(LOG_TAG, "method 1: true"); + return true; + } + if (checkRootMethod2()) { + Log.d(LOG_TAG, "method 2: true"); + return true; + } + if (checkRootMethod3()) { + Log.d(LOG_TAG, "method 3: true"); + return true; + } + return false; + } + + /* + * Method 1, check the SO builds Tags, Usually don't response with the + * correct answer + */ + public boolean checkRootMethod1() { + String buildTags = android.os.Build.TAGS; + + if (buildTags != null && buildTags.contains("test-keys")) { + return true; + } + return false; + } + + /* + * Method 2, If exists Superuser.apk, you can access as SuperUser. Usually, + * if the device is root, this method return true. + */ + public boolean checkRootMethod2() { + try { + File file = new File("/system/app/Superuser.apk"); + if (file.exists()) { + return true; + } + } catch (Exception e) { + } + + return false; + } + + /* + * Method 2, check thought the shell. If you can exec su, the device is + * root. + */ + public boolean checkRootMethod3() { + if (executeCommand(SHELL_CMD.check_su_binary) != null) { + return true; + } else { + return false; + } + } + + public ArrayList executeCommand(SHELL_CMD shellCmd) { + String line = null; + ArrayList fullResponse = new ArrayList(); + Process localProcess = null; + + try { + localProcess = Runtime.getRuntime().exec(shellCmd.command); + } catch (Exception e) { + + e.printStackTrace(); + return null; + } + + BufferedWriter out = new BufferedWriter(new OutputStreamWriter( + localProcess.getOutputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader( + localProcess.getInputStream())); + + try { + while ((line = in.readLine()) != null) { + Log.d(LOG_TAG, "--> Line received: " + line); + fullResponse.add(line); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Log.d(LOG_TAG, "--> Full response was: " + fullResponse); + + return fullResponse; + } } From 8faaabc18e5cc79f870f86d38591572b3a900d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Jun 2014 11:24:25 +0200 Subject: [PATCH 6/9] GPII-779: Adding androidDeviceReporter's JS node.js module --- node_modules/deviceReporter/deviceReporter.js | 53 +++++++++++++++++++ node_modules/deviceReporter/index.js | 28 ++++++++++ node_modules/deviceReporter/package.json | 19 +++++++ 3 files changed, 100 insertions(+) create mode 100644 node_modules/deviceReporter/deviceReporter.js create mode 100644 node_modules/deviceReporter/index.js create mode 100644 node_modules/deviceReporter/package.json diff --git a/node_modules/deviceReporter/deviceReporter.js b/node_modules/deviceReporter/deviceReporter.js new file mode 100644 index 0000000..186daf2 --- /dev/null +++ b/node_modules/deviceReporter/deviceReporter.js @@ -0,0 +1,53 @@ +/*! +GPII Android Device Reporter + +Copyright 2014 Emergya + +Licensed under the New BSD license. You may not use this file except in +compliance with this License. + +You may obtain a copy of the License at +https://github.com/gpii/universal/LICENSE.txt +*/ + +// Currently we need to do this in order to work correctly with +// Anode's JS bridge +var thatall = this; + +(function () { + "use strict"; + + var fluid = require("universal"); + var gpii = fluid.registerNamespace("gpii"); + + var bridge = require("bridge"); + + fluid.registerNamespace("gpii.androidDeviceReporter"); + + fluid.defaults("gpii.androidDeviceReporter.findService", { + gradeNames: "fluid.function", + argumentMap: { + name: 0 + } + }); + + fluid.defaults("gpii.androidDeviceReporter.findApplication", { + gradeNames: "fluid.function", + argumentMap: { + name: 0 + } + }); + + gpii.androidDeviceReporter.findService = function(name) { + return gpii.androidDeviceReporter.deviceInfoCache.Services.some(function (srv) { + return srv === name; + }); + }; + + gpii.androidDeviceReporter.findApplication = function(name) { + return gpii.androidDeviceReporter.deviceInfoCache.Applications.some(function (app) { + return app === name; + }); + }; + +})(); diff --git a/node_modules/deviceReporter/index.js b/node_modules/deviceReporter/index.js new file mode 100644 index 0000000..893be31 --- /dev/null +++ b/node_modules/deviceReporter/index.js @@ -0,0 +1,28 @@ +/*! +GPII Android Activity Manager + +Copyright 2014 Emergya + +Licensed under the New BSD license. You may not use this file except in +compliance with this License. + +You may obtain a copy of the License at +https://github.com/gpii/universal/LICENSE.txt +*/ +var thatall = this; + +var fluid = require("universal"); + +var loader = fluid.getLoader(__dirname); + +loader.require("./deviceReporter.js"); + +// Initialize the Device Reporter at the very beginning and avoid a delay when +// a user is logging in into the system. +// +gpii = fluid.registerNamespace("gpii"); +fluid.registerNamespace("gpii.androidDeviceReporter"); + +var bridge = require("bridge"); +var deviceReporter = bridge.load("net.gpii.AndroidDeviceReporterImpl", this); +gpii.androidDeviceReporter.deviceInfoCache = JSON.parse(deviceReporter.getJSONOutput()); diff --git a/node_modules/deviceReporter/package.json b/node_modules/deviceReporter/package.json new file mode 100644 index 0000000..00f9e68 --- /dev/null +++ b/node_modules/deviceReporter/package.json @@ -0,0 +1,19 @@ +{ + "name": "deviceReporter", + "description": "This module provides information about the device.", + "version": "0.1", + "author": "Javier Hernández", + "bugs": "http://wiki.gpii.net/index.php/Main_Page", + "homepage": "http://gpii.net/", + "dependencies": {}, + "licenses": [ + { + "type": "BSD-3-Clause", + "url": "http://www.opensource.org/licenses/BSD-3-Clause" + } + ], + "keywords": ["gpii", "accessibility", "settings", "fluid"], + "repository": "git://github.com:GPII/android.git", + "main": "./index.js", + "engines": { "node" : ">=0.1.9" } +} From 18da519a2c52006bd428918fba906696848bab44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Jun 2014 11:25:31 +0200 Subject: [PATCH 7/9] GPII-779: Loading the androidDeviceReporter at start-up time --- gpii.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gpii.js b/gpii.js index e00cf53..57cbb23 100644 --- a/gpii.js +++ b/gpii.js @@ -2,6 +2,7 @@ GPII Linux Personalization Framework Node.js Bootstrap Copyright 2012 OCAD University +Copyright 2013 2014 Emergya Licensed under the New BSD license. You may not use this file except in compliance with this License. @@ -13,11 +14,15 @@ https://github.com/gpii/universal/LICENSE.txt var fluid = require("universal"), kettle = fluid.registerNamespace("kettle"); +// Settings Handlers & Lifecycle Actions-related modules fluid.require("activitymanager", require); fluid.require("androidSettings", require); fluid.require("audioManager", require); fluid.require("persistentConfiguration", require); +// Android Device Reporter +fluid.require("deviceReporter", require); + // For Android, if we don't explicity use the __dirname on the configPath // we end up getting something like /node_modules/universal/gpii/configs/file.json' kettle.config.makeConfigLoader({ From 88314ebfc3a8f4fa0e4793f29d8bfaa454e85c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 22 Aug 2014 14:32:15 +0200 Subject: [PATCH 8/9] GPII-779: Removing useless test.js file This file is no longer required because it was just an example of how the device reporter should be called from a js script. --- test.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100755 test.js diff --git a/test.js b/test.js deleted file mode 100755 index 8f80dca..0000000 --- a/test.js +++ /dev/null @@ -1,19 +0,0 @@ -/*! -GPII Linux Personalization Framework Node.js Bootstrap - -Copyright 2012 OCAD University - -Licensed under the New BSD license. You may not use this file except in -compliance with this License. - -You may obtain a copy of the License at -https://github.com/gpii/universal/LICENSE.txt -*/ -thatall = this; - -var bridge = require("bridge"); - -var deviceReporter = bridge.load("net.gpii.AndroidDeviceReporterImpl", this); -var output = deviceReporter.getJSONOutput(); - -console.log("deviceReporter output: " + output); From e5685a5c47f6e7bdc62ab1c07ebc17c6ea91eb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Fri, 30 Oct 2015 03:08:45 +0100 Subject: [PATCH 9/9] GPII-779: Added some tests for the native module --- .../deviceReporter/deviceReporter.js | 12 +-- .../deviceReporter/deviceReporterTests.js | 75 +++++++++++++++++++ gpii/node_modules/deviceReporter/index.js | 4 +- 3 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 gpii/node_modules/deviceReporter/deviceReporterTests.js diff --git a/gpii/node_modules/deviceReporter/deviceReporter.js b/gpii/node_modules/deviceReporter/deviceReporter.js index 186daf2..ee9b7e4 100644 --- a/gpii/node_modules/deviceReporter/deviceReporter.js +++ b/gpii/node_modules/deviceReporter/deviceReporter.js @@ -11,8 +11,6 @@ https://github.com/gpii/universal/LICENSE.txt */ // Currently we need to do this in order to work correctly with -// Anode's JS bridge -var thatall = this; (function () { "use strict"; @@ -20,8 +18,6 @@ var thatall = this; var fluid = require("universal"); var gpii = fluid.registerNamespace("gpii"); - var bridge = require("bridge"); - fluid.registerNamespace("gpii.androidDeviceReporter"); fluid.defaults("gpii.androidDeviceReporter.findService", { @@ -38,14 +34,14 @@ var thatall = this; } }); - gpii.androidDeviceReporter.findService = function(name) { - return gpii.androidDeviceReporter.deviceInfoCache.Services.some(function (srv) { + gpii.androidDeviceReporter.findService = function (name) { + return gpii.androidDeviceReporter.deviceInfoCache.Services.some(function (srv) { return srv === name; }); }; - gpii.androidDeviceReporter.findApplication = function(name) { - return gpii.androidDeviceReporter.deviceInfoCache.Applications.some(function (app) { + gpii.androidDeviceReporter.findApplication = function (name) { + return gpii.androidDeviceReporter.deviceInfoCache.Applications.some(function (app) { return app === name; }); }; diff --git a/gpii/node_modules/deviceReporter/deviceReporterTests.js b/gpii/node_modules/deviceReporter/deviceReporterTests.js new file mode 100644 index 0000000..46a5b72 --- /dev/null +++ b/gpii/node_modules/deviceReporter/deviceReporterTests.js @@ -0,0 +1,75 @@ +/* + * GPII Android Device Reporter Tests + * + * Copyright 2013, 2014, 2015 Emergya + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * The research leading to these results has received funding from the European Union's + * Seventh Framework Programme (FP7/2007-2013) + * under grant agreement no. 289016. + * + * You may obtain a copy of the License at + * https://github.com/GPII/universal/blob/master/LICENSE.txt + */ + +var thatall = this; + +(function () { + "use strict"; + + var fluid = require("universal"), + gpii = fluid.registerNamespace("gpii"), + jqUnit = fluid.require("jqUnit"), + bridge = require("bridge"), + androidDeviceReporter = bridge.load("net.gpii.AndroidDeviceReporterImpl", + thatall); + + jqUnit.module("GPII Android deviceReporter"); + + jqUnit.test("Running tests for deviceReporter node module", function () { + // Check if all required methods are available through the java bridge + // + var methods = ["getJSONOutput"]; + + for (var method in methods) { + jqUnit.assertTrue("Checking availability of method '" + method + "'", + (methods[method] in androidDeviceReporter)); + } + + jqUnit.assertNotEquals("'getJSONOutput' does not return an empty object", + androidDeviceReporter.getJSONOutput(), + null); + + // Check information that JSONOutput must contain + // + var deviceInfoCache = JSON.parse(androidDeviceReporter.getJSONOutput()); + + var fields = ["Device", "Model", "Manufacturer", "Product", "Brand", + "CPU", "rootAccess", "OS Version", "Build name", + "Kernel Version", "OS API Level", "Applications", + "Services"]; + + for (var field in fields) { + jqUnit.assertTrue("Checking availability of field '" + field + "'", + (fields[field] in deviceInfoCache)); + } + + // Check find methods + // + require("deviceReporter"); + + fluid.registerNamespace("gpii.androidDeviceReporter"); + gpii.androidDeviceReporter.deviceInfoCache = deviceInfoCache; + + jqUnit.assertNotEquals("Testing gpii.androidDeviceReporter.findApplication with a non-existent app name", + gpii.androidDeviceReporter.findApplication("should.not.exist"), true); + + jqUnit.assertTrue("Testing gpii.androidDeviceReporter.findService", + gpii.androidDeviceReporter.findService("android")); + + + }); + +})(); diff --git a/gpii/node_modules/deviceReporter/index.js b/gpii/node_modules/deviceReporter/index.js index 893be31..fad803a 100644 --- a/gpii/node_modules/deviceReporter/index.js +++ b/gpii/node_modules/deviceReporter/index.js @@ -9,8 +9,6 @@ compliance with this License. You may obtain a copy of the License at https://github.com/gpii/universal/LICENSE.txt */ -var thatall = this; - var fluid = require("universal"); var loader = fluid.getLoader(__dirname); @@ -20,7 +18,7 @@ loader.require("./deviceReporter.js"); // Initialize the Device Reporter at the very beginning and avoid a delay when // a user is logging in into the system. // -gpii = fluid.registerNamespace("gpii"); +var gpii = fluid.registerNamespace("gpii"); fluid.registerNamespace("gpii.androidDeviceReporter"); var bridge = require("bridge");