@ -0,0 +1 @@
|
||||
12
|
@ -0,0 +1 @@
|
||||
12
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.battery;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Whenever battery level changes This receiver will be triggered
|
||||
*/
|
||||
public class BatteryDataReceiver extends BroadcastReceiver {
|
||||
|
||||
private Vector<BatteryData> batteryDatas = new Vector<BatteryData>();
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
|
||||
BatteryData bt = new BatteryData(intent);
|
||||
batteryDatas.add(bt);
|
||||
|
||||
for (BatteryData data : batteryDatas) {
|
||||
DataMap.getBatteryDataMap().add(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SenseUtils {
|
||||
|
||||
|
||||
//http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id
|
||||
public static String generateDeviceId(Context baseContext, ContentResolver contentResolver) {
|
||||
|
||||
final TelephonyManager tm = (TelephonyManager) baseContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
final String tmDevice, tmSerial, androidId;
|
||||
tmDevice = "" + tm.getDeviceId();
|
||||
tmSerial = "" + tm.getSimSerialNumber();
|
||||
androidId = "" + android.provider.Settings.Secure.getString(contentResolver, android.provider.Settings.Secure.ANDROID_ID);
|
||||
|
||||
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
|
||||
return deviceUuid.toString();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class LocationDataReader extends DataReader implements LocationListener {
|
||||
protected LocationManager locationManager;
|
||||
private Context mContext;
|
||||
private boolean canGetLocation = false;
|
||||
|
||||
Location location; // location
|
||||
double latitude; // latitude
|
||||
double longitude; // longitude
|
||||
|
||||
private Vector<LocationData> locationDatas = new Vector<LocationData>();
|
||||
// The minimum distance to change Updates in meters
|
||||
// private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
|
||||
|
||||
// The minimum time between updates in milliseconds
|
||||
//private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
|
||||
|
||||
public LocationDataReader(Context context) {
|
||||
mContext = context;
|
||||
getLocation();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
try {
|
||||
locationManager = (LocationManager) mContext.getSystemService(mContext.LOCATION_SERVICE);
|
||||
|
||||
// getting GPS status
|
||||
boolean isGPSEnabled = locationManager
|
||||
.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
|
||||
// getting network status
|
||||
boolean isNetworkEnabled = locationManager
|
||||
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
|
||||
if (!isGPSEnabled && !isNetworkEnabled) {
|
||||
// no network provider is enabled
|
||||
} else {
|
||||
this.canGetLocation = true;
|
||||
// First get location from Network Provider
|
||||
if (isNetworkEnabled) {
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
||||
// MIN_TIME_BW_UPDATES,
|
||||
// MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
|
||||
|
||||
if (locationManager != null) {
|
||||
location = locationManager
|
||||
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
}
|
||||
}
|
||||
// if GPS Enabled get lat/long using GPS Services
|
||||
if (isGPSEnabled) {
|
||||
if (location == null) {
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
//MIN_TIME_BW_UPDATES,
|
||||
//MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
|
||||
|
||||
Log.d(this.getClass().getName(), "GPS Enabled");
|
||||
if (locationManager != null) {
|
||||
location = locationManager
|
||||
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("Location Sense", "Error O");
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public boolean canGetLocation() {
|
||||
return this.canGetLocation;
|
||||
}
|
||||
|
||||
public void stopUsingGPS() {
|
||||
if (locationManager != null) {
|
||||
locationManager.removeUpdates(LocationDataReader.this);
|
||||
}
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
}
|
||||
|
||||
// return latitude
|
||||
return latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get longitude
|
||||
*/
|
||||
public double getLongitude() {
|
||||
if (location != null) {
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
|
||||
// return longitude
|
||||
return longitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(this.getClass().getSimpleName(), "running -Location");
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10000);
|
||||
locationDatas.add(new LocationData(getLatitude(), getLongitude()));
|
||||
for (LocationData data : locationDatas) {
|
||||
DataMap.getLocationDataMap().add(data);
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Log.i("Location Data", " Location Data Retrieval Failed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
include ':app'
|
@ -0,0 +1,96 @@
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Sensor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class SensorDataReader extends DataReader implements SensorEventListener {
|
||||
private SensorManager mSensorManager;
|
||||
private List<Sensor> mSensors;
|
||||
private Map<String, SensorData> senseDataStruct = new HashMap<String, SensorData>();
|
||||
private Vector<SensorData> sensorVector = new Vector<SensorData>();
|
||||
Context ctx;
|
||||
|
||||
|
||||
|
||||
public SensorDataReader(Context context) {
|
||||
ctx=context;
|
||||
mSensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||
mSensors= mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||
for (Sensor sensor : mSensors)
|
||||
{
|
||||
mSensorManager.registerListener((SensorEventListener) this, sensor, SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectSensorData(){
|
||||
|
||||
Log.d(this.getClass().getName(), "Sensor Type");
|
||||
for (Sensor sensor : mSensors)
|
||||
{
|
||||
try{
|
||||
if (senseDataStruct.containsKey(sensor.getName())){
|
||||
|
||||
SensorData sensorInfo=senseDataStruct.get(sensor.getName());
|
||||
sensorVector.add(sensorInfo);
|
||||
Log.d(this.getClass().getName(),"Sensor Name "+sensor.getName()+", Type "+ sensor.getType() + " " +
|
||||
", sensorValue :" + sensorInfo.getSensorValues());
|
||||
}
|
||||
}catch(Throwable e){
|
||||
Log.d(this.getClass().getName(),"error on sensors");
|
||||
}
|
||||
|
||||
}
|
||||
mSensorManager.unregisterListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Vector<SensorData> getSensorData(){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(SensorDataReader.class.getName(),e.getMessage());
|
||||
}
|
||||
collectSensorData();
|
||||
return sensorVector;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
senseDataStruct.put(event.sensor.getName(), new SensorData(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(this.getClass().getName(),"running -sensor");
|
||||
Vector<SensorData> sensorDatas=getSensorData();
|
||||
for( SensorData data : sensorDatas){
|
||||
DataMap.getSensorDataMap().add(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.SenseDataCollector;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryDataReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseWakeLock;
|
||||
|
||||
|
||||
public class SenseService extends Service {
|
||||
|
||||
//private final IBinder senseBinder = new SenseBinder();
|
||||
public static Context context;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SenseWakeLock.acquireWakeLock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent arg0) {
|
||||
//return senseBinder;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
context = this;
|
||||
if (!LocalRegister.isExist(context)) return Service.START_NOT_STICKY;
|
||||
|
||||
SenseDataCollector Sensor = new SenseDataCollector(this, SenseDataCollector.DataType.SENSOR);
|
||||
SenseDataCollector Location = new SenseDataCollector(this, SenseDataCollector.DataType.LOCATION);
|
||||
registerReceiver(new BatteryDataReceiver(), new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
//service will not be stopped until we manually stop the service
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
SenseWakeLock.releaseCPUWakeLock();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String, String>> {
|
||||
|
||||
private static List<String> cookies;
|
||||
private Context context;
|
||||
private final static String TAG = "SenseService Client";
|
||||
|
||||
public SenseClientAsyncExecutor(Context context) {
|
||||
this.context = context;
|
||||
|
||||
}
|
||||
|
||||
private HttpsURLConnection getTrustedConnection(HttpsURLConnection conn) {
|
||||
HttpsURLConnection urlConnection = conn;
|
||||
try {
|
||||
KeyStore localTrustStore;
|
||||
|
||||
localTrustStore = KeyStore.getInstance("BKS");
|
||||
|
||||
InputStream in = context.getResources().openRawResource(
|
||||
R.raw.client_truststore);
|
||||
|
||||
localTrustStore.load(in, SenseConstants.TRUSTSTORE_PASSWORD.toCharArray());
|
||||
|
||||
TrustManagerFactory tmf;
|
||||
tmf = TrustManagerFactory.getInstance(TrustManagerFactory
|
||||
.getDefaultAlgorithm());
|
||||
|
||||
tmf.init(localTrustStore);
|
||||
|
||||
SSLContext sslCtx;
|
||||
|
||||
sslCtx = SSLContext.getInstance("TLS");
|
||||
|
||||
sslCtx.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
urlConnection.setSSLSocketFactory(sslCtx.getSocketFactory());
|
||||
return urlConnection;
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException | CertificateException | IOException | KeyStoreException e) {
|
||||
|
||||
Log.e(SenseClientAsyncExecutor.class.getName(), "Invalid Certifcate");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> doInBackground(String... parameters) {
|
||||
if (android.os.Debug.isDebuggerConnected())
|
||||
android.os.Debug.waitForDebugger();
|
||||
String response = null;
|
||||
Map<String, String> response_params = new HashMap<String, String>();
|
||||
|
||||
|
||||
String endpoint = parameters[0];
|
||||
String body = parameters[1];
|
||||
String option = parameters[2];
|
||||
String jsonBody = parameters[3];
|
||||
|
||||
if(jsonBody!=null && !jsonBody.isEmpty()){
|
||||
body = jsonBody;
|
||||
}
|
||||
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(endpoint);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException("invalid url: " + endpoint);
|
||||
}
|
||||
|
||||
Log.v(TAG, "post'" + body + "'to" + url);
|
||||
|
||||
|
||||
HttpURLConnection conn = null;
|
||||
HttpsURLConnection sConn = null;
|
||||
try {
|
||||
|
||||
if (url.getProtocol().toLowerCase().equals("https")) {
|
||||
|
||||
sConn = (HttpsURLConnection) url.openConnection();
|
||||
sConn = getTrustedConnection(sConn);
|
||||
sConn.setHostnameVerifier(SERVER_HOST);
|
||||
conn = sConn;
|
||||
|
||||
} else {
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
|
||||
if (cookies != null) {
|
||||
for (String cookie : cookies) {
|
||||
conn.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
|
||||
}
|
||||
|
||||
}
|
||||
if (conn == null) {
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
byte[] bytes = body.getBytes();
|
||||
conn.setDoOutput(true);
|
||||
conn.setUseCaches(false);
|
||||
conn.setFixedLengthStreamingMode(bytes.length);
|
||||
conn.setRequestMethod(option);
|
||||
if(jsonBody!=null && !jsonBody.isEmpty()){
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
}else {
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||
}
|
||||
conn.setRequestProperty("Accept", "*/*");
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
|
||||
// post the request
|
||||
int status = 0;
|
||||
|
||||
if (!option.equals("DELETE")) {
|
||||
OutputStream out = conn.getOutputStream();
|
||||
out.write(bytes);
|
||||
out.close();
|
||||
// handle the response
|
||||
status = conn.getResponseCode();
|
||||
response_params.put("status", String.valueOf(status));
|
||||
Log.v("Response Status", status + "");
|
||||
|
||||
List<String> receivedCookie = conn.getHeaderFields().get("Set-Cookie");
|
||||
if(receivedCookie!=null){
|
||||
cookies=receivedCookie;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
InputStream inStream = conn.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append("\n"); // append a new line
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
// System.out.println(builder.toString());
|
||||
response = builder.toString();
|
||||
response_params.put("response", response);
|
||||
Log.v("Response Message", response);
|
||||
} catch (IOException ex) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
status = Integer.valueOf(SenseConstants.Request.REQUEST_SUCCESSFUL);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return response_params;
|
||||
}
|
||||
|
||||
public HostnameVerifier SERVER_HOST = new HostnameVerifier() {
|
||||
//String allowHost = LocalRegister.getServerHost(context);
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
|
||||
return true;
|
||||
//return hv.verify(allowHost, session);
|
||||
}
|
||||
};
|
||||
}
|
After Width: | Height: | Size: 7.5 KiB |
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="agent.sense.android.iot.carbon.wso2.org.wso2_senseagent" >
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.BATTERY_STATS"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="org.wso2.carbon.iot.android.sense.register.RegisterActivity"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="adjustResize|stateVisible" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="org.wso2.carbon.iot.android.sense.service.SenseService"
|
||||
android:enabled="true"
|
||||
android:label="@string/app_name" >
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name="org.wso2.carbon.iot.android.sense.scheduler.DataUploaderService"
|
||||
android:enabled="true"
|
||||
android:label="@string/app_name" >
|
||||
</service>
|
||||
|
||||
|
||||
<receiver android:name="org.wso2.carbon.iot.android.sense.service.SenseScheduleReceiver" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="org.wso2.carbon.iot.android.sense.events.input.battery.BatteryDataReceiver"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BATTERY_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<activity
|
||||
android:name="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll"
|
||||
android:label="@string/title_activity_sense_settings">
|
||||
<!--android:parentActivityName="org.wso2.carbon.iot.android.sense.register.RegisterActivity" >-->
|
||||
<!--<meta-data-->
|
||||
<!--android:name="android.support.PARENT_ACTIVITY"-->
|
||||
<!--android:value="org.wso2.carbon.iot.android.sense.register.RegisterActivity" />-->
|
||||
|
||||
<!--<intent-filter>-->
|
||||
<!--<action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!--<category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!--</intent-filter>-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,18 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class SenseWakeLock {
|
||||
|
||||
private static PowerManager.WakeLock wakeLock;
|
||||
|
||||
public static void acquireWakeLock(Context context) {
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(), "Acquire CPU wakeup lock start");
|
||||
|
||||
if (wakeLock == null) {
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(),"CPU wakeUp log is not null");
|
||||
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"SenseWakeLock");
|
||||
}
|
||||
|
||||
wakeLock.acquire();
|
||||
|
||||
}
|
||||
|
||||
public static void releaseCPUWakeLock() {
|
||||
|
||||
if (wakeLock != null) {
|
||||
|
||||
|
||||
wakeLock.release();
|
||||
wakeLock = null;
|
||||
}
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(),"Release wakeup");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/ayyoobhamza/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
public class SenseClient {
|
||||
|
||||
|
||||
private final static String TAG = "SenseService Client";
|
||||
|
||||
private Context context;
|
||||
|
||||
public SenseClient(Context context) {
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public boolean isAuthenticate(String username, String password) {
|
||||
Map<String, String> _response = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
String response = "";
|
||||
try {
|
||||
|
||||
String endpoint = LocalRegister.getServerURL(context) + SenseConstants.LOGIN_CONTEXT;
|
||||
response = sendWithTimeWait(endpoint, params, "POST", null).get("status");
|
||||
|
||||
if (response.trim().contains(SenseConstants.Request.REQUEST_SUCCESSFUL)) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
//Toast.makeText(context, "Authentication failed, please check your credentials and try again.", Toast.LENGTH_LONG).show();
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e("Authentication", "Authentication failed due to a connection failure");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean register(String username, String deviceId) {
|
||||
Map<String, String> _response = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("deviceId", deviceId);
|
||||
params.put("owner", username);
|
||||
|
||||
try {
|
||||
String endpoint = LocalRegister.getServerURL(context) + SenseConstants.REGISTER_CONTEXT;
|
||||
Map<String, String> response = sendWithTimeWait(endpoint, params, "PUT", null);
|
||||
|
||||
String responseStatus = response.get("status");
|
||||
|
||||
if (responseStatus.trim().contains(SenseConstants.Request.REQUEST_SUCCESSFUL)) {
|
||||
|
||||
Toast.makeText(context, "Device Registered", Toast.LENGTH_LONG).show();
|
||||
|
||||
return true;
|
||||
} else if (responseStatus.trim().contains(SenseConstants.Request.REQUEST_CONFLICT)) {
|
||||
Toast.makeText(context, "Login Successful", Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
} else {
|
||||
Toast.makeText(context, "Authentication failed, please check your credentials and try again.", Toast
|
||||
.LENGTH_LONG).show();
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e("Authentication", "Authentication failed due to a connection failure");
|
||||
Toast.makeText(context, "Authentication failed due to a connection failure", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> sendWithTimeWait(String endpoint, Map<String, String> params, String option, String
|
||||
jsonBody) {
|
||||
Map<String, String> response = null;
|
||||
Map<String, String> responseFinal = null;
|
||||
for (int i = 1; i <= SenseConstants.Request.MAX_ATTEMPTS; i++) {
|
||||
Log.d(TAG, "Attempt #" + i + " to register");
|
||||
try {
|
||||
|
||||
response = sendToServer(endpoint, params, option, jsonBody);
|
||||
|
||||
if (response != null && !response.equals(null)) {
|
||||
responseFinal = response;
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to register on attempt " + i, e);
|
||||
if (i == SenseConstants.Request.MAX_ATTEMPTS) {
|
||||
break;
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
}
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
}
|
||||
|
||||
public void sendSensorDataToServer(String data) {
|
||||
String urlString = null;
|
||||
try {
|
||||
urlString = LocalRegister.getServerURL(context) + SenseConstants.DATA_ENDPOINT;
|
||||
Log.i("SENDING DATAs", "SENDING JSON to " + urlString + " : " + data);
|
||||
Map<String, String> response = sendWithTimeWait(urlString, null, "POST", data);
|
||||
String responseStatus = response.get("status");
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e("Send Sensor Data", "Failure to send data to "+ urlString);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> sendToServer(String endpoint, Map<String, String> params,
|
||||
String option, String jsonBody) throws IOException {
|
||||
String body = null;
|
||||
if (params != null && !params.isEmpty()) {
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String> param = iterator.next();
|
||||
bodyBuilder.append(param.getKey()).append('=')
|
||||
.append(param.getValue());
|
||||
if (iterator.hasNext()) {
|
||||
bodyBuilder.append('&');
|
||||
}
|
||||
}
|
||||
body = bodyBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
SenseClientAsyncExecutor senseClientAsyncExecutor = new SenseClientAsyncExecutor(context);
|
||||
return senseClientAsyncExecutor.execute(endpoint, body, option, jsonBody).get();
|
||||
} catch (InterruptedException e) {
|
||||
Log.e("Send Sensor Data", "Thread Inturption for endpoint " + endpoint);
|
||||
} catch (ExecutionException e) {
|
||||
Log.e("Send Sensor Data", "Failed to push data to the endpoint " + endpoint);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String inputStreamAsString(InputStream in) {
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append("\n"); // append a new line
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(SenseClient.class.getName(), e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(SenseClient.class.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
// System.out.println(builder.toString());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class LocalRegister {
|
||||
|
||||
private static final String SENSE_SHARED_PREFERENCES = "senseSharedPreferences";
|
||||
private static final String USERNAME_KEY = "usernameKey";
|
||||
private static final String DEVICE_ID_KEY = "deviceIdKey";
|
||||
private static final String SERVER_HOST_KEY = "serverHostKey";
|
||||
private static boolean exists = false;
|
||||
private static String username;
|
||||
private static String deviceId;
|
||||
private static String serverURL;
|
||||
|
||||
public static boolean isExist(Context context){
|
||||
if(!exists) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
String username = sharedpreferences.getString(USERNAME_KEY, "");
|
||||
String deviceId = sharedpreferences.getString(DEVICE_ID_KEY, "");
|
||||
exists = (username != null && !username.isEmpty() && deviceId != null && !deviceId.isEmpty());
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
public static void setExist(boolean status){
|
||||
exists = status;
|
||||
}
|
||||
|
||||
|
||||
public static void addUsername(Context context, String username){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(USERNAME_KEY, username);
|
||||
editor.commit();
|
||||
LocalRegister.username = username;
|
||||
}
|
||||
|
||||
public static String getUsername(Context context){
|
||||
if(LocalRegister.username==null || username.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.username = sharedpreferences.getString(USERNAME_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.username;
|
||||
}
|
||||
|
||||
public static void removeUsername(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.clear();
|
||||
editor.remove(USERNAME_KEY);
|
||||
editor.commit();
|
||||
LocalRegister.username = null;
|
||||
}
|
||||
|
||||
public static void addDeviceId(Context context, String deviceId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(DEVICE_ID_KEY, deviceId);
|
||||
editor.commit();
|
||||
LocalRegister.deviceId = deviceId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void removeDeviceId(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.remove(DEVICE_ID_KEY);
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
LocalRegister.deviceId = null;
|
||||
}
|
||||
|
||||
public static String getDeviceId(Context context){
|
||||
if(LocalRegister.deviceId==null || LocalRegister.deviceId.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.deviceId = sharedpreferences.getString(DEVICE_ID_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.deviceId;
|
||||
}
|
||||
|
||||
public static void addServerURL(Context context, String host){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(SERVER_HOST_KEY, host);
|
||||
editor.commit();
|
||||
LocalRegister.serverURL = host;
|
||||
}
|
||||
|
||||
public static void removeServerURL(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.remove(SERVER_HOST_KEY);
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
LocalRegister.serverURL = null;
|
||||
}
|
||||
|
||||
public static String getServerURL(Context context){
|
||||
if(LocalRegister.serverURL ==null || LocalRegister.serverURL.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.serverURL = sharedpreferences.getString(SERVER_HOST_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.serverURL;
|
||||
}
|
||||
|
||||
public static String getServerHost(Context context){
|
||||
|
||||
URL url = null;
|
||||
String urlString = getServerURL(context);
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
return url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
Log.e("Host " , "Invalid urlString :" + urlString);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input.battery;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.BatteryManager;
|
||||
|
||||
public class BatteryData {
|
||||
|
||||
private int health;
|
||||
private int level;
|
||||
private int plugged;
|
||||
private int present;
|
||||
private int scale;
|
||||
private int status;
|
||||
private int temperature;
|
||||
private int voltage;
|
||||
private String timestamp;
|
||||
|
||||
BatteryData(Intent intent) {
|
||||
timestamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
|
||||
level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
|
||||
present = intent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT) ? 1 : 0;
|
||||
scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
||||
status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
|
||||
String technology = intent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0);
|
||||
voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0);
|
||||
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getPlugged() {
|
||||
return plugged;
|
||||
}
|
||||
|
||||
public void setPlugged(int plugged) {
|
||||
this.plugged = plugged;
|
||||
}
|
||||
|
||||
public int getPresent() {
|
||||
return present;
|
||||
}
|
||||
|
||||
public void setPresent(int present) {
|
||||
this.present = present;
|
||||
}
|
||||
|
||||
public int getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(int scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(int temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public int getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setVoltage(int voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.register;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
public class SenseDeEnroll extends Activity {
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
if (!LocalRegister.isExist(getApplicationContext())) {
|
||||
Intent activity = new Intent(getApplicationContext(), RegisterActivity.class);
|
||||
startActivity(activity);
|
||||
|
||||
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_sense_settings);
|
||||
Button deviceRegisterButton = (Button) findViewById(R.id.unregister);
|
||||
deviceRegisterButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
LocalRegister.removeUsername(getApplicationContext());
|
||||
LocalRegister.removeDeviceId(getApplicationContext());
|
||||
LocalRegister.removeServerURL(getApplicationContext());
|
||||
LocalRegister.setExist(false);
|
||||
Intent activity = new Intent(getApplicationContext(), RegisterActivity.class);
|
||||
startActivity(activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
@ -0,0 +1,13 @@
|
||||
<resources>
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="prompt_username">Username</string>
|
||||
<string name="prompt_password">Password</string>
|
||||
<string name="action_sign_in">Register Device</string>
|
||||
<string name="action_sign_in_short">Sign in</string>
|
||||
|
||||
<string name="error_invalid_username">This email address is invalid</string>
|
||||
<string name="error_invalid_password">This password is too short</string>
|
||||
<string name="error_incorrect_password">This password is incorrect</string>
|
||||
<string name="error_field_required">This field is required</string>
|
||||
</resources>
|
@ -0,0 +1,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll">
|
||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
||||
android:orderInCategory="100" app:showAsAction="never" />
|
||||
</menu>
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.scheduler;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryData;
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseClient;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class DataUploaderService extends Service {
|
||||
|
||||
public static Context context;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
context = this;
|
||||
|
||||
Log.i("SENDING DATA", "service started");
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray sensorJsonArray = new JSONArray();
|
||||
|
||||
jsonObject.put("owner", LocalRegister.getUsername(context));
|
||||
jsonObject.put("deviceId", LocalRegister.getDeviceId(context));
|
||||
|
||||
boolean noSensorData = false;
|
||||
boolean noBatteryData = false;
|
||||
boolean noLocationData = false;
|
||||
|
||||
|
||||
List<SensorData> sensorDataMap = DataMap.getSensorDataMap();
|
||||
if (sensorDataMap.size() <= 0) {
|
||||
noSensorData = true;
|
||||
}
|
||||
for (SensorData sensorData : sensorDataMap) {
|
||||
JSONObject sensorJsonObject = new JSONObject();
|
||||
sensorJsonObject.put("time", "" + sensorData.getCollectTimestamp());
|
||||
sensorJsonObject.put("key", "" + sensorData.getSensorType());
|
||||
sensorJsonObject.put("value", sensorData.getSensorValues());
|
||||
sensorJsonArray.put(sensorJsonObject);
|
||||
}
|
||||
DataMap.resetSensorDataMap();
|
||||
|
||||
List<BatteryData> batteryDataMap = DataMap.getBatteryDataMap();
|
||||
if (batteryDataMap.size() <= 0) {
|
||||
noBatteryData = true;
|
||||
}
|
||||
for (BatteryData batteryData : batteryDataMap) {
|
||||
JSONObject batteryJsonObject = new JSONObject();
|
||||
batteryJsonObject.put("time", "" + batteryData.getTimestamp());
|
||||
batteryJsonObject.put("key", "battery");
|
||||
batteryJsonObject.put("value", batteryData.getLevel());
|
||||
sensorJsonArray.put(batteryJsonObject);
|
||||
}
|
||||
DataMap.resetBatteryDataMap();
|
||||
|
||||
List<LocationData> locationDataMap = DataMap.getLocationDataMap();
|
||||
if (locationDataMap.size() <= 0) {
|
||||
noLocationData = true;
|
||||
}
|
||||
for (LocationData locationData : locationDataMap) {
|
||||
JSONObject locationJsonObject = new JSONObject();
|
||||
locationJsonObject.put("time", "" + locationData.getTimeStamp());
|
||||
locationJsonObject.put("key", "GPS");
|
||||
locationJsonObject.put("value", locationData.getLatitude() + "," + locationData.getLongitude());
|
||||
sensorJsonArray.put(locationJsonObject);
|
||||
}
|
||||
DataMap.resetLocationDataMap();
|
||||
|
||||
jsonObject.put("values", sensorJsonArray);
|
||||
|
||||
if (!(noSensorData && noBatteryData && noLocationData)) {
|
||||
SenseClient client = new SenseClient(context);
|
||||
client.sendSensorDataToServer(jsonObject.toString());
|
||||
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
Log.i("Data Upload", " Json Data Parsing Exception");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Thread dataUploaderThread = new Thread(runnable);
|
||||
dataUploaderThread.start();
|
||||
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.scheduler;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class DataUploaderReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent i = new Intent(context, DataUploaderService.class);
|
||||
PendingIntent pending = PendingIntent.getService(context, 0, i, 0);
|
||||
service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 30 * 1000, pending);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryData;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class DataMap {
|
||||
|
||||
private static List<SensorData> sensorDataMap;
|
||||
private static List<BatteryData> batteryDataMap;
|
||||
private static List<LocationData> locationDataMap;
|
||||
|
||||
|
||||
public static List<SensorData> getSensorDataMap(){
|
||||
if(sensorDataMap == null){
|
||||
sensorDataMap = new CopyOnWriteArrayList<SensorData>();
|
||||
}
|
||||
return sensorDataMap;
|
||||
}
|
||||
|
||||
public static List<BatteryData> getBatteryDataMap(){
|
||||
if(batteryDataMap == null){
|
||||
batteryDataMap = new CopyOnWriteArrayList<BatteryData>();
|
||||
}
|
||||
return batteryDataMap;
|
||||
}
|
||||
|
||||
public static List<LocationData> getLocationDataMap(){
|
||||
if(locationDataMap == null){
|
||||
locationDataMap = new CopyOnWriteArrayList<LocationData>();
|
||||
}
|
||||
return locationDataMap;
|
||||
}
|
||||
|
||||
public static void resetSensorDataMap(){
|
||||
sensorDataMap = null;
|
||||
}
|
||||
|
||||
public static void resetBatteryDataMap(){
|
||||
batteryDataMap = null;
|
||||
}
|
||||
|
||||
public static void resetLocationDataMap(){
|
||||
locationDataMap = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,362 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<items version="2" >
|
||||
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-safetynet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1a6411087ab88ce5542f593e63a2752b6b0d6f1a">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-5f37f316d503119e8e940bc6147423a28028938e.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="69dd177337ead693c408c8dddc9546bb6f1244fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-a49bba393352e40b3a2c77305b4d175131c6035b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/libs/internal_impl-22.0.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba3df4eb0a630d7de294f0e48d3f9267d279b784">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/internal_impl-22.0.0-3c739e94ff5c382efc8e190c64b046f8f08548f9.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8d736fefa22d896e84a268354b3ed48a42663150">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-a2ac0984c99126a23f2ff9eaee1ad9ea2590428f.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1ee588ff2c4daf7b97c1cbf922a6c7f027285c2f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7cc641f33fbb083914dc34a6f21f017d3100e50a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/libs/internal_impl-22.0.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba3df4eb0a630d7de294f0e48d3f9267d279b784">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/internal_impl-22.0.0-9c4ee3b5d5a65a3cd9a176e67ac7281853e32156.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-identity/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="d405025c600055237c171a0bbabaa49d69696573">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-f85dea88ee04abe2b44516da321ea168577149e7.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-fitness/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a172852a35ff919e85b9b7f14bbc15c5bee25520">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-f85bb224fe40682e29567ed759f0d8147789d99a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appinvite/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="63ec6e9f4fe5482a7447d0f3091b8e543a02554c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-fc685315c00e30381a68ae1e40e618f5633b148a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-fitness/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a172852a35ff919e85b9b7f14bbc15c5bee25520">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7b993cace9f2f89ea7878cee3734d43164761324.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f02127a85abd52a2cd526d4c2409f21969f80ee8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-c8073c83524abffdd450dc16bdddbe5e9a2473c9.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appstate/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="68c140702c7242d914655bcb3164d9e8c45b84cb">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-27570a1dd1163b87dda5a680824455c7c0b5e7bb.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a1372c17fccacca753d3951d3ad820571cbce075">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-c965435894746702a284be3b219dc7f9890de78b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-panorama/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba207be21987c11b37d9f8faa08ed6e722569f30">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-bd9210bc6461a94fd375de690573f7692fb8f6ca.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1e98ef3f124bb7a11f8575f9ff5dfea330b61b6f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-eea806d1c31c7f035fd293a56b4eddee9896f68b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a78183f30e769a98ab4820794f597763088d3065">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-b31ab94c7b4f25bba7f50e7db83969c0abb17395.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-cast/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8e3a972f28b8bae817e382257ba177a31bcadbbc">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-5f18676280d30833bd6e2bfc0802c27f7e2a7c90.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appinvite/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="63ec6e9f4fe5482a7447d0f3091b8e543a02554c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-89c8becd4e40d23a240904b0e866e339422193de.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-cast/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8e3a972f28b8bae817e382257ba177a31bcadbbc">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-67f38bb2e0123552baad0942e6ae8f2ecc29e83e.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-nearby/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6440e5e5cfe368f9bff3c537fb8988048069cb33">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-f8cdc886172afca7899ddc2d3bc98b881ef0471d.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/22.2.0/support-annotations-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="66b42a1f3eb7676070b7ef7f14b603483aecbee1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/support-annotations-22.2.0-06eef0469b7ba17fe99e86a1ff9124f95eca2e22.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/internal_impl-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="57f2ab85c164ff1676ec64dee787981c046fab79">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/internal_impl-22.2.0-0aa32945d2af5dd313fdf82dfcc6dca7c4a61b17.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1ee588ff2c4daf7b97c1cbf922a6c7f027285c2f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-3d021cc2ce59490f31c720e586470122ed3081fb.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="73753982da6bde518f3a4c6b372749981d14d1a0">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-bc85cbe1b3709c53b31a4b4670324bf0714cbb72.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-games/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="02bac2dc792d78241077861566f2c82da955e7fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-4bf713786a72281f07dde60a3edbd94854995c4b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/internal_impl-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="57f2ab85c164ff1676ec64dee787981c046fab79">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/internal_impl-22.2.0-b1ae13d9667717f01e87e38dbf4767cb4a147255.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f02127a85abd52a2cd526d4c2409f21969f80ee8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-b408adab78303a462e4e242268eaa27d6fb68f51.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-safetynet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1a6411087ab88ce5542f593e63a2752b6b0d6f1a">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-818c83a292835cb905b1fc65b1920fcee95185ef.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="29ebc7e04d877062317c8cc0e68b20f0c1fcda66">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-15077e775d127c164c0e4724bd0af2dadb8ead83.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wallet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6836d188602ec5382d1967c58b00960eb8ff8773">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-dd36a7cfa280312b0e8f1f9bb4e30d7509180a29.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-nearby/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6440e5e5cfe368f9bff3c537fb8988048069cb33">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-c2af74b50463bf6f99827d4bc59971116edf6161.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-identity/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="d405025c600055237c171a0bbabaa49d69696573">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-b0300288a8318525a44e614cb685db1d3b4ead6b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8d736fefa22d896e84a268354b3ed48a42663150">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7bed73ef0e569b49a728e9673620253e0e9f9301.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-drive/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f44d03c138cb6488fdbaa65e3a7e5878861a56d8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-cf87780c02ccc07e8d1dc8d4c844d5d32b3e2683.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-panorama/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba207be21987c11b37d9f8faa08ed6e722569f30">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-6d1942f94bcc0ec99afd8b7ee5ba8f6e9a89bb9b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="69dd177337ead693c408c8dddc9546bb6f1244fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-9ade1828bea97427006e9c998f42a444280ec927.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a78183f30e769a98ab4820794f597763088d3065">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-5450e680e7872436414a9548385011f2c8487550.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appstate/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="68c140702c7242d914655bcb3164d9e8c45b84cb">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-f75044418b6dcc7ff2a8d70d7e8cf2a208d6c0e1.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="73753982da6bde518f3a4c6b372749981d14d1a0">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-d10cc88287864f8e0f831e7776e22b9da9685859.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="29ebc7e04d877062317c8cc0e68b20f0c1fcda66">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-7d0fbd0b4530d75b7bbc6689c38f1c12734bff26.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="272bc5d7063f24bc3a33ea1d318cde8f31f5ec4c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-2cbb13942165cbc89aca7bc9e1f777bcbc04c277.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="e7b35244f50663b3f8d150714bca9ecd7a290da1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-79fb523ec54f1f40f7369c408490512821a15f50.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="e7b35244f50663b3f8d150714bca9ecd7a290da1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-8800f13f43b3b1432fa2889783a68afc980d420b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="06a42becc33232ec0ee125161da68c1829c9f8fd">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-2e38d3423be45e0d0b2adb09d8e0065dfba0823c.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a1372c17fccacca753d3951d3ad820571cbce075">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-9ce95b9a9877ca5c2e327b16fee4e5f629d4a2ab.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="06a42becc33232ec0ee125161da68c1829c9f8fd">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-3efa6e6ec21335ccac2678be64d362c7b9036130.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-games/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="02bac2dc792d78241077861566f2c82da955e7fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-d4bc6409918d6a5d4a5a5d98100031f46ef8e160.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="272bc5d7063f24bc3a33ea1d318cde8f31f5ec4c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-216941976bfed9962f878deb4820b6efeb31478c.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1e98ef3f124bb7a11f8575f9ff5dfea330b61b6f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-191fabc4812c8279f59a14d02fff6cde1a9a8c4b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-drive/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f44d03c138cb6488fdbaa65e3a7e5878861a56d8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-3a95e3adf772a9a13406050763e81edacddb99d4.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wallet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6836d188602ec5382d1967c58b00960eb8ff8773">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-886652be47aab5a3958fdda8eb5716d478c1be98.jar" />
|
||||
</item>
|
||||
|
||||
</items>
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Location;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class LocationData {
|
||||
private double latitude; // latitude
|
||||
private double longitude; // longitude
|
||||
private String TimeStamp;
|
||||
|
||||
LocationData(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
TimeStamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getTimeStamp() {
|
||||
return TimeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(String timeStamp) {
|
||||
TimeStamp = timeStamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input;
|
||||
|
||||
public abstract class DataReader implements Runnable {
|
||||
|
||||
|
||||
}
|
After Width: | Height: | Size: 3.3 KiB |
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">WSO2-SenseAgent</string>
|
||||
<string name="title_activity_sense_settings">Sense Settings</string>
|
||||
<string name="hostname">Server URL https://host:9443</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,11 @@
|
||||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Thu Oct 22 22:12:40 IST 2015
|
||||
sdk.dir=/Users/ayyoobhamza/Library/Android/sdk
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Sensor;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.hardware.SensorEvent;
|
||||
|
||||
public class SensorData {
|
||||
private int sensorType;
|
||||
private String sensorName;
|
||||
private String sensorVendor;
|
||||
private String sensorValues;
|
||||
private int accuracyStatus;
|
||||
private String timestamp;
|
||||
private String collectTimestamp;
|
||||
|
||||
SensorData(SensorEvent event) {
|
||||
sensorValues = "";
|
||||
for (int m = 0; m < event.values.length; m++) {
|
||||
sensorValues += event.values[m] + ",";
|
||||
|
||||
}
|
||||
sensorValues = sensorValues.substring(0, sensorValues.length() - 1);
|
||||
accuracyStatus = event.accuracy;
|
||||
|
||||
collectTimestamp = "" + event.timestamp;
|
||||
timestamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
sensorName = event.sensor.getName();
|
||||
sensorVendor = event.sensor.getVendor();
|
||||
sensorType = event.sensor.getType();
|
||||
|
||||
}
|
||||
|
||||
public int getSensorType() {
|
||||
return sensorType;
|
||||
}
|
||||
|
||||
public void setSensorType(int sensorType) {
|
||||
this.sensorType = sensorType;
|
||||
}
|
||||
|
||||
public String getSensorName() {
|
||||
return sensorName;
|
||||
}
|
||||
|
||||
public void setSensorName(String sensorName) {
|
||||
this.sensorName = sensorName;
|
||||
}
|
||||
|
||||
public String getSensorVendor() {
|
||||
return sensorVendor;
|
||||
}
|
||||
|
||||
public void setSensorVendor(String sensorVendor) {
|
||||
this.sensorVendor = sensorVendor;
|
||||
}
|
||||
|
||||
public String getSensorValues() {
|
||||
return sensorValues;
|
||||
}
|
||||
|
||||
public void setSensorValues(String sensorValues) {
|
||||
this.sensorValues = sensorValues;
|
||||
}
|
||||
|
||||
public int getAccuracyStatus() {
|
||||
return accuracyStatus;
|
||||
}
|
||||
|
||||
public void setAccuracyStatus(int accuracyStatus) {
|
||||
this.accuracyStatus = accuracyStatus;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getCollectTimestamp() {
|
||||
return collectTimestamp;
|
||||
}
|
||||
|
||||
public void setCollectTimestamp(String collectTimestamp) {
|
||||
this.collectTimestamp = collectTimestamp;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.service;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class SenseScheduleReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent i = new Intent(context, SenseService.class);
|
||||
PendingIntent pending = PendingIntent.getService(context, 0, i, 0);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.add(Calendar.SECOND, 30);
|
||||
service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 20 * 1000, pending);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input;
|
||||
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationDataReader;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorDataReader;
|
||||
|
||||
public class SenseDataCollector {
|
||||
public enum DataType {
|
||||
SENSOR ,LOCATION
|
||||
};
|
||||
|
||||
public SenseDataCollector(Context ctx, DataType dt) {
|
||||
|
||||
|
||||
try{
|
||||
DataReader dr=null;
|
||||
|
||||
switch(dt){
|
||||
case SENSOR: dr=new SensorDataReader(ctx);
|
||||
break;
|
||||
|
||||
|
||||
case LOCATION: dr=new LocationDataReader(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
Thread DataCollector =new Thread(dr);
|
||||
DataCollector.start();
|
||||
}catch(NullPointerException e){
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="username"></string>
|
||||
<bool name="registered">false</bool>
|
||||
</resources>
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.register;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.scheduler.DataUploaderReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.service.SenseScheduleReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseClient;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseUtils;
|
||||
|
||||
import java.net.CookieHandler;
|
||||
import java.net.CookieManager;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
|
||||
/**
|
||||
* A login screen that offers to register the device.
|
||||
*/
|
||||
public class RegisterActivity extends Activity {
|
||||
|
||||
private EditText mUsernameView;
|
||||
private EditText mPasswordView;
|
||||
private EditText mHostView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (LocalRegister.isExist(getApplicationContext())) {
|
||||
Intent activity = new Intent(getApplicationContext(), SenseDeEnroll.class);
|
||||
startActivity(activity);
|
||||
|
||||
}
|
||||
setContentView(R.layout.activity_register);
|
||||
mUsernameView = (EditText) findViewById(R.id.username);
|
||||
mPasswordView = (EditText) findViewById(R.id.password);
|
||||
mHostView = (EditText) findViewById(R.id.hostname);
|
||||
|
||||
Button deviceRegisterButton = (Button) findViewById(R.id.device_register_button);
|
||||
deviceRegisterButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
attemptLogin();
|
||||
}
|
||||
});
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
public void attemptLogin() {
|
||||
Context context = this;
|
||||
showProgress(true);
|
||||
// Reset errors.
|
||||
mUsernameView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
// Store values at the time of the login attempt.
|
||||
String username = mUsernameView.getText().toString();
|
||||
String password = mPasswordView.getText().toString();
|
||||
String hostname = mHostView.getText().toString();
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
// Check for a valid password, if the user entered one.
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
// mPasswordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = mPasswordView;
|
||||
//cancel = true;
|
||||
}
|
||||
|
||||
// Check for a valid username .
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
mUsernameView.setError(getString(R.string.error_field_required));
|
||||
focusView = mUsernameView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
mHostView.setError(getString(R.string.error_field_required));
|
||||
focusView = mHostView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
|
||||
focusView.requestFocus();
|
||||
} else {
|
||||
|
||||
|
||||
SenseClient client = new SenseClient(getApplicationContext());
|
||||
LocalRegister.addServerURL(getBaseContext(), hostname);
|
||||
boolean auth = client.isAuthenticate(username, password);
|
||||
|
||||
if(auth) {
|
||||
//TODO API SECURITY need to be added.
|
||||
String deviceId = SenseUtils.generateDeviceId(getBaseContext(), getContentResolver());
|
||||
boolean registerStatus=client.register(username, deviceId);
|
||||
if(registerStatus){
|
||||
LocalRegister.addUsername(getApplicationContext(), username);
|
||||
LocalRegister.addDeviceId(getApplicationContext(), deviceId);
|
||||
|
||||
SenseScheduleReceiver senseScheduleReceiver = new SenseScheduleReceiver();
|
||||
senseScheduleReceiver.clearAbortBroadcast();
|
||||
senseScheduleReceiver.onReceive(this, null);
|
||||
|
||||
DataUploaderReceiver dataUploaderReceiver = new DataUploaderReceiver();
|
||||
dataUploaderReceiver.clearAbortBroadcast();
|
||||
dataUploaderReceiver.onReceive(this, null);
|
||||
|
||||
Intent activity = new Intent(getApplicationContext(), SenseDeEnroll.class);
|
||||
startActivity(activity);
|
||||
|
||||
}
|
||||
}
|
||||
showProgress(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
public void showProgress(final boolean show) {
|
||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
||||
// for very easy animations. If available, use these APIs to fade-in
|
||||
// the progress spinner.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
||||
// and hide the relevant UI components.
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="De-enroll Device"
|
||||
android:id="@+id/unregister"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
</RelativeLayout>
|
@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "agent.sense.android.iot.carbon.wso2.org.wso2_senseagent"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:22.2.0'
|
||||
compile 'com.google.android.gms:play-services:7.5.0'
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.iot.agents</groupId>
|
||||
<artifactId>org.wso2.sample.iot.android.agent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>Android Sense</name>
|
||||
<description>Android Sense</description>
|
||||
<packaging>pom</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Gradle Build</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./gradlew</executable>
|
||||
<arguments>
|
||||
<argument>assembleRelease</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,50 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:gravity="center_horizontal"
|
||||
android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.wso2.carbon.iot.android.sense.register.RegisterActivity">
|
||||
|
||||
<!-- Login progress -->
|
||||
<ProgressBar android:id="@+id/login_progress" style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp" android:visibility="gone" />
|
||||
|
||||
<ScrollView android:id="@+id/login_form" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout android:id="@+id/email_login_form" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/prompt_username"
|
||||
android:id="@+id/username"
|
||||
android:inputType="text"
|
||||
android:maxLines="1" android:singleLine="true"/>
|
||||
|
||||
<EditText android:id="@+id/password" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionUnspecified" android:inputType="textPassword"
|
||||
android:maxLines="1" android:singleLine="true" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/hostname"
|
||||
android:id="@+id/hostname"
|
||||
android:text=""
|
||||
android:inputType="text"
|
||||
android:maxLines="1" android:singleLine="true"/>
|
||||
|
||||
<Button android:id="@+id/device_register_button" style="?android:textAppearanceSmall"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.constants;
|
||||
|
||||
|
||||
public class SenseConstants {
|
||||
public final static String LOGIN_CONTEXT = "/store/apis/authenticate";
|
||||
public final static String REGISTER_CONTEXT = "/android_sense/manager/device";
|
||||
public final static String DATA_ENDPOINT = "/android_sense/controller/sensordata";
|
||||
public final static String TRUSTSTORE_PASSWORD = "wso2carbon";
|
||||
|
||||
public final class Request {
|
||||
public final static String REQUEST_SUCCESSFUL = "200";
|
||||
public final static String REQUEST_CONFLICT = "409";
|
||||
public final static int MAX_ATTEMPTS = 2;
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -0,0 +1,19 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 22
|
||||
buildToolsVersion "22.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "agent.sense.android.iot.carbon.wso2.org.wso2_senseagent"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:22.2.0'
|
||||
compile 'com.google.android.gms:play-services:7.5.0'
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/ayyoobhamza/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="agent.sense.android.iot.carbon.wso2.org.wso2_senseagent" >
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.BATTERY_STATS"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="org.wso2.carbon.iot.android.sense.register.RegisterActivity"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="adjustResize|stateVisible" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="org.wso2.carbon.iot.android.sense.service.SenseService"
|
||||
android:enabled="true"
|
||||
android:label="@string/app_name" >
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name="org.wso2.carbon.iot.android.sense.scheduler.DataUploaderService"
|
||||
android:enabled="true"
|
||||
android:label="@string/app_name" >
|
||||
</service>
|
||||
|
||||
|
||||
<receiver android:name="org.wso2.carbon.iot.android.sense.service.SenseScheduleReceiver" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver
|
||||
android:name="org.wso2.carbon.iot.android.sense.events.input.battery.BatteryDataReceiver"
|
||||
android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BATTERY_CHANGED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
<activity
|
||||
android:name="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll"
|
||||
android:label="@string/title_activity_sense_settings">
|
||||
<!--android:parentActivityName="org.wso2.carbon.iot.android.sense.register.RegisterActivity" >-->
|
||||
<!--<meta-data-->
|
||||
<!--android:name="android.support.PARENT_ACTIVITY"-->
|
||||
<!--android:value="org.wso2.carbon.iot.android.sense.register.RegisterActivity" />-->
|
||||
|
||||
<!--<intent-filter>-->
|
||||
<!--<action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!--<category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!--</intent-filter>-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.constants;
|
||||
|
||||
|
||||
public class SenseConstants {
|
||||
public final static String LOGIN_CONTEXT = "/store/apis/authenticate";
|
||||
public final static String REGISTER_CONTEXT = "/android_sense/manager/device";
|
||||
public final static String DATA_ENDPOINT = "/android_sense/controller/sensordata";
|
||||
public final static String TRUSTSTORE_PASSWORD = "wso2carbon";
|
||||
|
||||
public final class Request {
|
||||
public final static String REQUEST_SUCCESSFUL = "200";
|
||||
public final static String REQUEST_CONFLICT = "409";
|
||||
public final static int MAX_ATTEMPTS = 2;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input;
|
||||
|
||||
public abstract class DataReader implements Runnable {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Location;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class LocationData {
|
||||
private double latitude; // latitude
|
||||
private double longitude; // longitude
|
||||
private String TimeStamp;
|
||||
|
||||
LocationData(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
TimeStamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getTimeStamp() {
|
||||
return TimeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(String timeStamp) {
|
||||
TimeStamp = timeStamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class LocationDataReader extends DataReader implements LocationListener {
|
||||
protected LocationManager locationManager;
|
||||
private Context mContext;
|
||||
private boolean canGetLocation = false;
|
||||
|
||||
Location location; // location
|
||||
double latitude; // latitude
|
||||
double longitude; // longitude
|
||||
|
||||
private Vector<LocationData> locationDatas = new Vector<LocationData>();
|
||||
// The minimum distance to change Updates in meters
|
||||
// private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
|
||||
|
||||
// The minimum time between updates in milliseconds
|
||||
//private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
|
||||
|
||||
public LocationDataReader(Context context) {
|
||||
mContext = context;
|
||||
getLocation();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
try {
|
||||
locationManager = (LocationManager) mContext.getSystemService(mContext.LOCATION_SERVICE);
|
||||
|
||||
// getting GPS status
|
||||
boolean isGPSEnabled = locationManager
|
||||
.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
|
||||
// getting network status
|
||||
boolean isNetworkEnabled = locationManager
|
||||
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
|
||||
if (!isGPSEnabled && !isNetworkEnabled) {
|
||||
// no network provider is enabled
|
||||
} else {
|
||||
this.canGetLocation = true;
|
||||
// First get location from Network Provider
|
||||
if (isNetworkEnabled) {
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.NETWORK_PROVIDER, 0, 0, this);
|
||||
// MIN_TIME_BW_UPDATES,
|
||||
// MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
|
||||
|
||||
if (locationManager != null) {
|
||||
location = locationManager
|
||||
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
}
|
||||
}
|
||||
// if GPS Enabled get lat/long using GPS Services
|
||||
if (isGPSEnabled) {
|
||||
if (location == null) {
|
||||
locationManager.requestLocationUpdates(
|
||||
LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
//MIN_TIME_BW_UPDATES,
|
||||
//MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
|
||||
|
||||
Log.d(this.getClass().getName(), "GPS Enabled");
|
||||
if (locationManager != null) {
|
||||
location = locationManager
|
||||
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("Location Sense", "Error O");
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
public boolean canGetLocation() {
|
||||
return this.canGetLocation;
|
||||
}
|
||||
|
||||
public void stopUsingGPS() {
|
||||
if (locationManager != null) {
|
||||
locationManager.removeUpdates(LocationDataReader.this);
|
||||
}
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
if (location != null) {
|
||||
latitude = location.getLatitude();
|
||||
}
|
||||
|
||||
// return latitude
|
||||
return latitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get longitude
|
||||
*/
|
||||
public double getLongitude() {
|
||||
if (location != null) {
|
||||
longitude = location.getLongitude();
|
||||
}
|
||||
|
||||
// return longitude
|
||||
return longitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(this.getClass().getSimpleName(), "running -Location");
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10000);
|
||||
locationDatas.add(new LocationData(getLatitude(), getLongitude()));
|
||||
for (LocationData data : locationDatas) {
|
||||
DataMap.getLocationDataMap().add(data);
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Log.i("Location Data", " Location Data Retrieval Failed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input;
|
||||
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationDataReader;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorDataReader;
|
||||
|
||||
public class SenseDataCollector {
|
||||
public enum DataType {
|
||||
SENSOR ,LOCATION
|
||||
};
|
||||
|
||||
public SenseDataCollector(Context ctx, DataType dt) {
|
||||
|
||||
|
||||
try{
|
||||
DataReader dr=null;
|
||||
|
||||
switch(dt){
|
||||
case SENSOR: dr=new SensorDataReader(ctx);
|
||||
break;
|
||||
|
||||
|
||||
case LOCATION: dr=new LocationDataReader(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
Thread DataCollector =new Thread(dr);
|
||||
DataCollector.start();
|
||||
}catch(NullPointerException e){
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Sensor;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.hardware.SensorEvent;
|
||||
|
||||
public class SensorData {
|
||||
private int sensorType;
|
||||
private String sensorName;
|
||||
private String sensorVendor;
|
||||
private String sensorValues;
|
||||
private int accuracyStatus;
|
||||
private String timestamp;
|
||||
private String collectTimestamp;
|
||||
|
||||
SensorData(SensorEvent event) {
|
||||
sensorValues = "";
|
||||
for (int m = 0; m < event.values.length; m++) {
|
||||
sensorValues += event.values[m] + ",";
|
||||
|
||||
}
|
||||
sensorValues = sensorValues.substring(0, sensorValues.length() - 1);
|
||||
accuracyStatus = event.accuracy;
|
||||
|
||||
collectTimestamp = "" + event.timestamp;
|
||||
timestamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
sensorName = event.sensor.getName();
|
||||
sensorVendor = event.sensor.getVendor();
|
||||
sensorType = event.sensor.getType();
|
||||
|
||||
}
|
||||
|
||||
public int getSensorType() {
|
||||
return sensorType;
|
||||
}
|
||||
|
||||
public void setSensorType(int sensorType) {
|
||||
this.sensorType = sensorType;
|
||||
}
|
||||
|
||||
public String getSensorName() {
|
||||
return sensorName;
|
||||
}
|
||||
|
||||
public void setSensorName(String sensorName) {
|
||||
this.sensorName = sensorName;
|
||||
}
|
||||
|
||||
public String getSensorVendor() {
|
||||
return sensorVendor;
|
||||
}
|
||||
|
||||
public void setSensorVendor(String sensorVendor) {
|
||||
this.sensorVendor = sensorVendor;
|
||||
}
|
||||
|
||||
public String getSensorValues() {
|
||||
return sensorValues;
|
||||
}
|
||||
|
||||
public void setSensorValues(String sensorValues) {
|
||||
this.sensorValues = sensorValues;
|
||||
}
|
||||
|
||||
public int getAccuracyStatus() {
|
||||
return accuracyStatus;
|
||||
}
|
||||
|
||||
public void setAccuracyStatus(int accuracyStatus) {
|
||||
this.accuracyStatus = accuracyStatus;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getCollectTimestamp() {
|
||||
return collectTimestamp;
|
||||
}
|
||||
|
||||
public void setCollectTimestamp(String collectTimestamp) {
|
||||
this.collectTimestamp = collectTimestamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package org.wso2.carbon.iot.android.sense.events.input.Sensor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.DataReader;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class SensorDataReader extends DataReader implements SensorEventListener {
|
||||
private SensorManager mSensorManager;
|
||||
private List<Sensor> mSensors;
|
||||
private Map<String, SensorData> senseDataStruct = new HashMap<String, SensorData>();
|
||||
private Vector<SensorData> sensorVector = new Vector<SensorData>();
|
||||
Context ctx;
|
||||
|
||||
|
||||
|
||||
public SensorDataReader(Context context) {
|
||||
ctx=context;
|
||||
mSensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
|
||||
mSensors= mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||
for (Sensor sensor : mSensors)
|
||||
{
|
||||
mSensorManager.registerListener((SensorEventListener) this, sensor, SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectSensorData(){
|
||||
|
||||
Log.d(this.getClass().getName(), "Sensor Type");
|
||||
for (Sensor sensor : mSensors)
|
||||
{
|
||||
try{
|
||||
if (senseDataStruct.containsKey(sensor.getName())){
|
||||
|
||||
SensorData sensorInfo=senseDataStruct.get(sensor.getName());
|
||||
sensorVector.add(sensorInfo);
|
||||
Log.d(this.getClass().getName(),"Sensor Name "+sensor.getName()+", Type "+ sensor.getType() + " " +
|
||||
", sensorValue :" + sensorInfo.getSensorValues());
|
||||
}
|
||||
}catch(Throwable e){
|
||||
Log.d(this.getClass().getName(),"error on sensors");
|
||||
}
|
||||
|
||||
}
|
||||
mSensorManager.unregisterListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Vector<SensorData> getSensorData(){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(SensorDataReader.class.getName(),e.getMessage());
|
||||
}
|
||||
collectSensorData();
|
||||
return sensorVector;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
senseDataStruct.put(event.sensor.getName(), new SensorData(event));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d(this.getClass().getName(),"running -sensor");
|
||||
Vector<SensorData> sensorDatas=getSensorData();
|
||||
for( SensorData data : sensorDatas){
|
||||
DataMap.getSensorDataMap().add(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.events.input.battery;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.BatteryManager;
|
||||
|
||||
public class BatteryData {
|
||||
|
||||
private int health;
|
||||
private int level;
|
||||
private int plugged;
|
||||
private int present;
|
||||
private int scale;
|
||||
private int status;
|
||||
private int temperature;
|
||||
private int voltage;
|
||||
private String timestamp;
|
||||
|
||||
BatteryData(Intent intent) {
|
||||
timestamp = "" + Calendar.getInstance().getTimeInMillis();
|
||||
health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
|
||||
level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
|
||||
present = intent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT) ? 1 : 0;
|
||||
scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0);
|
||||
status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
|
||||
String technology = intent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0);
|
||||
voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0);
|
||||
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getPlugged() {
|
||||
return plugged;
|
||||
}
|
||||
|
||||
public void setPlugged(int plugged) {
|
||||
this.plugged = plugged;
|
||||
}
|
||||
|
||||
public int getPresent() {
|
||||
return present;
|
||||
}
|
||||
|
||||
public void setPresent(int present) {
|
||||
this.present = present;
|
||||
}
|
||||
|
||||
public int getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(int scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(int temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public int getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setVoltage(int voltage) {
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.events.input.battery;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Whenever battery level changes This receiver will be triggered
|
||||
*/
|
||||
public class BatteryDataReceiver extends BroadcastReceiver {
|
||||
|
||||
private Vector<BatteryData> batteryDatas = new Vector<BatteryData>();
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
|
||||
BatteryData bt = new BatteryData(intent);
|
||||
batteryDatas.add(bt);
|
||||
|
||||
for (BatteryData data : batteryDatas) {
|
||||
DataMap.getBatteryDataMap().add(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.register;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.scheduler.DataUploaderReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.service.SenseScheduleReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseClient;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseUtils;
|
||||
|
||||
import java.net.CookieHandler;
|
||||
import java.net.CookieManager;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
|
||||
/**
|
||||
* A login screen that offers to register the device.
|
||||
*/
|
||||
public class RegisterActivity extends Activity {
|
||||
|
||||
private EditText mUsernameView;
|
||||
private EditText mPasswordView;
|
||||
private EditText mHostView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (LocalRegister.isExist(getApplicationContext())) {
|
||||
Intent activity = new Intent(getApplicationContext(), SenseDeEnroll.class);
|
||||
startActivity(activity);
|
||||
|
||||
}
|
||||
setContentView(R.layout.activity_register);
|
||||
mUsernameView = (EditText) findViewById(R.id.username);
|
||||
mPasswordView = (EditText) findViewById(R.id.password);
|
||||
mHostView = (EditText) findViewById(R.id.hostname);
|
||||
|
||||
Button deviceRegisterButton = (Button) findViewById(R.id.device_register_button);
|
||||
deviceRegisterButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
attemptLogin();
|
||||
}
|
||||
});
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
public void attemptLogin() {
|
||||
Context context = this;
|
||||
showProgress(true);
|
||||
// Reset errors.
|
||||
mUsernameView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
// Store values at the time of the login attempt.
|
||||
String username = mUsernameView.getText().toString();
|
||||
String password = mPasswordView.getText().toString();
|
||||
String hostname = mHostView.getText().toString();
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
// Check for a valid password, if the user entered one.
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
// mPasswordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = mPasswordView;
|
||||
//cancel = true;
|
||||
}
|
||||
|
||||
// Check for a valid username .
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
mUsernameView.setError(getString(R.string.error_field_required));
|
||||
focusView = mUsernameView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(username)) {
|
||||
mHostView.setError(getString(R.string.error_field_required));
|
||||
focusView = mHostView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
|
||||
focusView.requestFocus();
|
||||
} else {
|
||||
|
||||
|
||||
SenseClient client = new SenseClient(getApplicationContext());
|
||||
LocalRegister.addServerURL(getBaseContext(), hostname);
|
||||
boolean auth = client.isAuthenticate(username, password);
|
||||
|
||||
if(auth) {
|
||||
//TODO API SECURITY need to be added.
|
||||
String deviceId = SenseUtils.generateDeviceId(getBaseContext(), getContentResolver());
|
||||
boolean registerStatus=client.register(username, deviceId);
|
||||
if(registerStatus){
|
||||
LocalRegister.addUsername(getApplicationContext(), username);
|
||||
LocalRegister.addDeviceId(getApplicationContext(), deviceId);
|
||||
|
||||
SenseScheduleReceiver senseScheduleReceiver = new SenseScheduleReceiver();
|
||||
senseScheduleReceiver.clearAbortBroadcast();
|
||||
senseScheduleReceiver.onReceive(this, null);
|
||||
|
||||
DataUploaderReceiver dataUploaderReceiver = new DataUploaderReceiver();
|
||||
dataUploaderReceiver.clearAbortBroadcast();
|
||||
dataUploaderReceiver.onReceive(this, null);
|
||||
|
||||
Intent activity = new Intent(getApplicationContext(), SenseDeEnroll.class);
|
||||
startActivity(activity);
|
||||
|
||||
}
|
||||
}
|
||||
showProgress(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
public void showProgress(final boolean show) {
|
||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
||||
// for very easy animations. If available, use these APIs to fade-in
|
||||
// the progress spinner.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
||||
// and hide the relevant UI components.
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.register;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
public class SenseDeEnroll extends Activity {
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
if (!LocalRegister.isExist(getApplicationContext())) {
|
||||
Intent activity = new Intent(getApplicationContext(), RegisterActivity.class);
|
||||
startActivity(activity);
|
||||
|
||||
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_sense_settings);
|
||||
Button deviceRegisterButton = (Button) findViewById(R.id.unregister);
|
||||
deviceRegisterButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
LocalRegister.removeUsername(getApplicationContext());
|
||||
LocalRegister.removeDeviceId(getApplicationContext());
|
||||
LocalRegister.removeServerURL(getApplicationContext());
|
||||
LocalRegister.setExist(false);
|
||||
Intent activity = new Intent(getApplicationContext(), RegisterActivity.class);
|
||||
startActivity(activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.scheduler;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
|
||||
public class DataUploaderReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent i = new Intent(context, DataUploaderService.class);
|
||||
PendingIntent pending = PendingIntent.getService(context, 0, i, 0);
|
||||
service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 30 * 1000, pending);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.iot.android.sense.scheduler;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryData;
|
||||
import org.wso2.carbon.iot.android.sense.util.DataMap;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseClient;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class DataUploaderService extends Service {
|
||||
|
||||
public static Context context;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
context = this;
|
||||
|
||||
Log.i("SENDING DATA", "service started");
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray sensorJsonArray = new JSONArray();
|
||||
|
||||
jsonObject.put("owner", LocalRegister.getUsername(context));
|
||||
jsonObject.put("deviceId", LocalRegister.getDeviceId(context));
|
||||
|
||||
boolean noSensorData = false;
|
||||
boolean noBatteryData = false;
|
||||
boolean noLocationData = false;
|
||||
|
||||
|
||||
List<SensorData> sensorDataMap = DataMap.getSensorDataMap();
|
||||
if (sensorDataMap.size() <= 0) {
|
||||
noSensorData = true;
|
||||
}
|
||||
for (SensorData sensorData : sensorDataMap) {
|
||||
JSONObject sensorJsonObject = new JSONObject();
|
||||
sensorJsonObject.put("time", "" + sensorData.getCollectTimestamp());
|
||||
sensorJsonObject.put("key", "" + sensorData.getSensorType());
|
||||
sensorJsonObject.put("value", sensorData.getSensorValues());
|
||||
sensorJsonArray.put(sensorJsonObject);
|
||||
}
|
||||
DataMap.resetSensorDataMap();
|
||||
|
||||
List<BatteryData> batteryDataMap = DataMap.getBatteryDataMap();
|
||||
if (batteryDataMap.size() <= 0) {
|
||||
noBatteryData = true;
|
||||
}
|
||||
for (BatteryData batteryData : batteryDataMap) {
|
||||
JSONObject batteryJsonObject = new JSONObject();
|
||||
batteryJsonObject.put("time", "" + batteryData.getTimestamp());
|
||||
batteryJsonObject.put("key", "battery");
|
||||
batteryJsonObject.put("value", batteryData.getLevel());
|
||||
sensorJsonArray.put(batteryJsonObject);
|
||||
}
|
||||
DataMap.resetBatteryDataMap();
|
||||
|
||||
List<LocationData> locationDataMap = DataMap.getLocationDataMap();
|
||||
if (locationDataMap.size() <= 0) {
|
||||
noLocationData = true;
|
||||
}
|
||||
for (LocationData locationData : locationDataMap) {
|
||||
JSONObject locationJsonObject = new JSONObject();
|
||||
locationJsonObject.put("time", "" + locationData.getTimeStamp());
|
||||
locationJsonObject.put("key", "GPS");
|
||||
locationJsonObject.put("value", locationData.getLatitude() + "," + locationData.getLongitude());
|
||||
sensorJsonArray.put(locationJsonObject);
|
||||
}
|
||||
DataMap.resetLocationDataMap();
|
||||
|
||||
jsonObject.put("values", sensorJsonArray);
|
||||
|
||||
if (!(noSensorData && noBatteryData && noLocationData)) {
|
||||
SenseClient client = new SenseClient(context);
|
||||
client.sendSensorDataToServer(jsonObject.toString());
|
||||
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
Log.i("Data Upload", " Json Data Parsing Exception");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Thread dataUploaderThread = new Thread(runnable);
|
||||
dataUploaderThread.start();
|
||||
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.service;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class SenseScheduleReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
AlarmManager service = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
Intent i = new Intent(context, SenseService.class);
|
||||
PendingIntent pending = PendingIntent.getService(context, 0, i, 0);
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.add(Calendar.SECOND, 30);
|
||||
service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 20 * 1000, pending);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.SenseDataCollector;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryDataReceiver;
|
||||
import org.wso2.carbon.iot.android.sense.util.LocalRegister;
|
||||
import org.wso2.carbon.iot.android.sense.util.SenseWakeLock;
|
||||
|
||||
|
||||
public class SenseService extends Service {
|
||||
|
||||
//private final IBinder senseBinder = new SenseBinder();
|
||||
public static Context context;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SenseWakeLock.acquireWakeLock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent arg0) {
|
||||
//return senseBinder;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
context = this;
|
||||
if (!LocalRegister.isExist(context)) return Service.START_NOT_STICKY;
|
||||
|
||||
SenseDataCollector Sensor = new SenseDataCollector(this, SenseDataCollector.DataType.SENSOR);
|
||||
SenseDataCollector Location = new SenseDataCollector(this, SenseDataCollector.DataType.LOCATION);
|
||||
registerReceiver(new BatteryDataReceiver(), new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
//service will not be stopped until we manually stop the service
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
SenseWakeLock.releaseCPUWakeLock();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Location.LocationData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.Sensor.SensorData;
|
||||
import org.wso2.carbon.iot.android.sense.events.input.battery.BatteryData;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class DataMap {
|
||||
|
||||
private static List<SensorData> sensorDataMap;
|
||||
private static List<BatteryData> batteryDataMap;
|
||||
private static List<LocationData> locationDataMap;
|
||||
|
||||
|
||||
public static List<SensorData> getSensorDataMap(){
|
||||
if(sensorDataMap == null){
|
||||
sensorDataMap = new CopyOnWriteArrayList<SensorData>();
|
||||
}
|
||||
return sensorDataMap;
|
||||
}
|
||||
|
||||
public static List<BatteryData> getBatteryDataMap(){
|
||||
if(batteryDataMap == null){
|
||||
batteryDataMap = new CopyOnWriteArrayList<BatteryData>();
|
||||
}
|
||||
return batteryDataMap;
|
||||
}
|
||||
|
||||
public static List<LocationData> getLocationDataMap(){
|
||||
if(locationDataMap == null){
|
||||
locationDataMap = new CopyOnWriteArrayList<LocationData>();
|
||||
}
|
||||
return locationDataMap;
|
||||
}
|
||||
|
||||
public static void resetSensorDataMap(){
|
||||
sensorDataMap = null;
|
||||
}
|
||||
|
||||
public static void resetBatteryDataMap(){
|
||||
batteryDataMap = null;
|
||||
}
|
||||
|
||||
public static void resetLocationDataMap(){
|
||||
locationDataMap = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class LocalRegister {
|
||||
|
||||
private static final String SENSE_SHARED_PREFERENCES = "senseSharedPreferences";
|
||||
private static final String USERNAME_KEY = "usernameKey";
|
||||
private static final String DEVICE_ID_KEY = "deviceIdKey";
|
||||
private static final String SERVER_HOST_KEY = "serverHostKey";
|
||||
private static boolean exists = false;
|
||||
private static String username;
|
||||
private static String deviceId;
|
||||
private static String serverURL;
|
||||
|
||||
public static boolean isExist(Context context){
|
||||
if(!exists) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
String username = sharedpreferences.getString(USERNAME_KEY, "");
|
||||
String deviceId = sharedpreferences.getString(DEVICE_ID_KEY, "");
|
||||
exists = (username != null && !username.isEmpty() && deviceId != null && !deviceId.isEmpty());
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
public static void setExist(boolean status){
|
||||
exists = status;
|
||||
}
|
||||
|
||||
|
||||
public static void addUsername(Context context, String username){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(USERNAME_KEY, username);
|
||||
editor.commit();
|
||||
LocalRegister.username = username;
|
||||
}
|
||||
|
||||
public static String getUsername(Context context){
|
||||
if(LocalRegister.username==null || username.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.username = sharedpreferences.getString(USERNAME_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.username;
|
||||
}
|
||||
|
||||
public static void removeUsername(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.clear();
|
||||
editor.remove(USERNAME_KEY);
|
||||
editor.commit();
|
||||
LocalRegister.username = null;
|
||||
}
|
||||
|
||||
public static void addDeviceId(Context context, String deviceId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(DEVICE_ID_KEY, deviceId);
|
||||
editor.commit();
|
||||
LocalRegister.deviceId = deviceId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void removeDeviceId(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.remove(DEVICE_ID_KEY);
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
LocalRegister.deviceId = null;
|
||||
}
|
||||
|
||||
public static String getDeviceId(Context context){
|
||||
if(LocalRegister.deviceId==null || LocalRegister.deviceId.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.deviceId = sharedpreferences.getString(DEVICE_ID_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.deviceId;
|
||||
}
|
||||
|
||||
public static void addServerURL(Context context, String host){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(SERVER_HOST_KEY, host);
|
||||
editor.commit();
|
||||
LocalRegister.serverURL = host;
|
||||
}
|
||||
|
||||
public static void removeServerURL(Context context){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.remove(SERVER_HOST_KEY);
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
LocalRegister.serverURL = null;
|
||||
}
|
||||
|
||||
public static String getServerURL(Context context){
|
||||
if(LocalRegister.serverURL ==null || LocalRegister.serverURL.isEmpty()) {
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
LocalRegister.serverURL = sharedpreferences.getString(SERVER_HOST_KEY, "");
|
||||
//TODO Throw exception
|
||||
}
|
||||
return LocalRegister.serverURL;
|
||||
}
|
||||
|
||||
public static String getServerHost(Context context){
|
||||
|
||||
URL url = null;
|
||||
String urlString = getServerURL(context);
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
return url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
Log.e("Host " , "Invalid urlString :" + urlString);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
public class SenseClient {
|
||||
|
||||
|
||||
private final static String TAG = "SenseService Client";
|
||||
|
||||
private Context context;
|
||||
|
||||
public SenseClient(Context context) {
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public boolean isAuthenticate(String username, String password) {
|
||||
Map<String, String> _response = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
String response = "";
|
||||
try {
|
||||
|
||||
String endpoint = LocalRegister.getServerURL(context) + SenseConstants.LOGIN_CONTEXT;
|
||||
response = sendWithTimeWait(endpoint, params, "POST", null).get("status");
|
||||
|
||||
if (response.trim().contains(SenseConstants.Request.REQUEST_SUCCESSFUL)) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
//Toast.makeText(context, "Authentication failed, please check your credentials and try again.", Toast.LENGTH_LONG).show();
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e("Authentication", "Authentication failed due to a connection failure");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean register(String username, String deviceId) {
|
||||
Map<String, String> _response = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("deviceId", deviceId);
|
||||
params.put("owner", username);
|
||||
|
||||
try {
|
||||
String endpoint = LocalRegister.getServerURL(context) + SenseConstants.REGISTER_CONTEXT;
|
||||
Map<String, String> response = sendWithTimeWait(endpoint, params, "PUT", null);
|
||||
|
||||
String responseStatus = response.get("status");
|
||||
|
||||
if (responseStatus.trim().contains(SenseConstants.Request.REQUEST_SUCCESSFUL)) {
|
||||
|
||||
Toast.makeText(context, "Device Registered", Toast.LENGTH_LONG).show();
|
||||
|
||||
return true;
|
||||
} else if (responseStatus.trim().contains(SenseConstants.Request.REQUEST_CONFLICT)) {
|
||||
Toast.makeText(context, "Login Successful", Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
} else {
|
||||
Toast.makeText(context, "Authentication failed, please check your credentials and try again.", Toast
|
||||
.LENGTH_LONG).show();
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e("Authentication", "Authentication failed due to a connection failure");
|
||||
Toast.makeText(context, "Authentication failed due to a connection failure", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> sendWithTimeWait(String endpoint, Map<String, String> params, String option, String
|
||||
jsonBody) {
|
||||
Map<String, String> response = null;
|
||||
Map<String, String> responseFinal = null;
|
||||
for (int i = 1; i <= SenseConstants.Request.MAX_ATTEMPTS; i++) {
|
||||
Log.d(TAG, "Attempt #" + i + " to register");
|
||||
try {
|
||||
|
||||
response = sendToServer(endpoint, params, option, jsonBody);
|
||||
|
||||
if (response != null && !response.equals(null)) {
|
||||
responseFinal = response;
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to register on attempt " + i, e);
|
||||
if (i == SenseConstants.Request.MAX_ATTEMPTS) {
|
||||
break;
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
}
|
||||
}
|
||||
|
||||
return responseFinal;
|
||||
}
|
||||
|
||||
public void sendSensorDataToServer(String data) {
|
||||
String urlString = null;
|
||||
try {
|
||||
urlString = LocalRegister.getServerURL(context) + SenseConstants.DATA_ENDPOINT;
|
||||
Log.i("SENDING DATAs", "SENDING JSON to " + urlString + " : " + data);
|
||||
Map<String, String> response = sendWithTimeWait(urlString, null, "POST", data);
|
||||
String responseStatus = response.get("status");
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e("Send Sensor Data", "Failure to send data to "+ urlString);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> sendToServer(String endpoint, Map<String, String> params,
|
||||
String option, String jsonBody) throws IOException {
|
||||
String body = null;
|
||||
if (params != null && !params.isEmpty()) {
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String> param = iterator.next();
|
||||
bodyBuilder.append(param.getKey()).append('=')
|
||||
.append(param.getValue());
|
||||
if (iterator.hasNext()) {
|
||||
bodyBuilder.append('&');
|
||||
}
|
||||
}
|
||||
body = bodyBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
SenseClientAsyncExecutor senseClientAsyncExecutor = new SenseClientAsyncExecutor(context);
|
||||
return senseClientAsyncExecutor.execute(endpoint, body, option, jsonBody).get();
|
||||
} catch (InterruptedException e) {
|
||||
Log.e("Send Sensor Data", "Thread Inturption for endpoint " + endpoint);
|
||||
} catch (ExecutionException e) {
|
||||
Log.e("Send Sensor Data", "Failed to push data to the endpoint " + endpoint);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String inputStreamAsString(InputStream in) {
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append("\n"); // append a new line
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(SenseClient.class.getName(), e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(SenseClient.class.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
// System.out.println(builder.toString());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
|
||||
|
||||
public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String, String>> {
|
||||
|
||||
private static List<String> cookies;
|
||||
private Context context;
|
||||
private final static String TAG = "SenseService Client";
|
||||
|
||||
public SenseClientAsyncExecutor(Context context) {
|
||||
this.context = context;
|
||||
|
||||
}
|
||||
|
||||
private HttpsURLConnection getTrustedConnection(HttpsURLConnection conn) {
|
||||
HttpsURLConnection urlConnection = conn;
|
||||
try {
|
||||
KeyStore localTrustStore;
|
||||
|
||||
localTrustStore = KeyStore.getInstance("BKS");
|
||||
|
||||
InputStream in = context.getResources().openRawResource(
|
||||
R.raw.client_truststore);
|
||||
|
||||
localTrustStore.load(in, SenseConstants.TRUSTSTORE_PASSWORD.toCharArray());
|
||||
|
||||
TrustManagerFactory tmf;
|
||||
tmf = TrustManagerFactory.getInstance(TrustManagerFactory
|
||||
.getDefaultAlgorithm());
|
||||
|
||||
tmf.init(localTrustStore);
|
||||
|
||||
SSLContext sslCtx;
|
||||
|
||||
sslCtx = SSLContext.getInstance("TLS");
|
||||
|
||||
sslCtx.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
urlConnection.setSSLSocketFactory(sslCtx.getSocketFactory());
|
||||
return urlConnection;
|
||||
} catch (KeyManagementException | NoSuchAlgorithmException | CertificateException | IOException | KeyStoreException e) {
|
||||
|
||||
Log.e(SenseClientAsyncExecutor.class.getName(), "Invalid Certifcate");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, String> doInBackground(String... parameters) {
|
||||
if (android.os.Debug.isDebuggerConnected())
|
||||
android.os.Debug.waitForDebugger();
|
||||
String response = null;
|
||||
Map<String, String> response_params = new HashMap<String, String>();
|
||||
|
||||
|
||||
String endpoint = parameters[0];
|
||||
String body = parameters[1];
|
||||
String option = parameters[2];
|
||||
String jsonBody = parameters[3];
|
||||
|
||||
if(jsonBody!=null && !jsonBody.isEmpty()){
|
||||
body = jsonBody;
|
||||
}
|
||||
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(endpoint);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException("invalid url: " + endpoint);
|
||||
}
|
||||
|
||||
Log.v(TAG, "post'" + body + "'to" + url);
|
||||
|
||||
|
||||
HttpURLConnection conn = null;
|
||||
HttpsURLConnection sConn = null;
|
||||
try {
|
||||
|
||||
if (url.getProtocol().toLowerCase().equals("https")) {
|
||||
|
||||
sConn = (HttpsURLConnection) url.openConnection();
|
||||
sConn = getTrustedConnection(sConn);
|
||||
sConn.setHostnameVerifier(SERVER_HOST);
|
||||
conn = sConn;
|
||||
|
||||
} else {
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
|
||||
if (cookies != null) {
|
||||
for (String cookie : cookies) {
|
||||
conn.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
|
||||
}
|
||||
|
||||
}
|
||||
if (conn == null) {
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
byte[] bytes = body.getBytes();
|
||||
conn.setDoOutput(true);
|
||||
conn.setUseCaches(false);
|
||||
conn.setFixedLengthStreamingMode(bytes.length);
|
||||
conn.setRequestMethod(option);
|
||||
if(jsonBody!=null && !jsonBody.isEmpty()){
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
}else {
|
||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||
}
|
||||
conn.setRequestProperty("Accept", "*/*");
|
||||
conn.setRequestProperty("Connection", "close");
|
||||
|
||||
// post the request
|
||||
int status = 0;
|
||||
|
||||
if (!option.equals("DELETE")) {
|
||||
OutputStream out = conn.getOutputStream();
|
||||
out.write(bytes);
|
||||
out.close();
|
||||
// handle the response
|
||||
status = conn.getResponseCode();
|
||||
response_params.put("status", String.valueOf(status));
|
||||
Log.v("Response Status", status + "");
|
||||
|
||||
List<String> receivedCookie = conn.getHeaderFields().get("Set-Cookie");
|
||||
if(receivedCookie!=null){
|
||||
cookies=receivedCookie;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
InputStream inStream = conn.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append("\n"); // append a new line
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
// System.out.println(builder.toString());
|
||||
response = builder.toString();
|
||||
response_params.put("response", response);
|
||||
Log.v("Response Message", response);
|
||||
} catch (IOException ex) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
status = Integer.valueOf(SenseConstants.Request.REQUEST_SUCCESSFUL);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
return response_params;
|
||||
}
|
||||
|
||||
public HostnameVerifier SERVER_HOST = new HostnameVerifier() {
|
||||
//String allowHost = LocalRegister.getServerHost(context);
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
|
||||
return true;
|
||||
//return hv.verify(allowHost, session);
|
||||
}
|
||||
};
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SenseUtils {
|
||||
|
||||
|
||||
//http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id
|
||||
public static String generateDeviceId(Context baseContext, ContentResolver contentResolver) {
|
||||
|
||||
final TelephonyManager tm = (TelephonyManager) baseContext.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
final String tmDevice, tmSerial, androidId;
|
||||
tmDevice = "" + tm.getDeviceId();
|
||||
tmSerial = "" + tm.getSimSerialNumber();
|
||||
androidId = "" + android.provider.Settings.Secure.getString(contentResolver, android.provider.Settings.Secure.ANDROID_ID);
|
||||
|
||||
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
|
||||
return deviceUuid.toString();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package org.wso2.carbon.iot.android.sense.util;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class SenseWakeLock {
|
||||
|
||||
private static PowerManager.WakeLock wakeLock;
|
||||
|
||||
public static void acquireWakeLock(Context context) {
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(), "Acquire CPU wakeup lock start");
|
||||
|
||||
if (wakeLock == null) {
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(),"CPU wakeUp log is not null");
|
||||
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"SenseWakeLock");
|
||||
}
|
||||
|
||||
wakeLock.acquire();
|
||||
|
||||
}
|
||||
|
||||
public static void releaseCPUWakeLock() {
|
||||
|
||||
if (wakeLock != null) {
|
||||
|
||||
|
||||
wakeLock.release();
|
||||
wakeLock = null;
|
||||
}
|
||||
|
||||
Log.i(SenseWakeLock.class.getSimpleName(),"Release wakeup");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:gravity="center_horizontal"
|
||||
android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin" tools:context="org.wso2.carbon.iot.android.sense.register.RegisterActivity">
|
||||
|
||||
<!-- Login progress -->
|
||||
<ProgressBar android:id="@+id/login_progress" style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp" android:visibility="gone" />
|
||||
|
||||
<ScrollView android:id="@+id/login_form" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout android:id="@+id/email_login_form" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/prompt_username"
|
||||
android:id="@+id/username"
|
||||
android:inputType="text"
|
||||
android:maxLines="1" android:singleLine="true"/>
|
||||
|
||||
<EditText android:id="@+id/password" android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionUnspecified" android:inputType="textPassword"
|
||||
android:maxLines="1" android:singleLine="true" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:hint="@string/hostname"
|
||||
android:id="@+id/hostname"
|
||||
android:text=""
|
||||
android:inputType="text"
|
||||
android:maxLines="1" android:singleLine="true"/>
|
||||
|
||||
<Button android:id="@+id/device_register_button" style="?android:textAppearanceSmall"
|
||||
android:layout_width="match_parent" android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp" android:text="@string/action_sign_in"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -0,0 +1,16 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="De-enroll Device"
|
||||
android:id="@+id/unregister"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
</RelativeLayout>
|
@ -0,0 +1,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="org.wso2.carbon.iot.android.sense.register.SenseDeEnroll">
|
||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
||||
android:orderInCategory="100" app:showAsAction="never" />
|
||||
</menu>
|
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 7.5 KiB |
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<string name="username"></string>
|
||||
<bool name="registered">false</bool>
|
||||
</resources>
|
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
@ -0,0 +1,7 @@
|
||||
<resources>
|
||||
<string name="app_name">WSO2-SenseAgent</string>
|
||||
<string name="title_activity_sense_settings">Sense Settings</string>
|
||||
<string name="hostname">Server URL https://host:9443</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
@ -0,0 +1,13 @@
|
||||
<resources>
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="prompt_username">Username</string>
|
||||
<string name="prompt_password">Password</string>
|
||||
<string name="action_sign_in">Register Device</string>
|
||||
<string name="action_sign_in_short">Sign in</string>
|
||||
|
||||
<string name="error_invalid_username">This email address is invalid</string>
|
||||
<string name="error_invalid_password">This password is too short</string>
|
||||
<string name="error_incorrect_password">This password is incorrect</string>
|
||||
<string name="error_field_required">This field is required</string>
|
||||
</resources>
|
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -0,0 +1,19 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
@ -0,0 +1,362 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<items version="2" >
|
||||
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-safetynet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1a6411087ab88ce5542f593e63a2752b6b0d6f1a">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-5f37f316d503119e8e940bc6147423a28028938e.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="69dd177337ead693c408c8dddc9546bb6f1244fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-a49bba393352e40b3a2c77305b4d175131c6035b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/libs/internal_impl-22.0.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba3df4eb0a630d7de294f0e48d3f9267d279b784">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/internal_impl-22.0.0-3c739e94ff5c382efc8e190c64b046f8f08548f9.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8d736fefa22d896e84a268354b3ed48a42663150">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-a2ac0984c99126a23f2ff9eaee1ad9ea2590428f.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1ee588ff2c4daf7b97c1cbf922a6c7f027285c2f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7cc641f33fbb083914dc34a6f21f017d3100e50a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/libs/internal_impl-22.0.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba3df4eb0a630d7de294f0e48d3f9267d279b784">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/internal_impl-22.0.0-9c4ee3b5d5a65a3cd9a176e67ac7281853e32156.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-identity/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="d405025c600055237c171a0bbabaa49d69696573">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-f85dea88ee04abe2b44516da321ea168577149e7.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-fitness/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a172852a35ff919e85b9b7f14bbc15c5bee25520">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-f85bb224fe40682e29567ed759f0d8147789d99a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appinvite/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="63ec6e9f4fe5482a7447d0f3091b8e543a02554c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-fc685315c00e30381a68ae1e40e618f5633b148a.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-fitness/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a172852a35ff919e85b9b7f14bbc15c5bee25520">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7b993cace9f2f89ea7878cee3734d43164761324.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f02127a85abd52a2cd526d4c2409f21969f80ee8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-c8073c83524abffdd450dc16bdddbe5e9a2473c9.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appstate/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="68c140702c7242d914655bcb3164d9e8c45b84cb">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-27570a1dd1163b87dda5a680824455c7c0b5e7bb.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a1372c17fccacca753d3951d3ad820571cbce075">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-c965435894746702a284be3b219dc7f9890de78b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-panorama/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba207be21987c11b37d9f8faa08ed6e722569f30">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-bd9210bc6461a94fd375de690573f7692fb8f6ca.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1e98ef3f124bb7a11f8575f9ff5dfea330b61b6f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-eea806d1c31c7f035fd293a56b4eddee9896f68b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a78183f30e769a98ab4820794f597763088d3065">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-b31ab94c7b4f25bba7f50e7db83969c0abb17395.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-cast/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8e3a972f28b8bae817e382257ba177a31bcadbbc">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-5f18676280d30833bd6e2bfc0802c27f7e2a7c90.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appinvite/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="63ec6e9f4fe5482a7447d0f3091b8e543a02554c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-89c8becd4e40d23a240904b0e866e339422193de.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-cast/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8e3a972f28b8bae817e382257ba177a31bcadbbc">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-67f38bb2e0123552baad0942e6ae8f2ecc29e83e.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-nearby/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6440e5e5cfe368f9bff3c537fb8988048069cb33">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-f8cdc886172afca7899ddc2d3bc98b881ef0471d.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/22.2.0/support-annotations-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="66b42a1f3eb7676070b7ef7f14b603483aecbee1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/support-annotations-22.2.0-06eef0469b7ba17fe99e86a1ff9124f95eca2e22.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/internal_impl-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="57f2ab85c164ff1676ec64dee787981c046fab79">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/internal_impl-22.2.0-0aa32945d2af5dd313fdf82dfcc6dca7c4a61b17.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1ee588ff2c4daf7b97c1cbf922a6c7f027285c2f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-3d021cc2ce59490f31c720e586470122ed3081fb.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="73753982da6bde518f3a4c6b372749981d14d1a0">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-bc85cbe1b3709c53b31a4b4670324bf0714cbb72.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-games/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="02bac2dc792d78241077861566f2c82da955e7fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-4bf713786a72281f07dde60a3edbd94854995c4b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars/libs/internal_impl-22.2.0.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="57f2ab85c164ff1676ec64dee787981c046fab79">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/internal_impl-22.2.0-b1ae13d9667717f01e87e38dbf4767cb4a147255.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appindexing/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f02127a85abd52a2cd526d4c2409f21969f80ee8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-b408adab78303a462e4e242268eaa27d6fb68f51.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-safetynet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1a6411087ab88ce5542f593e63a2752b6b0d6f1a">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-818c83a292835cb905b1fc65b1920fcee95185ef.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="29ebc7e04d877062317c8cc0e68b20f0c1fcda66">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-15077e775d127c164c0e4724bd0af2dadb8ead83.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wallet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6836d188602ec5382d1967c58b00960eb8ff8773">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-dd36a7cfa280312b0e8f1f9bb4e30d7509180a29.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-nearby/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6440e5e5cfe368f9bff3c537fb8988048069cb33">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-c2af74b50463bf6f99827d4bc59971116edf6161.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-identity/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="d405025c600055237c171a0bbabaa49d69696573">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-b0300288a8318525a44e614cb685db1d3b4ead6b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="8d736fefa22d896e84a268354b3ed48a42663150">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-7bed73ef0e569b49a728e9673620253e0e9f9301.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-drive/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f44d03c138cb6488fdbaa65e3a7e5878861a56d8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-cf87780c02ccc07e8d1dc8d4c844d5d32b3e2683.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-panorama/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="ba207be21987c11b37d9f8faa08ed6e722569f30">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-6d1942f94bcc0ec99afd8b7ee5ba8f6e9a89bb9b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="69dd177337ead693c408c8dddc9546bb6f1244fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-9ade1828bea97427006e9c998f42a444280ec927.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a78183f30e769a98ab4820794f597763088d3065">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-5450e680e7872436414a9548385011f2c8487550.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-appstate/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="68c140702c7242d914655bcb3164d9e8c45b84cb">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-f75044418b6dcc7ff2a8d70d7e8cf2a208d6c0e1.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="73753982da6bde518f3a4c6b372749981d14d1a0">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-d10cc88287864f8e0f831e7776e22b9da9685859.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="29ebc7e04d877062317c8cc0e68b20f0c1fcda66">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-7d0fbd0b4530d75b7bbc6689c38f1c12734bff26.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="272bc5d7063f24bc3a33ea1d318cde8f31f5ec4c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-2cbb13942165cbc89aca7bc9e1f777bcbc04c277.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="e7b35244f50663b3f8d150714bca9ecd7a290da1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-79fb523ec54f1f40f7369c408490512821a15f50.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-analytics/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="e7b35244f50663b3f8d150714bca9ecd7a290da1">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-8800f13f43b3b1432fa2889783a68afc980d420b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="06a42becc33232ec0ee125161da68c1829c9f8fd">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-2e38d3423be45e0d0b2adb09d8e0065dfba0823c.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="a1372c17fccacca753d3951d3ad820571cbce075">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-9ce95b9a9877ca5c2e327b16fee4e5f629d4a2ab.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="06a42becc33232ec0ee125161da68c1829c9f8fd">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-3efa6e6ec21335ccac2678be64d362c7b9036130.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-games/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="02bac2dc792d78241077861566f2c82da955e7fa">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-d4bc6409918d6a5d4a5a5d98100031f46ef8e160.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="272bc5d7063f24bc3a33ea1d318cde8f31f5ec4c">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/iot-server-agents/wso2_sense_agent/app/build/intermediates/pre-dexed/release/classes-216941976bfed9962f878deb4820b6efeb31478c.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="1e98ef3f124bb7a11f8575f9ff5dfea330b61b6f">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-191fabc4812c8279f59a14d02fff6cde1a9a8c4b.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-drive/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="f44d03c138cb6488fdbaa65e3a7e5878861a56d8">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-3a95e3adf772a9a13406050763e81edacddb99d4.jar" />
|
||||
</item>
|
||||
<item
|
||||
jar="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-wallet/7.5.0/jars/classes.jar"
|
||||
jumboMode="false"
|
||||
revision="22.0.1"
|
||||
sha1="6836d188602ec5382d1967c58b00960eb8ff8773">
|
||||
<dex dex="/Users/ayyoobhamza/Desktop/iot/wso2_sense_agent/app/build/intermediates/pre-dexed/debug/classes-886652be47aab5a3958fdda8eb5716d478c1be98.jar" />
|
||||
</item>
|
||||
|
||||
</items>
|
@ -0,0 +1,18 @@
|
||||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
@ -0,0 +1,6 @@
|
||||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
@ -0,0 +1,11 @@
|
||||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Thu Oct 22 22:12:40 IST 2015
|
||||
sdk.dir=/Users/ayyoobhamza/Library/Android/sdk
|
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.iot.agents</groupId>
|
||||
<artifactId>org.wso2.sample.iot.android.agent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>Android Sense</name>
|
||||
<description>Android Sense</description>
|
||||
<packaging>pom</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Gradle Build</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>./gradlew</executable>
|
||||
<arguments>
|
||||
<argument>assembleRelease</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|