Skip to content

Commit

Permalink
Apptentive Android SDK 5.8.3 (#236)
Browse files Browse the repository at this point in the history
Release Android SDK 5.8.3
  • Loading branch information
PoornimaApptentive authored Mar 16, 2022
1 parent ebaaa32 commit a236246
Show file tree
Hide file tree
Showing 25 changed files with 281 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @twinklesharma1311 @ChaseApptentive @PoornimaApptentive
* @ChaseApptentive @PoornimaApptentive
132 changes: 84 additions & 48 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,102 @@
language: android
dist: precise
dist: focal

language: java

jdk: openjdk11

env:
global:
- SNAPSHOT_REPOSITORY_USERNAME=travis
- SNAPSHOT_REPOSITORY_URL=http://54.183.158.246:8081/artifactory/apptentive-snapshots
- secure: pc2twMw60say0ASdXiJiRAD6tx9Qy82DIMw83qPijB2wyVHLpLbjptqBFyTYy4+JYthZ8xcB5Yretiv//AQS4wdDPsJNwOKUGXamm8IBx+1wnhG/R/ROz67Ibj4XWHIX24GaKN/MD8tCN9VPdeNEL1jysSEVxqqsvOGBsxitAyI=
jdk:
- oraclejdk8
# Android command line tools, check for updates here https://developer.android.com/studio/#command-tools
- COMMAND_LINE_TOOLS_VERSION=7583922
- ANDROID_HOME=$HOME/android-sdk
- TARGET_SDK_VERSION=31
- BUILD_TOOLS_VERSION=30.0.2

branches:
except:
- /^v\..*$/ # Exclude version tags

notifications:
slack:
secure: HejMl0EUociwGu+5djx95snbS+m/Yw8DseQKCSqeyWvMQLrAy8bi9oa89mZvXnvjqSVY3kKRZgJncEkQdIe9c7xwgNA9QYLkc7UVbXqga291HMoNnWaIMewD2ervbzM4aBQAHnkDr+GsXgb7+1YdOktIn8dA7jdIuB90ar4So9U=

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
# Only cache the latest version used by the Gradle wrapper
# List content in wrapper/dist sorted by modification time and remove entries starting by the second entry
- ls -d $HOME/.gradle/wrapper/dists/* -1t | tail -n +2 | xargs rm -rf
# Do not cache a few Gradle files/directories (see https://docs.travis-ci.com/user/languages/java/#caching)
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
- rm -f $HOME/.gradle/caches/*/executionHistory/executionHistory.bin
- rm -f $HOME/.gradle/caches/*/executionHistory/executionHistory.lock
- rm -f $HOME/.gradle/caches/*/fileContent/fileContent.lock
- rm -f $HOME/.gradle/caches/*/fileContent/java-modules.bin
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.lock
- rm -f $HOME/.gradle/caches/*/fileHashes/resourceHashesCache.bin
- rm -f $HOME/.gradle/caches/*/generated-gradle-jars/generated-gradle-jars.lock
- rm -f $HOME/.gradle/caches/*/javaCompile/jarAnalysis.bin
- rm -f $HOME/.gradle/caches/*/javaCompile/javaCompile.lock
- rm -f $HOME/.gradle/caches/*/kotlin-dsl/kotlin-dsl.lock
- rm -f $HOME/.gradle/caches/jars-9/*/buildSrc.jar
- rm -f $HOME/.gradle/caches/jars-9/*/buildSrc.jar.lock.lock
- rm -f $HOME/.gradle/caches/jars-9/*/buildSrc.jar.receipt
- rm -f $HOME/.gradle/caches/jars-9/jars-*.lock
- rm -f $HOME/.gradle/caches/journal-1/file-access.bin
- rm -f $HOME/.gradle/caches/journal-1/journal-1.lock
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -f $HOME/.gradle/caches/transforms-*/*/results.bin
- rm -f $HOME/.gradle/caches/transforms-*/*/transformed/android.jar
- rm -f $HOME/.gradle/caches/transforms-*/*/transformed/output.bin
- rm -f $HOME/.gradle/caches/transforms-*/transforms-*.lock
- rm -f $HOME/.gradle/caches/user-id.txt.lock

cache:
directories:
# Android SDK
- $HOME/android-cmdline-tools
- $HOME/android-sdk

# Gradle dependencies
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.android/build-cache
android:
components:
- tools # to get the new `repository-11.xml`
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- platform-tools
- build-tools-29.0.2
# - android-25
- android-29
- extra-android-m2repository
- extra-google-m2repository
- extra-google-google_play_services
- addon-google_apis-google-29
# - sys-img-armeabi-v7a-google_apis-25
# - sys-img-armeabi-v7a-android-25
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
before_install:
- yes | sdkmanager "platforms;android-29"
install: true

install:
- mkdir -p $HOME/android-cmdline-tools
# Download and unzip the Android command line tools (if not already there thanks to the cache mechanism)
- if test ! -e $HOME/android-cmdline-tools/cmdline-tools.zip ; then curl "https://dl.google.com/android/repository/commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip" > $HOME/android-cmdline-tools/cmdline-tools.zip ; fi
- unzip -qq -n $HOME/android-cmdline-tools/cmdline-tools.zip -d $HOME/android-cmdline-tools
- echo y | $HOME/android-cmdline-tools/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android-sdk "platform-tools"
- echo y | $HOME/android-cmdline-tools/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android-sdk "build-tools;${BUILD_TOOLS_VERSION}"
- echo y | $HOME/android-cmdline-tools/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android-sdk "platforms;android-${TARGET_SDK_VERSION}"

before_script:
# - echo "y" | android update sdk -a --no-ui --filter android-25
# - echo "y" | android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-25
# - android list targets | grep -E '^id:' | awk -F '"' '{$1=""; print $2}' # list all targets
# - echo no | android create avd --force -n test -t android-25 --abi google_apis/armeabi-v7a
# - emulator -avd test -no-window &
# - android-wait-for-emulator
# - adb shell input keyevent 82 &
# To see if the correct values have been extracted.
- echo TARGET_SDK_VERSION=$TARGET_SDK_VERSION
- echo BUILD_TOOLS_VERSION=$BUILD_TOOLS_VERSION

# Ensure Gradle wrapper is executable
- chmod +x gradlew

# Create directory for user Gradle settings
- mkdir -p $HOME/.gradle

# Reduce memory usage / avoid OutOfMemoryError with Gradle 4.10.3
- echo "org.gradle.jvmargs=-Xmx2048m -Xms512m -XX:MaxPermSize=768m" >> gradle.properties

# Enable Gradle's build cache. To be disabled for an Android RELEASE build.
- echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties

script:
- ./gradlew :apptentive:test -i
# - ./gradlew :test-app:connectedAndroidTest
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:installAutomatedDebug; fi
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:installAutomatedDebugAndroidTest; fi
# - if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:connectedAutomatedDebugAndroidTest -i; fi

after_script:
- >
if [ "$TRAVIS_BRANCH" = "develop" ]; then
./gradlew :apptentive:uploadArchives;
if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:assembleQaDebug; fi
if [ -d "apptentive-internal-app" ]; then ./gradlew :apptentive-internal-app:uploadQaDebugToHockeyApp; fi;
fi
after_failure:
#- echo " LOGCAT "; echo "========"; cat logcat.log; pkill -KILL -f adb
notifications:
slack:
secure: HejMl0EUociwGu+5djx95snbS+m/Yw8DseQKCSqeyWvMQLrAy8bi9oa89mZvXnvjqSVY3kKRZgJncEkQdIe9c7xwgNA9QYLkc7UVbXqga291HMoNnWaIMewD2ervbzM4aBQAHnkDr+GsXgb7+1YdOktIn8dA7jdIuB90ar4So9U=
addons:
# Fix OpenJDK builds
# https://github.com/travis-ci/travis-ci/issues/5227
hostname: short-hostname
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 2022-03-16 - v5.8.3

#### Fixes

* Fix conversation deserialization issue with conversation reset & throttle once per SDK version
* Register lifecycle callback on the main thread
* Remove all references of AndroidID

#### Improvements

* Add troubleshooting mode for Android 12+ with a Apptentive certificate
* Support long texts for alert dialog buttons

# 2022-01-06 - v5.8.0

#### Major changes
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.8.0|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.8.3|aar)

