Skip to content

Commit c121c32

Browse files
committed
Merge branch 'master' into wpinho-branch/EMT-1963
2 parents ebe57b1 + d13362c commit c121c32

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

Branch-SDK/src/main/java/io/branch/coroutines/InstallReferrers.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ suspend fun getSamsungGalaxyStoreReferrerDetails(context: Context): InstallRefer
163163
null,
164164
null
165165
)
166-
} catch (e: RemoteException) {
167-
BranchLogger.w("Caught getSamsungGalaxyStoreReferrerDetails exception: $e")
166+
}
167+
catch (e: Exception) {
168+
BranchLogger.e("Caught getSamsungGalaxyStoreReferrerDetails exception: $e")
168169
null
169170
}
170171
)
@@ -196,6 +197,7 @@ suspend fun getSamsungGalaxyStoreReferrerDetails(context: Context): InstallRefer
196197

197198
suspend fun getXiaomiGetAppsReferrerDetails(context: Context): InstallReferrerResult? {
198199
return withContext(Dispatchers.Default) {
200+
// Install Referrer API availability varies between Xiaomi's MIUI and HyperOS
199201
if(classExists(xiaomiInstallReferrerClass)) {
200202
try {
201203
val deferredReferrerDetails = CompletableDeferred<InstallReferrerResult?>()
@@ -217,8 +219,8 @@ suspend fun getXiaomiGetAppsReferrerDetails(context: Context): InstallReferrerRe
217219
result.installBeginTimestampServerSeconds,
218220
result.referrerClickTimestampServerSeconds
219221
)
220-
} catch (e: RemoteException) {
221-
BranchLogger.w("Caught getXiaomiGetAppsReferrerDetails exception: $e")
222+
} catch (e: Exception) {
223+
BranchLogger.e("Caught getXiaomiGetAppsReferrerDetails exception: $e")
222224
null
223225
}
224226
)

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void onActivityStarted(@NonNull Activity activity) {
5151
@Override
5252
public void onActivityResumed(@NonNull Activity activity) {
5353
Branch branch = Branch.getInstance();
54-
BranchLogger.v("onActivityResumed, activity = " + activity + " branch: " + branch + " Activities on stack: " + activitiesOnStack_);
54+
BranchLogger.v("onActivityResumed, activity = " + activity + " branch: " + branch);
5555
if (branch == null) return;
5656

5757
// if the intent state is bypassed from the last activity as it was closed before onResume, we need to skip this with the current
@@ -76,18 +76,22 @@ public void onActivityResumed(@NonNull Activity activity) {
7676
// must be called after session initialization, which relies on checking whether activity
7777
// that is initializing the session is being launched from stack or anew
7878
activitiesOnStack_.add(activity.toString());
79+
BranchLogger.v("activityCnt_: " + activityCnt_);
80+
BranchLogger.v("activitiesOnStack_: " + activitiesOnStack_);
7981
}
8082

8183
@Override
8284
public void onActivityPaused(@NonNull Activity activity) {
8385
Branch branch = Branch.getInstance();
84-
BranchLogger.v("onActivityPaused, activity = " + activity + " branch: " + branch + " Activities on stack: " + activitiesOnStack_);
86+
BranchLogger.v("onActivityPaused, activity = " + activity + " branch: " + branch);
8587
if (branch == null) return;
8688

8789
/* Close any opened sharing dialog.*/
8890
if (branch.getShareLinkManager() != null) {
8991
branch.getShareLinkManager().cancelShareLinkDialog(true);
9092
}
93+
BranchLogger.v("activityCnt_: " + activityCnt_);
94+
BranchLogger.v("activitiesOnStack_: " + activitiesOnStack_);
9195
}
9296

9397
@Override
@@ -101,7 +105,17 @@ public void onActivityStopped(@NonNull Activity activity) {
101105
if (activityCnt_ < 1) {
102106
branch.setInstantDeepLinkPossible(false);
103107
branch.closeSessionInternal();
108+
109+
/* It is possible some integrations do not call Branch.getAutoInstance() before the first
110+
activity's lifecycle methods execute.
111+
In such cases, activityCnt_ could be set to -1, which could cause the above line to clear
112+
session parameters. Just reset to 0 if we're here.
113+
*/
114+
activityCnt_ = 0;
115+
BranchLogger.v("activityCnt_: reset to 0");
104116
}
117+
118+
BranchLogger.v("activitiesOnStack_: " + activitiesOnStack_);
105119
}
106120

107121
@Override
@@ -111,14 +125,15 @@ public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bun
111125
@Override
112126
public void onActivityDestroyed(@NonNull Activity activity) {
113127
Branch branch = Branch.getInstance();
114-
BranchLogger.v("onActivityDestroyed, activity = " + activity + " branch: " + branch + " Activities on stack: " + activitiesOnStack_);
128+
BranchLogger.v("onActivityDestroyed, activity = " + activity + " branch: " + branch);
115129
if (branch == null) return;
116130

117131
if (branch.getCurrentActivity() == activity) {
118132
branch.currentActivityReference_.clear();
119133
}
120134

121135
activitiesOnStack_.remove(activity.toString());
136+
BranchLogger.v("activitiesOnStack_: " + activitiesOnStack_);
122137
}
123138

124139
boolean isCurrentActivityLaunchedFromStack() {

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Branch Android SDK change log
2+
- v5.18.1
3+
* _*Master Release*_ - May 27, 2025
4+
- Fixes a bug affecting Xiaomi devices.
5+
- Fix for rare instances of session parameters getting cleared.
6+
7+
28
- v5.18.0
39
* _*Master Release*_ - May 14, 2025
410
- Add browser experience for apps that have opted in.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=5.18.0
2-
VERSION_CODE=052200
1+
VERSION_NAME=5.18.1
2+
VERSION_CODE=052201
33
GROUP=io.branch.sdk.android
44

55
POM_DESCRIPTION=Use the Branch SDK (branch.io) to create and power the links that point back to your apps for all of these things and more. Branch makes it incredibly simple to create powerful deep links that can pass data across app install and open while handling all edge cases (using on desktop vs. mobile vs. already having the app installed, etc). Best of all, it is really simple to start using the links for your own app: only 2 lines of code to register the deep link router and one more line of code to create the links with custom data.

0 commit comments

Comments
 (0)