@Test public void testSetPushRegistrationId() throws Exception { appStateManager.getSession().start(context); BaseMPMessage message = manager.setPushRegistrationId(null, true); assertNull(message); message = manager.setPushRegistrationId("", true); assertNull(message); message = manager.setPushRegistrationId("coolgcmregid", true); assertNotNull(message); assertEquals(Constants.MessageType.PUSH_REGISTRATION, message.getMessageType()); assertEquals(message.getString(Constants.MessageKey.PUSH_TOKEN), "coolgcmregid"); assertEquals(message.getString(Constants.MessageKey.PUSH_TOKEN_TYPE), "google"); assertEquals(message.getBoolean(Constants.MessageKey.PUSH_REGISTER_FLAG), true); message = manager.setPushRegistrationId("coolgcmregid", false); assertEquals(message.getBoolean(Constants.MessageKey.PUSH_REGISTER_FLAG), false); Mockito.verify(messageHandler, Mockito.times(2)).sendMessage(Mockito.any(Message.class)); }
public BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag) { if (!MPUtility.isEmpty(token)) { try { mConfigManager.setPushInstanceId(token); BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_REGISTRATION) .timestamp(System.currentTimeMillis()) .build(mAppStateManager.getSession(), mLocation, mConfigManager.getMpid()); message.put(MessageKey.PUSH_TOKEN, token); message.put(MessageKey.PUSH_TOKEN_TYPE, "google"); message.put(MessageKey.PUSH_REGISTER_FLAG, registeringFlag); mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message)); return message; } catch (JSONException e) { Logger.warning("Failed to create mParticle push registration message."); } } return null; }
MessageManager implements MessageManagerCallbacks, ReportingManager { public BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag) { if (!MPUtility.isEmpty(token)) { try { mConfigManager.setPushInstanceId(token); BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_REGISTRATION) .timestamp(System.currentTimeMillis()) .build(mAppStateManager.getSession(), mLocation, mConfigManager.getMpid()); message.put(MessageKey.PUSH_TOKEN, token); message.put(MessageKey.PUSH_TOKEN_TYPE, "google"); message.put(MessageKey.PUSH_REGISTER_FLAG, registeringFlag); mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message)); return message; } catch (JSONException e) { Logger.warning("Failed to create mParticle push registration message."); } } return null; } }
MessageManager implements MessageManagerCallbacks, ReportingManager { public BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag) { if (!MPUtility.isEmpty(token)) { try { mConfigManager.setPushInstanceId(token); BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_REGISTRATION) .timestamp(System.currentTimeMillis()) .build(mAppStateManager.getSession(), mLocation, mConfigManager.getMpid()); message.put(MessageKey.PUSH_TOKEN, token); message.put(MessageKey.PUSH_TOKEN_TYPE, "google"); message.put(MessageKey.PUSH_REGISTER_FLAG, registeringFlag); mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message)); return message; } catch (JSONException e) { Logger.warning("Failed to create mParticle push registration message."); } } return null; } MessageManager();  MessageManager(Context appContext, ConfigManager configManager, MParticle.InstallType installType, AppStateManager appStateManager, MParticleDBManager dbManager, MessageHandler messageHandler, UploadHandler uploadHandler);  MessageManager(ConfigManager configManager, AppStateManager appStateManager, boolean devicePerformanceMetricsDisabled, MParticleDBManager dbManager, MParticleOptions options); }
MessageManager implements MessageManagerCallbacks, ReportingManager { public BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag) { if (!MPUtility.isEmpty(token)) { try { mConfigManager.setPushInstanceId(token); BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_REGISTRATION) .timestamp(System.currentTimeMillis()) .build(mAppStateManager.getSession(), mLocation, mConfigManager.getMpid()); message.put(MessageKey.PUSH_TOKEN, token); message.put(MessageKey.PUSH_TOKEN_TYPE, "google"); message.put(MessageKey.PUSH_REGISTER_FLAG, registeringFlag); mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message)); return message; } catch (JSONException e) { Logger.warning("Failed to create mParticle push registration message."); } } return null; } MessageManager();  MessageManager(Context appContext, ConfigManager configManager, MParticle.InstallType installType, AppStateManager appStateManager, MParticleDBManager dbManager, MessageHandler messageHandler, UploadHandler uploadHandler);  MessageManager(ConfigManager configManager, AppStateManager appStateManager, boolean devicePerformanceMetricsDisabled, MParticleDBManager dbManager, MParticleOptions options); boolean isDevicePerformanceMetricsDisabled(); void setDevicePerformanceMetricsDisabled(boolean disabled); static JSONObject getStateInfo(); static long getTotalMemory(); static long getSystemMemoryThreshold(); BaseMPMessage createFirstRunMessage(); BaseMPMessage startSession(InternalSession session); void updateSessionEnd(InternalSession session); void endSession(InternalSession session); void installReferrerUpdated(); BaseMPMessage logEvent(MPEvent event, String currentActivity); BaseMPMessage logEvent(CommerceEvent event); BaseMPMessage logScreen(MPEvent event, boolean started); BaseMPMessage logBreadcrumb(String breadcrumb); BaseMPMessage optOut(long time, boolean optOutStatus); BaseMPMessage logErrorEvent(String errorMessage, Throwable t, JSONObject attributes); BaseMPMessage logErrorEvent(String errorMessage, Throwable t, JSONObject attributes, boolean caught); BaseMPMessage logNetworkPerformanceEvent(long time, String method, String url, long length, long bytesSent, long bytesReceived, String requestString); BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag); void setSessionAttributes(); void startUploadLoop(); void doUpload(); @Override void messagesClearedForUpload(); void setLocation(@Nullable Location location); Location getLocation(); BaseMPMessage logStateTransition(String stateTransInit, String currentActivity,
                                            String launchUri, String launchExtras, String launchSourcePackage, long previousForegroundTime, long suspendedTime, int interruptions); void logNotification(ProviderCloudMessage cloudMessage, String appState); @Override void logNotification(int contentId, String payload, String appState, int newBehavior); void logProfileAction(String action); BaseMPMessage logUserIdentityChangeMessage(JSONObject newIdentity, JSONObject oldIdentity, JSONArray userIdentities, long mpId); BaseMPMessage logUserAttributeChangeMessage(String userAttributeKey, Object newValue, Object oldValue, boolean deleted, boolean isNewAttribute, long time, long mpId); @Override String getApiKey(); @SuppressLint("MissingPermission") @Override void delayedStart(); @Override void endUploadLoop(); @Override void checkForTrigger(BaseMPMessage message); void refreshConfiguration(); void initConfigDelayed(); @Override void log(JsonReportingMessage reportingMessage); @Override void logAll(List<? extends JsonReportingMessage> messageList); Map<String, Object> getUserAttributes(final UserAttributeListener listener, long mpId); void removeUserAttribute(String key, long mpId); @Override void attributeRemoved(String key, long mpId); void setUserAttribute(String key, Object value, long mpId); void setUserAttribute(String key, Object value, long mpId, boolean synchronously); void incrementUserAttribute(String key, int value, long mpId); synchronized DeviceAttributes getDeviceAttributes(); Map<MParticle.IdentityType, String> getUserIdentities(long mpId); JSONArray getUserIdentityJson(long mpId); void setDataConnection(NetworkInfo activeNetwork); BackgroundTaskHandler getTaskHandler(); Handler getMessageHandler(); MParticleDBManager getMParticleDBManager(); void disableHandlers(); void logAliasRequest(final AliasRequest aliasRequest); }
