Skip to content

Commit

Permalink
Merge pull request #175 from apptentive/branch_5.3.3
Browse files Browse the repository at this point in the history
Release 5.3.3
  • Loading branch information
weeeBox authored Dec 5, 2018
2 parents fc76707 + c5cf277 commit 6046d56
Show file tree
Hide file tree
Showing 110 changed files with 877 additions and 214 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 2018-12-05 - v5.3.3

#### Fixes

* Fixed rare Message Center crash due to concurrency issues.

#### Changes

* Improved encryption stability.
* Allow users to make sequential `login` calls for the same user name.

# 2018-08-30 - v5.3.2

#### Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use your app, to talk to them at the right time, and in the right way.

##### [Release Notes](https://learn.apptentive.com/knowledge-base/android-sdk-release-notes/)

##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.3.2|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.3.3|aar)

#### Reporting Bugs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.apptentive.android.sdk.conversation.Conversation;
import com.apptentive.android.sdk.conversation.ConversationDispatchTask;
import com.apptentive.android.sdk.conversation.ConversationProxy;
import com.apptentive.android.sdk.debug.ErrorMetrics;
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks;
import com.apptentive.android.sdk.model.CommerceExtendedData;
import com.apptentive.android.sdk.model.CompoundMessage;
Expand Down Expand Up @@ -128,6 +129,7 @@ public static void register(Application application, ApptentiveConfiguration con
ApptentiveInternal.createInstance(application, configuration);
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while registering Apptentive SDK");
logException(e);
}
}

Expand Down Expand Up @@ -176,6 +178,7 @@ public static String getPersonEmail() {
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION,"Exception while getting person email");
logException(e);
}
return null;
}
Expand Down Expand Up @@ -215,6 +218,7 @@ public static String getPersonName() {
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, "Exception while getting person name");
logException(e);
}
return null;
}
Expand Down Expand Up @@ -497,6 +501,7 @@ public static boolean isApptentivePushNotification(Intent intent) {
return ApptentiveInternal.getApptentivePushNotificationData(intent) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification intent");
logException(e);
}
return false;
}
Expand All @@ -516,6 +521,7 @@ public static boolean isApptentivePushNotification(Bundle bundle) {
return ApptentiveInternal.getApptentivePushNotificationData(bundle) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification bundle");
logException(e);
}
return false;
}
Expand All @@ -534,6 +540,7 @@ public static boolean isApptentivePushNotification(Map<String, String> data) {
return ApptentiveInternal.getApptentivePushNotificationData(data) != null;
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while checking for Apptentive push notification data");
logException(e);
}
return false;
}
Expand Down Expand Up @@ -722,6 +729,7 @@ public static String getTitleFromApptentivePush(Bundle bundle) {
JSONObject parseJson = new JSONObject(parseDataString);
return parseJson.optString(ApptentiveInternal.TITLE_DEFAULT, null);
} catch (JSONException e) {
logException(e);
return null;
}
}
Expand All @@ -734,6 +742,7 @@ public static String getTitleFromApptentivePush(Bundle bundle) {
}
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while getting title from Apptentive push");
logException(e);
}
return null;
}
Expand Down Expand Up @@ -764,6 +773,7 @@ public static String getBodyFromApptentivePush(Bundle bundle) {
JSONObject parseJson = new JSONObject(parseDataString);
return parseJson.optString(ApptentiveInternal.BODY_PARSE, null);
} catch (JSONException e) {
logException(e);
return null;
}
}
Expand All @@ -778,6 +788,7 @@ public static String getBodyFromApptentivePush(Bundle bundle) {
}
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while getting body from Apptentive push");
logException(e);
}
return null;
}
Expand All @@ -802,6 +813,7 @@ public static String getTitleFromApptentivePush(Map<String, String> data) {
return data.get(ApptentiveInternal.TITLE_DEFAULT);
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while getting title from Apptentive push");
logException(e);
}
return null;
}
Expand All @@ -826,6 +838,7 @@ public static String getBodyFromApptentivePush(Map<String, String> data) {
return data.get(ApptentiveInternal.BODY_DEFAULT);
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Exception while getting body from Apptentive push");
logException(e);
}
return null;
}
Expand All @@ -848,6 +861,7 @@ public static void setRatingProvider(IRatingProvider ratingProvider) {
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while setting rating provider");
logException(e);
}
}

Expand All @@ -865,6 +879,7 @@ public static void putRatingProviderArg(String key, String value) {
}
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while putting rating provider arg");
logException(e);
}
}

