diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index 289bfea8ad..e14b57dad8 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -106,7 +106,7 @@ public class AndroidAPIUtils { // PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); // GCMService gcmService = (GCMService) ctx.getOSGiService(GCMService.class, null); // if (gcmService == null) { -// String msg = "GCM service has not initialized."; +// String msg = "FCM service has not initialized."; // log.error(msg); // throw new IllegalStateException(msg); // } @@ -143,7 +143,7 @@ public class AndroidAPIUtils { DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers); // if (activity != null) { // GCMService gcmService = getGCMService(); -// if (gcmService.isGCMEnabled()) { +// if (gcmService.isFCMEnabled()) { // List deviceIDList = deviceIDHolder.getValidDeviceIDList(); // List devices = new ArrayList(deviceIDList.size()); // for (DeviceIdentifier deviceIdentifier : deviceIDList) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs index 5ace32cb31..f264830e84 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs @@ -52,15 +52,15 @@ -
+
-

diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js index ec2af96395..5d75b35d91 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js @@ -29,7 +29,7 @@ function isPositiveInteger(str) { var notifierTypeConstants = { "LOCAL": "1", - "GCM": "2" + "FCM": "2" }; // Constants to define platform types available var platformTypeConstants = { @@ -47,8 +47,8 @@ var responseCodes = { var configParams = { "NOTIFIER_TYPE": "notifierType", "NOTIFIER_FREQUENCY": "notifierFrequency", - "GCM_API_KEY": "gcmAPIKey", - "GCM_SENDER_ID": "gcmSenderId", + "FCM_API_KEY": "fcmAPIKey", + "FCM_SENDER_ID": "fcmSenderId", "ANDROID_EULA": "androidEula", "IOS_EULA": "iosEula", "CONFIG_COUNTRY": "configCountry", @@ -81,7 +81,7 @@ var configParams = { }; $(document).ready(function () { - $("#gcm-inputs").hide(); + $("#fcm-inputs").hide(); tinymce.init({ selector: "textarea", height:500, @@ -113,17 +113,17 @@ $(document).ready(function () { var config = data.configuration[i]; if (config.name == configParams["NOTIFIER_TYPE"]) { $("#android-config-notifier").val(config.value); - if (config.value != notifierTypeConstants["GCM"]) { - $("#gcm-inputs").hide(); + if (config.value != notifierTypeConstants["FCM"]) { + $("#fcm-inputs").hide(); $("#local-inputs").show(); } else { - $("#gcm-inputs").show(); + $("#fcm-inputs").show(); $("#local-inputs").hide(); } } else if (config.name == configParams["NOTIFIER_FREQUENCY"]) { $("input#android-config-notifier-frequency").val(config.value / 1000); - } else if (config.name == configParams["GCM_API_KEY"]) { - $("input#android-config-gcm-api-key").val(config.value); + } else if (config.name == configParams["FCM_API_KEY"]) { + $("input#android-config-fcm-api-key").val(config.value); } else if (config.name == configParams["ANDROID_EULA"]) { $("#android-eula").val(config.value); } @@ -139,12 +139,12 @@ $(document).ready(function () { $("#android-config-notifier").change(function () { var notifierType = $("#android-config-notifier").find("option:selected").attr("value"); - if (notifierType != notifierTypeConstants["GCM"]) { - $("#gcm-inputs").hide(); + if (notifierType != notifierTypeConstants["FCM"]) { + $("#fcm-inputs").hide(); $("#local-inputs").show(); } else { $("#local-inputs").hide(); - $("#gcm-inputs").show(); + $("#fcm-inputs").show(); } }); @@ -156,8 +156,8 @@ $(document).ready(function () { $("button#save-android-btn").click(function () { var notifierType = $("#android-config-notifier").find("option:selected").attr("value"); var notifierFrequency = $("input#android-config-notifier-frequency").val(); - var gcmAPIKey = $("input#android-config-gcm-api-key").val(); - var gcmSenderId = "sender_id"; + var fcmAPIKey = $("input#android-config-fcm-api-key").val(); + var fcmSenderId = "sender_id"; var androidLicense = tinyMCE.activeEditor.getContent(); var errorMsgWrapper = "#android-config-error-msg"; var errorMsg = "#android-config-error-msg span"; @@ -167,7 +167,7 @@ $(document).ready(function () { } else if (notifierType == notifierTypeConstants["LOCAL"] && !isPositiveInteger(notifierFrequency)) { $(errorMsg).text("Provided notifier frequency is invalid. "); $(errorMsgWrapper).removeClass("hidden"); - } else if (notifierType == notifierTypeConstants["GCM"] && !gcmAPIKey) { + } else if (notifierType == notifierTypeConstants["FCM"] && !fcmAPIKey) { $(errorMsg).text("FCM API Key is a required field. It cannot be empty."); $(errorMsgWrapper).removeClass("hidden"); } else { @@ -187,15 +187,15 @@ $(document).ready(function () { "contentType": "text" }; - var gcmKey = { - "name": configParams["GCM_API_KEY"], - "value": gcmAPIKey, + var fcmKey = { + "name": configParams["FCM_API_KEY"], + "value": fcmAPIKey, "contentType": "text" }; - var gcmId = { - "name": configParams["GCM_SENDER_ID"], - "value": gcmSenderId, + var fcmId = { + "name": configParams["FCM_SENDER_ID"], + "value": fcmSenderId, "contentType": "text" }; @@ -208,9 +208,9 @@ $(document).ready(function () { configList.push(type); configList.push(frequency); configList.push(androidEula); - if (notifierType == notifierTypeConstants["GCM"]) { - configList.push(gcmKey); - configList.push(gcmId); + if (notifierType == notifierTypeConstants["FCM"]) { + configList.push(fcmKey); + configList.push(fcmId); } addConfigFormData.type = platformTypeConstants["ANDROID"]; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java index e7022c15cc..f5b762db02 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java @@ -43,8 +43,8 @@ public class AndroidDeviceManagementService implements DeviceManagementService { public static final String DEVICE_TYPE_ANDROID = "android"; private static final String SUPER_TENANT_DOMAIN = "carbon.super"; private static final String NOTIFIER_PROPERTY = "notifierType"; - private static final String GCM_API_KEY = "gcmAPIKey"; - private static final String GCM_SENDER_ID = "gcmSenderId"; + private static final String FCM_API_KEY = "fcmAPIKey"; + private static final String FCM_SENDER_ID = "fcmSenderId"; private PolicyMonitoringManager policyMonitoringManager; @Override @@ -92,9 +92,9 @@ public class AndroidDeviceManagementService implements DeviceManagementService { int notifierType = Integer.parseInt(notifierValue); if (notifierType == 2) { HashMap config = new HashMap<>(); - config.put(GCM_API_KEY, this.getConfigProperty(configuration, GCM_API_KEY)); - config.put(GCM_SENDER_ID, this.getConfigProperty(configuration, GCM_SENDER_ID)); - return new PushNotificationConfig(AndroidPluginConstants.NotifierType.GCM, config); + config.put(FCM_API_KEY, this.getConfigProperty(configuration, FCM_API_KEY)); + config.put(FCM_SENDER_ID, this.getConfigProperty(configuration, FCM_SENDER_ID)); + return new PushNotificationConfig(AndroidPluginConstants.NotifierType.FCM, config); } } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java index 8df98747fb..416a4d90dd 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java @@ -52,7 +52,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = AndroidDAOFactory.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + + "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE" + " FROM AD_DEVICE WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(selectDBQuery); @@ -73,7 +73,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE)); Map propertyMap = new HashMap(); - propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN)); + propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN)); propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); mobileDevice.setDeviceProperties(propertyMap); @@ -103,7 +103,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = AndroidDAOFactory.getConnection(); String createDBQuery = - "INSERT INTO AD_DEVICE(DEVICE_ID, GCM_TOKEN, DEVICE_INFO, SERIAL, " + + "INSERT INTO AD_DEVICE(DEVICE_ID, FCM_TOKEN, DEVICE_INFO, SERIAL, " + "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " + "OS_VERSION, DEVICE_MODEL, OS_BUILD_DATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; @@ -111,7 +111,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ stmt.setString(1, mobileDevice.getMobileDeviceId()); Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(2, properties.get(AndroidPluginConstants.GCM_TOKEN)); + stmt.setString(2, properties.get(AndroidPluginConstants.FCM_TOKEN)); stmt.setString(3, properties.get(AndroidPluginConstants.DEVICE_INFO)); stmt.setString(4, mobileDevice.getSerial()); stmt.setString(5, mobileDevice.getVendor()); @@ -149,13 +149,13 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = AndroidDAOFactory.getConnection(); String updateDBQuery = - "UPDATE AD_DEVICE SET GCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " + + "UPDATE AD_DEVICE SET FCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " + "MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " + "IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ?, OS_BUILD_DATE = ? WHERE DEVICE_ID = ?"; stmt = conn.prepareStatement(updateDBQuery); Map properties = mobileDevice.getDeviceProperties(); - stmt.setString(1, properties.get(AndroidPluginConstants.GCM_TOKEN)); + stmt.setString(1, properties.get(AndroidPluginConstants.FCM_TOKEN)); stmt.setString(2, properties.get(AndroidPluginConstants.DEVICE_INFO)); stmt.setString(3, mobileDevice.getSerial()); stmt.setString(4, mobileDevice.getVendor()); @@ -227,7 +227,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ try { conn = AndroidDAOFactory.getConnection(); String selectDBQuery = - "SELECT DEVICE_ID, GCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + + "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " + "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE " + "FROM AD_DEVICE"; stmt = conn.prepareStatement(selectDBQuery); @@ -247,7 +247,7 @@ public class AndroidDeviceDAOImpl implements MobileDeviceDAO{ mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE)); Map propertyMap = new HashMap<>(); - propertyMap.put(AndroidPluginConstants.GCM_TOKEN, rs.getString(AndroidPluginConstants.GCM_TOKEN)); + propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN)); propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO)); propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME)); mobileDevice.setDeviceProperties(propertyMap); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMResult.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMResult.java similarity index 89% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMResult.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMResult.java index f9c7703587..530a56e30a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMResult.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMResult.java @@ -16,12 +16,12 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.gcm; +package org.wso2.carbon.device.mgt.mobile.android.impl.fcm; /** - * Represents model object for holding GCM response data. + * Represents model object for holding FCM response data. */ -public class GCMResult { +public class FCMResult { private String errorMsg; private String msg; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMService.java similarity index 67% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMService.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMService.java index bfa1685faa..15978f7a9d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMService.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.gcm; +package org.wso2.carbon.device.mgt.mobile.android.impl.fcm; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -26,17 +26,17 @@ import java.util.ArrayList; import java.util.List; /** - * GCM notification service implementation for Android platform. + * FCM notification service implementation for Android platform. */ -public class GCMService { +public class FCMService { - private static final Log log = LogFactory.getLog(GCMService.class); + private static final Log log = LogFactory.getLog(FCMService.class); private static final String NOTIFIER_TYPE = "notifierType"; - private static final String GCM_NOTIFIER_CODE = "2"; + private static final String FCM_NOTIFIER_CODE = "2"; - public boolean isGCMEnabled() { - String notifierType = GCMUtil.getConfigurationProperty(NOTIFIER_TYPE); - if (GCM_NOTIFIER_CODE.equals(notifierType)) { + public boolean isFCMEnabled() { + String notifierType = FCMUtil.getConfigurationProperty(NOTIFIER_TYPE); + if (FCM_NOTIFIER_CODE.equals(notifierType)) { return true; } return false; @@ -45,20 +45,20 @@ public class GCMService { public void sendNotification(String messageData, Device device) { List devices = new ArrayList<>(1); devices.add(device); - GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + FCMResult result = FCMUtil.sendWakeUpCall(messageData, devices); if (result.getStatusCode() != 200) { - log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); + log.error("Exception occurred while sending the FCM notification : " + result.getErrorMsg()); } } public void sendNotification(String messageData, List devices) { - GCMResult result = GCMUtil.sendWakeUpCall(messageData, devices); + FCMResult result = FCMUtil.sendWakeUpCall(messageData, devices); if (result.getStatusCode() != 200) { - log.error("Exception occurred while sending the GCM notification : " + result.getErrorMsg()); + log.error("Exception occurred while sending the FCM notification : " + result.getErrorMsg()); } } public void resetTenantConfigCache() { - GCMUtil.resetTenantConfigCache(); + FCMUtil.resetTenantConfigCache(); } } \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMUtil.java similarity index 81% rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMUtil.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMUtil.java index 381468bdfb..c561022684 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/gcm/GCMUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/fcm/FCMUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.android.impl.gcm; +package org.wso2.carbon.device.mgt.mobile.android.impl.fcm; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -45,32 +45,32 @@ import java.util.HashMap; import java.util.List; /** - * Implements utility methods used by GCMService. + * Implements utility methods used by FCMService. */ -public class GCMUtil { +public class FCMUtil { - private static final Log log = LogFactory.getLog(GCMService.class); + private static final Log log = LogFactory.getLog(FCMService.class); - private final static String GCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send"; - private static final String GCM_API_KEY = "gcmAPIKey"; + private final static String FCM_ENDPOINT = "https://fcm.googleapis.com/fcm/send"; + private static final String FCM_API_KEY = "fcmAPIKey"; 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(); + public static FCMResult sendWakeUpCall(String message, List devices) { + FCMResult result = new FCMResult(); - byte[] bytes = getGCMRequest(message, getGCMTokens(devices)).getBytes(); + byte[] bytes = getFCMRequest(message, getFCMTokens(devices)).getBytes(); HttpURLConnection conn; try { - conn = (HttpURLConnection) (new URL(GCM_ENDPOINT)).openConnection(); + conn = (HttpURLConnection) (new URL(FCM_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)); + conn.setRequestProperty("Authorization", "key=" + getConfigurationProperty(FCM_API_KEY)); OutputStream out = conn.getOutputStream(); out.write(bytes); @@ -86,7 +86,7 @@ public class GCMUtil { } 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); + log.error("Exception occurred while sending the FCM request.", ex); } return result; @@ -114,16 +114,16 @@ public class GCMUtil { 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); + private static String getFCMRequest(String message, List registrationIds) { + JsonObject fcmRequest = new JsonObject(); + fcmRequest.addProperty("delay_while_idle", false); + fcmRequest.addProperty("time_to_live", TIME_TO_LIVE); - //Add message to GCM request + //Add message to FCM request JsonObject data = new JsonObject(); if (message != null && !message.isEmpty()) { data.addProperty("data", message); - gcmRequest.add("data", data); + fcmRequest.add("data", data); } //Set device reg-ids @@ -135,27 +135,27 @@ public class GCMUtil { regIds.add(new JsonPrimitive(regId)); } - gcmRequest.add("registration_ids", regIds); - return gcmRequest.toString(); + fcmRequest.add("registration_ids", regIds); + return fcmRequest.toString(); } - private static List getGCMTokens(List devices) { + private static List getFCMTokens(List devices) { List tokens = new ArrayList<>(devices.size()); for (Device device : devices) { - tokens.add(getGCMToken(device.getProperties())); + tokens.add(getFCMToken(device.getProperties())); } return tokens; } - private static String getGCMToken(List properties) { - String gcmToken = null; + private static String getFCMToken(List properties) { + String fcmToken = null; for (Device.Property property : properties) { - if (AndroidPluginConstants.GCM_TOKEN.equals(property.getName())) { - gcmToken = property.getValue(); + if (AndroidPluginConstants.FCM_TOKEN.equals(property.getName())) { + fcmToken = property.getValue(); break; } } - return gcmToken; + return fcmToken; } public static String getConfigurationProperty(String property) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java index 3cea5588c7..09b278e2c3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java @@ -25,7 +25,7 @@ public final class AndroidPluginConstants { //Properties related to AD_DEVICE table public static final String DEVICE_ID = "DEVICE_ID"; - public static final String GCM_TOKEN = "GCM_TOKEN"; + public static final String FCM_TOKEN = "FCM_TOKEN"; public static final String DEVICE_INFO = "DEVICE_INFO"; public static final String SERIAL = "SERIAL"; public static final String DEVICE_MODEL = "DEVICE_MODEL"; @@ -50,7 +50,7 @@ public final class AndroidPluginConstants { throw new AssertionError(); } - public static final String GCM = "GCM"; + public static final String FCM = "FCM"; public static final String LOCAL = "LOCAL"; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java index ee4a7c0217..028c6aeda3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.android.internal; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService; +import org.wso2.carbon.device.mgt.mobile.android.impl.fcm.FCMService; import org.wso2.carbon.registry.core.service.RegistryService; /** @@ -29,7 +29,7 @@ public class AndroidDeviceManagementDataHolder { private RegistryService registryService; private DeviceManagementService androidDeviceManagementService; - private GCMService gcmService; + private FCMService fcmService; private static AndroidDeviceManagementDataHolder thisInstance = new AndroidDeviceManagementDataHolder(); @@ -57,11 +57,11 @@ public class AndroidDeviceManagementDataHolder { this.androidDeviceManagementService = androidDeviceManagementService; } - public GCMService getGCMService() { - return gcmService; + public FCMService getFCMService() { + return fcmService; } - public void setGCMService(GCMService gcmService) { - this.gcmService = gcmService; + public void setFCMService(FCMService fcmService) { + this.fcmService = fcmService; } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java index 66e441ecb9..c1ecae0a48 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java @@ -25,7 +25,7 @@ import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService; -import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService; +import org.wso2.carbon.device.mgt.mobile.android.impl.fcm.FCMService; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.registry.core.service.RegistryService; @@ -50,7 +50,7 @@ public class AndroidDeviceManagementServiceComponent { private static final Log log = LogFactory.getLog(AndroidDeviceManagementServiceComponent.class); private ServiceRegistration androidServiceRegRef; - private ServiceRegistration gcmServiceRegRef; + private ServiceRegistration fcmServiceRegRef; protected void activate(ComponentContext ctx) { @@ -61,14 +61,14 @@ public class AndroidDeviceManagementServiceComponent { BundleContext bundleContext = ctx.getBundleContext(); DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); - GCMService gcmService = new GCMService(); + FCMService fcmService = new FCMService(); // androidServiceRegRef = // bundleContext.registerService(DeviceManagementService.class.getName(), // androidDeviceManagementService, null); - gcmServiceRegRef = - bundleContext.registerService(GCMService.class.getName(), gcmService, null); + fcmServiceRegRef = + bundleContext.registerService(FCMService.class.getName(), fcmService, null); // Policy management service @@ -78,7 +78,7 @@ public class AndroidDeviceManagementServiceComponent { AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService( androidDeviceManagementService); - AndroidDeviceManagementDataHolder.getInstance().setGCMService(gcmService); + AndroidDeviceManagementDataHolder.getInstance().setFCMService(fcmService); if (log.isDebugEnabled()) { log.debug("Android Mobile Device Management Service Component has been successfully activated"); @@ -96,8 +96,8 @@ public class AndroidDeviceManagementServiceComponent { if (androidServiceRegRef != null) { androidServiceRegRef.unregister(); } - if (gcmServiceRegRef != null) { - gcmServiceRegRef.unregister(); + if (fcmServiceRegRef != null) { + fcmServiceRegRef.unregister(); } if (log.isDebugEnabled()) { log.debug( 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.platform.configuration/public/js/platform-configuration.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.platform.configuration/public/js/platform-configuration.js index 79ce06bcfb..e64afcccef 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.platform.configuration/public/js/platform-configuration.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.platform.configuration/public/js/platform-configuration.js @@ -30,8 +30,8 @@ var responseCodes = { var configParams = { "NOTIFIER_TYPE": "notifierType", "NOTIFIER_FREQUENCY": "notifierFrequency", - "GCM_API_KEY": "gcmAPIKey", - "GCM_SENDER_ID": "gcmSenderId", + "FCM_API_KEY": "fcmAPIKey", + "FCM_SENDER_ID": "fcmSenderId", "ANDROID_EULA": "androidEula", "IOS_EULA": "iosEula", "CONFIG_COUNTRY": "configCountry", diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index f929fd93d7..1c2c28219a 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -275,11 +275,11 @@ - - - - - + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android:${carbon.devicemgt.plugins.version} + + org.wso2.carbon.core.server:${carbon.kernel.version} diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql index 3352ba8de1..9eed9b2d5e 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql @@ -4,7 +4,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, + `FCM_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/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql index 3cd14ad6ad..2c22d4729b 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql @@ -4,7 +4,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_DEVICE]') AND TYPE IN (N'U')) CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL, - GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, + FCM_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/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql index 3fc6fd32c0..b7dcbe73ca 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql @@ -3,7 +3,7 @@ -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, + `FCM_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/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql index ba4b4239bf..703757e903 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql @@ -4,7 +4,7 @@ CREATE TABLE AD_DEVICE ( DEVICE_ID VARCHAR(45) NOT NULL , DEVICE_INFO VARCHAR(4000) DEFAULT NULL, - GCM_TOKEN VARCHAR(1000) DEFAULT NULL, + FCM_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/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql index 95c4709cc6..20a014b866 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/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(1000) NULL DEFAULT NULL, + FCM_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/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index be5e78b8d2..c18d183042 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -52,6 +52,10 @@ true + + + + jdbc/MobileAndroidDM_DS @@ -60,7 +64,7 @@ DEVICE_ID - GCM_TOKEN + FCM_TOKEN DEVICE_INFO IMEI IMSI