MessageManager implements MessageManagerCallbacks, ReportingManager { public BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag) { if (!MPUtility.isEmpty(token)) { try { mConfigManager.setPushInstanceId(token); BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_REGISTRATION) .timestamp(System.currentTimeMillis()) .build(mAppStateManager.getSession(), mLocation, mConfigManager.getMpid()); message.put(MessageKey.PUSH_TOKEN, token); message.put(MessageKey.PUSH_TOKEN_TYPE, "google"); message.put(MessageKey.PUSH_REGISTER_FLAG, registeringFlag); mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message)); return message; } catch (JSONException e) { Logger.warning("Failed to create mParticle push registration message."); } } return null; } MessageManager();  MessageManager(Context appContext, ConfigManager configManager, MParticle.InstallType installType, AppStateManager appStateManager, MParticleDBManager dbManager, MessageHandler messageHandler, UploadHandler uploadHandler);  MessageManager(ConfigManager configManager, AppStateManager appStateManager, boolean devicePerformanceMetricsDisabled, MParticleDBManager dbManager, MParticleOptions options); boolean isDevicePerformanceMetricsDisabled(); void setDevicePerformanceMetricsDisabled(boolean disabled); static JSONObject getStateInfo(); static long getTotalMemory(); static long getSystemMemoryThreshold(); BaseMPMessage createFirstRunMessage(); BaseMPMessage startSession(InternalSession session); void updateSessionEnd(InternalSession session); void endSession(InternalSession session); void installReferrerUpdated(); BaseMPMessage logEvent(MPEvent event, String currentActivity); BaseMPMessage logEvent(CommerceEvent event); BaseMPMessage logScreen(MPEvent event, boolean started); BaseMPMessage logBreadcrumb(String breadcrumb); BaseMPMessage optOut(long time, boolean optOutStatus); BaseMPMessage logErrorEvent(String errorMessage, Throwable t, JSONObject attributes); BaseMPMessage logErrorEvent(String errorMessage, Throwable t, JSONObject attributes, boolean caught); BaseMPMessage logNetworkPerformanceEvent(long time, String method, String url, long length, long bytesSent, long bytesReceived, String requestString); BaseMPMessage setPushRegistrationId(String token, boolean registeringFlag); void setSessionAttributes(); void startUploadLoop(); void doUpload(); @Override void messagesClearedForUpload(); void setLocation(@Nullable Location location); Location getLocation(); BaseMPMessage logStateTransition(String stateTransInit, String currentActivity,
                                            String launchUri, String launchExtras, String launchSourcePackage, long previousForegroundTime, long suspendedTime, int interruptions); void logNotification(ProviderCloudMessage cloudMessage, String appState); @Override void logNotification(int contentId, String payload, String appState, int newBehavior); void logProfileAction(String action); BaseMPMessage logUserIdentityChangeMessage(JSONObject newIdentity, JSONObject oldIdentity, JSONArray userIdentities, long mpId); BaseMPMessage logUserAttributeChangeMessage(String userAttributeKey, Object newValue, Object oldValue, boolean deleted, boolean isNewAttribute, long time, long mpId); @Override String getApiKey(); @SuppressLint("MissingPermission") @Override void delayedStart(); @Override void endUploadLoop(); @Override void checkForTrigger(BaseMPMessage message); void refreshConfiguration(); void initConfigDelayed(); @Override void log(JsonReportingMessage reportingMessage); @Override void logAll(List<? extends JsonReportingMessage> messageList); Map<String, Object> getUserAttributes(final UserAttributeListener listener, long mpId); void removeUserAttribute(String key, long mpId); @Override void attributeRemoved(String key, long mpId); void setUserAttribute(String key, Object value, long mpId); void setUserAttribute(String key, Object value, long mpId, boolean synchronously); void incrementUserAttribute(String key, int value, long mpId); synchronized DeviceAttributes getDeviceAttributes(); Map<MParticle.IdentityType, String> getUserIdentities(long mpId); JSONArray getUserIdentityJson(long mpId); void setDataConnection(NetworkInfo activeNetwork); BackgroundTaskHandler getTaskHandler(); Handler getMessageHandler(); MParticleDBManager getMParticleDBManager(); void disableHandlers(); void logAliasRequest(final AliasRequest aliasRequest); public UploadHandler mUploadHandler; }