Skip to content

Commit

Permalink
Merge pull request #240 from adjust/v4103
Browse files Browse the repository at this point in the history
V4103
  • Loading branch information
nonelse authored Nov 18, 2016
2 parents bbcfd50 + af4648d commit 6280f7e
Show file tree
Hide file tree
Showing 39 changed files with 589 additions and 347 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ atlassian-ide-plugin.xml

# add exception for private libraries
google-services.json

# generated native code
.externalNativeBuild/
29 changes: 29 additions & 0 deletions Adjust/adjust/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Sets the minimum version of CMake required to build the native
# library. You should either keep the default value or only pass a
# value of 3.4.0 or lower.

cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds it for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
native-lib

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
src/main/cpp/native-lib.cpp )


# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in the
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
native-lib )
30 changes: 22 additions & 8 deletions Adjust/adjust/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
apply plugin: 'com.android.library'

def getVersionName() {
return "4.10.3"
}

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 25
buildToolsVersion "25.0.0"

defaultConfig {
minSdkVersion 9
targetSdkVersion 24
targetSdkVersion 25
versionCode 1
versionName "4.10.2"
versionName getVersionName()
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}

Expand All @@ -17,14 +31,14 @@ dependencies {
}

task clearJar(type: Delete) {
delete '${project.buildDir}/outputs/adjust.jar'
delete "build/outputs/adjust-${getVersionName()}.jar"
}

task makeJar(type: Copy) {
from('${project.buildDir}/intermediates/bundles/release/')
into('${project.buildDir}/libs/')
from('build/intermediates/bundles/release/')
into('build/outputs/')
include('classes.jar')
rename ('classes.jar', 'adjust.jar')
rename ('classes.jar', "adjust-${getVersionName()}.jar")
}

makeJar.dependsOn(clearJar, build)
Expand Down
3 changes: 1 addition & 2 deletions Adjust/adjust/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
package="com.adjust.sdk">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="24" />
android:targetSdkVersion="25" />
<application />
</manifest>
25 changes: 25 additions & 0 deletions Adjust/adjust/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <jni.h>

extern "C"
jstring
Java_com_adjust_sdk_DeviceInfo_nativeISA(
JNIEnv *env,
jobject /* this */) {
const char* isa = "";
#if defined(__arm__)
isa = "arm";
#elif defined(__aarch64__)
isa = "arm64";
#elif defined(__mips__) && !defined(__LP64__)
isa = "mips";
#elif defined(__mips__) && defined(__LP64__)
isa = "mips64";
#elif defined(__i386__)
isa = "x86";
#elif defined(__x86_64__)
isa = "x86_64";
#else
isa= "none";
#endif
return env->NewStringUTF(isa);
}
15 changes: 9 additions & 6 deletions Adjust/adjust/src/main/java/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ public void setPushToken(final String token) {
scheduledExecutor.submit(new Runnable() {
@Override
public void run() {
if (activityState == null) {
startI();
}
setPushTokenI(token);
}
});
Expand Down Expand Up @@ -668,8 +671,7 @@ public void run() {

attributionHandler = AdjustFactory.getAttributionHandler(this,
attributionPackage,
toSendI(false),
adjustConfig.hasAttributionChangedListener());
toSendI(false));

sdkClickHandler = AdjustFactory.getSdkClickHandler(toSendI(true));

Expand Down Expand Up @@ -720,6 +722,7 @@ private void processSessionI() {
activityState.resetSessionAttributes(now);
activityState.enabled = internalState.isEnabled();
activityState.updatePackages = internalState.isToUpdatePackages();
activityState.pushToken = adjustConfig.pushToken;
writeActivityStateI();
return;
}
Expand Down Expand Up @@ -1425,11 +1428,11 @@ private void setPushTokenI(String token) {
}

long now = System.currentTimeMillis();
PackageBuilder clickPackageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, now);
clickPackageBuilder.pushToken = token;
PackageBuilder infoPackageBuilder = new PackageBuilder(adjustConfig, deviceInfo, activityState, now);
infoPackageBuilder.pushToken = token;

