Skip to content

Commit d033c3b

Browse files
Merge pull request #773 from BranchMetrics/Staging
Release v4.2.0
2 parents e236983 + 56822a6 commit d033c3b

File tree

3 files changed

+99
-1
lines changed

3 files changed

+99
-1
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Test plan for different (re)initialization scenarios
2+
3+
This is a test plan enlisting possible initialization scenarios. As CSMs
4+
find bugs arising from unforeseen initialization scenarios, this list should
5+
be updated. Unless noted, initialization is expected to work in all scenarios.
6+
7+
8+
## Assumptions:
9+
* User followed [Android documentation](https://docs.branch.io/apps/android/)
10+
* Application can have multiple activities (launcher activity is called
11+
`SplashActivity` and all others are `NextActivity`)
12+
* Latest Branch SDK version is being used
13+
14+
15+
## Scenario #1:
16+
* `initSession` is only called in `SplashActivity.onStart`.
17+
18+
19+
### 1. Application in background
20+
```
21+
Test by opening the app via:
22+
* launcher icon
23+
* recent apps tray (not available in cold start)
24+
* push notification
25+
```
26+
#### Cold start:
27+
* Repro: Close app and remove it from the recent apps list
28+
(not 100% guarantee that this will work because manufacturers determine
29+
if application is killed when removed from recents list). Alternatively,
30+
call `adb shell pm clear my.app.package.id` from the command line (this
31+
will also clear cache and stored data). Open app.
32+
* Initialization entry point = `SplashActivity.onCreate`
33+
34+
35+
#### Warm start:
36+
* Repro: Close app via the back button. Open app.
37+
* Initialization entry point = `SplashActivity.onCreate`
38+
39+
#### Hot start:
40+
* Repro: Close app via the home button. Open app.
41+
* Initialization entry point is either `SplashActivity.onStart` or
42+
`BranchActivityLifecycleObserver.onResume` depending on whether `SplashActivity`
43+
or `NextActivity` was in foreground last. However, if app is opened via
44+
a push notification, the Initialization entry point is guaranteed to be
45+
`SplashActivity.onStart`.
46+
47+
48+
### 2. Application in foreground
49+
```
50+
Test by opening the app via:
51+
* push notification
52+
```
53+
#### Burning hot start:
54+
* Repro: have the app open
55+
* Initialization entry point = either `SplashActivity.onNewIntent`
56+
or `SplashActivity.onStart` depending if user is currently on `SplashActivity`
57+
or `NextActivity` respectively. There is one exception, if the user is on
58+
`NextActivity` but `SplashActivity` is still partially visible, then the
59+
entry point will be `SplashActivity.onNewIntent`.
60+
61+
There are four possible scenarios the users can find themselves in,
62+
`reInitSession` is either called or not and the user is currently in
63+
`SplashActivity` or in `NextActivity`. Note that documentation gives
64+
instructions to use `reInitSession`, however it's a new instruction, so
65+
it may be overlooked by existing users. When the latter happens, we may
66+
expect an initialization failure:
67+
* `reInitSession` is not used (i.e. not following documentation)
68+
* User is in `SplashActivity` = Branch initialization is guaranteed to FAIL
69+
* User is in `NextActivity` = Branch initialization is expected work _unless_
70+
`SplashActivity` is still partially visible (e.g. `NextActivity` is
71+
semi-transparent or is not using the full screen)
72+
73+
74+
## Scenario #2:
75+
* `initSession` is called in both `SplashActivity` and `NextActivity`
76+
77+
### 1. Application in foreground
78+
```
79+
Test by opening the app via push notification launching `NextActivity`:
80+
* when `NextActivity` is currently in foreground
81+
* when `NextActivity` is in backstack (e.g. has been launched before
82+
but user is currently on another `NextActivity`)
83+
* when `NextActivity` is NOT in backstack (e.g. this particular
84+
`NextActivity` has NOT been launched before)
85+
```
86+
87+
#### Burning hot start:
88+
* Repro: have the app open
89+
90+
Again, there are expected failures when `reInitSession` is NOT used in `NextActivity`
91+
* user is currently in `NextActivity` = guaranteed initialization failure
92+
* `NextActivity` is in backstack BUT partially visible

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ public void onActivityResumed(@NonNull Activity activity) {
6969
branch.getInitState() != Branch.SESSION_STATE.INITIALISED;
7070
branch.onIntentReady(activity, grabIntentParams);
7171
}
72+
73+
if (branch.getInitState() == Branch.SESSION_STATE.UNINITIALISED) {
74+
// this is the only place where we self-initialize in case user opens the app from 'recent apps tray'
75+
// and the entry Activity is not the launcher Activity where user placed initSession themselves.
76+
branch.initSession(activity);
77+
}
7278
}
7379

7480
@Override

ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Branch Android SDK change log
22
- v4.2.0
3-
* _*Master Release*_ - November 13, 2019
3+
* _*Master Release*_ - November 19, 2019
44
* Remove initialization race conditions.
55
* Do not auto-initialize sessions, make calling initSession a mandatory step required of Branch SDK users (officially this was already implied).
66
* Overload reInitSession with different callbacks and start advertising it to users as the official way to handle session reinitialization in cases where activity is in foreground and is being reopened.

0 commit comments

Comments
 (0)