Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed SDK's artifact version in meta-data tags #79

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading