Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit ba9e22d

Browse files
Reconcile picks
Signed-off-by: Tavi <[email protected]>
1 parent 0b746ce commit ba9e22d

File tree

24 files changed

+474
-2193
lines changed

24 files changed

+474
-2193
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 00961ad29e26dde5d4f56de90ac333ceb2fc8d34 Mon Sep 17 00:00:00 2001
2+
From: Jing Ji <[email protected]>
3+
Date: Tue, 25 Oct 2022 22:39:52 -0700
4+
Subject: [PATCH] DO NOT MERGE: ActivityManager#killBackgroundProcesses can
5+
kill caller's own app only
6+
7+
unless it's a system app.
8+
9+
Bug: 239423414
10+
Bug: 223376078
11+
Test: atest CtsAppTestCases:ActivityManagerTest
12+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d1c95670b248df945784b0f2830acf83b5682de3)
13+
Merged-In: Iac6baa889965b8ffecd9a43179a4c96632ad1d02
14+
AOSP-Change-Id: Iac6baa889965b8ffecd9a43179a4c96632ad1d02
15+
16+
Change-Id: I41cd6fa1f71e950db18a9fd450355c4e6f80ec7d
17+
---
18+
.../server/am/ActivityManagerService.java | 16 ++++++++++++++++
19+
1 file changed, 16 insertions(+)
20+
21+
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
22+
index 234b23a996267..815ddf63e565a 100644
23+
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
24+
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
25+
@@ -4486,6 +4486,22 @@ void killAllBackgroundProcessesExcept(int minTargetSdk, int maxProcState) {
26+
throw new SecurityException(msg);
27+
}
28+
29+
+ final int callingUid = Binder.getCallingUid();
30+
+ final int callingPid = Binder.getCallingPid();
31+
+
32+
+ ProcessRecord proc;
33+
+ synchronized (mPidsSelfLocked) {
34+
+ proc = mPidsSelfLocked.get(callingPid);
35+
+ }
36+
+ if (callingUid >= FIRST_APPLICATION_UID
37+
+ && (proc == null || !proc.info.isSystemApp())) {
38+
+ final String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
39+
+ + callingPid + ", uid=" + callingUid + " is not allowed";
40+
+ Slog.w(TAG, msg);
41+
+ // Silently return to avoid existing apps from crashing.
42+
+ return;
43+
+ }
44+
+
45+
final long callingId = Binder.clearCallingIdentity();
46+
try {
47+
synchronized (this) {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 14804676d97278009b746073e8339374b0cce927 Mon Sep 17 00:00:00 2001
2+
From: Jing Ji <[email protected]>
3+
Date: Thu, 19 Oct 2023 14:22:58 -0700
4+
Subject: [PATCH] DO NOT MERGE: Fix ActivityManager#killBackgroundProcesses
5+
permissions
6+
7+
In the pevious CL, we incorrectly added the permission check in the
8+
killBackgroundProcessesExcept. Now fix this issue.
9+
10+
Bug: 239423414
11+
Bug: 223376078
12+
Test: atest CtsAppTestCases:ActivityManagerTest
13+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:140fce861944419a375c669010c6c47cd7ff5b37)
14+
Merged-In: I9471a77188ee63ec32cd0c81569193e4ccad885b
15+
Change-Id: I9471a77188ee63ec32cd0c81569193e4ccad885b
16+
---
17+
.../server/am/ActivityManagerService.java | 16 ----------------
18+
1 file changed, 16 deletions(-)
19+
20+
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
21+
index 815ddf63e565a..234b23a996267 100644
22+
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
23+
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
24+
@@ -4486,22 +4486,6 @@ void killAllBackgroundProcessesExcept(int minTargetSdk, int maxProcState) {
25+
throw new SecurityException(msg);
26+
}
27+
28+
- final int callingUid = Binder.getCallingUid();
29+
- final int callingPid = Binder.getCallingPid();
30+
-
31+
- ProcessRecord proc;
32+
- synchronized (mPidsSelfLocked) {
33+
- proc = mPidsSelfLocked.get(callingPid);
34+
- }
35+
- if (callingUid >= FIRST_APPLICATION_UID
36+
- && (proc == null || !proc.info.isSystemApp())) {
37+
- final String msg = "Permission Denial: killAllBackgroundProcesses() from pid="
38+
- + callingPid + ", uid=" + callingUid + " is not allowed";
39+
- Slog.w(TAG, msg);
40+
- // Silently return to avoid existing apps from crashing.
41+
- return;
42+
- }
43+
-
44+
final long callingId = Binder.clearCallingIdentity();
45+
try {
46+
synchronized (this) {

Patches/LineageOS-20.0/ASB-2024-06/fwb-02.patch renamed to Patches/LineageOS-18.1/android_frameworks_base/394555.patch

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From c0c16283997bbca63edc79d820652587cbde15bb Mon Sep 17 00:00:00 2001
1+
From 179a5a7b48c4ec3ffebbf53b9833f6be6ef4e2b1 Mon Sep 17 00:00:00 2001
22
From: Valentin Iftime <[email protected]>
33
Date: Thu, 1 Feb 2024 13:58:49 +0100
44
Subject: [PATCH] Verify URI permission for channel sound update from
@@ -10,19 +10,19 @@ Subject: [PATCH] Verify URI permission for channel sound update from
1010
Test: atest com.android.server.notification.NotificationManagerServiceTest#testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission
1111
Bug: 317357401
1212
(cherry picked from commit 9b7bbbf5ad542ecf9ecbf8cd819b468791b443c0)
13-
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2f26c0def503d3b8032c99adc8a11be87e35cdeb)
13+
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:f090c0538a27d8658d8a860046d5c5e931302341)
1414
Merged-In: Ic7d2e96e43565e98d2aa29b8f2ba35c142387ba9
1515
Change-Id: Ic7d2e96e43565e98d2aa29b8f2ba35c142387ba9
1616
---
17-
.../NotificationManagerService.java | 22 +++++++
18-
.../NotificationManagerServiceTest.java | 63 +++++++++++++++++++
19-
2 files changed, 85 insertions(+)
17+
.../NotificationManagerService.java | 22 ++++++
18+
.../NotificationManagerServiceTest.java | 67 +++++++++++++++++++
19+
2 files changed, 89 insertions(+)
2020

2121
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
22-
index ecd446519c09..4d1abc61aa73 100755
22+
index dfc9c135c7da7..40f6ed45174e2 100755
2323
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
2424
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
25-
@@ -5705,6 +5705,10 @@ public void updateNotificationChannelFromPrivilegedListener(INotificationListene
25+
@@ -5151,6 +5151,10 @@ public void updateNotificationChannelFromPrivilegedListener(INotificationListene
2626
Objects.requireNonNull(user);
2727

2828
verifyPrivilegedListener(token, user, false);
@@ -33,7 +33,7 @@ index ecd446519c09..4d1abc61aa73 100755
3333
updateNotificationChannelInt(pkg, getUidForPackageAndUser(pkg, user), channel, true);
3434
}
3535

36-
@@ -5796,6 +5800,24 @@ private void verifyPrivilegedListener(INotificationListener token, UserHandle us
36+
@@ -5230,6 +5234,24 @@ private void verifyPrivilegedListener(INotificationListener token, UserHandle us
3737
}
3838
}
3939

@@ -56,22 +56,24 @@ index ecd446519c09..4d1abc61aa73 100755
5656
+ }
5757
+
5858
private int getUidForPackageAndUser(String pkg, UserHandle user) throws RemoteException {
59-
int uid = INVALID_UID;
60-
final long identity = Binder.clearCallingIdentity();
59+
int uid = 0;
60+
long identity = Binder.clearCallingIdentity();
6161
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
62-
index 4f0a7ca0ad51..755bc1d35cf3 100755
62+
index 011c408492fa3..a1d6b56ff9cdb 100755
6363
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
6464
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
65-
@@ -3319,6 +3319,69 @@ public void testUpdateNotificationChannelFromPrivilegedListener_badUser() throws
65+
@@ -2664,6 +2664,73 @@ public void testUpdateNotificationChannelFromPrivilegedListener_badUser() throws
6666
eq(NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED));
6767
}
6868

