Skip to content

Commit cddc84b

Browse files
committed
Revert "Merge branch 'master' into Release-5.7.2"
This reverts commit 4c819c5, reversing changes made to 760e695.
1 parent 4c819c5 commit cddc84b

File tree

11 files changed

+147
-145
lines changed

11 files changed

+147
-145
lines changed

.github/workflows/unit-and-instrumented-tests-action.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
with:
3131
name: unit-test-api-level-$API_MIN
3232
path: ./Branch-SDK/build/
33-
3433
instrumented-test-api-level-min:
3534
name: instrumented-test-api-level-$API_MIN
3635
runs-on: macos-latest
@@ -67,44 +66,6 @@ jobs:
6766
with:
6867
name: instrumented-test-api-level-$API_MIN
6968
path: ./Branch-SDK/build/
70-
71-
jacoco-test-coverage-api-level-min:
72-
name: jacoco-test-coverage-api-level-$API_MIN
73-
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
74-
needs: [unit-test-api-level-min, instrumented-test-api-level-min]
75-
runs-on: macos-latest
76-
steps:
77-
- name: Checkout
78-
uses: actions/checkout@v3
79-
# create an emulator with google apis, runs on java 8
80-
- name: Create Android emulator
81-
run: |
82-
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses
83-
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_MIN";google_apis;x86_64"
84-
echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_MIN";google_apis;x86_64"
85-
# boots and waits for the emulator to be ready
86-
- name: Launch Emulator
87-
run: |
88-
echo "Starting emulator and waiting for boot to complete."
89-
nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
90-
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82'
91-
echo "Emulator has finished booting"
92-
# repo's gradle is configured to run on java 17
93-
- name: Setup java 17 for gradle
94-
uses: actions/setup-java@v3
95-
with:
96-
distribution: ${{ env.JAVA_DISTRIBUTION }}
97-
java-version: ${{ env.JAVA_VERSION }}
98-
- name: Run Coverage
99-
run: |
100-
./gradlew :Branch-SDK:jacocoTestReport --info
101-
- name: Upload Coverage Test Report
102-
if: success()
103-
uses: codecov/codecov-action@v3
104-
with:
105-
file: ./Branch-SDK/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
106-
fail_ci_if_error: true
107-
10869
unit-test-api-level-current:
10970
name: unit-test-api-level-$API_CURRENT
11071
runs-on: macos-latest

Branch-SDK-TestBed/src/main/java/io/branch/branchandroidtestbed/SettingsActivity.java

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Activity;
44

55
import android.os.Bundle;
6+
import android.view.KeyEvent;
67
import android.view.View;
78
import android.view.inputmethod.EditorInfo;
89
import android.view.inputmethod.InputMethodManager;
@@ -25,7 +26,6 @@ protected void onCreate(Bundle savedInstanceState) {
2526
setupDisableAdNetworkCalloutsSwitch();
2627
setupPrepHelperView();
2728
setupRetryEditText();
28-
setupApiUrlText();
2929
}
3030

3131
void setupRetryEditText() {
@@ -35,40 +35,21 @@ void setupRetryEditText() {
3535

3636
retryEditText.setText(Integer.toString(currentRetries));
3737

38-
retryEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
39-
if (i == EditorInfo.IME_ACTION_DONE) {
40-
int retries = Integer.parseInt(textView.getText().toString());
41-
PrefHelper.getInstance(SettingsActivity.this).setRetryCount(retries);
42-
43-
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
44-
imm.hideSoftInputFromWindow(retryEditText.getWindowToken(), 0);
45-
46-
Toast.makeText(getApplicationContext(), "Set Network Retries to " + retries, Toast.LENGTH_SHORT).show();
47-
return true;
48-
}
49-
return false;
50-
});
51-
}
52-
53-
void setupApiUrlText() {
54-
final EditText apiUrlText = findViewById(R.id.api_url_text);
55-
final PrefHelper prefHelper = PrefHelper.getInstance(this);
56-
String currentApiUrl = prefHelper.getAPIBaseUrl();
57-
58-
apiUrlText.setText(currentApiUrl);
59-
60-
apiUrlText.setOnEditorActionListener((textView, i, keyEvent) -> {
61-
if (i == EditorInfo.IME_ACTION_DONE) {
62-
String newApiUrl = textView.getText().toString();
63-
Branch.getInstance().setAPIUrl(newApiUrl);
64-
65-
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
66-
imm.hideSoftInputFromWindow(apiUrlText.getWindowToken(), 0);
67-
68-
Toast.makeText(getApplicationContext(), "Set API Base URL to " + newApiUrl, Toast.LENGTH_SHORT).show();
69-
return true;
38+
retryEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
39+
@Override
40+
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
41+
if (i == EditorInfo.IME_ACTION_DONE) {
42+
int retries = Integer.valueOf(textView.getText().toString());
43+
PrefHelper.getInstance(SettingsActivity.this).setRetryCount(retries);
44+
45+
InputMethodManager imm = (InputMethodManager)getSystemService(SettingsActivity.this.INPUT_METHOD_SERVICE);
46+
imm.hideSoftInputFromWindow(retryEditText.getWindowToken(), 0);
47+
48+
Toast.makeText(getApplicationContext(), "Set Network Retries to " + retries, Toast.LENGTH_SHORT).show();
49+
return true;
50+
}
51+
return false;
7052
}
71-
return false;
7253
});
7354
}
7455

