mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Device location history view feature
This commit is contained in:
parent
c9c19308e0
commit
bebf47981d
@ -485,7 +485,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
throws DeviceManagementException {
|
||||
|
||||
DeviceLocation location = null;
|
||||
String latitude = "", longitude = "";
|
||||
String latitude = "", longitude = "", altitude = "", speed = "", bearing = "", distance = "";
|
||||
|
||||
if (properties == null) return null;
|
||||
|
||||
@ -494,10 +494,22 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
if (propertyName == null) continue;
|
||||
if (propertyName.equals("LATITUDE")) {
|
||||
latitude = property.getValue();
|
||||
if (!longitude.isEmpty()) break;
|
||||
} else if (propertyName.equals("LONGITUDE")) {
|
||||
}
|
||||
if (propertyName.equals("LONGITUDE")) {
|
||||
longitude = property.getValue();
|
||||
if (!latitude.isEmpty()) break;
|
||||
}
|
||||
if (propertyName.equals("ALTITUDE")) {
|
||||
altitude = property.getValue();
|
||||
|
||||
}
|
||||
if (propertyName.equals("SPEED")) {
|
||||
speed = property.getValue();
|
||||
}
|
||||
if (propertyName.equals("BEARING")) {
|
||||
bearing = property.getValue();
|
||||
}
|
||||
if (propertyName.equals("DISTANCE")) {
|
||||
distance = property.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,6 +517,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
location = new DeviceLocation();
|
||||
location.setLatitude(Double.valueOf(latitude));
|
||||
location.setLongitude(Double.valueOf(longitude));
|
||||
location.setAltitude(Double.valueOf(altitude));
|
||||
location.setSpeed(Float.valueOf(speed));
|
||||
location.setBearing(Float.valueOf(bearing));
|
||||
location.setDistance(Double.valueOf(distance));
|
||||
location.setDeviceIdentifier(deviceIdentifier);
|
||||
Device savedDevice = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier, false);
|
||||
location.setDeviceId(savedDevice.getId());
|
||||
|
||||
@ -59,6 +59,10 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
|
||||
private static final String LONGITUDE = "longitude";
|
||||
private static final String LATITUDE = "latitude";
|
||||
private static final String ALTITUDE = "altitude";
|
||||
private static final String SPEED = "speed";
|
||||
private static final String DISTANCE = "distance";
|
||||
private static final String BEARING = "bearing";
|
||||
private static final String TIME_STAMP = "timeStamp";
|
||||
private static final String LOCATION_EVENT_TYPE = "location";
|
||||
|
||||
@ -100,7 +104,11 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
Object[] payload = {
|
||||
jsonObject.get(TIME_STAMP).getAsLong(),
|
||||
jsonObject.get(LATITUDE).getAsDouble(),
|
||||
jsonObject.get(LONGITUDE).getAsDouble()
|
||||
jsonObject.get(LONGITUDE).getAsDouble(),
|
||||
jsonObject.get(ALTITUDE).getAsDouble(),
|
||||
jsonObject.get(SPEED).getAsFloat(),
|
||||
jsonObject.get(BEARING).getAsFloat(),
|
||||
jsonObject.get(DISTANCE).getAsDouble()
|
||||
};
|
||||
try {
|
||||
if (AndroidAPIUtils.getEventPublisherService().publishEvent(
|
||||
|
||||
@ -226,6 +226,22 @@ public class DeviceManagementServiceTests {
|
||||
property.setName("LONGITUDE");
|
||||
property.setValue("6.9");
|
||||
properties.add(property);
|
||||
property = new Device.Property();
|
||||
property.setName("ALTITUDE");
|
||||
property.setValue("-59.8373726");
|
||||
properties.add(property);
|
||||
property = new Device.Property();
|
||||
property.setName("SPEED");
|
||||
property.setValue("0.5123423333");
|
||||
properties.add(property);
|
||||
property = new Device.Property();
|
||||
property.setName("BEARING");
|
||||
property.setValue("44.0");
|
||||
properties.add(property);
|
||||
property = new Device.Property();
|
||||
property.setName("DISTANCE");
|
||||
property.setValue("44.0");
|
||||
properties.add(property);
|
||||
androidDevice.setProperties(properties);
|
||||
|
||||
Response response = deviceManagementService.enrollDevice(androidDevice);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.wso2.carbon.mdm.services.android.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
@ -39,4 +40,5 @@ public class DeviceInformationManagerServiceMock implements DeviceInformationMan
|
||||
public List<DeviceLocation> getDeviceLocations(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.AmbiguousConfiguratio
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.DeviceConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistory;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceNotFoundException;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException;
|
||||
@ -590,6 +591,11 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceLocationHistory> getDeviceLocationInfo(String s, String s1, long l, long l1) throws DeviceManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyPullNotificationSubscriber(DeviceIdentifier deviceIdentifier, Operation operation)
|
||||
throws PullNotificationExecutionFailedException {
|
||||
|
||||
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.mocks;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
||||
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
||||
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceInformationManagerServiceMock implements DeviceInformationManager {
|
||||
@Override
|
||||
public void addDeviceInfo(DeviceIdentifier deviceIdentifier, DeviceInfo deviceInfo)
|
||||
throws DeviceDetailsMgtException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo getDeviceInfo(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> getDevicesInfo(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceLocation getDeviceLocation(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceLocation> getDeviceLocations(List<DeviceIdentifier> list) throws DeviceDetailsMgtException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceLocationHistory(Device device, DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
|
||||
|
||||
}
|
||||
}
|
||||
@ -323,6 +323,10 @@ public class AndroidDeviceManager implements DeviceManager {
|
||||
// Updating current object features using newer ones
|
||||
existingMobileDevice.setLatitude(mobileDevice.getLatitude());
|
||||
existingMobileDevice.setLongitude(mobileDevice.getLongitude());
|
||||
existingMobileDevice.setAltitude(mobileDevice.getAltitude());
|
||||
existingMobileDevice.setSpeed(mobileDevice.getSpeed());
|
||||
existingMobileDevice.setBearing(mobileDevice.getBearing());
|
||||
existingMobileDevice.setDistance(mobileDevice.getDistance());
|
||||
existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties());
|
||||
|
||||
try {
|
||||
|
||||
@ -34,6 +34,10 @@ public class MobileDevice implements Serializable {
|
||||
private String vendor;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private String altitude;
|
||||
private String speed;
|
||||
private String bearing;
|
||||
private String distance;
|
||||
private String imei;
|
||||
private String imsi;
|
||||
private String serial;
|
||||
@ -93,6 +97,38 @@ public class MobileDevice implements Serializable {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(String speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
public String getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(String distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void setBearing(String bearing) {
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public String getAltitude() {
|
||||
return altitude;
|
||||
}
|
||||
|
||||
public void setAltitude(String altitude) {
|
||||
this.altitude = altitude;
|
||||
}
|
||||
|
||||
public String getImei() {
|
||||
return imei;
|
||||
}
|
||||
|
||||
@ -81,6 +81,10 @@ public class MobileDeviceManagementUtil {
|
||||
private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL";
|
||||
private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE";
|
||||
private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE";
|
||||
private static final String MOBILE_DEVICE_ALTITUDE = "ALTITUDE";
|
||||
private static final String MOBILE_DEVICE_DISTANCE = "DISTANCE";
|
||||
private static final String MOBILE_DEVICE_SPEED = "SPEED";
|
||||
private static final String MOBILE_DEVICE_BEARING = "BEARING";
|
||||
private static final String MOBILE_DEVICE_SERIAL = "SERIAL";
|
||||
private static final String MOBILE_DEVICE_OS_BUILD_DATE = "OS_BUILD_DATE";
|
||||
|
||||
@ -132,6 +136,10 @@ public class MobileDeviceManagementUtil {
|
||||
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
||||
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
||||
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
||||
mobileDevice.setAltitude(getPropertyValue(device, MOBILE_DEVICE_ALTITUDE));
|
||||
mobileDevice.setDistance(getPropertyValue(device, MOBILE_DEVICE_DISTANCE));
|
||||
mobileDevice.setSpeed(getPropertyValue(device, MOBILE_DEVICE_SPEED));
|
||||
mobileDevice.setBearing(getPropertyValue(device, MOBILE_DEVICE_BEARING));
|
||||
mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL));
|
||||
mobileDevice.setOsBuildDate(getPropertyValue(device, MOBILE_DEVICE_OS_BUILD_DATE));
|
||||
|
||||
@ -160,11 +168,18 @@ public class MobileDeviceManagementUtil {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_BUILD_DATE, mobileDevice.getOsBuildDate()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_BEARING, mobileDevice.getBearing()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_SPEED, mobileDevice.getSpeed()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_DISTANCE, mobileDevice.getDistance()));
|
||||
|
||||
if(mobileDevice.getLatitude() != null) {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
|
||||
}
|
||||
if(mobileDevice.getLongitude() != null) {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
||||
}
|
||||
if(mobileDevice.getAltitude() != null) {
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_ALTITUDE, mobileDevice.getAltitude()));
|
||||
}
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user