Expand Down Expand Up @@ -1012,7 +1027,7 @@ public static int getUnreadMessageCount() {
}
} catch (Exception e) {
ApptentiveLog.e(MESSAGES, e, "Exception while getting unread message count");
MetricModule.sendError(e, null, null);
logException(e);
}
return 0;
}
Expand Down Expand Up @@ -1428,8 +1443,9 @@ protected void execute() {
loginGuarded(token, callback);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while trying to login");
logException(e);

notifyFailure(callback, "Exception while trying to login");
MetricModule.sendError(e, null, null);
}
}
});
Expand Down Expand Up @@ -1507,7 +1523,7 @@ public static void setAuthenticationFailedListener(AuthenticationFailedListener
ApptentiveInternal.getInstance().setAuthenticationFailedListener(listener);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Error in Apptentive.setUnreadMessagesListener()");
MetricModule.sendError(e, null, null);
logException(e);
}
}

Expand All @@ -1519,7 +1535,7 @@ public static void clearAuthenticationFailedListener() {
ApptentiveInternal.getInstance().setAuthenticationFailedListener(null);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while clearing authentication listener");
MetricModule.sendError(e, null, null);
logException(e);
}
}

Expand Down Expand Up @@ -1605,6 +1621,7 @@ public static AuthenticationFailedReason parse(String errorType, String error) {
return ret;
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, "Error parsing unknown Apptentive.AuthenticationFailedReason: %s", errorType);
logException(e);
}
return UNKNOWN;
}
Expand Down Expand Up @@ -1663,6 +1680,14 @@ protected boolean execute(Conversation conversation) {

//endregion

//region Error Reporting

private static void logException(Exception e) {
ErrorMetrics.logException(e); // TODO: add more context info
}

//endregion

/**
* <p>This type represents a <a href="http://semver.org/">semantic version</a>. It can be initialized
* with a string or a long, and there is no limit to the number of parts your semantic version can
Expand Down Expand Up @@ -1727,6 +1752,7 @@ public void toJsonObject() {
ret.put(TYPE, version);
} catch (JSONException e) {
ApptentiveLog.e(e, "Error creating Apptentive.Version.");
logException(e);
}
}

Expand Down Expand Up @@ -1804,6 +1830,7 @@ public JSONObject toJSONObject() {
ret.put(SEC, sec);
} catch (JSONException e) {
ApptentiveLog.e(e, "Error creating Apptentive.DateTime.");
logException(e);
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.apptentive.android.sdk.conversation.Conversation;
import com.apptentive.android.sdk.conversation.ConversationDispatchTask;
import com.apptentive.android.sdk.debug.ErrorMetrics;
import com.apptentive.android.sdk.module.engagement.EngagementModule;
import com.apptentive.android.sdk.module.engagement.interaction.model.Interaction;
import com.apptentive.android.sdk.notifications.ApptentiveNotification;
Expand Down Expand Up @@ -62,6 +63,10 @@ public void onReceiveNotification(ApptentiveNotification notification) {

//region Helpers

protected void logException(Exception e) {
ErrorMetrics.logException(e); // TODO: add more context info
}

protected void engageInternal(final String eventName) {
dispatchConversationTask(new ConversationDispatchTask() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;

import com.apptentive.android.sdk.Apptentive.LoginCallback;
import com.apptentive.android.sdk.comm.ApptentiveHttpClient;
import com.apptentive.android.sdk.conversation.Conversation;
import com.apptentive.android.sdk.conversation.ConversationManager;
import com.apptentive.android.sdk.conversation.ConversationProxy;
import com.apptentive.android.sdk.debug.ErrorMetrics;
import com.apptentive.android.sdk.debug.LogMonitor;
import com.apptentive.android.sdk.encryption.SecurityManager;
import com.apptentive.android.sdk.lifecycle.ApptentiveActivityLifecycleCallbacks;
Expand All @@ -54,6 +56,7 @@
import com.apptentive.android.sdk.util.AdvertiserManager.AdvertisingIdClientInfo;
import com.apptentive.android.sdk.util.threading.DispatchQueue;
import com.apptentive.android.sdk.util.threading.DispatchTask;

import org.json.JSONException;
import org.json.JSONObject;

Expand Down Expand Up @@ -127,6 +130,7 @@ public static PushAction parse(String name) {
return PushAction.valueOf(name);
} catch (IllegalArgumentException e) {
ApptentiveLog.w(PUSH, "This version of the SDK can't handle push action '%s'", name);
logException(e);
}
return unknown;
}
Expand Down Expand Up @@ -243,6 +247,7 @@ protected void execute() {

} catch (Exception e) {
ApptentiveLog.e(e, "Exception while initializing ApptentiveInternal instance");
logException(e);
}
} else {
ApptentiveLog.w("Apptentive instance is already initialized");
Expand Down Expand Up @@ -306,6 +311,7 @@ private boolean setApplicationDefaultTheme(int themeResId) {
}
} catch (Resources.NotFoundException e) {
ApptentiveLog.e("Theme Res id not found");
logException(e);
}
return false;
}
Expand Down Expand Up @@ -409,6 +415,10 @@ private void onAppLaunch(final Context appContext) {
checkConversationQueue();

if (isConversationActive()) {
Conversation conversation = getConversation();
if (!conversation.hasSession()) {
conversation.startSession();
}
engageInternal(appContext, EventPayload.EventLabel.app__launch.getLabelName());
}
}
Expand All @@ -418,6 +428,7 @@ private void onAppExit(final Context appContext) {

if (isConversationActive()) {
engageInternal(appContext, EventPayload.EventLabel.app__exit.getLabelName());
getConversation().endSession();
}
}

Expand Down Expand Up @@ -476,8 +487,8 @@ public void updateApptentiveInteractionTheme(Context context, Resources.Theme in

// Step 5: Update status bar color
/* Obtain the default status bar color. When an Apptentive Modal interaction is shown,
* a translucent overlay would be applied on top of statusBarColorDefault
*/
* a translucent overlay would be applied on top of statusBarColorDefault
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int transparentColor = ContextCompat.getColor(context, android.R.color.transparent);
TypedArray a = interactionTheme.obtainStyledAttributes(new int[]{android.R.attr.statusBarColor});
Expand Down Expand Up @@ -539,6 +550,7 @@ private boolean start() {

} catch (Exception e) {
ApptentiveLog.e(e, "Unexpected error while reading application or package info.");
logException(e);
bRet = false;
}

Expand Down Expand Up @@ -728,6 +740,7 @@ static String getApptentivePushNotificationData(Bundle pushBundle) {
return parseJson.optString(APPTENTIVE_PUSH_EXTRA_KEY, null);
} catch (JSONException e) {
ApptentiveLog.e(PUSH, "com.parse.Data is corrupt: %s", parseDataString);
logException(e);
return null;
}
} else if (pushBundle.containsKey(PUSH_EXTRA_KEY_UA)) { // Urban Airship
Expand Down Expand Up @@ -806,7 +819,7 @@ static PendingIntent generatePendingIntentFromApptentivePushData(Conversation co
}
} catch (Exception e) {
ApptentiveLog.e(PUSH, e, "Error parsing JSON from push notification.");
MetricModule.sendError(e, "Parsing Apptentive Push", apptentivePushData);
logException(e);
}
}
return null;
Expand Down Expand Up @@ -1076,11 +1089,16 @@ public void onReceiveNotification(ApptentiveNotification notification) {
if (notification.hasName(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE)) {
Conversation conversation = notification.getRequiredUserInfo(NOTIFICATION_KEY_CONVERSATION, Conversation.class);
if (conversation.hasActiveState()) {

// if conversation was just created - start a new session
if (!conversation.hasSession()) {
conversation.startSession();
}

checkSendVersionChanges(conversation);
updateConversationAdvertiserIdentifier(conversation);
}
}
else if (notification.hasName(NOTIFICATION_CONVERSATION_WILL_LOGOUT)) {
} else if (notification.hasName(NOTIFICATION_CONVERSATION_WILL_LOGOUT)) {
Conversation conversation = notification.getRequiredUserInfo(NOTIFICATION_KEY_CONVERSATION, Conversation.class);
conversation.addPayload(new LogoutPayload());
} else if (notification.hasName(NOTIFICATION_AUTHENTICATION_FAILED)) {
Expand Down Expand Up @@ -1146,6 +1164,7 @@ private void storeManifestResponse(Context context, String manifest) {
Util.writeText(file, manifest);
} catch (Exception e) {
ApptentiveLog.e(CONVERSATION, e, "Exception while trying to save engagement manifest data");
logException(e);
}
}

Expand All @@ -1164,9 +1183,18 @@ private void updateConversationAdvertiserIdentifier(Conversation conversation) {
conversation.getDevice().setAdvertiserId(advertiserId);
}
} catch (Exception e) {
ApptentiveLog.e(ADVERTISER_ID, e,"Exception while updating conversation advertiser id");
ApptentiveLog.e(ADVERTISER_ID, e, "Exception while updating conversation advertiser id");
logException(e);
}
}

//endregion

//region Error Reporting

private static void logException(Exception e) {
ErrorMetrics.logException(e); // TODO: add more context info
}

//endregion
}
Loading

0 comments on commit 6046d56

Please sign in to comment.