-
Notifications
You must be signed in to change notification settings - Fork 625
Removing dependency for activities #3298
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
Conversation
Coverage Report 1Affected Products
Test Logs
Notes |
Size Report 1Affected Products
Test Logs
Notes |
this.firebaseAppDistributionTesterApiClient = firebaseAppDistributionTesterApiClient; | ||
this.firebaseInstallationsApiProvider = firebaseInstallationsApiProvider; | ||
this.taskExecutor = Executors.newSingleThreadExecutor(); | ||
this( |
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.
Nice
@@ -93,7 +97,7 @@ void handleAppResume(Activity activity) { | |||
cachedInstallApkPath = path; | |||
} else { | |||
// only start the install activity if current Activity is in the foreground | |||
startInstallActivity(path, currentActivity); | |||
startInstallActivity(path); |
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.
The if
case on line 95 can be removed right?
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.
Yes it can!
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.
Can we now start the Install Activity regardless of whether or not the customer's app is in the foreground?
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.
Good question! Currently working on trying to see if there is a set up to make that work. In its current set up if the user backgrounds the app it seems to hang.
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.
It seems like this is not possible due to Install Activity relying on an activity to show unknown sources UI.
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.
That is surprising. I'd think that once the InstallActivity starts, then it's in the foreground and we can show the dialog. That's what happened when you were calling UpdateApp from a background thread, which worked.
What error/stacktrace are you seeing in the logs?
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.
I get a windowLeaked error. I can repro and show the error message. I believe that was because the app itself wasn't in the background, but once you background the app it wants to display the unknown sources UI but since the app is in the background you get this leaked error.
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.
Why does the app get backgrounded? Maybe we could look at it together over VC.
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.
We discussed this in person. Previously, backgrounding the app after starting the basic config would fail the task correctly. With this change it instead hangs the task.
I'm fine punting on this for now.
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.
To clarify it hangs if we don't depend on the currentActivity at all with checking what to do with InstallActivity.
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.
LGTM so far!
/run binary-size |
@@ -111,6 +111,7 @@ private void startInstallActivity(String path, Activity currentActivity) { | |||
} | |||
Intent intent = new Intent(currentActivity, InstallActivity.class); | |||
intent.putExtra("INSTALL_PATH", path); | |||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
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.
Why add this flag?
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.
Good catch! Leftover from trying to use application context. When using application Context it needs to be a new task but since that was taken out this should also be taken out.
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.
Oh interesting. Why does it need to a be a new task when using application context?
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.
I ran into the issue but this post sums up the issue and the reason for the fix. https://stackoverflow.com/questions/3918517/calling-startactivity-from-outside-of-an-activity-context
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.
Hmm, ok the fact that you saw that error is making me less confident in my suggestion to use intents + activities. It feels weird to have to start a new task every time.
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.
We do this in the AAB updater
Line 160 in 712e5b8
updateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
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.
I think it makes more sense in the AAB updater since we are launching an activity in a different app, Play.
In the case I was proposing, where we would launch a new intent/activity in order to simply show a dialog in the app, we wouldn't want an additional task. It should ideally just continue in the same task.
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.
This error is especially interesting, since we should be starting the install activity as a new task anyway according to the manifest I think https://github.com/firebase/firebase-android-sdk/blob/master/firebase-app-distribution/src/main/AndroidManifest.xml#L34-L35
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.
From the docs:
singleTask
The system creates a new task and instantiates the activity at the root of the new task.
@@ -48,18 +50,22 @@ | |||
private AppDistributionReleaseInternal aabReleaseInProgress; | |||
|
|||
private final Object updateAabLock = new Object(); | |||
private final Context applicationContext; |
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.
Nit: for brevity, can we just call this context
everywhere instead of applicationContext
?
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.
I did see we used context elsewhere. Context being so vague is the reason I added application to it, but I have no issue making it context.
|
||
AabUpdater() { | ||
AabUpdater(@NonNull FirebaseApp firebaseApp) { |
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.
This constructor should just take a Context object since that's all you need.
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.
Good thought! I had done this elsewhere before should do it here as well.
@@ -84,7 +98,8 @@ public void setup() throws IOException, FirebaseAppDistributionException { | |||
|
|||
aabUpdater = | |||
Mockito.spy( | |||
new AabUpdater(mockLifecycleNotifier, mockHttpsUrlConnectionFactory, testExecutor)); | |||
new AabUpdater( | |||
firebaseApp, mockLifecycleNotifier, mockHttpsUrlConnectionFactory, testExecutor)); |
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.
If you take my suggestion and require a Context
here instead of a FirebaseApp
, then you can just pass in ApplicationProvider.getApplicationContext()
.
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.
Some tiny nits. Looks great!
new BufferedOutputStream( | ||
context.openFileOutput(fileName, fileCreationMode)); |
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.
This can go back to being a one-liner.
context | ||
.getApplicationInfo() | ||
.loadLabel(context.getPackageManager()) | ||
.toString(); |
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.
This can also be a one-liner
@@ -148,7 +148,6 @@ public UpdateTask updateIfNewReleaseAvailable() { | |||
return cachedUpdateIfNewReleaseTask; | |||
} | |||
} | |||
|
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.
Nit: can you put this empty line back?
.setApplicationId(TEST_APP_ID_1) | ||
.setProjectId(TEST_PROJECT_ID) | ||
.setApiKey(TEST_API_KEY) | ||
.build()); |
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.
In case you missed my other comment, you don't need to a create a FirebaseApp
here. You can just inject ApplicationProvider.getApplicationContext()
into the constructor, below.
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.
I did miss this comment. Will fix now.
No description provided.