From b5ac09290e82467183c8f1b79acc367186931ef7 Mon Sep 17 00:00:00 2001 From: satsukies Date: Mon, 19 Aug 2024 16:59:13 +0900 Subject: [PATCH 01/23] chore: separate each method in DeloyGateCallback to interface class --- .../deploygate/sdk/DeployGateCallback.java | 15 +++++++++-- .../sdk/DeployGateInitializeCallback.java | 13 +++++++++ .../sdk/DeployGateStatusChangeCallback.java | 27 +++++++++++++++++++ .../DeployGateUpdateAvailableCallback.java | 19 +++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java create mode 100644 sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java create mode 100644 sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java index 8df3686..6560680 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -6,8 +6,10 @@ * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. * * @author tnj + * @deprecated since 4.9.0. Use each extended callback interfaces instead. */ -public interface DeployGateCallback { +@Deprecated +public interface DeployGateCallback extends DeployGateInitializeCallback, DeployGateStatusChangeCallback, DeployGateUpdateAvailableCallback { /** * Callback to tell the finish of DeployGate service initialization * procedure. @@ -15,7 +17,10 @@ public interface DeployGateCallback { * @param isServiceAvailable * true if DeployGate service is available on the * device. + * @deprecated since 4.9.0. Use {@link DeployGateInitializeCallback#onInitialized(boolean)} instead. */ + @Deprecated + @Override public void onInitialized(boolean isServiceAvailable); /** @@ -34,7 +39,10 @@ public interface DeployGateCallback { * isAuthorized is true. * @param isStopped * Reserved. + * @deprecated since 4.9.0. Use {@link DeployGateStatusChangeCallback#onStatusChanged(boolean, boolean, String, boolean)} instead. */ + @Deprecated + @Override public void onStatusChanged( boolean isManaged, boolean isAuthorized, @@ -51,10 +59,13 @@ public void onStatusChanged( * user-defined version name of new version * @param versionCode * user-defined version code of new version + * @deprecated since 4.9.0. Use {@link DeployGateUpdateAvailableCallback#onUpdateAvailable(int, String, int)} instead. */ + @Deprecated + @Override public void onUpdateAvailable( int revision, String versionName, int versionCode ); -} +} \ No newline at end of file diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java new file mode 100644 index 0000000..acb798e --- /dev/null +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -0,0 +1,13 @@ +package com.deploygate.sdk; + +public interface DeployGateInitializeCallback { + /** + * Callback to tell the finish of DeployGate service initialization + * procedure. + * + * @param isServiceAvailable + * true if DeployGate service is available on the + * device. + */ + public void onInitialized(boolean isServiceAvailable); +} diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java new file mode 100644 index 0000000..5c7f21e --- /dev/null +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -0,0 +1,27 @@ +package com.deploygate.sdk; + +public interface DeployGateStatusChangeCallback { + /** + * Callback to tell the app status on the DeployGate has changed. This will + * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, + * {@link DeployGate#refresh()} and + * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} with + * true in second argument. + * + * @param isManaged + * true if the app is known on DeployGate app + * @param isAuthorized + * true if the app is on current user's installed list + * @param loginUsername + * Current login username, returned only when + * isAuthorized is true. + * @param isStopped + * Reserved. + */ + public void onStatusChanged( + boolean isManaged, + boolean isAuthorized, + String loginUsername, + boolean isStopped + ); +} diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java new file mode 100644 index 0000000..a6d370e --- /dev/null +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -0,0 +1,19 @@ +package com.deploygate.sdk; + +public interface DeployGateUpdateAvailableCallback { + /** + * Callback to tell the new version is available. + * + * @param revision + * revision of new version + * @param versionName + * user-defined version name of new version + * @param versionCode + * user-defined version code of new version + */ + public void onUpdateAvailable( + int revision, + String versionName, + int versionCode + ); +} From c75248c79dd448d41a952809a5e2d217f699cf9a Mon Sep 17 00:00:00 2001 From: satsukies Date: Mon, 19 Aug 2024 17:07:47 +0900 Subject: [PATCH 02/23] feat: Add method for set each callbacks to DeployGateSdkConfiguration.Builder --- .../java/com/deploygate/sdk/DeployGate.java | 47 ++++++++++++++++++- .../sdk/DeployGateSdkConfiguration.java | 37 +++++++++++++-- 2 files changed, 79 insertions(+), 5 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 79db2bd..09af5e9 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -24,8 +24,6 @@ import com.deploygate.service.IDeployGateSdkService; import com.deploygate.service.IDeployGateSdkServiceCallback; -import org.json.JSONObject; - import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -68,6 +66,9 @@ public class DeployGate { private final ILogcatInstructionSerializer mLogcatInstructionSerializer; private final CustomLogInstructionSerializer mCustomLogInstructionSerializer; private final HashSet mCallbacks; + private final HashSet mInitializeCallbacks; + private final HashSet mStatusChangeCallbacks; + private final HashSet mUpdateAvailableCallbacks; private final HashMap mPendingEvents; private final String mExpectedAuthor; private String mAuthor; @@ -194,8 +195,19 @@ private void onInitialized( mHandler.post(new Runnable() { @Override public void run() { + // call onInitialized on each callbacks for (DeployGateCallback callback : mCallbacks) { callback.onInitialized(true); + } + for (DeployGateInitializeCallback callback : mInitializeCallbacks) { + callback.onInitialized(true); + } + + // after call onInitialized, then call onStatusChanged + for (DeployGateCallback callback : mCallbacks) { + callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); + } + for (DeployGateStatusChangeCallback callback : mStatusChangeCallbacks) { callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); } } @@ -232,6 +244,10 @@ public void run() { for (DeployGateCallback callback : mCallbacks) { callback.onUpdateAvailable(serial, versionName, versionCode); } + + for (DeployGateUpdateAvailableCallback callback : mUpdateAvailableCallbacks) { + callback.onUpdateAvailable(serial, versionName, versionCode); + } } }); } @@ -288,10 +304,22 @@ void callbackDeployGateUnavailable() { mHandler.post(new Runnable() { @Override public void run() { + // call onInitialized on each callbacks for (DeployGateCallback callback : mCallbacks) { callback.onInitialized(false); + } + for (DeployGateInitializeCallback callback : mInitializeCallbacks) { + callback.onInitialized(false); + } + + // after call onInitialized, then call onStatusChanged + for (DeployGateCallback callback : mCallbacks) { callback.onStatusChanged(false, false, null, false); } + for (DeployGateStatusChangeCallback callback : mStatusChangeCallbacks) { + callback.onStatusChanged(false, false, null, false); + } + } }); } @@ -315,6 +343,9 @@ private DeployGate( mLogcatInstructionSerializer = mHostApp.canUseLogcat ? new LogcatInstructionSerializer(mHostApp.packageName) : ILogcatInstructionSerializer.NULL_INSTANCE; mCustomLogInstructionSerializer = new CustomLogInstructionSerializer(mHostApp.packageName, sdkConfiguration.customLogConfiguration); mCallbacks = new HashSet<>(); + mInitializeCallbacks = new HashSet<>(); + mStatusChangeCallbacks = new HashSet<>(); + mUpdateAvailableCallbacks = new HashSet<>(); mPendingEvents = new HashMap<>(); mExpectedAuthor = sdkConfiguration.appOwnerName; @@ -324,6 +355,18 @@ private DeployGate( mCallbacks.add(sdkConfiguration.callback); } + if (sdkConfiguration.initializeCallback != null) { + mInitializeCallbacks.add(sdkConfiguration.initializeCallback); + } + + if (sdkConfiguration.statusChangeCallback != null) { + mStatusChangeCallbacks.add(sdkConfiguration.statusChangeCallback); + } + + if (sdkConfiguration.updateAvailableCallback != null) { + mUpdateAvailableCallbacks.add(sdkConfiguration.updateAvailableCallback); + } + mInitializedLatch = new CountDownLatch(1); ((Application) applicationContext).registerActivityLifecycleCallbacks(new VisibilityLifecycleCallbacks(mOnVisibilityChangeListener)); initService(true); diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 3250aed..5432111 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -12,8 +12,10 @@ public final class DeployGateSdkConfiguration { final boolean isCrashReportingEnabled; - final DeployGateCallback callback; + final DeployGateInitializeCallback initializeCallback; + final DeployGateStatusChangeCallback statusChangeCallback; + final DeployGateUpdateAvailableCallback updateAvailableCallback; final boolean isCaptureEnabled; @@ -27,7 +29,10 @@ private DeployGateSdkConfiguration( builder.appOwnerName, builder.isCrashReportingEnabled, builder.isCaptureEnabled, - builder.callback + builder.callback, + builder.initializeCallback, + builder.statusChangeCallback, + builder.updateAvailableCallback ); } @@ -38,7 +43,10 @@ private DeployGateSdkConfiguration( String appOwnerName, boolean isCrashReportingEnabled, boolean isCaptureEnabled, - DeployGateCallback callback + DeployGateCallback callback, + DeployGateInitializeCallback initializeCallback, + DeployGateStatusChangeCallback statusChangeCallback, + DeployGateUpdateAvailableCallback updateAvailableCallback ) { this.customLogConfiguration = customLogConfiguration; this.isDisabled = isDisabled; @@ -47,6 +55,9 @@ private DeployGateSdkConfiguration( this.isCrashReportingEnabled = isCrashReportingEnabled; this.isCaptureEnabled = isCaptureEnabled; this.callback = callback; + this.initializeCallback = initializeCallback; + this.statusChangeCallback = statusChangeCallback; + this.updateAvailableCallback = updateAvailableCallback; } public static final class Builder { @@ -62,6 +73,9 @@ public static final class Builder { private boolean isCaptureEnabled = true; private DeployGateCallback callback = null; + private DeployGateInitializeCallback initializeCallback = null; + private DeployGateStatusChangeCallback statusChangeCallback = null; + private DeployGateUpdateAvailableCallback updateAvailableCallback = null; public Builder() { } @@ -147,12 +161,29 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { * @param callback * Set an instance of callback. The reference won't be released. Please use {@link DeployGate#registerCallback(DeployGateCallback, boolean)} for memory sensitive works. * @return self + * @deprecated since 4.9.0. Use each extended callback interfaces instead. */ + @Deprecated public Builder setCallback(DeployGateCallback callback) { this.callback = callback; return this; } + public Builder setInitializeCallback(DeployGateInitializeCallback initializeCallback) { + this.initializeCallback = initializeCallback; + return this; + } + + public Builder setStatusChangeCallback(DeployGateStatusChangeCallback statusChangeCallback) { + this.statusChangeCallback = statusChangeCallback; + return this; + } + + public Builder setUpdateAvailableCallback(DeployGateUpdateAvailableCallback updateAvailableCallback) { + this.updateAvailableCallback = updateAvailableCallback; + return this; + } + /** * @return a new sdk configuration. */ From 36e88dcedd70e5247912cc98940332e8577e1853 Mon Sep 17 00:00:00 2001 From: satsukies Date: Mon, 19 Aug 2024 22:16:05 +0900 Subject: [PATCH 03/23] chore: add new callback interfaces to sdkMock module --- .../sdk/DeployGateInitializeCallback.java | 17 ++++---- .../sdk/DeployGateStatusChangeCallback.java | 42 +++++++++---------- .../DeployGateUpdateAvailableCallback.java | 27 ++++++------ .../deploygate/sdk/DeployGateCallback.java | 29 +++++++++---- .../sdk/DeployGateInitializeCallback.java | 12 ++++++ .../sdk/DeployGateStatusChangeCallback.java | 23 ++++++++++ .../DeployGateUpdateAvailableCallback.java | 16 +++++++ 7 files changed, 110 insertions(+), 56 deletions(-) create mode 100644 sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java create mode 100644 sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java create mode 100644 sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java index acb798e..b74b4d8 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -1,13 +1,12 @@ package com.deploygate.sdk; public interface DeployGateInitializeCallback { - /** - * Callback to tell the finish of DeployGate service initialization - * procedure. - * - * @param isServiceAvailable - * true if DeployGate service is available on the - * device. - */ - public void onInitialized(boolean isServiceAvailable); + /** + * Callback to tell the finish of DeployGate service initialization + * procedure. + * + * @param isServiceAvailable true if DeployGate service is available on the + * device. + */ + public void onInitialized(boolean isServiceAvailable); } diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java index 5c7f21e..f657046 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -1,27 +1,23 @@ package com.deploygate.sdk; public interface DeployGateStatusChangeCallback { - /** - * Callback to tell the app status on the DeployGate has changed. This will - * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, - * {@link DeployGate#refresh()} and - * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} with - * true in second argument. - * - * @param isManaged - * true if the app is known on DeployGate app - * @param isAuthorized - * true if the app is on current user's installed list - * @param loginUsername - * Current login username, returned only when - * isAuthorized is true. - * @param isStopped - * Reserved. - */ - public void onStatusChanged( - boolean isManaged, - boolean isAuthorized, - String loginUsername, - boolean isStopped - ); + /** + * Callback to tell the app status on the DeployGate has changed. This will + * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, + * {@link DeployGate#refresh()} and + * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean)} with + * true in second argument. + * + * @param isManaged true if the app is known on DeployGate app + * @param isAuthorized true if the app is on current user's installed list + * @param loginUsername Current login username, returned only when + * isAuthorized is true. + * @param isStopped Reserved. + */ + public void onStatusChanged( + boolean isManaged, + boolean isAuthorized, + String loginUsername, + boolean isStopped + ); } diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java index a6d370e..30c1ffa 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -1,19 +1,16 @@ package com.deploygate.sdk; public interface DeployGateUpdateAvailableCallback { - /** - * Callback to tell the new version is available. - * - * @param revision - * revision of new version - * @param versionName - * user-defined version name of new version - * @param versionCode - * user-defined version code of new version - */ - public void onUpdateAvailable( - int revision, - String versionName, - int versionCode - ); + /** + * Callback to tell the new version is available. + * + * @param revision revision of new version + * @param versionName user-defined version name of new version + * @param versionCode user-defined version code of new version + */ + public void onUpdateAvailable( + int revision, + String versionName, + int versionCode + ); } diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java index 8df3686..b2903d9 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -6,8 +6,10 @@ * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. * * @author tnj + * @deprecated since 4.9.0. Use each extended callback interfaces instead. */ -public interface DeployGateCallback { +@Deprecated +public interface DeployGateCallback extends DeployGateInitializeCallback, DeployGateStatusChangeCallback, DeployGateUpdateAvailableCallback { /** * Callback to tell the finish of DeployGate service initialization * procedure. @@ -15,7 +17,10 @@ public interface DeployGateCallback { * @param isServiceAvailable * true if DeployGate service is available on the * device. + * @deprecated since 4.9.0. Use {@link DeployGateInitializeCallback#onInitialized(boolean)} instead. */ + @Deprecated + @Override public void onInitialized(boolean isServiceAvailable); /** @@ -34,12 +39,15 @@ public interface DeployGateCallback { * isAuthorized is true. * @param isStopped * Reserved. + * @deprecated since 4.9.0. Use {@link DeployGateStatusChangeCallback#onStatusChanged(boolean, boolean, String, boolean)} instead. */ + @Deprecated + @Override public void onStatusChanged( - boolean isManaged, - boolean isAuthorized, - String loginUsername, - boolean isStopped + boolean isManaged, + boolean isAuthorized, + String loginUsername, + boolean isStopped ); /** @@ -51,10 +59,13 @@ public void onStatusChanged( * user-defined version name of new version * @param versionCode * user-defined version code of new version + * @deprecated since 4.9.0. Use {@link DeployGateUpdateAvailableCallback#onUpdateAvailable(int, String, int)} instead. */ + @Deprecated + @Override public void onUpdateAvailable( - int revision, - String versionName, - int versionCode + int revision, + String versionName, + int versionCode ); -} +} \ No newline at end of file diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java new file mode 100644 index 0000000..4a25a1a --- /dev/null +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -0,0 +1,12 @@ +package com.deploygate.sdk; + +public interface DeployGateInitializeCallback { + /** + * Callback to tell the finish of DeployGate service initialization + * procedure. + * + * @param isServiceAvailable true if DeployGate service is available on the + * device. + */ + public void onInitialized(boolean isServiceAvailable); +} diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java new file mode 100644 index 0000000..ee42904 --- /dev/null +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -0,0 +1,23 @@ +package com.deploygate.sdk; + +public interface DeployGateStatusChangeCallback { + /** + * Callback to tell the app status on the DeployGate has changed. This will + * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, + * {@link DeployGate#refresh()} and + * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean)} with + * true in second argument. + * + * @param isManaged true if the app is known on DeployGate app + * @param isAuthorized true if the app is on current user's installed list + * @param loginUsername Current login username, returned only when + * isAuthorized is true. + * @param isStopped Reserved. + */ + public void onStatusChanged( + boolean isManaged, + boolean isAuthorized, + String loginUsername, + boolean isStopped + ); +} diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java new file mode 100644 index 0000000..30c1ffa --- /dev/null +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -0,0 +1,16 @@ +package com.deploygate.sdk; + +public interface DeployGateUpdateAvailableCallback { + /** + * Callback to tell the new version is available. + * + * @param revision revision of new version + * @param versionName user-defined version name of new version + * @param versionCode user-defined version code of new version + */ + public void onUpdateAvailable( + int revision, + String versionName, + int versionCode + ); +} From 3d46edb0200628c72bb9caa39dda205ee9e30bba Mon Sep 17 00:00:00 2001 From: satsukies Date: Mon, 19 Aug 2024 22:24:31 +0900 Subject: [PATCH 04/23] feat: add register/unregister method for new callback interfaces --- .../java/com/deploygate/sdk/DeployGate.java | 169 ++++++++++++++++++ .../java/com/deploygate/sdk/DeployGate.java | 27 +++ 2 files changed, 196 insertions(+) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 09af5e9..09622ad 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -825,6 +825,165 @@ private void refreshInternal() { } } + /** + * Register a callback listener about the DeployGate initialization event. + * Don't forget to call {@link #unregisterInitializeCallback(DeployGateInitializeCallback)} + * when the callback is no longer needed (e.g., on destroying an activity.) + * If the listener has already in the callback list, just ignored. + * + * @param callback callback listener + * @param refreshImmediately if you want to receive current states, set this + * true. + * @since 4.9.0 + */ + public static void registerInitializeCallback( + DeployGateInitializeCallback callback, + boolean refreshImmediately + ) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.registerInitializeCallbackInternal(callback, refreshImmediately); + } + + private void registerInitializeCallbackInternal( + DeployGateInitializeCallback callback, + boolean refreshImmediately + ) { + mInitializeCallbacks.add(callback); + if (refreshImmediately) { + refresh(); + } + } + + /** + * Unregister a callback listener. + * If the listener was not registered, just ignored. + * + * @param callback callback listener to be removed + * @since 4.9.0 + */ + public static void unregisterInitializeCallback(DeployGateInitializeCallback callback) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.mInitializeCallbacks.remove(callback); + } + + /** + * Register a callback listener about the app status on DeployGate. + * Don't forget to call {@link #unregisterStatusChangeCallback(DeployGateStatusChangeCallback)} + * when the callback is no longer needed (e.g., on destroying an activity.) + * If the listener has already in the callback list, just ignored. + * + * @param callback callback listener + * @param refreshImmediately if you want to receive current states, set this + * true. + * @since 4.9.0 + */ + public static void registerStatusChangeCallback( + DeployGateStatusChangeCallback callback, + boolean refreshImmediately + ) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.registerStatusChangeCallbackInternal(callback, refreshImmediately); + } + + private void registerStatusChangeCallbackInternal( + DeployGateStatusChangeCallback callback, + boolean refreshImmediately + ) { + mStatusChangeCallbacks.add(callback); + if (refreshImmediately) { + refresh(); + } + } + + /** + * Unregister a callback listener. + * If the listener was not registered, just ignored. + * + * @param callback callback listener to be removed + * @since 4.9.0 + */ + public static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback callback) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.mStatusChangeCallbacks.remove(callback); + } + + /** + * Register a callback listener about the new version of the app is available. + * Don't forget to call {@link #unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback)} + * when the callback is no longer needed (e.g., on destroying an activity.) + * If the listener has already in the callback list, just ignored. + * + * @param callback callback listener + * @param refreshImmediately if you want to receive current states, set this + * true. + * @since 4.9.0 + */ + public static void registerUpdateAvailableCallback( + DeployGateUpdateAvailableCallback callback, + boolean refreshImmediately + ) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.registerUpdateAvailableCallbackInternal(callback, refreshImmediately); + } + + private void registerUpdateAvailableCallbackInternal( + DeployGateUpdateAvailableCallback callback, + boolean refreshImmediately + ) { + mUpdateAvailableCallbacks.add(callback); + if (refreshImmediately) { + refresh(); + } + } + + /** + * Unregister a callback listener. + * If the listener was not registered, just ignored. + * + * @param callback callback listener to be removed + * @since 4.9.0 + */ + public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { + if (sInstance == null) { + return; + } + if (callback == null) { + return; + } + + sInstance.mUpdateAvailableCallbacks.remove(callback); + } + /** * Register a DeployGate event callback listener. Don't forget to call * {@link #unregisterCallback(DeployGateCallback)} when the callback is no @@ -838,7 +997,12 @@ private void refreshInternal() { * true. * * @since r1 + * @deprecated since 4.9.0. Use each register method for separated callbacks instead. + * @see #registerInitializeCallback(DeployGateInitializeCallback, boolean) + * @see #registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean) + * @see #registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback, boolean) */ + @Deprecated public static void registerCallback( DeployGateCallback listener, boolean refreshImmediately @@ -871,7 +1035,12 @@ private void registerCallbackInternal( * callback listener to be removed * * @since r1 + * @deprecated since 4.9.0. Use each unregister method for separated callbacks instead. + * @see #unregisterInitializeCallback(DeployGateInitializeCallback) + * @see #unregisterStatusChangeCallback(DeployGateStatusChangeCallback) + * @see #unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback) */ + @Deprecated public static void unregisterCallback(DeployGateCallback listener) { if (sInstance == null) { return; diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java index 5d0b765..4dd6c38 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java @@ -71,6 +71,33 @@ public static void install( public static void refresh() { } + public static void registerInitializeCallback( + DeployGateInitializeCallback callback, + boolean refreshImmediately + ) { + } + + public static void unregisterInitializeCallback(DeployGateInitializeCallback callback) { + } + + public static void registerStatusChangeCallback( + DeployGateStatusChangeCallback callback, + boolean refreshImmediately + ) { + } + + public static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback callback) { + } + + public static void registerUpdateAvailableCallback( + DeployGateUpdateAvailableCallback callback, + boolean refreshImmediately + ) { + } + + public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { + } + public static void registerCallback( DeployGateCallback listener, boolean refreshImmediately From 5d6efe53ffcc4dc37e3e75f95674dd8199b03036 Mon Sep 17 00:00:00 2001 From: satsukies Date: Mon, 19 Aug 2024 22:25:09 +0900 Subject: [PATCH 05/23] chore: refactoring sample codes --- .../main/java/com/deploygate/sample/App.java | 44 +++++++------------ .../com/deploygate/sample/SampleActivity.java | 20 ++++++--- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/sample/src/main/java/com/deploygate/sample/App.java b/sample/src/main/java/com/deploygate/sample/App.java index 6bc710c..46bee46 100644 --- a/sample/src/main/java/com/deploygate/sample/App.java +++ b/sample/src/main/java/com/deploygate/sample/App.java @@ -7,7 +7,7 @@ import com.deploygate.sdk.CustomAttributes; import com.deploygate.sdk.DeployGate; -import com.deploygate.sdk.DeployGateCallback; +import com.deploygate.sdk.DeployGateSdkConfiguration; import java.util.Locale; @@ -27,12 +27,10 @@ public void onCreate() { // Note that you also need to edit your AndroidManifest.xml to activate customized initializer. // Refer the comment on stableReal/AndroidManifest.xml included in this sample. - DeployGate.install(this, new DeployGateCallback() { - // Please note that this callback is called iff you have removed the content provider. - // For those who wanna use the content provider, SDK provides DeployGate#registerCallback for your use-case. - - @Override - public void onInitialized(boolean isServiceAvailable) { + DeployGateSdkConfiguration configuration = new DeployGateSdkConfiguration.Builder() + // Please note that these callback is called if you have removed the content provider. + // For those who wanna use the content provider, SDK provides DeployGate#registerXXXCallback for your use-case. + .setInitializeCallback(isServiceAvailable -> { if (isServiceAvailable) { Log.i(TAG, "SDK is available"); DeployGate.logInfo("SDK is available"); @@ -44,44 +42,34 @@ public void onInitialized(boolean isServiceAvailable) { Log.i(TAG, "SDK is unavailable"); DeployGate.logInfo("SDK is unavailable"); // this fails silently } - } - - @Override - public void onStatusChanged( - boolean isManaged, - boolean isAuthorized, - String loginUsername, - boolean isStopped - ) { + }) + .setStatusChangeCallback((isManaged, isAuthorized, loginUsername, isStopped) -> { Bundle bundle = new Bundle(); bundle.putBoolean("isManaged", isManaged); bundle.putBoolean("isAuthorized", isAuthorized); bundle.putString("loginUsername", loginUsername); bundle.putBoolean("isStopped", isStopped); - String message = String.format(Locale.US, "onStatusChanged(%s)", bundle.toString()); + String message = String.format(Locale.US, "onStatusChanged(%s)", bundle); Log.i(TAG, message); DeployGate.logInfo(message); - } - - @Override - public void onUpdateAvailable( - int revision, - String versionName, - int versionCode - ) { + }) + .setUpdateAvailableCallback((revision, versionName, versionCode) -> { Bundle bundle = new Bundle(); bundle.putInt("revision", revision); bundle.putString("versionName", versionName); bundle.putInt("versionCode", versionCode); - String message = String.format(Locale.US, "onUpdateAvailable(%s)", bundle.toString()); + String message = String.format(Locale.US, "onUpdateAvailable(%s)", bundle); Log.i(TAG, message); DeployGate.logInfo(message); - } - }, true); + }) + .setEnabledOnNonDebuggableBuild(true) + .build(); + + DeployGate.install(this, configuration); // If you want to prevent the app distributed by someone else, specify your username on DeployGate // as a second argument of DeployGate.install, like: diff --git a/sample/src/main/java/com/deploygate/sample/SampleActivity.java b/sample/src/main/java/com/deploygate/sample/SampleActivity.java index 639f2b0..8ef1680 100644 --- a/sample/src/main/java/com/deploygate/sample/SampleActivity.java +++ b/sample/src/main/java/com/deploygate/sample/SampleActivity.java @@ -16,9 +16,11 @@ import com.deploygate.sdk.CustomAttributes; import com.deploygate.sdk.DeployGate; -import com.deploygate.sdk.DeployGateCallback; +import com.deploygate.sdk.DeployGateInitializeCallback; +import com.deploygate.sdk.DeployGateStatusChangeCallback; +import com.deploygate.sdk.DeployGateUpdateAvailableCallback; -public class SampleActivity extends Activity implements DeployGateCallback { +public class SampleActivity extends Activity implements DeployGateInitializeCallback, DeployGateStatusChangeCallback, DeployGateUpdateAvailableCallback { private static final String TAG = "SampleActivity"; @@ -68,8 +70,14 @@ public void onCreate(Bundle savedInstanceState) { protected void onResume() { super.onResume(); - // register for callback, also request refreshing (second argument) - DeployGate.registerCallback(this, true); + // register for callbacks + DeployGate.registerInitializeCallback(this, false); + DeployGate.registerStatusChangeCallback(this, false); + // call register method with second argument true to get the status immediately + DeployGate.registerUpdateAvailableCallback(this, true); + + // or you can also call DeployGate.refresh() if you want to check the status immediately + // DeployGate.refresh(); } @Override @@ -77,7 +85,9 @@ protected void onPause() { super.onPause(); // unregister to stop callback - DeployGate.unregisterCallback(this); + DeployGate.unregisterInitializeCallback(this); + DeployGate.unregisterStatusChangeCallback(this); + DeployGate.unregisterUpdateAvailableCallback(this); } From 9774b938303f00303adfd96c62eaa6fc50729280 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 09:07:57 +0900 Subject: [PATCH 06/23] chore: add methods to DeployGateSdkConfiguration at sdkMock module --- .../deploygate/sdk/DeployGateSdkConfiguration.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 56f17b1..5a6974d 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -36,6 +36,19 @@ public Builder setCallback(DeployGateCallback callback) { return this; } + public Builder setInitializeCallback(DeployGateInitializeCallback initializeCallback) { + return this; + } + + public Builder setStatusChangeCallback(DeployGateStatusChangeCallback statusChangeCallback) { + return this; + } + + public Builder setUpdateAvailableCallback(DeployGateUpdateAvailableCallback updateAvailableCallback) { + return this; + } + + public DeployGateSdkConfiguration build() { return new DeployGateSdkConfiguration(); } From f7d85ba3b29dd97763873cc0e4e257efbf67e157 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 09:09:14 +0900 Subject: [PATCH 07/23] test: add testcase of new interfaces --- .../sdk/DeployGateInterfaceTest.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java index 62684ee..89d02ad 100644 --- a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java @@ -26,6 +26,9 @@ public class DeployGateInterfaceTest { Application app; DeployGateCallback callback; + DeployGateInitializeCallback initializeCallback; + DeployGateStatusChangeCallback statusChangeCallback; + DeployGateUpdateAvailableCallback updateAvailableCallback; @Before public void setUp() { @@ -56,6 +59,24 @@ public void onUpdateAvailable( } }; + initializeCallback = new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + }; + statusChangeCallback = new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + }; + updateAvailableCallback = new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; DeployGate.clear(); } @@ -192,6 +213,57 @@ public void onUpdateAvailable( } }, false); + + DeployGate.registerInitializeCallback(null, true); + DeployGate.registerInitializeCallback(null, false); + DeployGate.registerInitializeCallback(initializeCallback, true); + DeployGate.registerInitializeCallback(initializeCallback, false); + DeployGate.registerInitializeCallback(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + + } + }, true); + DeployGate.registerInitializeCallback(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + + } + }, false); + + DeployGate.registerStatusChangeCallback(null, true); + DeployGate.registerStatusChangeCallback(null, false); + DeployGate.registerStatusChangeCallback(statusChangeCallback, true); + DeployGate.registerStatusChangeCallback(statusChangeCallback, false); + DeployGate.registerStatusChangeCallback(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + + } + }, true); + DeployGate.registerStatusChangeCallback(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + + } + }, false); + + DeployGate.registerUpdateAvailableCallback(null, true); + DeployGate.registerUpdateAvailableCallback(null, false); + DeployGate.registerUpdateAvailableCallback(updateAvailableCallback, true); + DeployGate.registerUpdateAvailableCallback(updateAvailableCallback, false); + DeployGate.registerUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + + } + }, true); + DeployGate.registerUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + + } + }, false); } @Test @@ -223,6 +295,33 @@ public void onUpdateAvailable( } }); DeployGate.unregisterCallback(callback); + + DeployGate.unregisterInitializeCallback(null); + DeployGate.unregisterInitializeCallback(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + + } + }); + DeployGate.unregisterInitializeCallback(initializeCallback); + + DeployGate.unregisterStatusChangeCallback(null); + DeployGate.unregisterStatusChangeCallback(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + + } + }); + DeployGate.unregisterStatusChangeCallback(statusChangeCallback); + + DeployGate.unregisterUpdateAvailableCallback(null); + DeployGate.unregisterUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + + } + }); + DeployGate.unregisterUpdateAvailableCallback(updateAvailableCallback); } @Test From 69bd4fc1097300a9fb7f522dddd7aca3797ffe26 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 09:09:52 +0900 Subject: [PATCH 08/23] test: add new testcase about public methods definition on DeployGateSdkConfigration in each module --- ...ployGateSdkConfigurationInterfaceTest.java | 134 ++++++++++++++++++ ...ployGateSdkConfigurationInterfaceTest.java | 1 + 2 files changed, 135 insertions(+) create mode 100644 sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java create mode 120000 sdkMock/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java new file mode 100644 index 0000000..4be2682 --- /dev/null +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java @@ -0,0 +1,134 @@ +package com.deploygate.sdk; + +import androidx.annotation.NonNull; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.google.common.truth.Truth; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * This test class will make sure all *public* interfaces are defined as expected. + */ +@RunWith(AndroidJUnit4.class) +public class DeployGateSdkConfigurationInterfaceTest { + + @NonNull + DeployGateSdkConfiguration.Builder builder; + + CustomLogConfiguration customLogConfiguration; + String appOwnerName; + DeployGateCallback callback; + DeployGateInitializeCallback initializeCallback; + DeployGateStatusChangeCallback statusChangeCallback; + DeployGateUpdateAvailableCallback updateAvailableCallback; + + @Before + public void setUp() { + builder = new DeployGateSdkConfiguration.Builder(); + customLogConfiguration = new CustomLogConfiguration.Builder().build(); + appOwnerName = "owner"; + callback = new DeployGateCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + } + + @Test + public void builder__set_method() { + // setCustomLogConfiguration + builder.setCustomLogConfiguration(null); + builder.setCustomLogConfiguration(customLogConfiguration); + builder.setCustomLogConfiguration(new CustomLogConfiguration.Builder().build()); + + // setAppOwnerName + builder.setAppOwnerName(null); + builder.setAppOwnerName(appOwnerName); + builder.setAppOwnerName("owner"); + + // setDisabled + builder.setDisabled(true); + builder.setDisabled(false); + + // setEnabledOnNonDebuggableBuild + builder.setEnabledOnNonDebuggableBuild(true); + builder.setEnabledOnNonDebuggableBuild(false); + + // setCaptureEnabled + builder.setCaptureEnabled(true); + builder.setCaptureEnabled(false); + + // setCrashReportingEnabled + builder.setCrashReportingEnabled(true); + builder.setCrashReportingEnabled(false); + + // setCallback + builder.setCallback(null); + builder.setCallback(callback); + builder.setCallback(new DeployGateCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }); + + // setInitializeCallback + builder.setInitializeCallback(null); + builder.setInitializeCallback(initializeCallback); + builder.setInitializeCallback(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + }); + + // setStatusChangeCallback + builder.setStatusChangeCallback(null); + builder.setStatusChangeCallback(statusChangeCallback); + builder.setStatusChangeCallback(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + }); + + // setUpdateAvailableCallback + builder.setUpdateAvailableCallback(null); + builder.setUpdateAvailableCallback(updateAvailableCallback); + builder.setUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }); + } + + @Test + public void builder__build() { + Truth.assertThat(builder.build()).isNotNull(); + } +} diff --git a/sdkMock/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java b/sdkMock/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java new file mode 120000 index 0000000..3d343fc --- /dev/null +++ b/sdkMock/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java @@ -0,0 +1 @@ +../../../../../../../sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationInterfaceTest.java \ No newline at end of file From 7a6f81df46adea9092f5a37a1bd27fc6100bfcdf Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 11:39:05 +0900 Subject: [PATCH 09/23] fix: remove class body --- .../deploygate/sdk/DeployGateCallback.java | 62 +------------------ .../deploygate/sdk/DeployGateCallback.java | 62 +------------------ 2 files changed, 6 insertions(+), 118 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java index 6560680..4f48e40 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -1,71 +1,15 @@ package com.deploygate.sdk; - /** * A callback interface to receive DeployGate events. Implement this and pass to * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. * * @author tnj * @deprecated since 4.9.0. Use each extended callback interfaces instead. + * @see com.deploygate.sdk.DeployGateInitializeCallback + * @see com.deploygate.sdk.DeployGateStatusChangeCallback + * @see com.deploygate.sdk.DeployGateUpdateAvailableCallback */ @Deprecated public interface DeployGateCallback extends DeployGateInitializeCallback, DeployGateStatusChangeCallback, DeployGateUpdateAvailableCallback { - /** - * Callback to tell the finish of DeployGate service initialization - * procedure. - * - * @param isServiceAvailable - * true if DeployGate service is available on the - * device. - * @deprecated since 4.9.0. Use {@link DeployGateInitializeCallback#onInitialized(boolean)} instead. - */ - @Deprecated - @Override - public void onInitialized(boolean isServiceAvailable); - - /** - * Callback to tell the app status on the DeployGate has changed. This will - * also be called back just after {@link #onInitialized(boolean)}, - * {@link DeployGate#refresh()} and - * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} with - * true in second argument. - * - * @param isManaged - * true if the app is known on DeployGate app - * @param isAuthorized - * true if the app is on current user's installed list - * @param loginUsername - * Current login username, returned only when - * isAuthorized is true. - * @param isStopped - * Reserved. - * @deprecated since 4.9.0. Use {@link DeployGateStatusChangeCallback#onStatusChanged(boolean, boolean, String, boolean)} instead. - */ - @Deprecated - @Override - public void onStatusChanged( - boolean isManaged, - boolean isAuthorized, - String loginUsername, - boolean isStopped - ); - - /** - * Callback to tell the new version is available. - * - * @param revision - * revision of new version - * @param versionName - * user-defined version name of new version - * @param versionCode - * user-defined version code of new version - * @deprecated since 4.9.0. Use {@link DeployGateUpdateAvailableCallback#onUpdateAvailable(int, String, int)} instead. - */ - @Deprecated - @Override - public void onUpdateAvailable( - int revision, - String versionName, - int versionCode - ); } \ No newline at end of file diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java index b2903d9..4f48e40 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -1,71 +1,15 @@ package com.deploygate.sdk; - /** * A callback interface to receive DeployGate events. Implement this and pass to * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. * * @author tnj * @deprecated since 4.9.0. Use each extended callback interfaces instead. + * @see com.deploygate.sdk.DeployGateInitializeCallback + * @see com.deploygate.sdk.DeployGateStatusChangeCallback + * @see com.deploygate.sdk.DeployGateUpdateAvailableCallback */ @Deprecated public interface DeployGateCallback extends DeployGateInitializeCallback, DeployGateStatusChangeCallback, DeployGateUpdateAvailableCallback { - /** - * Callback to tell the finish of DeployGate service initialization - * procedure. - * - * @param isServiceAvailable - * true if DeployGate service is available on the - * device. - * @deprecated since 4.9.0. Use {@link DeployGateInitializeCallback#onInitialized(boolean)} instead. - */ - @Deprecated - @Override - public void onInitialized(boolean isServiceAvailable); - - /** - * Callback to tell the app status on the DeployGate has changed. This will - * also be called back just after {@link #onInitialized(boolean)}, - * {@link DeployGate#refresh()} and - * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} with - * true in second argument. - * - * @param isManaged - * true if the app is known on DeployGate app - * @param isAuthorized - * true if the app is on current user's installed list - * @param loginUsername - * Current login username, returned only when - * isAuthorized is true. - * @param isStopped - * Reserved. - * @deprecated since 4.9.0. Use {@link DeployGateStatusChangeCallback#onStatusChanged(boolean, boolean, String, boolean)} instead. - */ - @Deprecated - @Override - public void onStatusChanged( - boolean isManaged, - boolean isAuthorized, - String loginUsername, - boolean isStopped - ); - - /** - * Callback to tell the new version is available. - * - * @param revision - * revision of new version - * @param versionName - * user-defined version name of new version - * @param versionCode - * user-defined version code of new version - * @deprecated since 4.9.0. Use {@link DeployGateUpdateAvailableCallback#onUpdateAvailable(int, String, int)} instead. - */ - @Deprecated - @Override - public void onUpdateAvailable( - int revision, - String versionName, - int versionCode - ); } \ No newline at end of file From 6bee4f7eb753630679e5a0b04f2bdfc31518cd3b Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 11:41:52 +0900 Subject: [PATCH 10/23] fix: mark deprecated in sdkMock module --- sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java index 4dd6c38..9644231 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java @@ -98,12 +98,14 @@ public static void registerUpdateAvailableCallback( public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { } + @Deprecated public static void registerCallback( DeployGateCallback listener, boolean refreshImmediately ) { } + @Deprecated public static void unregisterCallback(DeployGateCallback listener) { } From bcd6b861a4749025623b7f274ed58e4c29c5bac0 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 12:09:24 +0900 Subject: [PATCH 11/23] fix: delete member of deprecated interface --- .../java/com/deploygate/sdk/DeployGate.java | 65 +++++++++++-------- .../sdk/DeployGateSdkConfiguration.java | 29 +++++++-- .../java/com/deploygate/sdk/DeployGate.java | 4 +- .../sdk/DeployGateSdkConfiguration.java | 3 +- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 09622ad..b070c58 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -65,7 +65,6 @@ public class DeployGate { private final Handler mHandler; private final ILogcatInstructionSerializer mLogcatInstructionSerializer; private final CustomLogInstructionSerializer mCustomLogInstructionSerializer; - private final HashSet mCallbacks; private final HashSet mInitializeCallbacks; private final HashSet mStatusChangeCallbacks; private final HashSet mUpdateAvailableCallbacks; @@ -196,17 +195,11 @@ private void onInitialized( @Override public void run() { // call onInitialized on each callbacks - for (DeployGateCallback callback : mCallbacks) { - callback.onInitialized(true); - } for (DeployGateInitializeCallback callback : mInitializeCallbacks) { callback.onInitialized(true); } // after call onInitialized, then call onStatusChanged - for (DeployGateCallback callback : mCallbacks) { - callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); - } for (DeployGateStatusChangeCallback callback : mStatusChangeCallbacks) { callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); } @@ -241,10 +234,6 @@ private void onUpdateArrived( mHandler.post(new Runnable() { @Override public void run() { - for (DeployGateCallback callback : mCallbacks) { - callback.onUpdateAvailable(serial, versionName, versionCode); - } - for (DeployGateUpdateAvailableCallback callback : mUpdateAvailableCallbacks) { callback.onUpdateAvailable(serial, versionName, versionCode); } @@ -305,17 +294,11 @@ void callbackDeployGateUnavailable() { @Override public void run() { // call onInitialized on each callbacks - for (DeployGateCallback callback : mCallbacks) { - callback.onInitialized(false); - } for (DeployGateInitializeCallback callback : mInitializeCallbacks) { callback.onInitialized(false); } // after call onInitialized, then call onStatusChanged - for (DeployGateCallback callback : mCallbacks) { - callback.onStatusChanged(false, false, null, false); - } for (DeployGateStatusChangeCallback callback : mStatusChangeCallbacks) { callback.onStatusChanged(false, false, null, false); } @@ -342,7 +325,6 @@ private DeployGate( mHandler = new Handler(); mLogcatInstructionSerializer = mHostApp.canUseLogcat ? new LogcatInstructionSerializer(mHostApp.packageName) : ILogcatInstructionSerializer.NULL_INSTANCE; mCustomLogInstructionSerializer = new CustomLogInstructionSerializer(mHostApp.packageName, sdkConfiguration.customLogConfiguration); - mCallbacks = new HashSet<>(); mInitializeCallbacks = new HashSet<>(); mStatusChangeCallbacks = new HashSet<>(); mUpdateAvailableCallbacks = new HashSet<>(); @@ -351,10 +333,6 @@ private DeployGate( prepareBroadcastReceiver(); - if (sdkConfiguration.callback != null) { - mCallbacks.add(sdkConfiguration.callback); - } - if (sdkConfiguration.initializeCallback != null) { mInitializeCallbacks.add(sdkConfiguration.initializeCallback); } @@ -1018,10 +996,28 @@ public static void registerCallback( } private void registerCallbackInternal( - DeployGateCallback listener, + final DeployGateCallback listener, boolean callbackImmediately ) { - mCallbacks.add(listener); + mInitializeCallbacks.add(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + listener.onInitialized(isServiceAvailable); + } + }); + mStatusChangeCallbacks.add(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + listener.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); + } + }); + mUpdateAvailableCallbacks.add(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + listener.onUpdateAvailable(revision, versionName, versionCode); + } + }); + if (callbackImmediately) { refresh(); } @@ -1041,7 +1037,7 @@ private void registerCallbackInternal( * @see #unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback) */ @Deprecated - public static void unregisterCallback(DeployGateCallback listener) { + public static void unregisterCallback(final DeployGateCallback listener) { if (sInstance == null) { return; } @@ -1049,7 +1045,24 @@ public static void unregisterCallback(DeployGateCallback listener) { return; } - sInstance.mCallbacks.remove(listener); + sInstance.mInitializeCallbacks.remove(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + listener.onInitialized(isServiceAvailable); + } + }); + sInstance.mStatusChangeCallbacks.remove(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + listener.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); + } + }); + sInstance.mUpdateAvailableCallbacks.remove(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + listener.onUpdateAvailable(revision, versionName, versionCode); + } + }); } /** diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 5432111..1e55fa5 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -12,7 +12,6 @@ public final class DeployGateSdkConfiguration { final boolean isCrashReportingEnabled; - final DeployGateCallback callback; final DeployGateInitializeCallback initializeCallback; final DeployGateStatusChangeCallback statusChangeCallback; final DeployGateUpdateAvailableCallback updateAvailableCallback; @@ -29,7 +28,6 @@ private DeployGateSdkConfiguration( builder.appOwnerName, builder.isCrashReportingEnabled, builder.isCaptureEnabled, - builder.callback, builder.initializeCallback, builder.statusChangeCallback, builder.updateAvailableCallback @@ -43,7 +41,6 @@ private DeployGateSdkConfiguration( String appOwnerName, boolean isCrashReportingEnabled, boolean isCaptureEnabled, - DeployGateCallback callback, DeployGateInitializeCallback initializeCallback, DeployGateStatusChangeCallback statusChangeCallback, DeployGateUpdateAvailableCallback updateAvailableCallback @@ -54,7 +51,6 @@ private DeployGateSdkConfiguration( this.appOwnerName = appOwnerName; this.isCrashReportingEnabled = isCrashReportingEnabled; this.isCaptureEnabled = isCaptureEnabled; - this.callback = callback; this.initializeCallback = initializeCallback; this.statusChangeCallback = statusChangeCallback; this.updateAvailableCallback = updateAvailableCallback; @@ -72,7 +68,6 @@ public static final class Builder { private boolean isCaptureEnabled = true; - private DeployGateCallback callback = null; private DeployGateInitializeCallback initializeCallback = null; private DeployGateStatusChangeCallback statusChangeCallback = null; private DeployGateUpdateAvailableCallback updateAvailableCallback = null; @@ -162,10 +157,30 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { * Set an instance of callback. The reference won't be released. Please use {@link DeployGate#registerCallback(DeployGateCallback, boolean)} for memory sensitive works. * @return self * @deprecated since 4.9.0. Use each extended callback interfaces instead. + * @see #setInitializeCallback(DeployGateInitializeCallback) + * @see #setStatusChangeCallback(DeployGateStatusChangeCallback) + * @see #setUpdateAvailableCallback(DeployGateUpdateAvailableCallback) */ @Deprecated - public Builder setCallback(DeployGateCallback callback) { - this.callback = callback; + public Builder setCallback(final DeployGateCallback callback) { + this.setInitializeCallback(new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + callback.onInitialized(isServiceAvailable); + } + }); + this.setStatusChangeCallback(new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); + } + }); + this.setUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + callback.onUpdateAvailable(revision, versionName, versionCode); + } + }); return this; } diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java index 9644231..22232cb 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java @@ -100,13 +100,13 @@ public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCa @Deprecated public static void registerCallback( - DeployGateCallback listener, + final DeployGateCallback listener, boolean refreshImmediately ) { } @Deprecated - public static void unregisterCallback(DeployGateCallback listener) { + public static void unregisterCallback(final DeployGateCallback listener) { } public static boolean isInitialized() { diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 5a6974d..9c237a6 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -32,7 +32,7 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { return this; } - public Builder setCallback(DeployGateCallback callback) { + public Builder setCallback(final DeployGateCallback callback) { return this; } @@ -48,7 +48,6 @@ public Builder setUpdateAvailableCallback(DeployGateUpdateAvailableCallback upda return this; } - public DeployGateSdkConfiguration build() { return new DeployGateSdkConfiguration(); } From 41bdd9c6c7053c136f98ee10e06370252a1df293 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 12:30:36 +0900 Subject: [PATCH 12/23] fix: remove 'refreshImmediately' argument --- .../java/com/deploygate/sdk/DeployGate.java | 63 +++++-------------- .../sdk/DeployGateInterfaceTest.java | 42 +++---------- .../java/com/deploygate/sdk/DeployGate.java | 15 +---- 3 files changed, 27 insertions(+), 93 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index b070c58..eb426b5 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -809,15 +809,10 @@ private void refreshInternal() { * when the callback is no longer needed (e.g., on destroying an activity.) * If the listener has already in the callback list, just ignored. * - * @param callback callback listener - * @param refreshImmediately if you want to receive current states, set this - * true. + * @param callback callback listener * @since 4.9.0 */ - public static void registerInitializeCallback( - DeployGateInitializeCallback callback, - boolean refreshImmediately - ) { + public static void registerInitializeCallback(DeployGateInitializeCallback callback) { if (sInstance == null) { return; } @@ -825,17 +820,11 @@ public static void registerInitializeCallback( return; } - sInstance.registerInitializeCallbackInternal(callback, refreshImmediately); + sInstance.registerInitializeCallbackInternal(callback); } - private void registerInitializeCallbackInternal( - DeployGateInitializeCallback callback, - boolean refreshImmediately - ) { + private void registerInitializeCallbackInternal(DeployGateInitializeCallback callback) { mInitializeCallbacks.add(callback); - if (refreshImmediately) { - refresh(); - } } /** @@ -862,15 +851,10 @@ public static void unregisterInitializeCallback(DeployGateInitializeCallback cal * when the callback is no longer needed (e.g., on destroying an activity.) * If the listener has already in the callback list, just ignored. * - * @param callback callback listener - * @param refreshImmediately if you want to receive current states, set this - * true. + * @param callback callback listener * @since 4.9.0 */ - public static void registerStatusChangeCallback( - DeployGateStatusChangeCallback callback, - boolean refreshImmediately - ) { + public static void registerStatusChangeCallback(DeployGateStatusChangeCallback callback) { if (sInstance == null) { return; } @@ -878,17 +862,11 @@ public static void registerStatusChangeCallback( return; } - sInstance.registerStatusChangeCallbackInternal(callback, refreshImmediately); + sInstance.registerStatusChangeCallbackInternal(callback); } - private void registerStatusChangeCallbackInternal( - DeployGateStatusChangeCallback callback, - boolean refreshImmediately - ) { + private void registerStatusChangeCallbackInternal(DeployGateStatusChangeCallback callback) { mStatusChangeCallbacks.add(callback); - if (refreshImmediately) { - refresh(); - } } /** @@ -915,15 +893,10 @@ public static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback * when the callback is no longer needed (e.g., on destroying an activity.) * If the listener has already in the callback list, just ignored. * - * @param callback callback listener - * @param refreshImmediately if you want to receive current states, set this - * true. + * @param callback callback listener * @since 4.9.0 */ - public static void registerUpdateAvailableCallback( - DeployGateUpdateAvailableCallback callback, - boolean refreshImmediately - ) { + public static void registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { if (sInstance == null) { return; } @@ -931,17 +904,11 @@ public static void registerUpdateAvailableCallback( return; } - sInstance.registerUpdateAvailableCallbackInternal(callback, refreshImmediately); + sInstance.registerUpdateAvailableCallbackInternal(callback); } - private void registerUpdateAvailableCallbackInternal( - DeployGateUpdateAvailableCallback callback, - boolean refreshImmediately - ) { + private void registerUpdateAvailableCallbackInternal(DeployGateUpdateAvailableCallback callback) { mUpdateAvailableCallbacks.add(callback); - if (refreshImmediately) { - refresh(); - } } /** @@ -976,9 +943,9 @@ public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCa * * @since r1 * @deprecated since 4.9.0. Use each register method for separated callbacks instead. - * @see #registerInitializeCallback(DeployGateInitializeCallback, boolean) - * @see #registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean) - * @see #registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback, boolean) + * @see #registerInitializeCallback(DeployGateInitializeCallback) + * @see #registerStatusChangeCallback(DeployGateStatusChangeCallback) + * @see #registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback) */ @Deprecated public static void registerCallback( diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java index 89d02ad..bdbf79a 100644 --- a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java @@ -214,56 +214,32 @@ public void onUpdateAvailable( } }, false); - DeployGate.registerInitializeCallback(null, true); - DeployGate.registerInitializeCallback(null, false); - DeployGate.registerInitializeCallback(initializeCallback, true); - DeployGate.registerInitializeCallback(initializeCallback, false); + DeployGate.registerInitializeCallback(null); + DeployGate.registerInitializeCallback(initializeCallback); DeployGate.registerInitializeCallback(new DeployGateInitializeCallback() { @Override public void onInitialized(boolean isServiceAvailable) { } - }, true); - DeployGate.registerInitializeCallback(new DeployGateInitializeCallback() { - @Override - public void onInitialized(boolean isServiceAvailable) { - - } - }, false); - - DeployGate.registerStatusChangeCallback(null, true); - DeployGate.registerStatusChangeCallback(null, false); - DeployGate.registerStatusChangeCallback(statusChangeCallback, true); - DeployGate.registerStatusChangeCallback(statusChangeCallback, false); - DeployGate.registerStatusChangeCallback(new DeployGateStatusChangeCallback() { - @Override - public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + }); - } - }, true); + DeployGate.registerStatusChangeCallback(null); + DeployGate.registerStatusChangeCallback(statusChangeCallback); DeployGate.registerStatusChangeCallback(new DeployGateStatusChangeCallback() { @Override public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { } - }, false); - - DeployGate.registerUpdateAvailableCallback(null, true); - DeployGate.registerUpdateAvailableCallback(null, false); - DeployGate.registerUpdateAvailableCallback(updateAvailableCallback, true); - DeployGate.registerUpdateAvailableCallback(updateAvailableCallback, false); - DeployGate.registerUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { - @Override - public void onUpdateAvailable(int revision, String versionName, int versionCode) { + }); - } - }, true); + DeployGate.registerUpdateAvailableCallback(null); + DeployGate.registerUpdateAvailableCallback(updateAvailableCallback); DeployGate.registerUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { @Override public void onUpdateAvailable(int revision, String versionName, int versionCode) { } - }, false); + }); } @Test diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java index 22232cb..8dfda18 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java @@ -71,28 +71,19 @@ public static void install( public static void refresh() { } - public static void registerInitializeCallback( - DeployGateInitializeCallback callback, - boolean refreshImmediately - ) { + public static void registerInitializeCallback(DeployGateInitializeCallback callback) { } public static void unregisterInitializeCallback(DeployGateInitializeCallback callback) { } - public static void registerStatusChangeCallback( - DeployGateStatusChangeCallback callback, - boolean refreshImmediately - ) { + public static void registerStatusChangeCallback(DeployGateStatusChangeCallback callback) { } public static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback callback) { } - public static void registerUpdateAvailableCallback( - DeployGateUpdateAvailableCallback callback, - boolean refreshImmediately - ) { + public static void registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { } public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCallback callback) { From c361d0163a0dbd4879ed8941a4cd12b5e5bb5cb2 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 12:40:02 +0900 Subject: [PATCH 13/23] chore: update sample code --- sample/src/main/java/com/deploygate/sample/App.java | 4 ++-- .../java/com/deploygate/sample/SampleActivity.java | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sample/src/main/java/com/deploygate/sample/App.java b/sample/src/main/java/com/deploygate/sample/App.java index 46bee46..45abaf5 100644 --- a/sample/src/main/java/com/deploygate/sample/App.java +++ b/sample/src/main/java/com/deploygate/sample/App.java @@ -72,9 +72,9 @@ public void onCreate() { DeployGate.install(this, configuration); // If you want to prevent the app distributed by someone else, specify your username on DeployGate - // as a second argument of DeployGate.install, like: + // with setAuthor method when creating DeployGate SdkConfiguration. like: // - // DeployGate.install(this, "YOURUSERNAME"); + // builder.setAuthor("YOURUSERNAME") // // You can use DeployGate.isAuthorized() later to check the installation is valid or not. } diff --git a/sample/src/main/java/com/deploygate/sample/SampleActivity.java b/sample/src/main/java/com/deploygate/sample/SampleActivity.java index 8ef1680..dd10d67 100644 --- a/sample/src/main/java/com/deploygate/sample/SampleActivity.java +++ b/sample/src/main/java/com/deploygate/sample/SampleActivity.java @@ -71,13 +71,12 @@ protected void onResume() { super.onResume(); // register for callbacks - DeployGate.registerInitializeCallback(this, false); - DeployGate.registerStatusChangeCallback(this, false); - // call register method with second argument true to get the status immediately - DeployGate.registerUpdateAvailableCallback(this, true); + DeployGate.registerInitializeCallback(this); + DeployGate.registerStatusChangeCallback(this); + DeployGate.registerUpdateAvailableCallback(this); - // or you can also call DeployGate.refresh() if you want to check the status immediately - // DeployGate.refresh(); + // finally, call refresh() method if you want to check the status immediately + DeployGate.refresh(); } @Override From 3954e1c9d9e16ae1e09bdde445318bfd967d8376 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 12:51:08 +0900 Subject: [PATCH 14/23] chore: add javadoc --- .../deploygate/sdk/DeployGateInitializeCallback.java | 7 +++++++ .../sdk/DeployGateStatusChangeCallback.java | 11 ++++++++--- .../sdk/DeployGateUpdateAvailableCallback.java | 7 +++++++ .../deploygate/sdk/DeployGateInitializeCallback.java | 7 +++++++ .../sdk/DeployGateStatusChangeCallback.java | 11 ++++++++--- .../sdk/DeployGateUpdateAvailableCallback.java | 7 +++++++ 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java index b74b4d8..b1907e9 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -1,5 +1,12 @@ package com.deploygate.sdk; +/** + * A callback interface to receive DeployGate service initialization events.Implement this and pass to + * {@link DeployGate#registerInitializeCallback(DeployGateInitializeCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerInitializeCallback(DeployGateInitializeCallback) + */ public interface DeployGateInitializeCallback { /** * Callback to tell the finish of DeployGate service initialization diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java index f657046..c0d0ecf 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -1,12 +1,17 @@ package com.deploygate.sdk; +/** + * A callback interface to receive the app status on the DeployGate. Implement this and pass to + * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback) + */ public interface DeployGateStatusChangeCallback { /** * Callback to tell the app status on the DeployGate has changed. This will * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, - * {@link DeployGate#refresh()} and - * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean)} with - * true in second argument. + * {@link DeployGate#refresh()}. * * @param isManaged true if the app is known on DeployGate app * @param isAuthorized true if the app is on current user's installed list diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java index 30c1ffa..504a11f 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -1,5 +1,12 @@ package com.deploygate.sdk; +/** + * A callback interface to receive the app update event. Implement this and pass to + * {@link DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback) + */ public interface DeployGateUpdateAvailableCallback { /** * Callback to tell the new version is available. diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java index 4a25a1a..ccd5262 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -1,5 +1,12 @@ package com.deploygate.sdk; +/** + * A callback interface to receive DeployGate service initialization events.Implement this and pass to + * {@link DeployGate#registerInitializeCallback(DeployGateInitializeCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerInitializeCallback(DeployGateInitializeCallback) + */ public interface DeployGateInitializeCallback { /** * Callback to tell the finish of DeployGate service initialization diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java index ee42904..e269c1f 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -1,12 +1,17 @@ package com.deploygate.sdk; +/** + * A callback interface to receive the app status on the DeployGate. Implement this and pass to + * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback) + */ public interface DeployGateStatusChangeCallback { /** * Callback to tell the app status on the DeployGate has changed. This will * also be called back just after {@link DeployGateInitializeCallback#onInitialized(boolean)}, - * {@link DeployGate#refresh()} and - * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback, boolean)} with - * true in second argument. + * {@link DeployGate#refresh()}. * * @param isManaged true if the app is known on DeployGate app * @param isAuthorized true if the app is on current user's installed list diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java index 30c1ffa..504a11f 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -1,5 +1,12 @@ package com.deploygate.sdk; +/** + * A callback interface to receive the app update event. Implement this and pass to + * {@link DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback)} to listen. + * + * @since 4.9.0. + * @see DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback) + */ public interface DeployGateUpdateAvailableCallback { /** * Callback to tell the new version is available. From 40622883a0d4dd11ffbb84ffb8235488221d41d0 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 13:05:38 +0900 Subject: [PATCH 15/23] fix: forgot semi-colon --- sample/src/main/java/com/deploygate/sample/App.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/src/main/java/com/deploygate/sample/App.java b/sample/src/main/java/com/deploygate/sample/App.java index 45abaf5..3c00a3b 100644 --- a/sample/src/main/java/com/deploygate/sample/App.java +++ b/sample/src/main/java/com/deploygate/sample/App.java @@ -74,7 +74,7 @@ public void onCreate() { // If you want to prevent the app distributed by someone else, specify your username on DeployGate // with setAuthor method when creating DeployGate SdkConfiguration. like: // - // builder.setAuthor("YOURUSERNAME") + // builder.setAuthor("YOURUSERNAME"); // // You can use DeployGate.isAuthorized() later to check the installation is valid or not. } From 1d45993856590bf1d0fe3f3a2d0d5679a5408052 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 18:32:55 +0900 Subject: [PATCH 16/23] test: add testcase of register/unregister callbacks --- .../java/com/deploygate/sdk/DeployGate.java | 12 + .../com/deploygate/sdk/DeployGateTest.java | 208 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 sdk/src/test/java/com/deploygate/sdk/DeployGateTest.java diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index eb426b5..2671b61 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -1664,4 +1664,16 @@ private static CustomAttributes getSdkDeviceStates() { return sSdkDeviceStates; } + + static HashSet getInitializeCallbacks() { + return sInstance != null ? sInstance.mInitializeCallbacks : null; + } + + static HashSet getStatusChangeCallbacks() { + return sInstance != null ? sInstance.mStatusChangeCallbacks : null; + } + + static HashSet getUpdateAvailableCallbacks() { + return sInstance != null ? sInstance.mUpdateAvailableCallbacks : null; + } } diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateTest.java new file mode 100644 index 0000000..ee0dc61 --- /dev/null +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateTest.java @@ -0,0 +1,208 @@ +package com.deploygate.sdk; + +import static androidx.test.core.app.ApplicationProvider.getApplicationContext; + +import android.app.Application; + +import androidx.annotation.NonNull; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.google.common.truth.Truth; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class DeployGateTest { + + @NonNull + Application app; + + @NonNull + DeployGateSdkConfiguration configuration; + + DeployGateCallback callback; + DeployGateInitializeCallback initializeCallback; + DeployGateStatusChangeCallback statusChangeCallback; + DeployGateUpdateAvailableCallback updateAvailableCallback; + + @Before + public void setUp() { + app = getApplicationContext(); + configuration = new DeployGateSdkConfiguration.Builder().build(); + callback = new DeployGateCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + initializeCallback = new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + }; + statusChangeCallback = new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + }; + updateAvailableCallback = new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + + DeployGate.install(app, configuration); + } + + @After + public void tearDown() { + DeployGate.clear(); + } + + @Test + public void register_fine_grained_callbacks() { + DeployGateInitializeCallback anotherInitializeCallback = new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + }; + DeployGateStatusChangeCallback anotherStatusChangeCallback = new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + }; + DeployGateUpdateAvailableCallback anotherUpdateAvailableCallback = new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(0); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(0); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(0); + + DeployGate.registerInitializeCallback(initializeCallback); + DeployGate.registerStatusChangeCallback(statusChangeCallback); + DeployGate.registerUpdateAvailableCallback(updateAvailableCallback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getInitializeCallbacks().contains(initializeCallback)).isTrue(); + Truth.assertThat(DeployGate.getInitializeCallbacks().contains(anotherInitializeCallback)).isFalse(); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().contains(statusChangeCallback)).isTrue(); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().contains(anotherStatusChangeCallback)).isFalse(); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().contains(updateAvailableCallback)).isTrue(); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().contains(anotherUpdateAvailableCallback)).isFalse(); + + // Each callback already registered before, so DeployGate maybe ignore this operation. + DeployGate.registerInitializeCallback(initializeCallback); + DeployGate.registerStatusChangeCallback(statusChangeCallback); + DeployGate.registerUpdateAvailableCallback(updateAvailableCallback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + + // register another callbacks + DeployGate.registerInitializeCallback(anotherInitializeCallback); + DeployGate.registerStatusChangeCallback(anotherStatusChangeCallback); + DeployGate.registerUpdateAvailableCallback(anotherUpdateAvailableCallback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(2); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(2); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(2); + + DeployGate.unregisterInitializeCallback(initializeCallback); + DeployGate.unregisterStatusChangeCallback(statusChangeCallback); + DeployGate.unregisterUpdateAvailableCallback(updateAvailableCallback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + + // Each callback already unregistered before, so DeployGate maybe ignore this operation. + DeployGate.unregisterInitializeCallback(initializeCallback); + DeployGate.unregisterStatusChangeCallback(statusChangeCallback); + DeployGate.unregisterUpdateAvailableCallback(updateAvailableCallback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + } + + @Test + public void register_callback() { + DeployGateCallback anotherCallback = new DeployGateCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(0); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(0); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(0); + + DeployGate.registerCallback(callback, false); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getInitializeCallbacks().contains(callback)).isTrue(); + Truth.assertThat(DeployGate.getInitializeCallbacks().contains(anotherCallback)).isFalse(); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().contains(callback)).isTrue(); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().contains(anotherCallback)).isFalse(); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().contains(callback)).isTrue(); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().contains(anotherCallback)).isFalse(); + + // callback already registered before, so DeployGate maybe ignore this operation. + DeployGate.registerCallback(callback, false); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + + // register another callback + DeployGate.registerCallback(anotherCallback, false); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(2); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(2); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(2); + + DeployGate.unregisterCallback(callback); + + Truth.assertThat(DeployGate.getInitializeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getStatusChangeCallbacks().size()).isEqualTo(1); + Truth.assertThat(DeployGate.getUpdateAvailableCallbacks().size()).isEqualTo(1); + } +} From ee6bd30379fc78884ac98c254166a303865d583b Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 18:36:29 +0900 Subject: [PATCH 17/23] fix: use deprecated callback directly when register/unregister --- .../java/com/deploygate/sdk/DeployGate.java | 44 +++---------------- .../java/com/deploygate/sdk/DeployGate.java | 2 +- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 2671b61..2fee7af 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -963,27 +963,12 @@ public static void registerCallback( } private void registerCallbackInternal( - final DeployGateCallback listener, + DeployGateCallback listener, boolean callbackImmediately ) { - mInitializeCallbacks.add(new DeployGateInitializeCallback() { - @Override - public void onInitialized(boolean isServiceAvailable) { - listener.onInitialized(isServiceAvailable); - } - }); - mStatusChangeCallbacks.add(new DeployGateStatusChangeCallback() { - @Override - public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { - listener.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); - } - }); - mUpdateAvailableCallbacks.add(new DeployGateUpdateAvailableCallback() { - @Override - public void onUpdateAvailable(int revision, String versionName, int versionCode) { - listener.onUpdateAvailable(revision, versionName, versionCode); - } - }); + mInitializeCallbacks.add(listener); + mStatusChangeCallbacks.add(listener); + mUpdateAvailableCallbacks.add(listener); if (callbackImmediately) { refresh(); @@ -1012,24 +997,9 @@ public static void unregisterCallback(final DeployGateCallback listener) { return; } - sInstance.mInitializeCallbacks.remove(new DeployGateInitializeCallback() { - @Override - public void onInitialized(boolean isServiceAvailable) { - listener.onInitialized(isServiceAvailable); - } - }); - sInstance.mStatusChangeCallbacks.remove(new DeployGateStatusChangeCallback() { - @Override - public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { - listener.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); - } - }); - sInstance.mUpdateAvailableCallbacks.remove(new DeployGateUpdateAvailableCallback() { - @Override - public void onUpdateAvailable(int revision, String versionName, int versionCode) { - listener.onUpdateAvailable(revision, versionName, versionCode); - } - }); + sInstance.mInitializeCallbacks.remove(listener); + sInstance.mStatusChangeCallbacks.remove(listener); + sInstance.mUpdateAvailableCallbacks.remove(listener); } /** diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java index 8dfda18..e7d3593 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGate.java @@ -91,7 +91,7 @@ public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCa @Deprecated public static void registerCallback( - final DeployGateCallback listener, + DeployGateCallback listener, boolean refreshImmediately ) { } From 0ff07a40a65eaee58760803119fd720373cbfa18 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 18:42:50 +0900 Subject: [PATCH 18/23] chore: separate unregister logic to 'unregisterXXXInternal' private method --- .../java/com/deploygate/sdk/DeployGate.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 2fee7af..4ace0a3 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -842,7 +842,11 @@ public static void unregisterInitializeCallback(DeployGateInitializeCallback cal return; } - sInstance.mInitializeCallbacks.remove(callback); + sInstance.unregisterInitializeCallbackInternal(callback); + } + + private void unregisterInitializeCallbackInternal(DeployGateInitializeCallback callback) { + mInitializeCallbacks.remove(callback); } /** @@ -884,7 +888,11 @@ public static void unregisterStatusChangeCallback(DeployGateStatusChangeCallback return; } - sInstance.mStatusChangeCallbacks.remove(callback); + sInstance.unregisterStatusChangeCallbackInternal(callback); + } + + private void unregisterStatusChangeCallbackInternal(DeployGateStatusChangeCallback callback) { + mStatusChangeCallbacks.remove(callback); } /** @@ -926,7 +934,11 @@ public static void unregisterUpdateAvailableCallback(DeployGateUpdateAvailableCa return; } - sInstance.mUpdateAvailableCallbacks.remove(callback); + sInstance.unregisterUpdateAvailableCallbackInternal(callback); + } + + private void unregisterUpdateAvailableCallbackInternal(DeployGateUpdateAvailableCallback callback) { + mUpdateAvailableCallbacks.remove(callback); } /** @@ -997,9 +1009,13 @@ public static void unregisterCallback(final DeployGateCallback listener) { return; } - sInstance.mInitializeCallbacks.remove(listener); - sInstance.mStatusChangeCallbacks.remove(listener); - sInstance.mUpdateAvailableCallbacks.remove(listener); + sInstance.unregisterCallbackInternal(listener); + } + + private void unregisterCallbackInternal(DeployGateCallback listener) { + mInitializeCallbacks.remove(listener); + mStatusChangeCallbacks.remove(listener); + mUpdateAvailableCallbacks.remove(listener); } /** From 083c8f915177a051858aece8345ad455e8861549 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 19:03:24 +0900 Subject: [PATCH 19/23] fix: improve comments --- sample/src/main/java/com/deploygate/sample/App.java | 2 +- sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java | 5 ++--- .../com/deploygate/sdk/DeployGateInitializeCallback.java | 3 +-- .../com/deploygate/sdk/DeployGateStatusChangeCallback.java | 3 +-- .../deploygate/sdk/DeployGateUpdateAvailableCallback.java | 3 +-- .../src/main/java/com/deploygate/sdk/DeployGateCallback.java | 5 ++--- .../com/deploygate/sdk/DeployGateInitializeCallback.java | 3 +-- .../com/deploygate/sdk/DeployGateStatusChangeCallback.java | 3 +-- .../deploygate/sdk/DeployGateUpdateAvailableCallback.java | 3 +-- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/sample/src/main/java/com/deploygate/sample/App.java b/sample/src/main/java/com/deploygate/sample/App.java index 3c00a3b..b4fc254 100644 --- a/sample/src/main/java/com/deploygate/sample/App.java +++ b/sample/src/main/java/com/deploygate/sample/App.java @@ -28,7 +28,7 @@ public void onCreate() { // Refer the comment on stableReal/AndroidManifest.xml included in this sample. DeployGateSdkConfiguration configuration = new DeployGateSdkConfiguration.Builder() - // Please note that these callback is called if you have removed the content provider. + // Please note that this callback is called iff you have removed the content provider. // For those who wanna use the content provider, SDK provides DeployGate#registerXXXCallback for your use-case. .setInitializeCallback(isServiceAvailable -> { if (isServiceAvailable) { diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java index 4f48e40..e54d6a8 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -1,11 +1,10 @@ package com.deploygate.sdk; /** - * A callback interface to receive DeployGate events. Implement this and pass to - * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. + * A callback interface to receive DeployGate events. * * @author tnj - * @deprecated since 4.9.0. Use each extended callback interfaces instead. + * @deprecated since 4.9.0. Use fine-grained callback interfaces for each purpose. * @see com.deploygate.sdk.DeployGateInitializeCallback * @see com.deploygate.sdk.DeployGateStatusChangeCallback * @see com.deploygate.sdk.DeployGateUpdateAvailableCallback diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java index b1907e9..9288a43 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive DeployGate service initialization events.Implement this and pass to - * {@link DeployGate#registerInitializeCallback(DeployGateInitializeCallback)} to listen. + * A callback interface to receive DeployGate service initialization events. * * @since 4.9.0. * @see DeployGate#registerInitializeCallback(DeployGateInitializeCallback) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java index c0d0ecf..e00822f 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive the app status on the DeployGate. Implement this and pass to - * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback)} to listen. + * A callback interface to receive the app status on the DeployGate. * * @since 4.9.0. * @see DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java index 504a11f..96eaf4b 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive the app update event. Implement this and pass to - * {@link DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback)} to listen. + * A callback interface to receive the app update event. * * @since 4.9.0. * @see DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java index 4f48e40..e54d6a8 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateCallback.java @@ -1,11 +1,10 @@ package com.deploygate.sdk; /** - * A callback interface to receive DeployGate events. Implement this and pass to - * {@link DeployGate#registerCallback(DeployGateCallback, boolean)} to listen. + * A callback interface to receive DeployGate events. * * @author tnj - * @deprecated since 4.9.0. Use each extended callback interfaces instead. + * @deprecated since 4.9.0. Use fine-grained callback interfaces for each purpose. * @see com.deploygate.sdk.DeployGateInitializeCallback * @see com.deploygate.sdk.DeployGateStatusChangeCallback * @see com.deploygate.sdk.DeployGateUpdateAvailableCallback diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java index ccd5262..577ed6d 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateInitializeCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive DeployGate service initialization events.Implement this and pass to - * {@link DeployGate#registerInitializeCallback(DeployGateInitializeCallback)} to listen. + * A callback interface to receive DeployGate service initialization events. * * @since 4.9.0. * @see DeployGate#registerInitializeCallback(DeployGateInitializeCallback) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java index e269c1f..6b82c33 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateStatusChangeCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive the app status on the DeployGate. Implement this and pass to - * {@link DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback)} to listen. + * A callback interface to receive the app status on the DeployGate. * * @since 4.9.0. * @see DeployGate#registerStatusChangeCallback(DeployGateStatusChangeCallback) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java index 504a11f..96eaf4b 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateUpdateAvailableCallback.java @@ -1,8 +1,7 @@ package com.deploygate.sdk; /** - * A callback interface to receive the app update event. Implement this and pass to - * {@link DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback)} to listen. + * A callback interface to receive the app update event. * * @since 4.9.0. * @see DeployGate#registerUpdateAvailableCallback(DeployGateUpdateAvailableCallback) From 190ef4c3ef1441afd58afe56fb82439f6694bd15 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 19:26:52 +0900 Subject: [PATCH 20/23] fix: treat DeployGateCallback as fine-grained callbacks --- .../sdk/DeployGateSdkConfiguration.java | 23 +-- .../sdk/DeployGateSdkConfigurationTest.java | 157 ++++++++++++++++++ .../sdk/DeployGateSdkConfiguration.java | 2 +- 3 files changed, 162 insertions(+), 20 deletions(-) create mode 100644 sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationTest.java diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 1e55fa5..13d08c0 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -162,25 +162,10 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { * @see #setUpdateAvailableCallback(DeployGateUpdateAvailableCallback) */ @Deprecated - public Builder setCallback(final DeployGateCallback callback) { - this.setInitializeCallback(new DeployGateInitializeCallback() { - @Override - public void onInitialized(boolean isServiceAvailable) { - callback.onInitialized(isServiceAvailable); - } - }); - this.setStatusChangeCallback(new DeployGateStatusChangeCallback() { - @Override - public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { - callback.onStatusChanged(isManaged, isAuthorized, loginUsername, isStopped); - } - }); - this.setUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { - @Override - public void onUpdateAvailable(int revision, String versionName, int versionCode) { - callback.onUpdateAvailable(revision, versionName, versionCode); - } - }); + public Builder setCallback(DeployGateCallback callback) { + setInitializeCallback(callback); + setStatusChangeCallback(callback); + setUpdateAvailableCallback(callback); return this; } diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationTest.java new file mode 100644 index 0000000..4e201e6 --- /dev/null +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateSdkConfigurationTest.java @@ -0,0 +1,157 @@ +package com.deploygate.sdk; + +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import com.google.common.truth.Truth; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class DeployGateSdkConfigurationTest { + + CustomLogConfiguration customLogConfiguration; + DeployGateInitializeCallback initializeCallback; + DeployGateStatusChangeCallback statusChangeCallback; + DeployGateUpdateAvailableCallback updateAvailableCallback; + DeployGateCallback deployGateCallback; + + @Before + public void setUp() { + customLogConfiguration = new CustomLogConfiguration.Builder().build(); + initializeCallback = new DeployGateInitializeCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + }; + statusChangeCallback = new DeployGateStatusChangeCallback() { + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + }; + updateAvailableCallback = new DeployGateUpdateAvailableCallback() { + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + deployGateCallback = new DeployGateCallback() { + @Override + public void onInitialized(boolean isServiceAvailable) { + // no-op + } + + @Override + public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { + // no-op + } + + @Override + public void onUpdateAvailable(int revision, String versionName, int versionCode) { + // no-op + } + }; + } + + + @Test + public void builder() { + + DeployGateSdkConfiguration configuration = new DeployGateSdkConfiguration.Builder() + .setAppOwnerName("owner") + .setCaptureEnabled(true) + .setCrashReportingEnabled(true) + .setCustomLogConfiguration(customLogConfiguration) + .setDisabled(false) + .setEnabledOnNonDebuggableBuild(true) + .setInitializeCallback(initializeCallback) + .setStatusChangeCallback(statusChangeCallback) + .setUpdateAvailableCallback(updateAvailableCallback) + .build(); + + Truth.assertThat(configuration.appOwnerName).isEqualTo("owner"); + Truth.assertThat(configuration.isCaptureEnabled).isTrue(); + Truth.assertThat(configuration.isCrashReportingEnabled).isTrue(); + Truth.assertThat(configuration.customLogConfiguration).isEqualTo(customLogConfiguration); + Truth.assertThat(configuration.isDisabled).isFalse(); + Truth.assertThat(configuration.isEnabledOnNonDebuggableBuild).isTrue(); + Truth.assertThat(configuration.initializeCallback).isEqualTo(initializeCallback); + Truth.assertThat(configuration.statusChangeCallback).isEqualTo(statusChangeCallback); + Truth.assertThat(configuration.updateAvailableCallback).isEqualTo(updateAvailableCallback); + } + + @Test + public void builder_setCallback() { + DeployGateSdkConfiguration configurationWithCallback = new DeployGateSdkConfiguration.Builder() + .setCallback(deployGateCallback) + .build(); + + Truth.assertThat(configurationWithCallback.initializeCallback).isEqualTo(deployGateCallback); + Truth.assertThat(configurationWithCallback.statusChangeCallback).isEqualTo(deployGateCallback); + Truth.assertThat(configurationWithCallback.updateAvailableCallback).isEqualTo(deployGateCallback); + } + + @Test + public void builder_setXXXCallback() { + DeployGateSdkConfiguration configurationWithFineGrainedCallbacks = new DeployGateSdkConfiguration.Builder() + .setInitializeCallback(initializeCallback) + .setStatusChangeCallback(statusChangeCallback) + .setUpdateAvailableCallback(updateAvailableCallback) + .build(); + + Truth.assertThat(configurationWithFineGrainedCallbacks.initializeCallback).isEqualTo(initializeCallback); + Truth.assertThat(configurationWithFineGrainedCallbacks.statusChangeCallback).isEqualTo(statusChangeCallback); + Truth.assertThat(configurationWithFineGrainedCallbacks.updateAvailableCallback).isEqualTo(updateAvailableCallback); + } + + @Test + public void builder_setCallbackAndOverride() { + DeployGateSdkConfiguration configurationOverrideByFineGrainedCallbacks = new DeployGateSdkConfiguration.Builder() + .setCallback(deployGateCallback) + .setInitializeCallback(initializeCallback) + .setStatusChangeCallback(statusChangeCallback) + .setUpdateAvailableCallback(updateAvailableCallback) + .build(); + + // the last value set will be used + Truth.assertThat(configurationOverrideByFineGrainedCallbacks.initializeCallback).isEqualTo(initializeCallback); + Truth.assertThat(configurationOverrideByFineGrainedCallbacks.statusChangeCallback).isEqualTo(statusChangeCallback); + Truth.assertThat(configurationOverrideByFineGrainedCallbacks.updateAvailableCallback).isEqualTo(updateAvailableCallback); + + DeployGateSdkConfiguration configurationOverrideByCallback = new DeployGateSdkConfiguration.Builder() + .setInitializeCallback(initializeCallback) + .setStatusChangeCallback(statusChangeCallback) + .setUpdateAvailableCallback(updateAvailableCallback) + .setCallback(deployGateCallback) + .build(); + + Truth.assertThat(configurationOverrideByCallback.initializeCallback).isEqualTo(deployGateCallback); + Truth.assertThat(configurationOverrideByCallback.statusChangeCallback).isEqualTo(deployGateCallback); + Truth.assertThat(configurationOverrideByCallback.updateAvailableCallback).isEqualTo(deployGateCallback); + + DeployGateSdkConfiguration configurationWithCallbackOverrideByNull = new DeployGateSdkConfiguration.Builder() + .setCallback(deployGateCallback) + .setInitializeCallback(null) + .setStatusChangeCallback(null) + .setUpdateAvailableCallback(null) + .build(); + + Truth.assertThat(configurationWithCallbackOverrideByNull.initializeCallback).isNull(); + Truth.assertThat(configurationWithCallbackOverrideByNull.statusChangeCallback).isNull(); + Truth.assertThat(configurationWithCallbackOverrideByNull.updateAvailableCallback).isNull(); + + DeployGateSdkConfiguration configurationWithFineGrainedCallbacksOverrideByNull = new DeployGateSdkConfiguration.Builder() + .setInitializeCallback(initializeCallback) + .setStatusChangeCallback(statusChangeCallback) + .setUpdateAvailableCallback(updateAvailableCallback) + .setCallback(null) + .build(); + + Truth.assertThat(configurationWithFineGrainedCallbacksOverrideByNull.initializeCallback).isNull(); + Truth.assertThat(configurationWithFineGrainedCallbacksOverrideByNull.statusChangeCallback).isNull(); + Truth.assertThat(configurationWithFineGrainedCallbacksOverrideByNull.updateAvailableCallback).isNull(); + } +} diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index 9c237a6..ca999d4 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -32,7 +32,7 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { return this; } - public Builder setCallback(final DeployGateCallback callback) { + public Builder setCallback(DeployGateCallback callback) { return this; } From 6af347c278d707003ef5ed1139025f4bcb278b04 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 19:57:38 +0900 Subject: [PATCH 21/23] chore: add comment to package-private static methods --- sdk/src/main/java/com/deploygate/sdk/DeployGate.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java index 4ace0a3..924395d 100644 --- a/sdk/src/main/java/com/deploygate/sdk/DeployGate.java +++ b/sdk/src/main/java/com/deploygate/sdk/DeployGate.java @@ -1651,14 +1651,23 @@ private static CustomAttributes getSdkDeviceStates() { return sSdkDeviceStates; } + /** + * Not a public API. This is only for testing. + */ static HashSet getInitializeCallbacks() { return sInstance != null ? sInstance.mInitializeCallbacks : null; } + /** + * Not a public API. This is only for testing. + */ static HashSet getStatusChangeCallbacks() { return sInstance != null ? sInstance.mStatusChangeCallbacks : null; } + /** + * Not a public API. This is only for testing. + */ static HashSet getUpdateAvailableCallbacks() { return sInstance != null ? sInstance.mUpdateAvailableCallbacks : null; } From 12883ac2b4684512e9856cd8cf1e67319c3c5620 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 19:59:33 +0900 Subject: [PATCH 22/23] chore: add no-op comment --- .../sdk/DeployGateInterfaceTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java index bdbf79a..b4f3727 100644 --- a/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java +++ b/sdk/src/test/java/com/deploygate/sdk/DeployGateInterfaceTest.java @@ -219,7 +219,7 @@ public void onUpdateAvailable( DeployGate.registerInitializeCallback(new DeployGateInitializeCallback() { @Override public void onInitialized(boolean isServiceAvailable) { - + // no-op } }); @@ -228,7 +228,7 @@ public void onInitialized(boolean isServiceAvailable) { DeployGate.registerStatusChangeCallback(new DeployGateStatusChangeCallback() { @Override public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { - + // no-op } }); @@ -237,7 +237,7 @@ public void onStatusChanged(boolean isManaged, boolean isAuthorized, String logi DeployGate.registerUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { @Override public void onUpdateAvailable(int revision, String versionName, int versionCode) { - + // no-op } }); } @@ -248,7 +248,7 @@ public void unregisterCallback() { DeployGate.unregisterCallback(new DeployGateCallback() { @Override public void onInitialized(boolean isServiceAvailable) { - + // no-op } @Override @@ -258,7 +258,7 @@ public void onStatusChanged( String loginUsername, boolean isStopped ) { - + // no-op } @Override @@ -267,7 +267,7 @@ public void onUpdateAvailable( String versionName, int versionCode ) { - + // no-op } }); DeployGate.unregisterCallback(callback); @@ -276,7 +276,7 @@ public void onUpdateAvailable( DeployGate.unregisterInitializeCallback(new DeployGateInitializeCallback() { @Override public void onInitialized(boolean isServiceAvailable) { - + // no-op } }); DeployGate.unregisterInitializeCallback(initializeCallback); @@ -285,7 +285,7 @@ public void onInitialized(boolean isServiceAvailable) { DeployGate.unregisterStatusChangeCallback(new DeployGateStatusChangeCallback() { @Override public void onStatusChanged(boolean isManaged, boolean isAuthorized, String loginUsername, boolean isStopped) { - + // no-op } }); DeployGate.unregisterStatusChangeCallback(statusChangeCallback); @@ -294,7 +294,7 @@ public void onStatusChanged(boolean isManaged, boolean isAuthorized, String logi DeployGate.unregisterUpdateAvailableCallback(new DeployGateUpdateAvailableCallback() { @Override public void onUpdateAvailable(int revision, String versionName, int versionCode) { - + // no-op } }); DeployGate.unregisterUpdateAvailableCallback(updateAvailableCallback); From 7d5d76b7e915fd437907e69883ec37e1515e0a89 Mon Sep 17 00:00:00 2001 From: satsukies Date: Tue, 20 Aug 2024 19:59:47 +0900 Subject: [PATCH 23/23] fix: deprecated DeployGateSdkConfiguration.Builder#setCallback in sdkMock --- .../main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java | 1 + 1 file changed, 1 insertion(+) diff --git a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java index ca999d4..b512e88 100644 --- a/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java +++ b/sdkMock/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java @@ -32,6 +32,7 @@ public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { return this; } + @Deprecated public Builder setCallback(DeployGateCallback callback) { return this; }