mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 10:24:32 -05:00
59bf3b75c7
https://review.lineageos.org/c/LineageOS/android_frameworks_base/+/353117 https://review.lineageos.org/q/topic:Q_asb_2023-03 https://review.lineageos.org/q/topic:Q_asb_2023-04 https://review.lineageos.org/q/topic:Q_asb_2023-05 https://review.lineageos.org/q/topic:Q_asb_2023-06 https://review.lineageos.org/q/topic:Q_asb_2023-07 https://review.lineageos.org/q/topic:Q_asb_2023-08 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376560 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376561 https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376562 https://review.lineageos.org/q/topic:Q_asb_2023-09 https://review.lineageos.org/q/topic:Q_asb_2023-10 https://review.lineageos.org/q/topic:Q_asb_2023-11 accounted for via patches: https://review.lineageos.org/c/LineageOS/android_system_ca-certificates/+/376563 accounted for via manifest change: https://review.lineageos.org/c/LineageOS/android_external_webp/+/376568 https://review.lineageos.org/q/topic:Q_asb_2023-12 https://review.lineageos.org/q/topic:Q_asb_2024-01 https://review.lineageos.org/q/topic:Q_asb_2024-02 https://review.lineageos.org/q/topic:Q_asb_2024-03 Signed-off-by: Tavi <tavi@divested.dev>
79 lines
3.9 KiB
Diff
79 lines
3.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Christophe Pinelli <cpinelli@google.com>
|
|
Date: Tue, 16 May 2023 17:40:02 +0000
|
|
Subject: [PATCH] Restrict activity launch when caller is running in the
|
|
background
|
|
|
|
Test: test on device + atest-src BackgroundActivityLaunchTest#testBackgroundActivityBlockedInStartNextMatchingActivity
|
|
Bug: 230492947
|
|
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d8368be4f8fb7019ea24b4798f029301c704092c)
|
|
Merged-In: I7ae88eb62e435b9a77d2a724c5a953fe1f35b838
|
|
Change-Id: I7ae88eb62e435b9a77d2a724c5a953fe1f35b838
|
|
---
|
|
.../server/wm/ActivityTaskManagerService.java | 51 +++++++++++--------
|
|
1 file changed, 30 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
|
|
index 5bcc5975604a..7384ca7173d3 100644
|
|
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
|
|
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
|
|
@@ -1194,28 +1194,37 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|
|
|
final long origId = Binder.clearCallingIdentity();
|
|
// TODO(b/64750076): Check if calling pid should really be -1.
|
|
- final int res = getActivityStartController()
|
|
- .obtainStarter(intent, "startNextMatchingActivity")
|
|
- .setCaller(r.app.getThread())
|
|
- .setResolvedType(r.resolvedType)
|
|
- .setActivityInfo(aInfo)
|
|
- .setResultTo(resultTo != null ? resultTo.appToken : null)
|
|
- .setResultWho(resultWho)
|
|
- .setRequestCode(requestCode)
|
|
- .setCallingPid(-1)
|
|
- .setCallingUid(r.launchedFromUid)
|
|
- .setCallingPackage(r.launchedFromPackage)
|
|
- .setRealCallingPid(-1)
|
|
- .setRealCallingUid(r.launchedFromUid)
|
|
- .setActivityOptions(options)
|
|
- .execute();
|
|
- Binder.restoreCallingIdentity(origId);
|
|
-
|
|
- r.finishing = wasFinishing;
|
|
- if (res != ActivityManager.START_SUCCESS) {
|
|
- return false;
|
|
+ try {
|
|
+ if (options == null) {
|
|
+ options = new SafeActivityOptions(ActivityOptions.makeBasic());
|
|
+ }
|
|
+ // Fixes b/230492947
|
|
+ // Prevents background activity launch through #startNextMatchingActivity
|
|
+ // An activity going into the background could still go back to the foreground
|
|
+ // if the intent used matches both:
|
|
+ // - the activity in the background
|
|
+ // - a second activity.
|
|
+ options.getOptions(r).setAvoidMoveToFront();
|
|
+ final int res = getActivityStartController()
|
|
+ .obtainStarter(intent, "startNextMatchingActivity")
|
|
+ .setCaller(r.app.getThread())
|
|
+ .setResolvedType(r.resolvedType)
|
|
+ .setActivityInfo(aInfo)
|
|
+ .setResultTo(resultTo != null ? resultTo.appToken : null)
|
|
+ .setResultWho(resultWho)
|
|
+ .setRequestCode(requestCode)
|
|
+ .setCallingPid(-1)
|
|
+ .setCallingUid(r.launchedFromUid)
|
|
+ .setCallingPackage(r.launchedFromPackage)
|
|
+ .setRealCallingPid(-1)
|
|
+ .setRealCallingUid(r.launchedFromUid)
|
|
+ .setActivityOptions(options)
|
|
+ .execute();
|
|
+ r.finishing = wasFinishing;
|
|
+ return res == ActivityManager.START_SUCCESS;
|
|
+ } finally {
|
|
+ Binder.restoreCallingIdentity(origId);
|
|
}
|
|
- return true;
|
|
}
|
|
}
|
|
|