diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
index d4f13f28c..9adf7afb5 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
index aab41db1d..9aa36b192 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
index dda9dd8ac..988223499 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js
index ba0a14521..b74f8d7eb 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js
@@ -129,7 +129,11 @@ var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush;
var filter = {
"query": luceneQuery,
"start": 0,
- "count": limit
+ "count": limit,
+ "sortBy" : [{
+ "field" : "timeStamp",
+ "sortType" : "ASC"
+ }]
};
result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage();
} else {
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
index 4dbde58f8..ee92e8e65 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/index.xml
@@ -432,7 +432,7 @@
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
index 825b523a3..5b3e76834 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/app.js
@@ -29,8 +29,6 @@ $('body').on('hidden.bs.modal', '.modal', function () {
/*Map layer configurations*/
var map;
-initialLoad();
-
function initialLoad() {
if (document.getElementById('map') == null) {
setTimeout(initialLoad, 500); // give everything some time to render
@@ -41,10 +39,25 @@ function initialLoad() {
processAfterInitializationMap();
//Access gps and make zoom to server location as map center
//navigator.geolocation.getCurrentPosition(success, error);
+ setPageTitle();
$("#loading").hide();
}
}
+function setPageTitle() {
+ var hash = window.parent.location.hash;
+ if(hash) {
+ var startIdx = hash.indexOf("/") + 1;
+ var lastIdx = hash.length;
+ var deviceInfoString = hash.substring(startIdx,lastIdx);
+ var deviceInfo = JSON.parse(deviceInfoString);
+ if(deviceInfo) {
+ var newTitle = "[ " + deviceInfo.device.id + "]" + " - Geo Dashboard [" + deviceInfo.device.type + "]";
+ window.parent.document.title = newTitle;
+ $("#title").val(newTitle)
+ }
+ }
+}
//function success(position) {
// var browserLatitude = position.coords.latitude;
@@ -84,12 +97,12 @@ function initializeMap() {
zoom: 14,
center: [6.927078, 79.861243],
layers: [defaultOSM, defaultTFL],
- zoomControl: false,
+ zoomControl: true,
attributionControl: false,
maxZoom: 20,
maxNativeZoom: 18
});
-
+ map.zoomControl.setPosition('bottomleft');
map.on('click', function (e) {
$.UIkit.offcanvas.hide();//[force = false] no animation
});
@@ -340,6 +353,66 @@ function enableRealTime() {
isBatchModeOn = false;
}
+function InitSpatialObject() {
+ var fromDate = new Date();
+ fromDate.setHours(fromDate.getHours() - 2);
+ var toDate = new Date();
+ console.log(fromDate + " " + toDate);
+ var tableData = getProviderData(fromDate.valueOf(), toDate.valueOf());
+ for (var i = 0; i < tableData.length; i++) {
+ var data = tableData[i];
+ var geoMessage = {
+ "messageType": "Point",
+ "type": "Feature",
+ "id": data.id,
+ "deviceId": data.id,
+ "deviceType": data.type,
+ "properties": {
+ "speed": data.speed,
+ "heading": data.heading,
+ "state": data.state,
+ "information": data.information,
+ "notify": data.notify,
+ "type": data.type
+ },
+ "geometry": {
+ "type": "Point",
+ "coordinates": [data.longitude, data.latitude]
+ }
+ };
+ processPointMessage(geoMessage);
+ }
+ var spatialObject = currentSpatialObjects[deviceId];// (local)
+ if (!spatialObject) {
+ $.UIkit.notify({
+ message: "Spatial Object
" + deviceId + " not in the Map!!",
+ status: 'warning',
+ timeout: ApplicationOptions.constance.NOTIFY_WARNING_TIMEOUT,
+ pos: 'top-center'
+ });
+ return false;
+ }
+ selectedSpatialObject = deviceId;
+ if (spatialObject.type == "area") {
+ spatialObject.focusOn(map);
+ return true;
+ }
+
+ map.setView(spatialObject.marker.getLatLng(), 15, {animate: true}); // TODO: check the map._layersMaxZoom and set the zoom level accordingly
+
+ $('#objectInfo').find('#objectInfoId').html(selectedSpatialObject);
+ spatialObject.marker.openPopup();
+ if (!toggled) {
+ $('#objectInfo').animate({width: 'toggle'}, 100);
+ toggled = true;
+ }
+ spatialObject.drawPath();
+ setTimeout(function () {
+ createChart();
+ chart.load({columns: [spatialObject.speedHistory.getArray()]});
+ }, 100);
+}
+
function focusOnHistorySpatialObject(objectId, timeFrom, timeTo) {
if (!timeFrom) {
notifyError('No start time provided to show history. Please provide a suitable value' + timeFrom);
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
index ced06d049..8f10a9334 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/js/websocket.js
@@ -602,6 +602,8 @@ var webSocketOnAlertError = function (e) {
var webSocketOnOpen = function () {
websocket.set_opened();
+ initialLoad();
+ InitSpatialObject();
$.UIkit.notify({
message: 'You Are Connected to Spatial Stream !!',
status: 'success',
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml
new file mode 100644
index 000000000..bce9c10d4
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/Geo-Receiver-WSO2Event-LocationStream.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+ false
+
+
+
+
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/artifact.xml
new file mode 100755
index 000000000..8fe3c9a43
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/Geo-Dashboard-WSO2Event-Receiver_1.0.0/artifact.xml
@@ -0,0 +1,21 @@
+
+
+
+ Geo-Receiver-WSO2Event-LocationStream.xml
+
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/artifacts.xml
index d769028d3..2ce96dc81 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/artifacts.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/artifacts.xml
@@ -27,6 +27,7 @@
+
diff --git a/components/analytics/iot-analytics/pom.xml b/components/analytics/iot-analytics/pom.xml
index c29378e33..ac8a3c9b0 100644
--- a/components/analytics/iot-analytics/pom.xml
+++ b/components/analytics/iot-analytics/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-plugins
analytics
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/analytics/pom.xml b/components/analytics/pom.xml
index 9bc8d9591..d228e42c0 100644
--- a/components/analytics/pom.xml
+++ b/components/analytics/pom.xml
@@ -22,7 +22,7 @@
org.wso2.carbon.devicemgt-plugins
carbon-device-mgt-plugins-parent
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../../pom.xml
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/util/SenseDataReceiverManager.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/util/SenseDataReceiverManager.java
index 9b6c2f15b..e74362b4e 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/util/SenseDataReceiverManager.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/util/SenseDataReceiverManager.java
@@ -101,6 +101,7 @@ public class SenseDataReceiverManager {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
intentFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL);
+ intentFilter.setPriority(1000);
context.registerReceiver(callDataReceiver, intentFilter);
}
@@ -149,6 +150,7 @@ public class SenseDataReceiverManager {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Telephony.Sms.Intents.SMS_RECEIVED_ACTION);
intentFilter.addAction(Telephony.Sms.Intents.SMS_DELIVER_ACTION);
+ intentFilter.setPriority(1000);
context.registerReceiver(smsDataReceiver, intentFilter);
}
}
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml
index 1c76ab0bf..56f608416 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml
@@ -21,7 +21,7 @@
androidsense-plugin
org.wso2.carbon.devicemgt-plugins
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_dashboard/android-iot.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_dashboard/android-iot.json
index 41eaafb20..58a1b2718 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_dashboard/android-iot.json
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_dashboard/android-iot.json
@@ -56,13 +56,6 @@
"ishidden": false,
"subordinates": [],
"title": "Communication"
- },
- {
- "id": "test",
- "isanon": false,
- "ishidden": false,
- "title": "Test",
- "subordinates": []
}
],
"pages": [
@@ -1299,151 +1292,6 @@
"fluidLayout": false
},
"title": "Communication"
- },
- {
- "id": "test",
- "title": "Test",
- "layout": {
- "content": {
- "loggedIn": {
- "blocks": [
- {
- "id": "49cada6f023f237c953761b597752212",
- "x": 0,
- "y": 1,
- "width": 5,
- "height": 1,
- "banner": false
- },
- {
- "id": "a26d2f62dbb0011edf13371a2eb3cdd1",
- "x": 0,
- "y": 0,
- "width": 3,
- "height": 1,
- "banner": false
- }
- ]
- }
- },
- "fluidLayout": false
- },
- "isanon": false,
- "content": {
- "default": {
- "49cada6f023f237c953761b597752212": [
- {
- "id": "date-picker-widget-0",
- "content": {
- "id": "date-picker-widget",
- "title": "Date Picker Widget",
- "type": "widget",
- "category": "Widgets",
- "thumbnail": "fs://gadget/date-picker-widget/index.png",
- "data": {
- "url": "fs://gadget/date-picker-widget/index.xml"
- },
- "options": {},
- "styles": {
- "no_heading": true,
- "hide_gadget": false,
- "titlePosition": "left",
- "title": "Date Picker Widget"
- },
- "notify": {
- "date-selected": {
- "type": "message",
- "description": "This notifies selected date"
- }
- },
- "locale_titles": {
- "en-US": "Date Picker Widget"
- },
- "settings": {
- "priority": "5",
- "timeoutInterval": "60000"
- }
- }
- }
- ],
- "33faa57accead8af549c70f111face99": [
- {
- "id": "EsbAnalytics-Gadget-Search_Box-0",
- "content": {
- "id": "EsbAnalytics-Gadget-Search_Box",
- "title": "Search Box",
- "type": "widget",
- "category": "Widgets",
- "thumbnail": "fs://gadget/usa-business-revenue/index.png",
- "data": {
- "url": "fs://gadget/EsbAnalytics-Gadget-Search_Box/index.xml"
- },
- "styles": {
- "no_heading": true,
- "hide_gadget": false,
- "titlePosition": "left",
- "title": "Search Box"
- },
- "toolbarButtons": {
- "default": {
- "maximize": false,
- "configurations": false
- },
- "custom": [],
- "isDropdownView": false
- },
- "options": {},
- "locale_titles": {
- "en-US": "Search Box"
- },
- "settings": {
- "priority": "5",
- "timeoutInterval": "60000"
- }
- }
- }
- ],
- "be290fcc084ff118decc23588febc2ed": [],
- "a26d2f62dbb0011edf13371a2eb3cdd1": [
- {
- "id": "Android_Device_SearchBox-0",
- "content": {
- "id": "Android_Device_SearchBox",
- "title": "Search Box",
- "type": "gadget",
- "category": "Gadgets",
- "thumbnail": "fs://gadget/usa-business-revenue/index.png",
- "data": {
- "url": "fs://gadget/Android_Device_SearchBox/index.xml"
- },
- "styles": {
- "no_heading": true,
- "hide_gadget": false,
- "titlePosition": "left",
- "title": "Search Box"
- },
- "toolbarButtons": {
- "default": {
- "maximize": false,
- "configurations": false
- },
- "custom": [],
- "isDropdownView": false
- },
- "options": {},
- "locale_titles": {
- "en-US": "Search Box"
- },
- "settings": {
- "priority": "5",
- "timeoutInterval": "60000"
- }
- }
- }
- ]
- },
- "anon": {}
- }
}
],
"permissions": {
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml
index cd2d533ca..993349f35 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml
@@ -3,7 +3,7 @@
androidsense-plugin
org.wso2.carbon.devicemgt-plugins
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
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/AndroidSenseService.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/AndroidSenseService.java
index b259eb6b5..aca23b632 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/AndroidSenseService.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/AndroidSenseService.java
@@ -69,6 +69,8 @@ import javax.ws.rs.core.Response;
)
}
)
+@Api(value = "Android Sense Device Management",
+ description = "This carries all the resources related to the Android sense device management functionalities.")
public interface AndroidSenseService {
/**
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/constants/AndroidSenseConstants.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/constants/AndroidSenseConstants.java
index 3c1e93a5c..9aafb4eea 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/constants/AndroidSenseConstants.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/constants/AndroidSenseConstants.java
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -44,4 +44,9 @@ public class AndroidSenseConstants {
public static final String SCOPE = "scope";
+ public static final String PERM_ENROLL_ANDROID_SENSE = "/permission/admin/device-mgt/devices/enroll/android-sense";
+ public static final String PERM_OWNING_DEVICE_VIEW = "/permission/admin/device-mgt/devices/owning-device/view";
+
+ public static final String ROLE_NAME = "internal/devicemgt-user";
+
}
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
new file mode 100644
index 000000000..4cb0ccc9e
--- /dev/null
+++ 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
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2017, 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.device.mgt.iot.androidsense.service.impl.listener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants.AndroidSenseConstants;
+import org.wso2.carbon.user.api.AuthorizationManager;
+import org.wso2.carbon.user.api.Permission;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.core.service.RealmService;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public class AndroidSensePermissionUpdateListener implements ServletContextListener {
+
+ private static Log log = LogFactory.getLog(AndroidSensePermissionUpdateListener.class);
+
+ @Override
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+
+ UserStoreManager userStoreManager = getUserStoreManager();
+ try {
+ if (userStoreManager != null) {
+ if (!userStoreManager.isExistingRole(AndroidSenseConstants.ROLE_NAME)) {
+ userStoreManager.addRole(AndroidSenseConstants.ROLE_NAME, null, getPermissions());
+ } else {
+ getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME,
+ AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, CarbonConstants.UI_PERMISSION_ACTION);
+ getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME,
+ AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION);
+ }
+ } } catch (UserStoreException e) {
+ log.error("Error while creating a role and adding a user for Android Sense.", e);
+ }
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+
+ }
+
+ public static UserStoreManager getUserStoreManager() {
+ RealmService realmService;
+ 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();
+ 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;
+ 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();
+ 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};
+ }
+
+}
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml
index 2c66f5c1d..28b3d23f3 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml
@@ -30,4 +30,8 @@
managed-api-enabled
true
+
+
+ org.wso2.carbon.device.mgt.iot.androidsense.service.impl.listener.AndroidSensePermissionUpdateListener
+
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml
index 740ec5396..248d64651 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml
@@ -22,7 +22,7 @@
androidsense-plugin
org.wso2.carbon.devicemgt-plugins
- 3.0.7-SNAPSHOT
+ 3.0.9-SNAPSHOT
../pom.xml
diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs
index e23f3c0c1..63edd3ba2 100644
--- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs
+++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs
@@ -15,6 +15,7 @@
specific language governing permissions and limitations
under the License.
}}
+{{unit "cdmf.unit.device.type.android_sense.leaflet"}}
{{#zone "topCss"}}