#### Reporting Bugs

Expand Down
5 changes: 0 additions & 5 deletions apptentive/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.returnDefaultValues = true
}
Expand Down
1 change: 1 addition & 0 deletions apptentive/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Optional for Apptentive -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application>
<provider android:name=".debug.ApptentiveAttachmentFileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class ApptentiveConfiguration {
private boolean shouldSanitizeLogMessages;
private boolean troubleshootingModeEnabled;
private Encryption encryption;
private boolean shouldCollectAndroidIdOnPreOreoTargets;
private TermsAndConditions surveyTermsAndConditions;
private Long interactionThrottle;

Expand All @@ -42,7 +41,6 @@ public ApptentiveConfiguration(@NonNull String apptentiveKey, @NonNull String ap
this.shouldEncryptStorage = false;
this.shouldSanitizeLogMessages = true;
this.troubleshootingModeEnabled = true;
this.shouldCollectAndroidIdOnPreOreoTargets = true;
this.surveyTermsAndConditions = null;
}

Expand Down Expand Up @@ -132,18 +130,22 @@ public ApptentiveConfiguration setTroubleshootingModeEnabled(boolean troubleshoo
}

/**
* Overrides if the SDK should collect Android ID on pre Android-O targets. If set to <code>false</code>
* a random value would be generated on the initial SDK launch and provided on each subsequent launch.
* AndroidID is no longer collected
*
* @since Apptentive Android SDK version 5.8.3
*/
@Deprecated
public void setShouldCollectAndroidIdOnPreOreoTargets(boolean shouldCollectAndroidIdOnPreOreoTargets) {
this.shouldCollectAndroidIdOnPreOreoTargets = shouldCollectAndroidIdOnPreOreoTargets;
}

