Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Various Android console updates

Rich Turner4776b7a3257b
diff --git a/console/android/src/main/java/org/openremote/android/MainActivity.java b/console/android/src/main/java/org/openremote/android/MainActivity.java
index 1fb7a208a..9003fb574 100644
--- a/console/android/src/main/java/org/openremote/android/MainActivity.java
+++ b/console/android/src/main/java/org/openremote/android/MainActivity.java
@@ -39,6 +39,7 @@ import android.widget.Toast;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.firebase.iid.FirebaseInstanceId;
import org.json.JSONException;
import org.json.JSONObject;
import org.openremote.android.service.GeofenceProvider;
@@ -138,10 +139,24 @@ public class MainActivity extends Activity {
webView.restoreState(savedInstanceState);
} else {
initializeWebView();
+ if (!getIntent().hasExtra("url")) {
+ String url = getClientUrl();
+ LOG.fine("Loading web view: " + url);
+ webView.loadUrl(url);
+ }
+ }
+
+ if (getIntent().hasExtra("url")) {
String url = getClientUrl();
- if (getIntent().hasExtra("url")) {
- url = url + getIntent().getStringExtra("url");
+ String intentUrl = getIntent().getStringExtra("url");
+ if (intentUrl != null) {
+ if (intentUrl.startsWith("http") || intentUrl.startsWith("https")) {
+ url = intentUrl;
+ } else {
+ url = url + intentUrl;
+ }
}
+
LOG.fine("Loading web view: " + url);
webView.loadUrl(url);
}
@@ -473,7 +488,7 @@ public class MainActivity extends Activity {
notifyClient(response);
} else if (action.equalsIgnoreCase("PROVIDER_ENABLE")) {
// TODO: Implement topic support
- String fcmToken = sharedPreferences.getString(getString(R.string.SHARED_PREF_FCM_TOKEN), null);
+ String fcmToken = FirebaseInstanceId.getInstance().getToken();
Map<String, Object> response = new HashMap<>();
response.put("action", "PROVIDER_ENABLE");
response.put("provider", "push");
diff --git a/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java b/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
index 8d17bdf1b..63d7885d1 100644
--- a/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
+++ b/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
@@ -6,28 +6,18 @@ import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;
-import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.firebase.messaging.RemoteMessage;
-
import org.openremote.android.service.AlertAction;
import org.openremote.android.service.AlertNotification;
import org.openremote.android.service.TokenService;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-
public class ORFirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
private static final Logger LOG = Logger.getLogger(ORFirebaseMessagingService.class.getName());
@@ -35,9 +25,10 @@ public class ORFirebaseMessagingService extends com.google.firebase.messaging.Fi
private TokenService tokenService;
public class MyBroadcastReceiver extends BroadcastReceiver {
+
@Override
public void onReceive(Context context, Intent intent) {
- LOG.info("TODO: Remove notification");
+ LOG.info("TODO: Remove notification");
}
}
@@ -70,41 +61,54 @@ public class ORFirebaseMessagingService extends com.google.firebase.messaging.Fi
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
LOG.fine("Received message from: " + remoteMessage.getFrom());
- // Check if message contains a data payload.
- if (remoteMessage.getData().size() > 0) {
- LOG.fine("Message data payload: " + remoteMessage.getData());
- }
-
- // Check if message contains a notification payload.
+ // If the message contains a notification then we assume it has been shown to the user
if (remoteMessage.getNotification() != null) {
LOG.fine("Message contains notification body: " + remoteMessage.getNotification().getBody());
- }
+ } else if (remoteMessage.getData() != null && !remoteMessage.getData().isEmpty()) {
+ // Check if message contains a data payload with or-title or-body and actions
- tokenService.getAlerts(new Callback<List<AlertNotification>>() {
- @Override
- public void onResponse(Call<List<AlertNotification>> call, Response<List<AlertNotification>> response) {
- List<AlertNotification> alertNotifications = response.body();
- Set<String> actualAlertIds = new HashSet<>();
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- Set<String> previousAlertIds = sharedPreferences.getStringSet(getString(R.string.SHARED_PREF_OPENED_ALERT), new HashSet<String>());
-
- for (AlertNotification alertNotification : alertNotifications) {
- if (!previousAlertIds.contains(alertNotification.getId().toString())) {
- sendNotification(alertNotification);
- previousAlertIds.add(alertNotification.getId().toString());
- }
- actualAlertIds.add(alertNotification.getId().toString());
- LOG.fine("Retrieved alert notifications from service: " + alertNotification);
+ LOG.fine("Message data payload: " + remoteMessage.getData());
+ String title = remoteMessage.getData().get("or-title");
+ String body = remoteMessage.getData().get("or-body");
+ String actionsJson = remoteMessage.getData().get("actions");
+ AlertAction[] actions = null;
+
+ if (actionsJson != null && actionsJson.length() > 0) {
+ try {
+ actions = new ObjectMapper().readValue(actionsJson, AlertAction[].class);
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to de-serialise alert actions", e);
}
- previousAlertIds.retainAll(actualAlertIds);
- sharedPreferences.edit().putStringSet(getString(R.string.SHARED_PREF_OPENED_ALERT) ,previousAlertIds ).commit();
}
- @Override
- public void onFailure(Call<List<AlertNotification>> call, Throwable t) {
- LOG.log(Level.SEVERE, "Error retrieving alert", t);
- }
- });
+ handleNotification(title, body, actions);
+ }
+
+// tokenService.getAlerts(new Callback<List<AlertNotification>>() {
+// @Override
+// public void onResponse(Call<List<AlertNotification>> call, Response<List<AlertNotification>> response) {
+// List<AlertNotification> alertNotifications = response.body();
+// Set<String> actualAlertIds = new HashSet<>();
+// SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+// Set<String> previousAlertIds = sharedPreferences.getStringSet(getString(R.string.SHARED_PREF_OPENED_ALERT), new HashSet<String>());
+//
+// for (AlertNotification alertNotification : alertNotifications) {
+// if (!previousAlertIds.contains(alertNotification.getId().toString())) {
+// sendNotification(alertNotification);
+// previousAlertIds.add(alertNotification.getId().toString());
+// }
+// actualAlertIds.add(alertNotification.getId().toString());
+// LOG.fine("Retrieved alert notifications from service: " + alertNotification);
+// }
+// previousAlertIds.retainAll(actualAlertIds);
+// sharedPreferences.edit().putStringSet(getString(R.string.SHARED_PREF_OPENED_ALERT) ,previousAlertIds ).commit();
+// }
+//
+// @Override
+// public void onFailure(Call<List<AlertNotification>> call, Throwable t) {
+// LOG.log(Level.SEVERE, "Error retrieving alert", t);
+// }
+// });
// Also if you intend on generating your own notifications as a result of a received FCM
@@ -113,6 +117,42 @@ public class ORFirebaseMessagingService extends com.google.firebase.messaging.Fi
// [END receive_message]
+ private void handleNotification(String title, String body, AlertAction[] actions) {
+ Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+
+ // TODO: ID to come from backend
+ int id = title.hashCode() + body.hashCode();
+
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
+ .setContentTitle(title)
+ .setStyle(new NotificationCompat.BigTextStyle().bigText(body))
+ .setContentText(body)
+ .setSmallIcon(R.drawable.notification_icon)
+ .setWhen(0)
+ .setPriority(Notification.PRIORITY_MAX)
+ .setSound(defaultSoundUri);
+
+ for (AlertAction alertAction : actions) {
+ Intent actionIntent = new Intent(this, ORMessagingActionService.class);
+
+ actionIntent.putExtra("notificationId", id);
+ actionIntent.putExtra("action", alertAction);
+ actionIntent.setAction(Long.toString(System.currentTimeMillis()));
+ PendingIntent actionPendingIntent = PendingIntent.getService(this,
+ 0,
+ actionIntent,
+ PendingIntent.FLAG_ONE_SHOT);
+ notificationBuilder = notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.empty,
+ alertAction.getTitle(),
+ actionPendingIntent));
+ }
+
+ LOG.fine("Showing notification (" + actions.length + " actions): " + body);
+
+ NotificationManager notificationManager =
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.notify(id, notificationBuilder.build());
+ }
private void sendNotification(AlertNotification alertNotification) {
@@ -120,35 +160,43 @@ public class ORFirebaseMessagingService extends com.google.firebase.messaging.Fi
Intent intent = new Intent(this, ORMessagingActionService.class);
intent.putExtra("notification", alertNotification);
- PendingIntent pendingIntent = PendingIntent.getService(this, notificationId, intent, PendingIntent.FLAG_ONE_SHOT);
+ PendingIntent pendingIntent = PendingIntent.getService(this,
+ notificationId,
+ intent,
+ PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
- .setContentTitle(alertNotification.getTitle())
- .setStyle(new NotificationCompat.BigTextStyle().bigText(alertNotification.getMessage()))
- .setContentText(alertNotification.getMessage())
- .setDeleteIntent(pendingIntent)
- .setSmallIcon(R.drawable.notification_icon)
- .setWhen(0)
- .setPriority(Notification.PRIORITY_MAX)
- .setSound(defaultSoundUri);
+ .setContentTitle(alertNotification.getTitle())
+ .setStyle(new NotificationCompat.BigTextStyle().bigText(alertNotification.getMessage()))
+ .setContentText(alertNotification.getMessage())
+ .setDeleteIntent(pendingIntent)
+ .setSmallIcon(R.drawable.notification_icon)
+ .setWhen(0)
+ .setPriority(Notification.PRIORITY_MAX)
+ .setSound(defaultSoundUri);
for (AlertAction alertAction : alertNotification.getActions()) {
- Intent actionIntent = new Intent(this, ORMessagingActionService.class);
+ Intent actionIntent = new Intent(this, ORMessagingActionService.class);
actionIntent.putExtra("action", alertAction);
- actionIntent.putExtra("url", alertNotification.getAppUrl());
+ actionIntent.putExtra("url", alertAction.getAppUrl());
actionIntent.putExtra("notification", alertNotification);
actionIntent.setAction(Long.toString(System.currentTimeMillis()));
- PendingIntent actionPendingIntent = PendingIntent.getService(this, notificationId, actionIntent, PendingIntent.FLAG_ONE_SHOT);
- notificationBuilder = notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.empty, alertAction.getTitle(), actionPendingIntent));
+ PendingIntent actionPendingIntent = PendingIntent.getService(this,
+ notificationId,
+ actionIntent,
+ PendingIntent.FLAG_ONE_SHOT);
+ notificationBuilder = notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.empty,
+ alertAction.getTitle(),
+ actionPendingIntent));
}
LOG.fine("Showing notification (" + alertNotification.getActions().size() + " actions): " + alertNotification.getMessage());
NotificationManager notificationManager =
- (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notificationBuilder.build());
}
}
\ No newline at end of file
diff --git a/console/android/src/main/java/org/openremote/android/ORMessagingActionService.java b/console/android/src/main/java/org/openremote/android/ORMessagingActionService.java
index 9d64587f3..3eafc6c62 100644
--- a/console/android/src/main/java/org/openremote/android/ORMessagingActionService.java
+++ b/console/android/src/main/java/org/openremote/android/ORMessagingActionService.java
@@ -30,15 +30,35 @@ public class ORMessagingActionService extends IntentService {
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
this.sendBroadcast(it);
- AlertNotification notification = (AlertNotification) intent.getSerializableExtra("notification");
- tokenService.deleteAlert(notification.getId());
+ if (intent.hasExtra("notification")) {
+ AlertNotification notification = (AlertNotification) intent.getSerializableExtra("notification");
+ tokenService.deleteAlert(notification.getId());
+ NotificationManager manager = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
+ manager.cancel(notification.getId().hashCode());
+ } else if (intent.hasExtra("notificationId")) {
+ int id = intent.getIntExtra("notificationId", 0);
+ if (id != 0) {
+ NotificationManager manager = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
+ manager.cancel(id);
+ }
+ }
- NotificationManager manager = (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
- manager.cancel(notification.getId().hashCode());
AlertAction alertAction = (AlertAction) intent.getSerializableExtra("action");
- if(alertAction != null && AlertNotification.ActionType.ACTUATOR.equals(alertAction.getType())) {
- tokenService.executeAction(alertAction);
+ if(alertAction != null) {
+ if (AlertNotification.ActionType.ACTUATOR.equals(alertAction.getType())) {
+ tokenService.executeAction(alertAction);
+ } else if (alertAction.getAppUrl() != null) {
+ // TODO: decide how to handle absolute URLs (i.e. open in the normal browser or inside the console?)
+ // For now replicated behaviour of iOS for important demo
+ Intent activityIntent = new Intent(this, MainActivity.class);
+ activityIntent.setAction(Intent.ACTION_MAIN);
+ activityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
+ activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+ Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ activityIntent.putExtra("url", alertAction.getAppUrl());
+ startActivity(activityIntent);
+ }
} else if (intent.hasExtra("url")) {
Intent activityIntent = new Intent(this, MainActivity.class);
activityIntent.setAction(Intent.ACTION_MAIN);
diff --git a/console/android/src/main/java/org/openremote/android/service/AlertAction.java b/console/android/src/main/java/org/openremote/android/service/AlertAction.java
index 5d9dd685b..28b72fa2d 100644
--- a/console/android/src/main/java/org/openremote/android/service/AlertAction.java
+++ b/console/android/src/main/java/org/openremote/android/service/AlertAction.java
@@ -1,6 +1,5 @@
package org.openremote.android.service;
-
import java.io.Serializable;
public class AlertAction implements Serializable {
@@ -8,6 +7,7 @@ public class AlertAction implements Serializable {
private String title;
private String assetId;
private String attributeName;
+ private String appUrl;
private String rawJson;
public String getAssetId() {
@@ -53,6 +53,14 @@ public class AlertAction implements Serializable {
this.title = title;
}
+ public String getAppUrl() {
+ return appUrl;
+ }
+
+ public void setAppUrl(String appUrl) {
+ this.appUrl = appUrl;
+ }
+
@Override
public String toString() {
return "AlertAction{" +
diff --git a/console/android/src/main/java/org/openremote/android/service/GeofenceTransitionsIntentService.kt b/console/android/src/main/java/org/openremote/android/service/GeofenceTransitionsIntentService.kt
index 55dfc4a8a..7ec809cb9 100644
--- a/console/android/src/main/java/org/openremote/android/service/GeofenceTransitionsIntentService.kt
+++ b/console/android/src/main/java/org/openremote/android/service/GeofenceTransitionsIntentService.kt
@@ -7,6 +7,11 @@ import android.util.Log
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.android.gms.location.Geofence
import com.google.android.gms.location.GeofencingEvent
+import org.openremote.android.R
+import org.openremote.android.service.TokenService.getUnsafeOkHttpClient
+import retrofit2.Retrofit
+import retrofit2.converter.jackson.JacksonConverterFactory
+import retrofit2.converter.scalars.ScalarsConverterFactory
import java.io.DataOutputStream
import java.net.HttpURLConnection
import java.net.URL
@@ -14,7 +19,10 @@ import kotlin.text.Charsets.UTF_8
class GeofenceTransitionsIntentService : IntentService("or-geofence") {
+
+
override fun onHandleIntent(intent: Intent?) {
+
val geofencingEvent = GeofencingEvent.fromIntent(intent)
if (geofencingEvent.hasError()) {
Log.e(TAG, "Error handling geofence event")
@@ -26,6 +34,12 @@ class GeofenceTransitionsIntentService : IntentService("or-geofence") {
val geofence = geofencingEvent.triggeringGeofences.first()
val postUrl = GeofenceProvider.geoPostUrls[geofence.requestId]
+ val url = URL("$baseUrl$postUrl")
+ val connection = url.openConnection() as HttpURLConnection
+ connection.setRequestProperty("Content-Type", "application/json")
+ connection.requestMethod = "POST"
+ connection.connectTimeout = 10000
+
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {
val postJson = {
@@ -35,49 +49,16 @@ class GeofenceTransitionsIntentService : IntentService("or-geofence") {
}
}
- val url = URL("$baseUrl$postUrl")
- val connection = url.openConnection() as HttpURLConnection
- connection.requestMethod = "POST"
- connection.connectTimeout = 100000
connection.doOutput = true
-
- val postData: ByteArray = ObjectMapper().writeValueAsString(postJson).toByteArray(UTF_8)
-
- connection.setRequestProperty("charset", "utf-8")
- connection.setRequestProperty("Content-lenght", postData.size.toString())
- connection.setRequestProperty("Content-Type", "application/json")
-
- try {
- val outputStream = DataOutputStream(connection.outputStream)
- outputStream.write(postData)
- outputStream.flush()
- } catch (exception: Exception) {
- print(exception)
- }
+ connection.setChunkedStreamingMode(0)
+ connection.outputStream
+ ObjectMapper().writeValue(connection.outputStream, postJson)
}
- if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {
- val postJson = hashMapOf<String, Any>()
-
- val url = URL("$baseUrl$postUrl")
- val connection = url.openConnection() as HttpURLConnection
- connection.requestMethod = "POST"
- connection.connectTimeout = 100000
- connection.doOutput = true
-
- val postData: ByteArray = ObjectMapper().writeValueAsString(postJson).toByteArray(UTF_8)
-
- connection.setRequestProperty("charset", "utf-8")
- connection.setRequestProperty("Content-lenght", postData.size.toString())
- connection.setRequestProperty("Content-Type", "application/json")
-
- try {
- val outputStream = DataOutputStream(connection.outputStream)
- outputStream.write(postData)
- outputStream.flush()
- } catch (exception: Exception) {
- print(exception)
- }
+ try {
+ connection.outputStream.flush()
+ } catch (exception: Exception) {
+ print(exception)
}
}
}
\ No newline at end of file
diff --git a/console/android/src/main/java/org/openremote/android/service/NotificationService.java b/console/android/src/main/java/org/openremote/android/service/RestApiResource.java
similarity index 77%
rename from console/android/src/main/java/org/openremote/android/service/NotificationService.java
rename to console/android/src/main/java/org/openremote/android/service/RestApiResource.java
index 4c1aaa768..63a401702 100644
--- a/console/android/src/main/java/org/openremote/android/service/NotificationService.java
+++ b/console/android/src/main/java/org/openremote/android/service/RestApiResource.java
@@ -3,18 +3,11 @@ package org.openremote.android.service;
import java.util.List;
+import org.json.JSONObject;
import retrofit2.Call;
-import retrofit2.http.Body;
-import retrofit2.http.DELETE;
-import retrofit2.http.Field;
-import retrofit2.http.FormUrlEncoded;
-import retrofit2.http.GET;
-import retrofit2.http.Header;
-import retrofit2.http.Headers;
-import retrofit2.http.PUT;
-import retrofit2.http.Path;
-
-public interface NotificationService {
+import retrofit2.http.*;
+
+public interface RestApiResource {
@FormUrlEncoded
@PUT("/{realm}/notification/token")
Call<Void> updateToken(@Path("realm") String realm, @Header("Authorization") String authorization, @Field("token") String token, @Field("device_id") String deviceId, @Field("device_type") String deviceType);
@@ -29,4 +22,7 @@ public interface NotificationService {
@PUT("/{realm}/asset/{assetId}/attribute/{attributeName}")
@Headers("Content-Type:application/json")
Call<Void> updateAssetAction(@Path("realm") String realm, @Header("Authorization") String accessToken,@Path("assetId") String assetId,@Path("attributeName") String attributeName,@Body String rawJson);
+
+ @POST("{realm}/asset/public/{assetId}/updateLocation")
+ Call<Void> updatePublicAssetLocation(@Path("realm") String realm, String assetId, @Body JSONObject json);
}
diff --git a/console/android/src/main/java/org/openremote/android/service/TokenService.java b/console/android/src/main/java/org/openremote/android/service/TokenService.java
index ad4bc2712..2e5440478 100644
--- a/console/android/src/main/java/org/openremote/android/service/TokenService.java
+++ b/console/android/src/main/java/org/openremote/android/service/TokenService.java
@@ -39,7 +39,7 @@ public class TokenService {
private final String deviceIdKey;
private final String realm;
private final OAuth2Service oauth2Service;
- private final NotificationService notificationService;
+ private final RestApiResource restApiResource;
public TokenService(Context context) {
Retrofit.Builder builder = new Retrofit.Builder()
@@ -52,7 +52,7 @@ public class TokenService {
Retrofit retrofit = builder.build();
oauth2Service = retrofit.create(OAuth2Service.class);
- notificationService = retrofit.create(NotificationService.class);
+ restApiResource = retrofit.create(RestApiResource.class);
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
refreshTokenKey = context.getString(R.string.SHARED_PREF_REFRESH_TOKEN);
fcmTokenKey = context.getString(R.string.SHARED_PREF_FCM_TOKEN);
@@ -140,7 +140,7 @@ public class TokenService {
withAccessToken(new TokenCallback() {
@Override
public void onToken(String accessToken) {
- Call call = notificationService.updateToken(realm, accessToken, fcmToken, id, "ANDROID");
+ Call call = restApiResource.updateToken(realm, accessToken, fcmToken, id, "ANDROID");
call.enqueue(new Callback() {
@Override
@@ -181,7 +181,7 @@ public class TokenService {
withAccessToken(new TokenCallback() {
@Override
public void onToken(String accessToken) {
- notificationService.getAlertNotification(realm, accessToken).enqueue(callback);
+ restApiResource.getAlertNotification(realm, accessToken).enqueue(callback);
}
@Override
@@ -202,7 +202,7 @@ public class TokenService {
withAccessToken(new TokenCallback() {
@Override
public void onToken(String accessToken) throws IOException {
- notificationService.deleteNotification(realm, accessToken,id).enqueue(new Callback<Void>() {
+ restApiResource.deleteNotification(realm, accessToken, id).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.code() != 204) {
@@ -232,7 +232,7 @@ public class TokenService {
withAccessToken(new TokenCallback() {
@Override
public void onToken(String accessToken) throws IOException {
- notificationService.updateAssetAction(realm, accessToken,alertAction.getAssetId(),alertAction.getAttributeName(),alertAction.getRawJson()).enqueue(new Callback<Void>() {
+ restApiResource.updateAssetAction(realm, accessToken, alertAction.getAssetId(), alertAction.getAttributeName(), alertAction.getRawJson()).enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.code() != 204) {
@@ -260,7 +260,7 @@ public class TokenService {
}
- private static OkHttpClient getUnsafeOkHttpClient() {
+ static OkHttpClient getUnsafeOkHttpClient() {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[] {