ActivityPackage clickPackage = clickPackageBuilder.buildClickPackage(Constants.PUSH);
sdkClickHandler.sendSdkClick(clickPackage);
ActivityPackage infoPackage = infoPackageBuilder.buildInfoPackage(Constants.PUSH);
sdkClickHandler.sendSdkClick(infoPackage);

// save new push token
activityState.pushToken = token;
Expand Down
6 changes: 5 additions & 1 deletion Adjust/adjust/src/main/java/com/adjust/sdk/ActivityKind.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.adjust.sdk;

public enum ActivityKind {
UNKNOWN, SESSION, EVENT, CLICK, ATTRIBUTION, REVENUE, REATTRIBUTION;
UNKNOWN, SESSION, EVENT, CLICK, ATTRIBUTION, REVENUE, REATTRIBUTION, INFO;

public static ActivityKind fromString(String string) {
if ("session".equals(string)) {
Expand All @@ -12,6 +12,8 @@ public static ActivityKind fromString(String string) {
return CLICK;
} else if ("attribution".equals(string)) {
return ATTRIBUTION;
} else if ("info".equals(string)) {
return INFO;
} else {
return UNKNOWN;
}
Expand All @@ -28,6 +30,8 @@ public String toString() {
return "click";
case ATTRIBUTION:
return "attribution";
case INFO:
return "info";
default:
return "unknown";
}
Expand Down
4 changes: 1 addition & 3 deletions Adjust/adjust/src/main/java/com/adjust/sdk/AdjustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AdjustConfig {
boolean allowSuppressLogLevel;
ILogger logger;
String userAgent;
String pushToken;

public static final String ENVIRONMENT_SANDBOX = "sandbox";
public static final String ENVIRONMENT_PRODUCTION = "production";
Expand Down Expand Up @@ -127,9 +128,6 @@ public void setDelayStart(double delayStart) {
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public boolean hasAttributionChangedListener() {
return onAttributionChangedListener != null;
}

public boolean hasListener() {
return onAttributionChangedListener != null
Expand Down
7 changes: 3 additions & 4 deletions Adjust/adjust/src/main/java/com/adjust/sdk/AdjustFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ public static IActivityHandler getActivityHandler(AdjustConfig config) {

public static IAttributionHandler getAttributionHandler(IActivityHandler activityHandler,
ActivityPackage attributionPackage,
boolean startsSending,
boolean hasListener) {
boolean startsSending) {
if (attributionHandler == null) {
return new AttributionHandler(activityHandler, attributionPackage, startsSending, hasListener);
return new AttributionHandler(activityHandler, attributionPackage, startsSending);
}
attributionHandler.init(activityHandler, attributionPackage, startsSending, hasListener);
attributionHandler.init(activityHandler, attributionPackage, startsSending);
return attributionHandler;
}

Expand Down
10 changes: 8 additions & 2 deletions Adjust/adjust/src/main/java/com/adjust/sdk/AdjustInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class AdjustInstance {
private long referrerClickTime;
private ActivityHandler activityHandler;
private List<IRunActivityHandler> sessionParametersActionsArray;
private String pushToken;

private static ILogger getLogger() {
return AdjustFactory.getLogger();
Expand All @@ -27,6 +28,7 @@ public void onCreate(AdjustConfig adjustConfig) {
adjustConfig.referrer = this.referrer;
adjustConfig.referrerClickTime = this.referrerClickTime;
adjustConfig.sessionParametersActionsArray = sessionParametersActionsArray;
adjustConfig.pushToken = pushToken;

activityHandler = ActivityHandler.getInstance(adjustConfig);
}
Expand Down Expand Up @@ -200,8 +202,12 @@ public void teardown(boolean deleteState) {
}

public void setPushToken(String token) {
if (!checkActivityHandler()) return;
activityHandler.setPushToken(token);
pushToken = token;

if (activityHandler != null) {
activityHandler.setPushToken(token);
return;
}
}

private boolean checkActivityHandler() {
Expand Down
14 changes: 3 additions & 11 deletions Adjust/adjust/src/main/java/com/adjust/sdk/AttributionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class AttributionHandler implements IAttributionHandler {
private static final String ATTRIBUTION_TIMER_NAME = "Attribution timer";

private boolean paused;
private boolean hasListener;

public URL lastUrlUsed;

Expand All @@ -47,8 +46,7 @@ public void teardown() {

public AttributionHandler(IActivityHandler activityHandler,
ActivityPackage attributionPackage,
boolean startsSending,
boolean hasListener) {
boolean startsSending) {
scheduledExecutor = new CustomScheduledExecutor("AttributionHandler");
logger = AdjustFactory.getLogger();

Expand All @@ -63,18 +61,16 @@ public void run() {
this.logger.error("Timer not initialized, attribution handler is disabled");
}

init(activityHandler, attributionPackage, startsSending, hasListener);
init(activityHandler, attributionPackage, startsSending);
}

@Override
public void init(IActivityHandler activityHandler,
ActivityPackage attributionPackage,
boolean startsSending,
boolean hasListener) {
boolean startsSending) {
this.activityHandlerWeakRef = new WeakReference<IActivityHandler>(activityHandler);
this.attributionPackage = attributionPackage;
this.paused = !startsSending;
this.hasListener = hasListener;
}

@Override
Expand Down Expand Up @@ -190,10 +186,6 @@ private void checkDeeplinkI(AttributionResponseData attributionResponseData) {
}

private void getAttributionI() {
if (!hasListener) {
return;
}

if (paused) {
logger.debug("Attribution handler is paused");
return;
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion Adjust/adjust/src/main/java/com/adjust/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Constants {
String BASE_URL = "https://app.adjust.com";
String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android4.10.2";
String CLIENT_SDK = "android4.10.3";
String LOGTAG = "Adjust";
String REFTAG = "reftag";
String DEEPLINK = "deeplink";
Expand Down
23 changes: 21 additions & 2 deletions Adjust/adjust/src/main/java/com/adjust/sdk/DeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ class DeviceInfo {
String displayHeight;
String hardwareName;
String abi;
String buildName;
String vmInstructionSet;
Map<String, String> pluginKeys;

DeviceInfo(Context context, String sdkPrefix) {
Resources resources = context.getResources();
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
Configuration configuration = resources.getConfiguration();
Locale locale = configuration.locale;
Locale locale = Util.getLocale(configuration);
int screenLayout = configuration.screenLayout;
boolean isGooglePlayServicesAvailable = Util.getPlayAdId(context) != null;
String macAddress = getMacAddress(context, isGooglePlayServicesAvailable);
ContentResolver contentResolver = context.getContentResolver();

packageName = getPackageName(context);
appVersion = getAppVersion(context);
Expand All @@ -83,6 +86,8 @@ class DeviceInfo {
macShortMd5 = getMacShortMd5(macAddress);
hardwareName = getHardwareName();
abi = getABI();
buildName = getBuildName();
vmInstructionSet = getVmInstructionSet();
}

private String getMacAddress(Context context, boolean isGooglePlayServicesAvailable) {
Expand Down Expand Up @@ -154,10 +159,13 @@ private String getCountry(Locale locale) {
return locale.getCountry();
}

private String getBuildName() {
return Build.ID;
}

private String getHardwareName() {
return Build.DISPLAY;
}

private String getScreenSize(int screenLayout) {
int screenSize = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;

Expand Down Expand Up @@ -281,4 +289,15 @@ private String getABI() {

return SupportedABIS[0];
}

private String getVmInstructionSet() {
String instructionSet = Util.getVmInstructionSet();
if (instructionSet == null) {
System.loadLibrary("native-lib");
instructionSet = nativeISA();
}
return instructionSet;
}

private native String nativeISA();
}
Loading

0 comments on commit 6280f7e

Please sign in to comment.