Repository navigation
Cover the UI with the boot splash when the app is backgrounded to prevent sensitive data exposure #100590
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
Open
OlGierd03
wants to merge
7
commits into
Expensify:main
Choose a base branch
from
software-mansion-labs:@OlGierd03/BootSplash-Covers-UI-When-App-Backgrounded-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Cover the UI with the boot splash when the app is backgrounded to prevent sensitive data exposure #100590
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebb1e5f
Cover the UI with the boot splash when the app is backgrounded to pre…
OlGierd03 ce784a3
Merge main and resolve conflict
OlGierd03 4bccaf6
Move privacy overlay to SceneDelegate lifecycle
OlGierd03 87737c0
Cover third-party activities and skip cover when starting our own
OlGierd03 b22a57a
Drop splash cover in Plaid on Android bcs of unfixable bug with popup…
OlGierd03 e9e4cf4
Trim privacy cover TaskDescription and skip cover in multi-window
OlGierd03 bdb8770
Replace privacy cover map with a single field and clarify override co…
OlGierd03 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 hidden or 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
This file contains hidden or 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
59 changes: 59 additions & 0 deletions
59
android/app/src/main/java/com/expensify/chat/bootsplash/PrivacyCover.java
This file contains hidden or 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,59 @@ | ||
| package com.expensify.chat.bootsplash; | ||
|
|
||
| import android.app.Activity; | ||
| import android.app.ActivityManager; | ||
| import android.os.Build; | ||
| import android.view.Window; | ||
| import android.view.WindowManager; | ||
| import com.expensify.chat.R; | ||
|
|
||
| // Covers the UI with the boot splash while the app is leaving the foreground | ||
| public final class PrivacyCover { | ||
|
|
||
| // Only MainActivity shows the cover | ||
| private static BootSplashDialog cover; | ||
|
|
||
| private PrivacyCover() {} | ||
|
|
||
| // setRecentsScreenshotEnabled() requires API 33, so the cover alone wouldn't suppress the snapshot | ||
| public static boolean isSupported() { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU; | ||
| } | ||
|
|
||
| public static void show(Activity activity) { | ||
| if (!isSupported() || activity.isFinishing() || activity.isDestroyed() | ||
| || activity.isInMultiWindowMode() || cover != null) { | ||
| return; | ||
| } | ||
| BootSplashDialog dialog = new BootSplashDialog(activity, R.style.BootTheme); | ||
| Window window = dialog.getWindow(); | ||
| if (window != null) { | ||
| // Leave the focus with the activity underneath so it returns exactly as the user left it | ||
| window.setFlags( | ||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, | ||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); | ||
| // The default dialog fade-in would let the snapshot see the content underneath | ||
| window.setWindowAnimations(0); | ||
| } | ||
| dialog.show(); | ||
| cover = dialog; | ||
| } | ||
|
|
||
| public static void hide() { | ||
| if (cover != null) { | ||
| cover.dismiss(); | ||
| cover = null; | ||
| } | ||
| } | ||
|
|
||
| // Recents shows this card instead of a snapshot, since snapshots are disabled for privacy. | ||
| public static void applyTaskDescription(Activity activity) { | ||
| if (!isSupported()) { | ||
| return; | ||
| } | ||
| activity.setTaskDescription(new ActivityManager.TaskDescription.Builder() | ||
| .setBackgroundColor(activity.getColor(R.color.bootsplash_background)) | ||
| .setStatusBarColor(activity.getColor(R.color.bootsplash_background)) | ||
| .build()); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
Is it safe to use the deprecated method?
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 is. The method lives in two places: the platform Activity, where it's not deprecated and the androidx
ComponentActivitywe extend, which overrides it and marks it deprecated. The deprecation just tells callers to launch activities withregisterForActivityResultinstead, the method itself is not going away. We don't call it, we override it to catch activity starts:startActivity()andregisterForActivityResultboth end up going through it.I edited the comment to make it clearer.