/**
* Indicates if the SDK should collect Android ID on pre Android-O targets.
* AndroidID is no longer collected
*
* @since Apptentive Android SDK version 5.8.3
*/
@Deprecated
public boolean shouldCollectAndroidIdOnPreOreoTargets() {
return shouldCollectAndroidIdOnPreOreoTargets;
return false;
}

public TermsAndConditions getSurveyTermsAndConditions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public ApptentiveInternal(Context appContext) {
appRelease = null;
}

private ApptentiveInternal(Application application, ApptentiveConfiguration configuration, @NonNull String androidID) {
private ApptentiveInternal(Application application, ApptentiveConfiguration configuration) {
if (configuration == null) {
throw new IllegalArgumentException("Configuration is null");
}
Expand All @@ -180,8 +180,8 @@ private ApptentiveInternal(Application application, ApptentiveConfiguration conf
apptentiveHttpClient = new ApptentiveHttpClient(apptentiveKey, apptentiveSignature, getEndpointBase(globalSharedPrefs));

this.throttleUtils = new ThrottleUtils(configuration.getInteractionThrottle(), getGlobalSharedPrefs());
DeviceManager deviceManager = new DeviceManager(androidID);
conversationManager = new ConversationManager(appContext, Util.getInternalDir(appContext, CONVERSATIONS_DIR, true), encryption, deviceManager);
DeviceManager deviceManager = new DeviceManager();
conversationManager = new ConversationManager(appContext, Util.getInternalDir(appContext, CONVERSATIONS_DIR, true), encryption, deviceManager, throttleUtils);

appRelease = AppReleaseManager.generateCurrentAppRelease(application, this);
taskManager = new ApptentiveTaskManager(appContext, apptentiveHttpClient, encryption);
Expand Down Expand Up @@ -230,9 +230,7 @@ static void createInstance(@NonNull Application application, @NonNull Apptentive
if (sApptentiveInternal == null) {
ApptentiveLog.i("Registering Apptentive Android SDK %s", Constants.getApptentiveSdkVersion());
ApptentiveLog.v("ApptentiveKey=%s ApptentiveSignature=%s", apptentiveKey, apptentiveSignature);
// resolve Android ID
boolean shouldGenerateRandomAndroidID = Build.VERSION.SDK_INT < Build.VERSION_CODES.O && !configuration.shouldCollectAndroidIdOnPreOreoTargets();
String androidID = resolveAndroidID(application.getApplicationContext(), shouldGenerateRandomAndroidID);
sApptentiveInternal = new ApptentiveInternal(application, configuration);
dispatchOnConversationQueue(new DispatchTask() {
@Override
protected void execute() {
Expand All @@ -246,8 +244,6 @@ protected void execute() {
} else {
ApptentiveLog.i(TROUBLESHOOT, "Troubleshooting is disabled in the app configuration");
}

sApptentiveInternal = new ApptentiveInternal(application, configuration, androidID);
sApptentiveInternal.start();
}
});
Expand Down Expand Up @@ -1167,36 +1163,4 @@ private static void logException(Exception e) {
}

//endregion

//region Android ID

private static final String PREFS_NAME_ANDROID_ID = "com.apptentive.sdk.androidID";
private static final String PREFS_KEY_NAME_ANDROID_ID = "androidID";

private static String resolveAndroidID(Context context, boolean shouldGenerateRandomAndroidID) {
if (shouldGenerateRandomAndroidID) {
String existingAndroidID = loadAndroidID(context);
if (existingAndroidID != null) {
return existingAndroidID;
}

String androidID = StringUtils.randomAndroidID();
saveAndroidID(context, androidID);
return androidID;
}

return Util.getAndroidID(context);
}

private static String loadAndroidID(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME_ANDROID_ID, Context.MODE_PRIVATE);
return sharedPreferences.getString(PREFS_KEY_NAME_ANDROID_ID, null);
}

private static void saveAndroidID(Context context, String androidID) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_NAME_ANDROID_ID, Context.MODE_PRIVATE);
sharedPreferences.edit().putString(PREFS_KEY_NAME_ANDROID_ID, androidID).apply();
}

//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ public class ApptentiveNotifications {
public static final String NOTIFICATION_MESSAGE_STORE_DID_CHANGE = "MESSAGE_STORE_DID_CHANGE"; // { messageStore: MessageStore }

/**
* Sent when advertiser id was resolved.
* AdvertiserID is not collected
*/
public static final String NOTIFICATION_ADVERTISER_ID_DID_RESOLVE = "ADVERTISER_ID_DID_RESOLVE"; // { successful: Boolean, clientInfo: AdvertisingIdClientInfo }
@Deprecated
public static final String NOTIFICATION_ADVERTISER_ID_DID_RESOLVE = "ADVERTISER_ID_DID_RESOLVE";

/**
* Sent when advertiser id was resolved.
* Sent when Configuration fetch finishes.
*/
public static final String NOTIFICATION_CONFIGURATION_FETCH_DID_FINISH = "CONFIGURATION_FETCH_DID_FINISH"; // { configuration: Configuration, conversation: Conversation }

Expand Down
Loading

0 comments on commit a236246

Please sign in to comment.