6969
+ @Test
7070
+ public void testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission()
7171
+ throws Exception {
7272
+ mService.setPreferencesHelper(mPreferencesHelper);
73+
+ List<String> associations = new ArrayList<>();
74+
+ associations.add("a");
7375
+ when(mCompanionMgr.getAssociations(PKG, UserHandle.getUserId(mUid)))
74-
+ .thenReturn(singletonList(mock(AssociationInfo.class)));
76+
+ .thenReturn(associations);
7577
+ when(mPreferencesHelper.getNotificationChannel(eq(PKG), anyInt(),
7678
+ eq(mTestNotificationChannel.getId()), anyBoolean()))
7779
+ .thenReturn(mTestNotificationChannel);
@@ -102,8 +104,10 @@ index 4f0a7ca0ad51..755bc1d35cf3 100755
102104
+ public void testUpdateNotificationChannelFromPrivilegedListener_noSoundUriPermission_sameSound()
103105
+ throws Exception {
104106
+ mService.setPreferencesHelper(mPreferencesHelper);
107+
+ List<String> associations = new ArrayList<>();
108+
+ associations.add("a");
105109
+ when(mCompanionMgr.getAssociations(PKG, UserHandle.getUserId(mUid)))
106-
+ .thenReturn(singletonList(mock(AssociationInfo.class)));
110+
+ .thenReturn(associations);
107111
+ when(mPreferencesHelper.getNotificationChannel(eq(PKG), anyInt(),
108112
+ eq(mTestNotificationChannel.getId()), anyBoolean()))
109113
+ .thenReturn(mTestNotificationChannel);

0 commit comments

Comments
 (0)