Skip to content

Commit

Permalink
Merge pull request #79 from DeployGate/jmastu/feat/embed_sdk_version_…
Browse files Browse the repository at this point in the history
…in_meta_tag

Embed SDK's artifact version in meta-data tags
  • Loading branch information
jmatsu authored Mar 14, 2024
2 parents 0e8f201 + 9fd973b commit 4bb5b01
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
// sdk/java/com/deploygate/sdk/HostAppTest.java needs to be changed for a new release
releaseVersion = '4.6.1'
}

Expand Down
3 changes: 2 additions & 1 deletion sdk.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ android {

manifestPlaceholders += [
featureFlags: flags,
sdkVersion: "4"
sdkVersion: "4",
sdkArtifactVersion: project.version,
]
}

Expand Down
5 changes: 5 additions & 0 deletions sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
android:value="${sdkVersion}"
/>

<meta-data
android:name="com.deploygate.sdk.artifact_version"
android:value="${sdkArtifactVersion}"
/>

<meta-data
android:name="com.deploygate.sdk.feature_flags"
android:value="${featureFlags}"
Expand Down
1 change: 1 addition & 0 deletions sdk/src/main/java/com/deploygate/sdk/DeployGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ private void requestServiceInit(final boolean isBoot) {
args.putBoolean(DeployGateEvent.EXTRA_CAN_LOGCAT, mHostApp.canUseLogcat);
args.putString(DeployGateEvent.EXTRA_EXPECTED_AUTHOR, mExpectedAuthor);
args.putInt(DeployGateEvent.EXTRA_SDK_VERSION, mHostApp.sdkVersion);
args.putString(DeployGateEvent.EXTRA_SDK_ARTIFACT_VERSION, mHostApp.sdkArtifactVersion);
try {
mRemoteService.init(mRemoteCallback, mHostApp.packageName, args);
} catch (RemoteException e) {
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/main/java/com/deploygate/sdk/HostApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class HostApp {
public final boolean canUseLogcat;
public final boolean debuggable;
public final int sdkVersion;
public final String sdkArtifactVersion;

HostApp(
Context context
Expand All @@ -32,6 +33,7 @@ class HostApp {
this.debuggable = false;
this.canUseLogcat = false;
this.sdkVersion = 0;
this.sdkArtifactVersion = null;
return;
}

Expand All @@ -44,5 +46,6 @@ class HostApp {
}

this.sdkVersion = info.metaData.getInt("com.deploygate.sdk.version", 0);
this.sdkArtifactVersion = info.metaData.getString("com.deploygate.sdk.artifact_version");
}
}
11 changes: 11 additions & 0 deletions sdk/src/main/java/com/deploygate/service/DeployGateEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ public interface DeployGateEvent {

public static final String EXTRA_AUTHOR = "author";
public static final String EXTRA_EXPECTED_AUTHOR = "expectedAuthor";

/**
* A SDK's model version queried by this key from INIT event.
*/
public static final String EXTRA_SDK_VERSION = "sdkVersion";

/**
* A SDK's artifact version queried by this key from INIT event.
*
* @since 4.7.0
*/
public static final String EXTRA_SDK_ARTIFACT_VERSION = "e.sdk-artifact-version";
public static final String EXTRA_IS_MANAGED = "isManaged";
public static final String EXTRA_IS_AUTHORIZED = "isAuthorized";
public static final String EXTRA_LOGIN_USERNAME = "loginUsername";
Expand Down
1 change: 1 addition & 0 deletions sdk/src/test/java/com/deploygate/sdk/HostAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void default_properties() {
Truth.assertThat(app.canUseLogcat).isTrue();
Truth.assertThat(app.packageName).isEqualTo("com.deploygate.sdk.test");
Truth.assertThat(app.sdkVersion).isEqualTo(4);
Truth.assertThat(app.sdkArtifactVersion).isEqualTo("4.6.1");
}

@Test
Expand Down

0 comments on commit 4bb5b01

Please sign in to comment.