Branch-SDK-TestBed/src/main/res/layout/activity_settings.xml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,6 @@
5656

5757
</LinearLayout>
5858

59-
<LinearLayout
60-
android:layout_width="match_parent"
61-
android:layout_height="wrap_content"
62-
android:orientation="horizontal">
63-
64-
<TextView
65-
style="@style/testbed_text_view"
66-
android:layout_width="wrap_content"
67-
android:layout_height="match_parent"
68-
android:text="API Base URL" />
69-
70-
<EditText
71-
android:id="@+id/api_url_text"
72-
android:layout_width="240dp"
73-
android:layout_height="wrap_content"
74-
android:gravity="center"
75-
android:inputType="text"
76-
android:maxLines="1"
77-
android:hint="api2.branch.io" />
78-
79-
</LinearLayout>
80-
8159
<TextView
8260
android:id="@+id/prefhelper_text_view"
8361
style="@style/testbed_text_view"

Branch-SDK/build.gradle.kts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ plugins {
66
`maven-publish`
77
signing
88
id("org.gradle.test-retry") version "1.5.3"
9-
id("jacoco")
109
}
1110
val coroutinesVersion = "1.6.4"
12-
jacoco {
13-
toolVersion = "0.8.10"
14-
}
1511

1612
dependencies {
1713
implementation(fileTree(mapOf("dir" to "libs", "include" to "*.jar")))
@@ -96,7 +92,6 @@ android {
9692

9793
debug {
9894
enableUnitTestCoverage = true
99-
enableAndroidTestCoverage = true
10095
buildConfigField("long", "VERSION_CODE", VERSION_CODE)
10196
buildConfigField("String", "VERSION_NAME", VERSION_NAME.wrapInQuotes())
10297
}
@@ -279,30 +274,5 @@ tasks {
279274
retry {
280275
maxRetries.set(3)
281276
}
282-
configure<JacocoTaskExtension> {
283-
isIncludeNoLocationClasses = true
284-
excludes = listOf("jdk.internal.*")
285-
}
286277
}
287278
}
288-
289-
tasks.create<JacocoReport>("jacocoTestReport") {
290-
group = "Reporting"
291-
description = "Generate Jacoco code coverage reports after running tests."
292-
dependsOn("testDebugUnitTest","createDebugCoverageReport")
293-
reports {
294-
xml.required.set(true)
295-
html.required.set(true)
296-
}
297-
sourceDirectories.setFrom("${project.projectDir}/src/main/java")
298-
classDirectories.setFrom("${project.buildDir}/intermediates/javac/debug/classes")
299-
executionData.setFrom(
300-
fileTree(project.buildDir) {
301-
include(
302-
"jacoco/testDebugUnitTest.exec",
303-
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec",
304-
"outputs/code_coverage/debugAndroidTest/connected/**/*.ec",
305-
)
306-
}
307-
)
308-
}

Branch-SDK/src/androidTest/java/io/branch/referral/PrefHelperTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ public void testGetAPIBaseUrl() {
4949

5050
@Test
5151
public void testSetAPIUrl_Example() {
52-
prefHelper.setAPIUrl("https://www.example.com/");
52+
PrefHelper.setAPIUrl("https://www.example.com/");
5353
String actual = prefHelper.getAPIBaseUrl();
5454
Assert.assertEquals("https://www.example.com/", actual);
5555
}
5656

5757
@Test
5858
public void testSetAPIUrl_InvalidHttp() {
59-
prefHelper.setAPIUrl("http://www.example.com/");
59+
PrefHelper.setAPIUrl("http://www.example.com/");
6060
assertDefaultURL();
6161
}
6262

6363
@Test
6464
public void testSetAPIUrl_InvalidNull() {
65-
prefHelper.setAPIUrl(null);
65+
PrefHelper.setAPIUrl(null);
6666
assertDefaultURL();
6767
}
6868

6969
@Test
7070
public void testSetAPIUrl_InvalidEmpty() {
71-
prefHelper.setAPIUrl("");
71+
PrefHelper.setAPIUrl("");
7272
assertDefaultURL();
7373
}
7474

Branch-SDK/src/main/java/io/branch/referral/Branch.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,10 @@ public static void expectDelayedSessionInitialization(boolean expectDelayedInit)
508508
* <p>Sets a custom base URL for all calls to the Branch API. Requires https.</p>
509509
* @param url The {@link String} URL base URL that the Branch API uses.
510510
*/
511-
public void setAPIUrl(String url) {
512-
if (prefHelper_ != null && url.length() > 0) {
513-
prefHelper_.setAPIUrl(url);
514-
}
511+
public static void setAPIUrl(String url) {
512+
PrefHelper.setAPIUrl(url);
515513
}
514+
516515
/**
517516
* <p>Sets a custom CDN base URL.</p>
518517
* @param url The {@link String} base URL for CDN endpoints.
@@ -1025,13 +1024,9 @@ public void logout() {
10251024
* @param callback An instance of {@link io.branch.referral.Branch.LogoutStatusListener} to callback with the logout operation status.
10261025
*/
10271026
public void logout(LogoutStatusListener callback) {
1028-
prefHelper_.setIdentity(PrefHelper.NO_STRING_VALUE);
1029-
prefHelper_.clearUserValues();
1030-
//On Logout clear the link cache and all pending requests
1031-
linkCache_.clear();
1032-
requestQueue_.clear();
1033-
if (callback != null) {
1034-
callback.onLogoutFinished(true, null);
1027+
ServerRequest req = new ServerRequestLogout(context_, callback);
1028+
if (!req.constructError_ && !req.handleErrors(context_)) {
1029+
requestQueue_.handleNewRequest(req);
10351030
}
10361031
}
10371032

Branch-SDK/src/main/java/io/branch/referral/Defines.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public enum RequestPath {
246246
RegisterInstall("v1/install"),
247247
RegisterOpen("v1/open"),
248248
IdentifyUser("v1/profile"),
249+
Logout("v1/logout"),
249250
ContentEvent("v1/content-events"),
250251
TrackStandardEvent("v2/event/standard"),
251252
TrackCustomEvent("v2/event/custom"),

Branch-SDK/src/main/java/io/branch/referral/PrefHelper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ public class PrefHelper {
121121

122122
static final String KEY_REFERRING_URL_QUERY_PARAMETERS = "bnc_referringUrlQueryParameters";
123123
static final String KEY_ANON_ID = "bnc_anon_id";
124-
private static final String KEY_BASE_URL = "bnc_base_url";
125124

126125
/**
127126
* Internal static variable of own type {@link PrefHelper}. This variable holds the single
@@ -157,6 +156,11 @@ public class PrefHelper {
157156
*/
158157
private final JSONObject secondaryRequestMetadata = new JSONObject();
159158

159+
/**
160+
* Branch Custom server url. Used by clients that want to proxy all requests.
161+
*/
162+
private static String customServerURL_ = null;
163+
160164
/**
161165
* Branch Custom server url. Used by clients that want to proxy all CDN requests.
162166
*/
@@ -203,15 +207,16 @@ static void shutDown() {
203207
// Reset all of the statics.
204208
enableLogging_ = false;
205209
prefHelper_ = null;
210+
customServerURL_ = null;
206211
customCDNBaseURL_ = null;
207212
}
208213

209214
/**
210215
* <p>Sets a custom base URL for all calls to the Branch API. Requires https.</p>
211216
* @param url The {@link String} URL base URL that the Branch API uses.
212217
*/
213-
public void setAPIUrl(String url) {
214-
setString(KEY_BASE_URL, url);
218+
static void setAPIUrl(String url) {
219+
customServerURL_ = url;
215220
}
216221

217222
/**
@@ -222,8 +227,8 @@ public void setAPIUrl(String url) {
222227
* API uses.
223228
*/
224229
public String getAPIBaseUrl() {
225-
if (URLUtil.isHttpsUrl(getString(KEY_BASE_URL))) {
226-
return getString(KEY_BASE_URL);
230+
if (URLUtil.isHttpsUrl(customServerURL_)) {
231+
return customServerURL_;
227232
}
228233

229234
if (Build.VERSION.SDK_INT >= 20) {

Branch-SDK/src/main/java/io/branch/referral/ServerRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ private static ServerRequest getExtendedServerRequest(String requestPath, JSONOb
372372
extendedReq = new ServerRequestCreateUrl(Defines.RequestPath.GetURL, post, context);
373373
} else if (requestPath.equalsIgnoreCase(Defines.RequestPath.IdentifyUser.getPath())) {
374374
extendedReq = new ServerRequestIdentifyUserRequest(Defines.RequestPath.IdentifyUser, post, context);
375+
} else if (requestPath.equalsIgnoreCase(Defines.RequestPath.Logout.getPath())) {
376+
extendedReq = new ServerRequestLogout(Defines.RequestPath.Logout, post, context);
375377
} else if (requestPath.equalsIgnoreCase(Defines.RequestPath.RegisterInstall.getPath())) {
376378
extendedReq = new ServerRequestRegisterInstall(Defines.RequestPath.RegisterInstall, post, context, initiatedByClient);
377379
} else if (requestPath.equalsIgnoreCase(Defines.RequestPath.RegisterOpen.getPath())) {

0 commit comments

Comments
 (0)