Skip to content

Commit 67a6e09

Browse files
committed
feat: add Samsung CloudDev SDK plugin
1 parent e4222a8 commit 67a6e09

File tree

10 files changed

+346
-1
lines changed

10 files changed

+346
-1
lines changed

Adjust/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ext {
1414
webbridgeMinSdkVersion = 17
1515
samsungReferrerMinSdkVersion = 18
1616
vivoReferrerMinSdkVersion = 23
17+
samsungCloudDevMinSdkVersion = 24
1718

1819
// POM.
1920
adjustGroupId = 'com.adjust.sdk'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/libs
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven-publish'
3+
apply plugin: 'signing'
4+
5+
repositories {
6+
maven {
7+
url "https://oss.sonatype.org/content/repositories/staging/"
8+
}
9+
}
10+
11+
android {
12+
compileSdkVersion rootProject.ext.coreCompileSdkVersion
13+
publishing {
14+
multipleVariants {
15+
allVariants()
16+
withJavadocJar()
17+
}
18+
}
19+
defaultConfig {
20+
minSdkVersion rootProject.ext.samsungCloudDevMinSdkVersion
21+
targetSdkVersion rootProject.ext.coreTargetSdkVersion
22+
}
23+
namespace 'com.adjust.sdk.samsung.clouddev'
24+
}
25+
26+
dependencies {
27+
// Add SDK via module.
28+
compileOnly project(':sdk-core')
29+
// Add SDK via Maven.
30+
// implementation 'com.adjust.sdk:adjust-android:4.38.2'
31+
32+
// Add Samsung clouddev lib.
33+
implementation files ('libs/clouddevsdk-0.0.1.2-release.aar')
34+
}
35+
36+
// read local properties
37+
File localPropsFile = project.rootProject.file('local.properties')
38+
if (localPropsFile.exists()) {
39+
Properties p = new Properties()
40+
new FileInputStream(localPropsFile).withCloseable { is ->
41+
p.load(is)
42+
}
43+
p.each { name, value ->
44+
ext[name] = value
45+
}
46+
}
47+
48+
task adjustSamsungCloudDevPluginAar(type: Copy) {
49+
dependsOn 'assembleRelease'
50+
51+
from('build/outputs/aar/')
52+
include 'sdk-plugin-samsung-clouddev-release.aar'
53+
destinationDir file('build/libs/')
54+
rename 'sdk-plugin-samsung-clouddev-release.aar', "${project.name}.aar"
55+
56+
}
57+
58+
task adjustSamsungCloudDevPluginJar(type: Jar) {
59+
dependsOn 'packageReleaseAssets'
60+
dependsOn 'compileReleaseJavaWithJavac'
61+
62+
from('build/intermediates/library_assets/release/packageReleaseAssets/out/') {
63+
into('assets')
64+
}
65+
from('build/intermediates/javac/release/classes/')
66+
67+
archiveFileName = project.provider { "${project.name}.jar" }
68+
}
69+
70+
71+
task adjustSamsungCloudDevPluginSourcesJar(type: Jar) {
72+
setArchiveClassifier('sources')
73+
from android.sourceSets.main.java.srcDirs
74+
}
75+
76+
artifacts {
77+
archives adjustSamsungCloudDevPluginJar
78+
archives adjustSamsungCloudDevPluginSourcesJar
79+
}
80+
81+
afterEvaluate {
82+
publishing {
83+
publications {
84+
/*
85+
mavenAndroidSamsungCloudDevJar(MavenPublication) {
86+
customizePomForJar(pom)
87+
groupId rootProject.ext.adjustGroupId
88+
artifactId 'adjust-android-samsung-clouddev'
89+
version rootProject.ext.coreVersionName
90+
91+
artifact adjustSamsungCloudDevPluginJar
92+
artifact adjustSamsungCloudDevPluginSourcesJar
93+
}
94+
*/
95+
mavenAndroidSamsungCloudDevAar(MavenPublication) {
96+
customizePomForAar(pom)
97+
groupId rootProject.ext.adjustGroupId
98+
artifactId 'adjust-android-samsung-clouddev'
99+
version rootProject.ext.coreVersionName
100+
101+
artifact("$buildDir/outputs/aar/sdk-plugin-samsung-clouddev-release.aar") {
102+
builtBy tasks.getByPath("adjustSamsungCloudDevPluginAar")
103+
}
104+
artifact adjustSamsungCloudDevPluginSourcesJar
105+
}
106+
}
107+
108+
repositories {
109+
maven {
110+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
111+
if (project.hasProperty("sonatypeUsername")) {
112+
credentials {
113+
username sonatypeUsername
114+
password sonatypePassword
115+
}
116+
}
117+
}
118+
}
119+
}
120+
signing {
121+
// sign publishing.publications.mavenAndroidSamsungCloudDevJar
122+
sign publishing.publications.mavenAndroidSamsungCloudDevAar
123+
}
124+
}
125+
126+
def customizePomForJar(pom) {
127+
pom.withXml {
128+
def root = asNode()
129+
130+
// Add all items necessary for maven central publication.
131+
root.children().last() + {
132+
resolveStrategy = Closure.DELEGATE_FIRST
133+
description 'The Samsung CloudDev plugin for Adjust SDK for Android'
134+
name 'Adjust Android SDK Samsung CloudDev plugin'
135+
url 'https://github.com/adjust/android_sdk'
136+
137+
organization {
138+
name 'adjust GmbH'
139+
url 'http://www.adjust.com'
140+
}
141+
licenses {
142+
license {
143+
name 'MIT License'
144+
url 'http://www.opensource.org/licenses/mit-license.php'
145+
}
146+
}
147+
scm {
148+
url '[email protected]:adjust/android_sdk.git'
149+
connection 'scm:git:[email protected]:adjust/android_sdk.git'
150+
developerConnection 'scm:git:[email protected]:adjust/android_sdk.git'
151+
}
152+
developers {
153+
developer {
154+
name 'Pedro Silva'
155+
156+
}
157+
developer {
158+
name 'Ugljesa Erceg'
159+
160+
}
161+
}
162+
}
163+
}
164+
}
165+
166+
def customizePomForAar(pom) {
167+
pom.withXml {
168+
def root = asNode()
169+
170+
// Add all items necessary for maven central publication.
171+
root.children().last() + {
172+
resolveStrategy = Closure.DELEGATE_FIRST
173+
description 'The Samsung CloudDev plugin for Adjust SDK for Android'
174+
name 'Adjust Android SDK Samsung CloudDev plugin'
175+
url 'https://github.com/adjust/android_sdk'
176+
177+
organization {
178+
name 'adjust GmbH'
179+
url 'http://www.adjust.com'
180+
}
181+
licenses {
182+
license {
183+
name 'MIT License'
184+
url 'http://www.opensource.org/licenses/mit-license.php'
185+
}
186+
}
187+
scm {
188+
url '[email protected]:adjust/android_sdk.git'
189+
connection 'scm:git:[email protected]:adjust/android_sdk.git'
190+
developerConnection 'scm:git:[email protected]:adjust/android_sdk.git'
191+
}
192+
developers {
193+
developer {
194+
name 'Pedro Silva'
195+
196+
}
197+
developer {
198+
name 'Ugljesa Erceg'
199+
200+
}
201+
}
202+
}
203+
}
204+
}
205+
206+
model {
207+
// tasks.generatePomFileForMavenAndroidSamsungCloudDevJarPublication {
208+
// destination = file("${project.buildDir}/generated-pom.xml")
209+
// }
210+
/* TODO check if/how to replace this tasks
211+
tasks.publishMavenAndroidSamsungCloudDevPublicationToMavenLocal {
212+
dependsOn project.tasks.signArchives
213+
}
214+
tasks.publishMavenAndroidSamsungCloudDevPublicationToMavenRepository {
215+
dependsOn project.tasks.signArchives
216+
}
217+
*/
218+
tasks.generatePomFileForMavenAndroidSamsungCloudDevAarPublication {
219+
destination = file("${project.buildDir}/generated-pom.xml")
220+
}
221+
}
222+
223+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
-keepclassmembers, includecode class com.samsung.android.game.cloudgame.dev.sdk.* { *;}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
3+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.adjust.sdk.samsung.clouddev;
2+
3+
import android.content.Context;
4+
5+
public class AdjustSamsungCloudDev {
6+
7+
static boolean shouldUseSamsungCloudDevSdk = true;
8+
9+
public static void useSamsungCloudDevSdk(Context context) {
10+
shouldUseSamsungCloudDevSdk = true;
11+
}
12+
13+
public static void doNotUseSamsungCloudDevSdk() {
14+
shouldUseSamsungCloudDevSdk = false;
15+
}
16+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.adjust.sdk.samsung.clouddev;
2+
3+
import android.content.Context;
4+
5+
import com.adjust.sdk.ILogger;
6+
import com.samsung.android.game.cloudgame.dev.sdk.CloudDevCallback;
7+
import com.samsung.android.game.cloudgame.dev.sdk.CloudDevSdk;
8+
9+
import java.util.Arrays;
10+
import java.util.Map;
11+
import java.util.concurrent.BlockingQueue;
12+
import java.util.concurrent.LinkedBlockingQueue;
13+
import java.util.concurrent.TimeUnit;
14+
15+
public class SamsungCloudDevClient {
16+
17+
public static String getGoogleAdId(Context context, final ILogger logger, long maxWaitTimeInMilli) {
18+
19+
try {
20+
final BlockingQueue<String> gaidHolder = new LinkedBlockingQueue<String>(1);
21+
22+
CloudDevSdk.INSTANCE.request(context, Arrays.asList("gaid"), new CloudDevCallback() {
23+
@Override
24+
public void onSuccess(Map<String, String> kinds) { // This is called in IO thread
25+
String gaid = kinds.getOrDefault("gaid", "");
26+
logger.info("Google Advertising ID: " + gaid);
27+
gaidHolder.offer(gaid);
28+
}
29+
@Override
30+
public void onError(String reason) { // This is called in IO thread
31+
logger.error("Error: " + reason);
32+
} });
33+
34+
return gaidHolder.poll(maxWaitTimeInMilli, TimeUnit.MILLISECONDS);
35+
36+
} catch (Throwable t) {
37+
logger.error("Error while getting gps adid from samsung clould sdk: ", t.getMessage());
38+
}
39+
40+
return null;
41+
}
42+
43+
public static boolean isAppRunningInCloudEnvironment(Context context, final ILogger logger) {
44+
try {
45+
return CloudDevSdk.INSTANCE.isCloudEnvironment(context);
46+
} catch (Throwable t) {
47+
logger.error("Error while calling CloudDevSdk isCloudEnvironment: ", t.getMessage());
48+
}
49+
return false;
50+
}
51+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.adjust.sdk.samsung.clouddev;
2+
3+
import android.content.Context;
4+
5+
import com.adjust.sdk.ILogger;
6+
7+
public class Util {
8+
public synchronized static String getGoogleAdId(Context context, ILogger logger) {
9+
if (!AdjustSamsungCloudDev.shouldUseSamsungCloudDevSdk) {
10+
return null;
11+
}
12+
13+
return SamsungCloudDevClient.getGoogleAdId(context, logger, 4000);
14+
}
15+
16+
public synchronized static boolean isAppRunningInCloudEnvironment(Context context, ILogger logger) {
17+
if (!AdjustSamsungCloudDev.shouldUseSamsungCloudDevSdk) {
18+
return false;
19+
}
20+
21+
return SamsungCloudDevClient.isAppRunningInCloudEnvironment(context, logger);
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">AdjustPluginSamsungCloudDev</string>
3+
</resources>

Adjust/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
include ':sdk-core', ':sdk-plugin-webbridge', ':sdk-plugin-oaid', ':sdk-plugin-sociomantic', ':sdk-plugin-trademob', ':sdk-plugin-imei', ':sdk-plugin-criteo', ':sdk-plugin-xiaomi-referrer', ':sdk-plugin-samsung-referrer', ':sdk-plugin-vivo-referrer'
1+
include ':sdk-core', ':sdk-plugin-webbridge', ':sdk-plugin-oaid', ':sdk-plugin-sociomantic', ':sdk-plugin-trademob', ':sdk-plugin-imei', ':sdk-plugin-criteo', ':sdk-plugin-xiaomi-referrer', ':sdk-plugin-samsung-referrer', ':sdk-plugin-vivo-referrer', ':sdk-plugin-samsung-clouddev'
22
include ':test-options', ':test-unit', ':test-library', ':test-app-core', ':test-kotlin', ':test-app-webbridge'
33
include ':example-app-java', ':example-app-kotlin', ':example-app-tv', ':example-app-webbridge', ':example-app-fbpixel', ':example-app-keyboard'

0 commit comments

Comments
 (0)