-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide opt-out for crash reporting and device capture features #80
Merged
+338
−30
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f240816
feat: Provide opt-out for crash reporting and device capture
jmatsu d0017ed
feat: Make HostApp state *disabled* if an app is a non-debuggable build
jmatsu 61ff4b6
fix: forceApplyOnReleaseBuild has been renamed to setEnabledOnNonDebu…
jmatsu 504541b
refactor: DRY for a disabled configuration
jmatsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
sdk/src/main/java/com/deploygate/sdk/DeployGateSdkConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package com.deploygate.sdk; | ||
|
||
import com.deploygate.sdk.internal.annotations.Experimental; | ||
|
||
public final class DeployGateSdkConfiguration { | ||
final CustomLogConfiguration customLogConfiguration; | ||
|
||
final boolean isDisabled; | ||
final boolean isEnabledOnNonDebuggableBuild; | ||
|
||
final String appOwnerName; | ||
|
||
final boolean isCrashReportingEnabled; | ||
|
||
|
||
final DeployGateCallback callback; | ||
|
||
final boolean isCaptureEnabled; | ||
|
||
private DeployGateSdkConfiguration( | ||
Builder builder | ||
) { | ||
this( | ||
builder.isDisabled, | ||
builder.customLogConfiguration, | ||
builder.isEnabledOnNonDebuggableBuild, | ||
builder.appOwnerName, | ||
builder.isCrashReportingEnabled, | ||
builder.isCaptureEnabled, | ||
builder.callback | ||
); | ||
} | ||
|
||
private DeployGateSdkConfiguration( | ||
boolean isDisabled, | ||
CustomLogConfiguration customLogConfiguration, | ||
boolean isEnabledOnNonDebuggableBuild, | ||
String appOwnerName, | ||
boolean isCrashReportingEnabled, | ||
boolean isCaptureEnabled, | ||
DeployGateCallback callback | ||
) { | ||
this.customLogConfiguration = customLogConfiguration; | ||
this.isDisabled = isDisabled; | ||
this.isEnabledOnNonDebuggableBuild = isEnabledOnNonDebuggableBuild; | ||
this.appOwnerName = appOwnerName; | ||
this.isCrashReportingEnabled = isCrashReportingEnabled; | ||
this.isCaptureEnabled = isCaptureEnabled; | ||
this.callback = callback; | ||
} | ||
|
||
public static final class Builder { | ||
private CustomLogConfiguration customLogConfiguration = new CustomLogConfiguration.Builder().build(); | ||
|
||
private boolean isDisabled = false; | ||
private boolean isEnabledOnNonDebuggableBuild = false; | ||
|
||
private String appOwnerName = null; | ||
|
||
private boolean isCrashReportingEnabled = true; | ||
|
||
private boolean isCaptureEnabled = true; | ||
|
||
private DeployGateCallback callback = null; | ||
|
||
public Builder() { | ||
} | ||
|
||
/** | ||
* Set a custom log configuration | ||
* | ||
* @param customLogConfiguration | ||
* a configuration object for custom logs like {@link DeployGate#logDebug(String)} | ||
* @see CustomLogConfiguration | ||
* @return self | ||
*/ | ||
@Experimental | ||
public Builder setCustomLogConfiguration(CustomLogConfiguration customLogConfiguration) { | ||
this.customLogConfiguration = customLogConfiguration; | ||
return this; | ||
} | ||
|
||
/** | ||
* Ensure the authority of this app to prevent casual redistribution via DeployGate. | ||
* | ||
* @param appOwnerName | ||
* A name of this app's owner on DeployGate. | ||
* @return self | ||
*/ | ||
public Builder setAppOwnerName(String appOwnerName) { | ||
this.appOwnerName = appOwnerName; | ||
return this; | ||
} | ||
|
||
/** | ||
* Disable all SDK features. | ||
* | ||
* @param disabled | ||
* Specify true if you would like to disable SDK completely. Defaults to false. | ||
* @return self | ||
*/ | ||
public Builder setDisabled(boolean disabled) { | ||
isDisabled = disabled; | ||
return this; | ||
} | ||
|
||
/** | ||
* Enable SDK even on non-debuggable builds. | ||
* | ||
* @param enabledOnNonDebuggableBuild | ||
* Specify true if you would like to enable SDK on non-debuggable builds. Defaults to false. | ||
* @return self | ||
*/ | ||
public Builder setEnabledOnNonDebuggableBuild(boolean enabledOnNonDebuggableBuild) { | ||
isEnabledOnNonDebuggableBuild = enabledOnNonDebuggableBuild; | ||
return this; | ||
} | ||
|
||
/** | ||
* Enable DeployGate Capture feature. | ||
* | ||
* @param captureEnabled | ||
* Specify true if you would like to use DeployGate Capture feature if available. Otherwise, false. Defaults to true. | ||
* @return self | ||
*/ | ||
@Experimental | ||
public Builder setCaptureEnabled(boolean captureEnabled) { | ||
isCaptureEnabled = captureEnabled; | ||
return this; | ||
} | ||
|
||
/** | ||
* Enable DeployGate Crash reporting feature. | ||
* | ||
* @param crashReportingEnabled | ||
* Specify true if you would like to use DeployGate Crash reporting feature. Otherwise, false. Defaults to true. | ||
* @return self | ||
*/ | ||
public Builder setCrashReportingEnabled(boolean crashReportingEnabled) { | ||
isCrashReportingEnabled = crashReportingEnabled; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set a callback of the communication events between DeployGate client app and this app. | ||
* | ||
* @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 | ||
*/ | ||
public Builder setCallback(DeployGateCallback callback) { | ||
this.callback = callback; | ||
return this; | ||
} | ||
|
||
/** | ||
* @return a new sdk configuration. | ||
*/ | ||
public DeployGateSdkConfiguration build() { | ||
if (isDisabled) { | ||
// Create a new builder instance to release all references just in case. | ||
return new DeployGateSdkConfiguration(new Builder().setDisabled(true)); | ||
} else { | ||
return new DeployGateSdkConfiguration(this); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDK cannot turn off the device capture feature completely because triggers will be fired from the client app.