From b401d7f61ebeedc952d5e3a6edd5b7e032e5a23d Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 17 Nov 2015 23:05:21 +0530 Subject: [PATCH 1/9] added GCM support to android --- .../pom.xml | 14 +- .../AndroidPolicyMonitoringService.java | 7 +- .../mobile/impl/android/gcm/GCMService.java | 140 ++++++++++++++++++ .../MobileDeviceManagementDataHolder.java | 20 +++ ...obileDeviceManagementServiceComponent.java | 16 +- .../dbscripts/plugins/android/h2.sql | 2 +- .../dbscripts/plugins/android/mssql.sql | 2 +- .../dbscripts/plugins/android/mysql.sql | 2 +- .../dbscripts/plugins/android/oracle.sql | 4 +- .../dbscripts/plugins/android/postgresql.sql | 2 +- pom.xml | 12 +- 11 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index 05201d0159..c632be6bed 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -61,28 +61,28 @@ javax.xml.bind.*, javax.naming, javax.sql, - javax.xml.bind.annotation.*, javax.xml.parsers, org.w3c.dom, - org.wso2.carbon.core, org.wso2.carbon.context, org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.policy.mgt.core.*, org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.gson.* + com.google.android.gcm.*, + com.google.gson, + org.json.simple, + org.json.simple.parser !org.wso2.carbon.device.mgt.mobile.internal, !org.wso2.carbon.device.mgt.mobile.impl, org.wso2.carbon.device.mgt.mobile.*, + com.google.android.gcm.*, @@ -170,5 +170,9 @@ com.google.code.gson gson + + com.google.android.gcm + gcm-server + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 49ff0ab17d..3738d156e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -28,6 +28,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; +import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; @@ -43,7 +45,10 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { @Override public void notifyDevices(List list) throws PolicyComplianceException { - + GCMService gcmService = MobileDeviceManagementDataHolder.getInstance().getGCMService(); + if (gcmService.isGCMEnabled()) { + gcmService.sendNotification("POLICY_BUNDLE", list); + } } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java new file mode 100644 index 0000000000..57c79f7a94 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.android.gcm; + +import com.google.android.gcm.server.Message; +import com.google.android.gcm.server.Sender; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; +import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * GCM notification service implementation for Android platform. + */ +public class GCMService { + + private static final Log log = LogFactory.getLog(GCMService.class); + public static final String GCM_APIKEY = "gcmAPIKey"; + public static final String NOTIFIER_TYPE = "notifierType"; + public static final String GCM_NOTIFIER_CODE = "2"; + private static HashMap tenantConfigurationCache = new HashMap<>(); + + public boolean isGCMEnabled() { + String notifierType = getConfigurationProperty(NOTIFIER_TYPE); + if (GCM_NOTIFIER_CODE.equals(notifierType)) { + return true; + } + return false; + } + + public void sendNotification(String messageData, Device device) { + int seconds = 60; + Sender sender = new Sender(getConfigurationProperty(GCM_APIKEY)); + Message message = + new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); + try { + sender.send(message, getGCMToken(device.getProperties()), 5); + } catch (IOException e) { + log.error("Exception occurred while sending the GCM notification.",e); + } + } + + public void sendNotification(String messageData, List devices) { + int seconds = 60; + Sender sender = new Sender(getConfigurationProperty(GCM_APIKEY)); + Message message = + new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); + try { + sender.send(message, getGCMTokens(devices), 5); + } catch (IOException e) { + log.error("Exception occurred while sending the GCM notification.",e); + } + } + + private static List getGCMTokens(List devices) { + List tokens = new ArrayList<>(); + for (Device device : devices) { + tokens.add(getGCMToken(device.getProperties())); + } + return tokens; + } + + private static String getGCMToken(List properties) { + String gcmToken = null; + for (Device.Property property : properties) { + if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { + gcmToken = property.getValue(); + break; + } + } + return gcmToken; + } + + private static String getConfigurationProperty(String property) { + DeviceManagementService androidDMService = MobileDeviceManagementDataHolder.getInstance(). + getAndroidDeviceManagementService(); + try { + //Get the TenantConfiguration from cache if not we'll get it from DM service + TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); + if (tenantConfiguration == null) { + tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); + if (tenantConfiguration != null) { + addTenantConfigurationToCache(tenantConfiguration); + } + } + + if (tenantConfiguration != null) { + List configs = tenantConfiguration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (property.equals(entry.getName())) { + return (String) entry.getValue(); + } + } + } + return ""; + } catch (DeviceManagementException e) { + log.error("Exception occurred while fetching the tenant-config.",e); + } + return null; + } + + private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { + tenantConfigurationCache.put(getTenantId(), tenantConfiguration); + } + + private static TenantConfiguration getTenantConfigurationFromCache() { + return tenantConfigurationCache.get(getTenantId()); + } + + private static int getTenantId() { + return CarbonContext.getThreadLocalCarbonContext().getTenantId(); + } +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java index 40c6610090..869904e81c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.mobile.internal; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -26,6 +28,8 @@ import org.wso2.carbon.registry.core.service.RegistryService; public class MobileDeviceManagementDataHolder { private RegistryService registryService; + private DeviceManagementService androidDeviceManagementService; + private GCMService gcmService; private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); @@ -44,4 +48,20 @@ public class MobileDeviceManagementDataHolder { this.registryService = registryService; } + public DeviceManagementService getAndroidDeviceManagementService() { + return androidDeviceManagementService; + } + + public void setAndroidDeviceManagementService( + DeviceManagementService androidDeviceManagementService) { + this.androidDeviceManagementService = androidDeviceManagementService; + } + + public GCMService getGCMService() { + return gcmService; + } + + public void setGCMService(GCMService gcmService) { + this.gcmService = gcmService; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index 8f71321f43..92404b67ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -32,6 +32,7 @@ import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFa import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService; import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidPolicyMonitoringService; +import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService; import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService; import org.wso2.carbon.ndatasource.core.DataSourceService; @@ -61,6 +62,7 @@ public class MobileDeviceManagementServiceComponent { private ServiceRegistration androidServiceRegRef; private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration gcmServiceRegRef; private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); @@ -98,14 +100,20 @@ public class MobileDeviceManagementServiceComponent { log.error("Exception occurred while initializing mobile device management database schema", e); } } + DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); + GCMService gcmService = new GCMService(); androidServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName(), - new AndroidDeviceManagementService(), null); + androidDeviceManagementService, null); windowsServiceRegRef = bundleContext.registerService(DeviceManagementService.class.getName(), new WindowsDeviceManagementService(), null); + gcmServiceRegRef = + bundleContext.registerService(GCMService.class.getName(), gcmService, null); + + // Policy management service bundleContext.registerService(PolicyMonitoringService.class, @@ -113,6 +121,9 @@ public class MobileDeviceManagementServiceComponent { bundleContext.registerService(PolicyMonitoringService.class, new WindowsPolicyMonitoringService(), null); + MobileDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( + androidDeviceManagementService); + MobileDeviceManagementDataHolder.getInstance().setGCMService(gcmService); if (log.isDebugEnabled()) { log.debug("Mobile Device Management Service Component has been successfully activated"); } @@ -132,6 +143,9 @@ public class MobileDeviceManagementServiceComponent { if (windowsServiceRegRef != null) { windowsServiceRegRef.unregister(); } + if (gcmServiceRegRef != null) { + gcmServiceRegRef.unregister(); + } if (log.isDebugEnabled()) { log.debug( "Mobile Device Management Service Component has been successfully de-activated"); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql index 09b3cc91c3..3673fd122e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql @@ -4,7 +4,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql index f95ec0f913..be8caf6c43 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, - GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, IMSI VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql index 0f80bdd344..8e85b92c2b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(45) NULL DEFAULT NULL, + `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, `IMEI` VARCHAR(45) NULL DEFAULT NULL, `IMSI` VARCHAR(45) NULL DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql index 7e3007ee6c..8f00cd3316 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -3,8 +3,8 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(1000) DEFAULT NULL, - GCM_TOKEN VARCHAR(45) DEFAULT NULL, + DEVICE_INFO VARCHAR(8000) DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, IMSI VARCHAR(45) DEFAULT NULL, OS_VERSION VARCHAR(45) DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql index 18d67c43dd..e4512c53fc 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , DEVICE_INFO TEXT NULL DEFAULT NULL, - GCM_TOKEN VARCHAR(45) NULL DEFAULT NULL, + GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, IMEI VARCHAR(45) NULL DEFAULT NULL, IMSI VARCHAR(45) NULL DEFAULT NULL, OS_VERSION VARCHAR(45) NULL DEFAULT NULL, diff --git a/pom.xml b/pom.xml index 029ddf51e5..1ece8c3c17 100644 --- a/pom.xml +++ b/pom.xml @@ -528,6 +528,11 @@ gson ${google.gson.version} + + com.google.android.gcm + gcm-server + ${gcm.server.version} + @@ -595,7 +600,7 @@ 2.0.0 3.0.21 2.2.4 - + 1.0.2 @@ -785,5 +790,10 @@ false + + gcm-server-repository + GCM Server repository - GitHub + https://github.com/slorber/gcm-server-repository/raw/master/releases/ + From cfb6464cbe4de259142837193587a9cdec1130cb Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 18 Nov 2015 12:51:54 +0530 Subject: [PATCH 2/9] Fixed policy monitoring empty device list issue --- .../mgt/mobile/impl/android/AndroidPolicyMonitoringService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 3738d156e1..6a03fa962f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -46,7 +46,7 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { @Override public void notifyDevices(List list) throws PolicyComplianceException { GCMService gcmService = MobileDeviceManagementDataHolder.getInstance().getGCMService(); - if (gcmService.isGCMEnabled()) { + if (gcmService.isGCMEnabled() && !list.isEmpty()) { gcmService.sendNotification("POLICY_BUNDLE", list); } } From 9d807400cef3aa86f67205ff551c8331e32a2050 Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 18 Nov 2015 14:38:18 +0530 Subject: [PATCH 3/9] Added GCM failure handling logic --- .../mobile/impl/android/gcm/GCMService.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java index 57c79f7a94..1ee07387cc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.gcm; import com.google.android.gcm.server.Message; +import com.google.android.gcm.server.MulticastResult; +import com.google.android.gcm.server.Result; import com.google.android.gcm.server.Sender; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -61,7 +63,10 @@ public class GCMService { Message message = new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); try { - sender.send(message, getGCMToken(device.getProperties()), 5); + Result result = sender.send(message, getGCMToken(device.getProperties()), 5); + if (result.getErrorCodeName() != null) { + log.error("Unable to send notification via GCM : " + result.getErrorCodeName()); + } } catch (IOException e) { log.error("Exception occurred while sending the GCM notification.",e); } @@ -73,7 +78,16 @@ public class GCMService { Message message = new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); try { - sender.send(message, getGCMTokens(devices), 5); + MulticastResult result = sender.send(message, getGCMTokens(devices), 5); + if (result.getFailure() == 1) { + List resultList = result.getResults(); + if (resultList != null && resultList.size() > 0) { + Result error = resultList.get(0); + log.error("Unable to send notification via GCM : " + error.getErrorCodeName()); + } else { + log.error("Unable to send notification via GCM."); + } + } } catch (IOException e) { log.error("Exception occurred while sending the GCM notification.",e); } From 92317260d36b0711192db8b829effbcad1e22a59 Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 18 Nov 2015 20:14:36 +0530 Subject: [PATCH 4/9] Added GCM support to android --- .../pom.xml | 6 +- .../mobile/impl/android/gcm/GCMResult.java | 53 +++++ .../mobile/impl/android/gcm/GCMService.java | 116 +---------- .../mgt/mobile/impl/android/gcm/GCMUtil.java | 191 ++++++++++++++++++ 4 files changed, 256 insertions(+), 110 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index c632be6bed..5737b21532 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -73,16 +73,12 @@ org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.android.gcm.*, - com.google.gson, - org.json.simple, - org.json.simple.parser + com.google.gson.*, !org.wso2.carbon.device.mgt.mobile.internal, !org.wso2.carbon.device.mgt.mobile.impl, org.wso2.carbon.device.mgt.mobile.*, - com.google.android.gcm.*, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java new file mode 100644 index 0000000000..c15d6d4c4c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMResult.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.android.gcm; + +/** + * Represents model object for holding GCM response data. + */ +public class GCMResult { + + private String errorMsg; + private String msg; + private int statusCode; + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java index 1ee07387cc..2113dd062f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMService.java @@ -18,24 +18,11 @@ package org.wso2.carbon.device.mgt.mobile.impl.android.gcm; -import com.google.android.gcm.server.Message; -import com.google.android.gcm.server.MulticastResult; -import com.google.android.gcm.server.Result; -import com.google.android.gcm.server.Sender; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; -import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; -import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; /** @@ -44,13 +31,11 @@ import java.util.List; public class GCMService { private static final Log log = LogFactory.getLog(GCMService.class); - public static final String GCM_APIKEY = "gcmAPIKey"; - public static final String NOTIFIER_TYPE = "notifierType"; - public static final String GCM_NOTIFIER_CODE = "2"; - private static HashMap tenantConfigurationCache = new HashMap<>(); + private static final String NOTIFIER_TYPE = "notifierType"; + private static final String GCM_NOTIFIER_CODE = "2"; public boolean isGCMEnabled() { - String notifierType = getConfigurationProperty(NOTIFIER_TYPE); + String notifierType = GCMUtil.getConfigurationProperty(NOTIFIER_TYPE); if (GCM_NOTIFIER_CODE.equals(notifierType)) { return true; } @@ -58,97 +43,18 @@ public class GCMService { } public void sendNotification(String messageData, Device device) { - int seconds = 60; - Sender sender = new Sender(getConfigurationProperty(GCM_APIKEY)); - Message message = - new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); - try { - Result result = sender.send(message, getGCMToken(device.getProperties()), 5); - if (result.getErrorCodeName() != null) { - log.error("Unable to send notification via GCM : " + result.getErrorCodeName()); - } - } catch (IOException e) { - log.error("Exception occurred while sending the GCM notification.",e); + List devices = new ArrayList<>(); + devices.add(device); + GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + if (result.getStatusCode() != 200) { + log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); } } public void sendNotification(String messageData, List devices) { - int seconds = 60; - Sender sender = new Sender(getConfigurationProperty(GCM_APIKEY)); - Message message = - new Message.Builder().timeToLive(seconds).delayWhileIdle(false).addData("data", messageData).build(); - try { - MulticastResult result = sender.send(message, getGCMTokens(devices), 5); - if (result.getFailure() == 1) { - List resultList = result.getResults(); - if (resultList != null && resultList.size() > 0) { - Result error = resultList.get(0); - log.error("Unable to send notification via GCM : " + error.getErrorCodeName()); - } else { - log.error("Unable to send notification via GCM."); - } - } - } catch (IOException e) { - log.error("Exception occurred while sending the GCM notification.",e); + GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + if (result.getStatusCode() != 200) { + log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); } } - - private static List getGCMTokens(List devices) { - List tokens = new ArrayList<>(); - for (Device device : devices) { - tokens.add(getGCMToken(device.getProperties())); - } - return tokens; - } - - private static String getGCMToken(List properties) { - String gcmToken = null; - for (Device.Property property : properties) { - if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { - gcmToken = property.getValue(); - break; - } - } - return gcmToken; - } - - private static String getConfigurationProperty(String property) { - DeviceManagementService androidDMService = MobileDeviceManagementDataHolder.getInstance(). - getAndroidDeviceManagementService(); - try { - //Get the TenantConfiguration from cache if not we'll get it from DM service - TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); - if (tenantConfiguration == null) { - tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); - if (tenantConfiguration != null) { - addTenantConfigurationToCache(tenantConfiguration); - } - } - - if (tenantConfiguration != null) { - List configs = tenantConfiguration.getConfiguration(); - for (ConfigurationEntry entry : configs) { - if (property.equals(entry.getName())) { - return (String) entry.getValue(); - } - } - } - return ""; - } catch (DeviceManagementException e) { - log.error("Exception occurred while fetching the tenant-config.",e); - } - return null; - } - - private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { - tenantConfigurationCache.put(getTenantId(), tenantConfiguration); - } - - private static TenantConfiguration getTenantConfigurationFromCache() { - return tenantConfigurationCache.get(getTenantId()); - } - - private static int getTenantId() { - return CarbonContext.getThreadLocalCarbonContext().getTenantId(); - } } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java new file mode 100644 index 0000000000..ce08d896d5 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/gcm/GCMUtil.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.mobile.impl.android.gcm; + +import com.google.gson.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.mobile.impl.android.util.AndroidPluginConstants; +import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.ProtocolException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * Implements utility methods used by GCMService. + */ +public class GCMUtil { + + private static final Log log = LogFactory.getLog(GCMService.class); + + private final static String GCM_ENDPOINT = "https://gcm-http.googleapis.com/gcm/send"; + private static final String GCM_API_KEY = "gcmAPIKey"; + private static final int TIME_TO_LIVE = 60; + private static final int HTTP_STATUS_CODE_OK = 200; + + private static HashMap tenantConfigurationCache = new HashMap<>(); + + public static GCMResult sendWakeUpCall(String message, List devices) { + GCMResult result = new GCMResult(); + + byte[] bytes = getGCMRequest(message, getGCMTokens(devices)).getBytes(); + HttpURLConnection conn; + try { + conn = (HttpURLConnection) (new URL(GCM_ENDPOINT)).openConnection(); + conn.setDoOutput(true); + conn.setUseCaches(false); + conn.setFixedLengthStreamingMode(bytes.length); + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Authorization", "key=" + getConfigurationProperty(GCM_API_KEY)); + + OutputStream out = conn.getOutputStream(); + out.write(bytes); + out.close(); + + int status = conn.getResponseCode(); + result.setStatusCode(status); + if (status != HTTP_STATUS_CODE_OK) { + result.setErrorMsg(getString(conn.getErrorStream())); + } else { + result.setMsg(getString(conn.getInputStream())); + } + } catch (ProtocolException e) { + log.error("Exception occurred while setting the HTTP protocol.", e); + } catch (IOException ex) { + log.error("Exception occurred while sending the GCM request.", ex); + } + + return result; + } + + private static String getString(InputStream stream) throws IOException { + if (stream != null) { + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + StringBuilder content = new StringBuilder(); + + String newLine; + do { + newLine = reader.readLine(); + if (newLine != null) { + content.append(newLine).append('\n'); + } + } while (newLine != null); + + if (content.length() > 0) { + content.setLength(content.length() - 1); + } + + return content.toString(); + } + return null; + } + + private static String getGCMRequest(String message, List registrationIds) { + JsonObject gcmRequest = new JsonObject(); + gcmRequest.addProperty("delay_while_idle", false); + gcmRequest.addProperty("time_to_live", TIME_TO_LIVE); + + //Add message to GCM request + JsonObject data = new JsonObject(); + if (message != null && !message.isEmpty()) { + data.addProperty("data", message); + gcmRequest.add("data", data); + } + + //Set device reg-ids + JsonArray regIds = new JsonArray(); + for (String regId : registrationIds) { + regIds.add(new JsonPrimitive(regId)); + } + + gcmRequest.add("registration_ids", regIds); + return gcmRequest.toString(); + } + + private static List getGCMTokens(List devices) { + List tokens = new ArrayList<>(); + for (Device device : devices) { + tokens.add(getGCMToken(device.getProperties())); + } + return tokens; + } + + private static String getGCMToken(List properties) { + String gcmToken = null; + for (Device.Property property : properties) { + if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { + gcmToken = property.getValue(); + break; + } + } + return gcmToken; + } + + public static String getConfigurationProperty(String property) { + DeviceManagementService androidDMService = MobileDeviceManagementDataHolder.getInstance(). + getAndroidDeviceManagementService(); + try { + //Get the TenantConfiguration from cache if not we'll get it from DM service + TenantConfiguration tenantConfiguration = getTenantConfigurationFromCache(); + if (tenantConfiguration == null) { + tenantConfiguration = androidDMService.getDeviceManager().getConfiguration(); + if (tenantConfiguration != null) { + addTenantConfigurationToCache(tenantConfiguration); + } + } + + if (tenantConfiguration != null) { + List configs = tenantConfiguration.getConfiguration(); + for (ConfigurationEntry entry : configs) { + if (property.equals(entry.getName())) { + return (String) entry.getValue(); + } + } + } + return ""; + } catch (DeviceManagementException e) { + log.error("Exception occurred while fetching the tenant-config.",e); + } + return null; + } + + private static void addTenantConfigurationToCache(TenantConfiguration tenantConfiguration) { + tenantConfigurationCache.put(getTenantId(), tenantConfiguration); + } + + private static TenantConfiguration getTenantConfigurationFromCache() { + return tenantConfigurationCache.get(getTenantId()); + } + + private static int getTenantId() { + return CarbonContext.getThreadLocalCarbonContext().getTenantId(); + } +} \ No newline at end of file From aa19dc72618b0faffa3a3ef5e54cd8c2a7a62336 Mon Sep 17 00:00:00 2001 From: manoj Date: Thu, 19 Nov 2015 10:58:43 +0530 Subject: [PATCH 5/9] APP manager integration --- .../android/AndroidDeviceManagementService.java | 15 ++++++++++++--- .../windows/WindowsDeviceManagementService.java | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java index 9f1e22167f..5bc70f4eab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java @@ -72,9 +72,18 @@ public class AndroidDeviceManagementService implements DeviceManagementService { return null; } - @Override - public void installApplication(Operation operation, - List deviceIdentifiers) throws ApplicationManagementException { + @Override public void installApplicationForDevices(Operation operation, List deviceIdentifiers) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUsers(Operation operation, List strings) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUserRoles(Operation operation, List strings) + throws ApplicationManagementException { } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java index 39743e642c..f90b677237 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java @@ -74,9 +74,19 @@ public class WindowsDeviceManagementService implements DeviceManagementService { return null; } - @Override - public void installApplication(Operation operation, - List deviceIdentifiers) throws ApplicationManagementException { + @Override public void installApplicationForDevices(Operation operation, List deviceIdentifiers) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUsers(Operation operation, List strings) + throws ApplicationManagementException { + + } + + @Override public void installApplicationForUserRoles(Operation operation, List strings) + throws ApplicationManagementException { + } } From 5ff566baf8f22052462f598887f139990c72bb50 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Thu, 19 Nov 2015 11:15:26 +0530 Subject: [PATCH 6/9] Refactored Oracle DB scripts --- .../src/main/resources/dbscripts/plugins/android/oracle.sql | 2 +- .../src/main/resources/dbscripts/plugins/ios/oracle.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql index 8f00cd3316..1331581e79 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(8000) DEFAULT NULL, + DEVICE_INFO VARCHAR(4000) DEFAULT NULL, GCM_TOKEN VARCHAR(1000) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, IMSI VARCHAR(45) DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql index 315402e181..3ce0a85780 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql @@ -8,7 +8,7 @@ CREATE TABLE IOS_DEVICE ( MDM_TOKEN VARCHAR(100) DEFAULT NULL, UNLOCK_TOKEN VARCHAR(2000) DEFAULT NULL, CHALLENGE_TOKEN VARCHAR(45) DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) DEFAULT NULL, + DEVICE_INFO VARCHAR(4000) DEFAULT NULL, SERIAL VARCHAR(45) DEFAULT NULL, PRODUCT VARCHAR(45) DEFAULT NULL, IMEI VARCHAR(45) DEFAULT NULL, From 09f40c3027840a150034d59de0fbc17ff9614c10 Mon Sep 17 00:00:00 2001 From: mharindu Date: Fri, 20 Nov 2015 19:46:38 +0530 Subject: [PATCH 7/9] Adding a space in pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 1ece8c3c17..5c32110872 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ ~ under the License. --> + From 2be37f67745c58cc1ea66f01bbcb3ce0360a512e Mon Sep 17 00:00:00 2001 From: geethkokila Date: Fri, 20 Nov 2015 20:07:18 +0530 Subject: [PATCH 8/9] adding scm id for git hub --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 1ece8c3c17..e7c21da4bf 100644 --- a/pom.xml +++ b/pom.xml @@ -601,6 +601,9 @@ 3.0.21 2.2.4 1.0.2 + + + github-scm From be6d0647a6e8a5b1a5e818df6751ab2dcaf63d7c Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 20 Nov 2015 22:20:33 +0530 Subject: [PATCH 9/9] Add notify to plugin for ios operations --- .../mobile/impl/android/AndroidDeviceManagementService.java | 6 ++++++ .../mobile/impl/windows/WindowsDeviceManagementService.java | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java index 5bc70f4eab..18e088ee0f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java @@ -55,6 +55,12 @@ public class AndroidDeviceManagementService implements DeviceManagementService { return null; } + @Override + public void notifyOperationToDevices(Operation operation, List deviceIdentifiers) + throws DeviceManagementException { + + } + @Override public Application[] getApplications(String s, int i, int i2) throws ApplicationManagementException { return new Application[0]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java index f90b677237..45426cd357 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/windows/WindowsDeviceManagementService.java @@ -57,6 +57,11 @@ public class WindowsDeviceManagementService implements DeviceManagementService { return null; } + @Override public void notifyOperationToDevices(Operation operation, List deviceIdentifiers) + throws DeviceManagementException { + + } + @Override public Application[] getApplications(String s, int i, int i2) throws ApplicationManagementException { return new Application[0];