diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java index 5354cc1ae..bf532d00b 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java @@ -43,7 +43,6 @@ import org.wso2.carbon.iot.android.sense.util.dto.RegisterInfo; import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R; - /** * A login screen that offers to register the device. */ @@ -159,7 +158,6 @@ public class RegisterActivity extends Activity { startActivity(intent); } }); - } mUiHandler.post(new Runnable() { @Override @@ -167,11 +165,9 @@ public class RegisterActivity extends Activity { showProgress(false); } }); - } }); myThread.start(); - } } @@ -208,6 +204,4 @@ public class RegisterActivity extends Activity { deviceRegisterButton.setVisibility(show? View.VISIBLE : View.GONE); } } - } - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java index 4ece0fe95..de4c14b3c 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java @@ -34,5 +34,4 @@ public class DataPublisherReceiver extends BroadcastReceiver { PendingIntent pending = PendingIntent.getService(context, 0, i, 0); service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), ALARM_INTERVAL, pending); } - } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java index ecff96371..09f254ddb 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java @@ -20,7 +20,6 @@ import android.hardware.Sensor; 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; @@ -29,17 +28,17 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; -import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData; -import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; -import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData; import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; import org.wso2.carbon.iot.android.sense.event.streams.call.CallData; import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData; +import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData; +import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData; +import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData; import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords; import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData; import org.wso2.carbon.iot.android.sense.util.LocalRegistry; @@ -65,257 +64,250 @@ public class DataPublisherService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { context = this; Log.d(TAG, "service started"); -// Runnable runnable = new Runnable() { -// @Override -// public void run() { - try { - List events = new ArrayList<>(); - //retrieve sensor data. - List sensorDataMap = SenseDataHolder.getSensorDataHolder(); - if (!sensorDataMap.isEmpty()) { - for (SensorData sensorData : sensorDataMap) { - Event event = new Event(); - event.setTimestamp(sensorData.getTimestamp()); - switch (sensorData.getSensorType()) { - case Sensor.TYPE_ACCELEROMETER: - event.setAccelerometer(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_MAGNETIC_FIELD: - event.setMagnetic(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_GYROSCOPE: - event.setGyroscope(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_LIGHT: - event.setLight(sensorData.getSensorValues()[0]); - break; - case Sensor.TYPE_PRESSURE: - event.setPressure(sensorData.getSensorValues()[0]); - events.add(event); - break; - case Sensor.TYPE_PROXIMITY: - event.setProximity(sensorData.getSensorValues()[0]); - events.add(event); - break; - case Sensor.TYPE_GRAVITY: - event.setGravity(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_GAME_ROTATION_VECTOR: - event.setRotation(sensorData.getSensorValues()); - events.add(event); - break; - } - } - } - SenseDataHolder.resetSensorDataHolder(); - - //retrieve battery data. - List batteryDataMap = SenseDataHolder.getBatteryDataHolder(); - if (!batteryDataMap.isEmpty()) { - for (BatteryData batteryData : batteryDataMap) { - Event event = new Event(); - event.setTimestamp(batteryData.getTimestamp()); - event.setBattery(batteryData.getLevel()); - event.setBatteryTemperature(batteryData.getTemperature()); - event.setBatteryStatus(batteryData.getStatus()); - event.setBatteryState(batteryData.getState().toString()); + try { + List events = new ArrayList<>(); + //retrieve sensor data. + List sensorDataMap = SenseDataHolder.getSensorDataHolder(); + if (!sensorDataMap.isEmpty()) { + for (SensorData sensorData : sensorDataMap) { + Event event = new Event(); + event.setTimestamp(sensorData.getTimestamp()); + switch (sensorData.getSensorType()) { + case Sensor.TYPE_ACCELEROMETER: + event.setAccelerometer(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_MAGNETIC_FIELD: + event.setMagnetic(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_GYROSCOPE: + event.setGyroscope(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_LIGHT: + event.setLight(sensorData.getSensorValues()[0]); + break; + case Sensor.TYPE_PRESSURE: + event.setPressure(sensorData.getSensorValues()[0]); + events.add(event); + break; + case Sensor.TYPE_PROXIMITY: + event.setProximity(sensorData.getSensorValues()[0]); + events.add(event); + break; + case Sensor.TYPE_GRAVITY: + event.setGravity(sensorData.getSensorValues()); events.add(event); - } + break; + case Sensor.TYPE_GAME_ROTATION_VECTOR: + event.setRotation(sensorData.getSensorValues()); + events.add(event); + break; } - SenseDataHolder.resetBatteryDataHolder(); + } + } + SenseDataHolder.resetSensorDataHolder(); - //retrieve location data. - List locationDataMap = SenseDataHolder.getLocationDataHolder(); + //retrieve battery data. + List batteryDataMap = SenseDataHolder.getBatteryDataHolder(); + if (!batteryDataMap.isEmpty()) { + for (BatteryData batteryData : batteryDataMap) { + Event event = new Event(); + event.setTimestamp(batteryData.getTimestamp()); + event.setBattery(batteryData.getLevel()); + event.setBatteryTemperature(batteryData.getTemperature()); + event.setBatteryStatus(batteryData.getStatus()); + event.setBatteryState(batteryData.getState().toString()); + events.add(event); + } + } + SenseDataHolder.resetBatteryDataHolder(); - if (!locationDataMap.isEmpty()) { - for (LocationData locationData : locationDataMap) { - Event event = new Event(); - event.setTimestamp(locationData.getTimeStamp()); - event.setGps(new double[]{locationData.getLatitude(), locationData.getLongitude()}); - events.add(event); - } - } - SenseDataHolder.resetLocationDataHolder(); + //retrieve location data. + List locationDataMap = SenseDataHolder.getLocationDataHolder(); - //retrieve speed data. - List speedDataMap = SenseDataHolder.getSpeedDataHolder(); - if (!speedDataMap.isEmpty()) { - for (SpeedData speedData : speedDataMap) { - Event event = new Event(); - event.setTimestamp(speedData.getTimeStamp()); - event.setTurns(speedData.getTurns()); - event.setSpeed(speedData.getSpeed()); + if (!locationDataMap.isEmpty()) { + for (LocationData locationData : locationDataMap) { + Event event = new Event(); + event.setTimestamp(locationData.getTimeStamp()); + event.setGps(new double[]{locationData.getLatitude(), locationData.getLongitude()}); + events.add(event); + } + } + SenseDataHolder.resetLocationDataHolder(); - events.add(event); - } - } - SenseDataHolder.resetSpeedDataHolder(); + //retrieve speed data. + List speedDataMap = SenseDataHolder.getSpeedDataHolder(); + if (!speedDataMap.isEmpty()) { + for (SpeedData speedData : speedDataMap) { + Event event = new Event(); + event.setTimestamp(speedData.getTimeStamp()); + event.setTurns(speedData.getTurns()); + event.setSpeed(speedData.getSpeed()); - //retrieve speed data. - List beaconDataMap = SenseDataHolder.getBeaconScanedDataHolder(); - if (!speedDataMap.isEmpty()) { - for (BeaconScanedData beaconData : beaconDataMap) { - Event event = new Event(); - event.setBeaconMajor(beaconData.getBeaconMajor()); - event.setBeaconMinor(beaconData.getBeaconMinor()); - event.setBeaconProximity(beaconData.getBeaconProximity()); - event.setBeaconUuid(beaconData.getBeaconUuid()); + events.add(event); + } + } + SenseDataHolder.resetSpeedDataHolder(); - events.add(event); - } - } - SenseDataHolder.resetSpeedDataHolder(); + //retrieve speed data. + List beaconDataMap = SenseDataHolder.getBeaconScanedDataHolder(); + if (!speedDataMap.isEmpty()) { + for (BeaconScanedData beaconData : beaconDataMap) { + Event event = new Event(); + event.setBeaconMajor(beaconData.getBeaconMajor()); + event.setBeaconMinor(beaconData.getBeaconMinor()); + event.setBeaconProximity(beaconData.getBeaconProximity()); + event.setBeaconUuid(beaconData.getBeaconUuid()); - //retrieve words - ProcessWords.cleanAndPushToWordMap(); - List wordDatMap = SenseDataHolder.getWordDataHolder(); - for (WordData wordData : wordDatMap) { - if (wordData.getOccurences() == 0) { - continue; - } - for (int i = 0; i < wordData.getOccurences(); i++) { - Event event = new Event(); - event.setTimestamp(wordData.getTimestamp()); - event.setWord(wordData.getWord()); - String word = wordData.getWord(); - String status = word; - if ((!word.equals(SenseConstants.EVENT_LISTENER_STARTED)) && (!word.equals(SenseConstants - .EVENT_LISTENER_FINISHED))) { - status = SenseConstants.EVENT_LISTENER_ONGOING; - } - event.setWordStatus(status); - events.add(event); - } + events.add(event); + } + } + SenseDataHolder.resetSpeedDataHolder(); + + //retrieve words + ProcessWords.cleanAndPushToWordMap(); + List wordDatMap = SenseDataHolder.getWordDataHolder(); + for (WordData wordData : wordDatMap) { + if (wordData.getOccurences() == 0) { + continue; + } + for (int i = 0; i < wordData.getOccurences(); i++) { + Event event = new Event(); + event.setTimestamp(wordData.getTimestamp()); + event.setWord(wordData.getWord()); + String word = wordData.getWord(); + String status = word; + if ((!word.equals(SenseConstants.EVENT_LISTENER_STARTED)) && (!word.equals(SenseConstants + .EVENT_LISTENER_FINISHED))) { + status = SenseConstants.EVENT_LISTENER_ONGOING; } - SenseDataHolder.resetWordDataHolder(); + event.setWordStatus(status); + events.add(event); + } + } + SenseDataHolder.resetWordDataHolder(); - // retrieve call data. - List callDataList = SenseDataHolder.getCallDataHolder(); - if (!callDataList.isEmpty()) { - for (CallData callData : callDataList) { - Event event = new Event(); - event.setCallNumber(callData.getPhoneNumber()); - event.setCallType(callData.getType().toString().toLowerCase()); - event.setCallStartTime(callData.getStartTime()); - event.setCallEndTime(callData.getEndTime()); - event.setTimestamp(callData.getStartTime()); + // retrieve call data. + List callDataList = SenseDataHolder.getCallDataHolder(); + if (!callDataList.isEmpty()) { + for (CallData callData : callDataList) { + Event event = new Event(); + event.setCallNumber(callData.getPhoneNumber()); + event.setCallType(callData.getType().toString().toLowerCase()); + event.setCallStartTime(callData.getStartTime()); + event.setCallEndTime(callData.getEndTime()); + event.setTimestamp(callData.getStartTime()); - events.add(event); - } - } - SenseDataHolder.resetCallDataHolder(); + events.add(event); + } + } + SenseDataHolder.resetCallDataHolder(); - // retrieve screen data. - List screenDataList = SenseDataHolder.getScreenDataHolder(); - if (!screenDataList.isEmpty()) { - for (ScreenData screenData : screenDataList) { - Event event = new Event(); - event.setScreenState(screenData.getAction()); - event.setTimestamp(screenData.getTimestamp()); + // retrieve screen data. + List screenDataList = SenseDataHolder.getScreenDataHolder(); + if (!screenDataList.isEmpty()) { + for (ScreenData screenData : screenDataList) { + Event event = new Event(); + event.setScreenState(screenData.getAction()); + event.setTimestamp(screenData.getTimestamp()); - events.add(event); - } - } - SenseDataHolder.resetScreenDataHolder(); + events.add(event); + } + } + SenseDataHolder.resetScreenDataHolder(); - // retrieve audio data. - List audioDataList = SenseDataHolder.getAudioDataHolder(); - if (!audioDataList.isEmpty()) { - for (AudioData audioData : audioDataList) { - Event event = new Event(); - event.setTimestamp(audioData.getTimestamp()); - event.setAudioPlaying(audioData.isPlaying()); - event.setHeadsetOn(audioData.isHeadsetOn()); - event.setMusicVolume(audioData.getMusicVolume()); - events.add(event); - } - } - SenseDataHolder.resetAudioDataHolder(); + // retrieve audio data. + List audioDataList = SenseDataHolder.getAudioDataHolder(); + if (!audioDataList.isEmpty()) { + for (AudioData audioData : audioDataList) { + Event event = new Event(); + event.setTimestamp(audioData.getTimestamp()); + event.setAudioPlaying(audioData.isPlaying()); + event.setHeadsetOn(audioData.isHeadsetOn()); + event.setMusicVolume(audioData.getMusicVolume()); + events.add(event); + } + } + SenseDataHolder.resetAudioDataHolder(); - // retrieve activity data. - List activityDataList = SenseDataHolder.getActivityDataHolder(); - if (!activityDataList.isEmpty()) { - for (ActivityData activityData : activityDataList) { - Event event = new Event(); - event.setTimestamp(activityData.getTimestamp()); - event.setActivityType(activityData.getActivity()); - event.setConfidence(activityData.getConfidence()); - events.add(event); - } - } - SenseDataHolder.resetActivityDataHolder(); + // retrieve activity data. + List activityDataList = SenseDataHolder.getActivityDataHolder(); + if (!activityDataList.isEmpty()) { + for (ActivityData activityData : activityDataList) { + Event event = new Event(); + event.setTimestamp(activityData.getTimestamp()); + event.setActivityType(activityData.getActivity()); + event.setConfidence(activityData.getConfidence()); + events.add(event); + } + } + SenseDataHolder.resetActivityDataHolder(); - // retrieve sms data. - List smsDataList = SenseDataHolder.getSmsDataHolder(); - if (!smsDataList.isEmpty()) { - for (SmsData smsData : smsDataList) { - Event event = new Event(); - event.setTimestamp(smsData.getTimestamp()); - event.setSmsNumber(smsData.getPhoneNumber()); - events.add(event); - } - } - SenseDataHolder.resetSmsDataHolder(); + // retrieve sms data. + List smsDataList = SenseDataHolder.getSmsDataHolder(); + if (!smsDataList.isEmpty()) { + for (SmsData smsData : smsDataList) { + Event event = new Event(); + event.setTimestamp(smsData.getTimestamp()); + event.setSmsNumber(smsData.getPhoneNumber()); + events.add(event); + } + } + SenseDataHolder.resetSmsDataHolder(); - // retrieve application data. - List appDataList = SenseDataHolder.getApplicationDataHolder(); - if (!appDataList.isEmpty()) { - for (ApplicationData appData : appDataList) { - Event event = new Event(); - event.setTimestamp(appData.getTimestamp()); - event.setPackageName(appData.getPackageName()); - event.setAction(appData.getAction().toString()); - events.add(event); - } - } - SenseDataHolder.resetApplicationDataHolder(); + // retrieve application data. + List appDataList = SenseDataHolder.getApplicationDataHolder(); + if (!appDataList.isEmpty()) { + for (ApplicationData appData : appDataList) { + Event event = new Event(); + event.setTimestamp(appData.getTimestamp()); + event.setPackageName(appData.getPackageName()); + event.setAction(appData.getAction().toString()); + events.add(event); + } + } + SenseDataHolder.resetApplicationDataHolder(); - //Retrieve network data - List networkDataList = SenseDataHolder.getNetworkDataHolder(); - if (!networkDataList.isEmpty()) { - for (NetworkData networkData : networkDataList) { - Event event = new Event(); - event.setTimestamp(networkData.getTimeStamp()); - event.setDataType(networkData.getDataType()); - event.setDataReceived(networkData.getDataReceived()); - event.setDataSent(networkData.getDataSent()); - events.add(event); - } - } - SenseDataHolder.resetNetworkDataHolder(); + //Retrieve network data + List networkDataList = SenseDataHolder.getNetworkDataHolder(); + if (!networkDataList.isEmpty()) { + for (NetworkData networkData : networkDataList) { + Event event = new Event(); + event.setTimestamp(networkData.getTimeStamp()); + event.setDataType(networkData.getDataType()); + event.setDataReceived(networkData.getDataReceived()); + event.setDataSent(networkData.getDataSent()); + events.add(event); + } + } + SenseDataHolder.resetNetworkDataHolder(); - //publish the data - if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { - String user = LocalRegistry.getUsername(context); - String deviceId = LocalRegistry.getDeviceId(context); - JSONArray jsonArray = new JSONArray(); - for (Event event : events) { - event.setOwner(user); - event.setDeviceId(deviceId); - jsonArray.put(new JSONObject().put("event", event.getEvent())); - } + //publish the data + if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { + String user = LocalRegistry.getUsername(context); + String deviceId = LocalRegistry.getDeviceId(context); + JSONArray jsonArray = new JSONArray(); + for (Event event : events) { + event.setOwner(user); + event.setDeviceId(deviceId); + jsonArray.put(new JSONObject().put("event", event.getEvent())); + } - MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); - if (!mqttTransportHandler.isConnected()) { - mqttTransportHandler.connect(); - } - String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants.DEVICE_TYPE + "/" + deviceId + "/data"; - mqttTransportHandler.publishDeviceData(user, deviceId, jsonArray.toString(), topic); - } - } catch (JSONException e) { - Log.e(TAG, "Json Data Parsing Exception", e); - } catch (TransportHandlerException e) { - Log.e(TAG, "Data Publish Failed", e); + MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); + if (!mqttTransportHandler.isConnected()) { + mqttTransportHandler.connect(); } -// } -// }; -// Thread dataUploaderThread = new Thread(runnable); -// dataUploaderThread.start(); + String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants.DEVICE_TYPE + "/" + deviceId + "/data"; + mqttTransportHandler.publishDeviceData(user, deviceId, jsonArray.toString(), topic); + } + } catch (JSONException e) { + Log.e(TAG, "Json Data Parsing Exception", e); + } catch (TransportHandlerException e) { + Log.e(TAG, "Data Publish Failed", e); + } return Service.START_NOT_STICKY; } } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java index 62a365976..cfce21dd9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java @@ -552,5 +552,4 @@ public class Event { return jsonEvent; } - } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java index 5d607546f..10f32a8ad 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java @@ -236,6 +236,5 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler { public void processIncomingMessage(MqttMessage message) throws TransportHandlerException { } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java index 4b76b5cca..4e4134358 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java @@ -38,5 +38,4 @@ public class SenseScheduleReceiver extends BroadcastReceiver { cal.add(Calendar.SECOND, 10); service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), ALARM_INTERVAL, pending); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java index 7554f6524..3ad384e75 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java @@ -59,7 +59,6 @@ public class SenseService extends Service { SenseDataReceiverManager.registerNetworkDataReader(this); //service will not be stopped until we manually stop the service return Service.START_NOT_STICKY; - } @Override @@ -75,4 +74,4 @@ public class SenseService extends Service { SenseWakeLock.releaseCPUWakeLock(); super.onDestroy(); } -} \ No newline at end of file +} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java index 541be98b4..885bd5c9b 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java @@ -25,7 +25,6 @@ import android.net.TrafficStats; import android.os.AsyncTask; import android.os.Handler; import android.util.Log; - import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import java.util.Date; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java index 0ddc42236..b72754f44 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java @@ -56,7 +56,6 @@ public class SensorDataReader extends DataReader implements SensorEventListener for (Sensor sensor : sensorList) { mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } - } private void collectSensorData() { @@ -112,5 +111,4 @@ public class SensorDataReader extends DataReader implements SensorEventListener } } } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java index fd7bf2ae9..41b661ec6 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java @@ -73,7 +73,6 @@ public class ActivitySelectSensor extends AppCompatActivity private ListView listView; private SensorManager sensorManager; private ArrayList sensors = new ArrayList<>(); -// private EditText sessionIdText; private RealTimeSensorReader sensorReader = null; private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver(); private SupportedSensors supportedSensors = SupportedSensors.getInstance(); @@ -87,22 +86,10 @@ public class ActivitySelectSensor extends AppCompatActivity Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); - //sessionIdText = (EditText) findViewById(R.id.sessionId); -// sessionIdText.setCursorVisible(false); - listView = (ListView) findViewById(R.id.senseListContainer); - //verifyBluetooth(); registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap")); -// sessionIdText.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// sessionIdText.setCursorVisible(true); -// -// } -// }); - //Publish data FloatingActionButton fbtnPublishData = (FloatingActionButton) findViewById(R.id.publish); @@ -126,35 +113,6 @@ public class ActivitySelectSensor extends AppCompatActivity } }); - //FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech); -// fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// String sessionId = sessionIdText.getText().toString(); -// if (!sessionId.isEmpty()) { -// Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class); -// intent.putExtra("sessionId", sessionId); -// startActivity(intent); -// } else { -// Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT) -// .show(); -// } -// -// } -// }); - -// FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon); -// fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class); -// startActivity(intent); -// -// -// } -// }); - - sharedPreferences = getSharedPreferences(SupportedSensors.SELECTED_SENSORS, 0); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); @@ -223,7 +181,6 @@ public class ActivitySelectSensor extends AppCompatActivity finish(); return true; } - return super.onOptionsItemSelected(item); } @@ -272,7 +229,6 @@ public class ActivitySelectSensor extends AppCompatActivity realTimeSensorChangeReceiver.updateOnChange(adaptor1); listView.setAdapter(adaptor1); - } public void update() { @@ -305,51 +261,10 @@ public class ActivitySelectSensor extends AppCompatActivity } } - /** * This method unregisters the real-time broadcast receiver. */ public void unregisterReceivers() { unregisterReceiver(realTimeSensorChangeReceiver); } - -// private void verifyBluetooth() { -// -// try { -// if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) { -// final AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("Bluetooth not enabled"); -// builder.setMessage("Please enable bluetooth in settings and restart this application."); -// builder.setPositiveButton(android.R.string.ok, null); -// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { -// -// @Override -// public void onDismiss(DialogInterface dialog) { -// finish(); -// System.exit(0); -// } -// -// }); -// builder.show(); -// -// } -// } catch (RuntimeException e) { -// final AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("Bluetooth LE not available"); -// builder.setMessage("Sorry, this device does not support Bluetooth LE."); -// builder.setPositiveButton(android.R.string.ok, null); -// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { -// -// @Override -// public void onDismiss(DialogInterface dialog) { -// finish(); -// System.exit(0); -// } -// -// }); -// builder.show(); -// -// } -// -// } } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java index 2e5343834..dd5a9f86a 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java @@ -33,5 +33,4 @@ public class TempStore { * Array List which is used to populate the List view. */ public static ArrayList sensorArrayList = new ArrayList<>(); - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java index c231ac87e..3413f4e43 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java @@ -37,5 +37,4 @@ public class RealTimeSensorChangeReceiver extends BroadcastReceiver { TempStore.sensorArrayList.clear(); TempStore.sensorArrayList.addAll(TempStore.sensorDataMap.values()); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java index 6504e65ab..441b25195 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java @@ -58,5 +58,4 @@ public class RealTimeSensorReader implements SensorEventListener { @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java index 726c8cded..e8cdfc808 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java @@ -60,6 +60,4 @@ public class AvailableSensorsInDevice { editor.putStringSet(SupportedSensors.GET_AVAILABLE_SENSORS, sensorSet); editor.apply(); } - - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java index 2b0f5351b..d5113eb33 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java @@ -119,5 +119,4 @@ public class SupportedSensors { public String getType(int type) { return typeSensorMap.get(type); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java index 77f3f710c..c526ab36b 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java @@ -83,7 +83,6 @@ public class SensorViewAdaptor extends BaseAdapter { holder.valuesZ.setText(data.getValueZ()); return view; - } private class ViewHolder { diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java index 5c163c802..f04463353 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java @@ -36,7 +36,6 @@ import java.util.Set; * Get the user selections * Put them in to shared preferences */ - public class SelectSensorDialog extends DialogFragment { protected boolean[] selections = new boolean[SupportedSensors.SUPPORTED_SENSOR_COUNT]; @@ -79,7 +78,6 @@ public class SelectSensorDialog extends DialogFragment { Log.d("Click", "Ok"); //call sensorDataMap reading class sensorListListener.onDialogPositiveClick(SelectSensorDialog.this); - } }); @@ -96,7 +94,6 @@ public class SelectSensorDialog extends DialogFragment { } } }); - return builder.create(); } @@ -143,5 +140,4 @@ public class SelectSensorDialog extends DialogFragment { public interface SensorListListener { void onDialogPositiveClick(SelectSensorDialog dialog); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml index f092a81df..d0e97eb7f 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml index cb58d51c7..2df0ad03f 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml @@ -1,4 +1,21 @@ + true AndroidActivityScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml index 5536405ef..01d32787d 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml index d8ed723b3..d9be6dc15 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml @@ -1,4 +1,21 @@ + true AndroidAudioScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml index 525d31c23..76f3cd36b 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml @@ -1,4 +1,21 @@ + true AndroidBatteryScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml index 6a7d67d51..00d4d1ce1 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml index 422c8b864..b939e8d26 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml @@ -1,4 +1,21 @@ + true AndroidCallScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml index 7cf8dbb14..5a0c24e21 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml index 718477818..c4726c0ad 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml @@ -1,4 +1,21 @@ + true AndroidDataScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml index b2f5bf4d8..71c3bbdd9 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml index a2fb1a3ac..4a767d115 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml index a686c52d9..21101d99f 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml @@ -1,4 +1,21 @@ + true AndroidFrequentContactsScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml index 00a70f9fb..f390c4f72 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml index a958cd10d..170534b05 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml index 08acc1d8b..235988174 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml @@ -1,4 +1,21 @@ + true HeadsetScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml index d24d7b007..a6a1fb84f 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml index 2239d4b9a..19441b9a4 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml index 703d07725..888f151cd 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml index 8e63f319d..9fa3c9a86 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml index ac71c9df9..36bb991d8 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml index 7cac9fff1..1b152c620 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml index 17701ac0b..b6501a60e 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml index e8fec6a96..41ffd86c6 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml index d9e5d45a2..4ad1912b6 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml index 66d87162e..685b95b3d 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java index 4cb0ccc9e..b29458e95 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class AndroidSensePermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(AndroidSensePermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class AndroidSensePermissionUpdateListener implements ServletContextListe getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME, AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Android Sense.", e); } } @@ -57,57 +61,44 @@ public class AndroidSensePermissionUpdateListener implements ServletContextListe } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java index 353cdde5d..d06a7dda9 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class ArduinoPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(ArduinoPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class ArduinoPermissionUpdateListener implements ServletContextListener { getAuthorizationManager().authorizeRole(ArduinoConstants.ROLE_NAME, ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Arduino.", e); } } @@ -57,57 +61,44 @@ public class ArduinoPermissionUpdateListener implements ServletContextListener { } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java index 20b8daee8..704ef518f 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class RaspberryPIPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(RaspberryPIPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class RaspberryPIPermissionUpdateListener implements ServletContextListen getAuthorizationManager().authorizeRole(RaspberrypiConstants.ROLE_NAME, RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Raspberry PI.", e); } } @@ -57,57 +61,44 @@ public class RaspberryPIPermissionUpdateListener implements ServletContextListen } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java index 829868010..16a6897b3 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class VirtualFireAlarmPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(VirtualFireAlarmPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class VirtualFireAlarmPermissionUpdateListener implements ServletContextL getAuthorizationManager().authorizeRole(VirtualFireAlarmConstants.ROLE_NAME, VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Raspberry PI.", e); } } @@ -57,57 +61,44 @@ public class VirtualFireAlarmPermissionUpdateListener implements ServletContextL } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - -} +} \ No newline at end of file diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java similarity index 82% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java index 8f68577a6..6bb8ddd72 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java @@ -33,9 +33,9 @@ import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; * Accept Type(s): (STRING, STRING) * Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT) */ -public class getPropertyFunctionExtension extends FunctionExecutor { +public class GetPropertyFunctionExtension extends FunctionExecutor { - Attribute.Type returnType = Attribute.Type.STRING; + private Attribute.Type returnType = Attribute.Type.STRING; @Override protected void init(ExpressionExecutor[] attributeExpressionExecutors, @@ -47,32 +47,34 @@ public class getPropertyFunctionExtension extends FunctionExecutor { } if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the first argument of json:getProperty() function, " + "required " + "Invalid parameter type found for the first argument of json:getProperty() function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType() .toString()); } if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the second argument of json:getProperty() function, " + "required " - + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType() - .toString()); + "Invalid parameter type found for the second argument of json:getProperty() function, required " + + Attribute.Type.STRING + ", but found " + + attributeExpressionExecutors[1].getReturnType().toString()); } } @Override protected Object execute(Object[] data) { if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. First argument cannot be null"); + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function." + + " First argument cannot be null"); } if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. Second argument cannot be null"); + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. " + + "Second argument cannot be null"); } String jsonString = (String) data[0]; String property = (String) data[1]; - JSONObject jsonObject = null; + Object jsonObject; try { - jsonObject = new JSONObject(jsonString); - return jsonObject.get(property).toString(); + jsonObject = new JSONObject(jsonString).get(property); + return jsonObject == null ? null : jsonObject.toString(); } catch (JSONException e) { throw new ExecutionPlanRuntimeException("Cannot parse JSON String in json:getPeroperty() function. " + e); } @@ -80,7 +82,8 @@ public class getPropertyFunctionExtension extends FunctionExecutor { @Override protected Object execute(Object data) { - return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented. + return null; //Since the getProperty function takes in 2 parameters, this method does not get called. + // Hence,not implemented. } @Override diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext index f1886dd63..f2a86a7eb 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext @@ -16,4 +16,4 @@ # under the License. # -getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension +getProperty=org.wso2.extension.siddhi.execution.json.GetPropertyFunctionExtension diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java index 7bc66478c..c1c49f788 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java @@ -45,7 +45,7 @@ public class getPropertyFunctionTestCase { @Test public void testGetPropertyFunctionExtension() throws InterruptedException { - log.info("getPropertyFunctionExtension TestCase"); + log.info("GetPropertyFunctionExtension TestCase"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);"; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js index ec7ae0003..1e756185b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js @@ -107,7 +107,6 @@ var generatePolicyProfile = function () { return windowsOperationModule.generateProfile(configuredOperations); }; - /** * Checks if provided number is valid against a range. * @@ -387,7 +386,6 @@ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { }; // End of HTML embedded invoke methods - // Start of functions related to grid-input-view /** * Method to set count id to cloned elements.