DivestOS/Patches/LineageOS-20.0/android_frameworks_base/0031-appops_reset_fix-2.patch

31 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dmitry Muhomor <muhomor.dmitry@gmail.com>
Date: Fri, 6 Jan 2023 17:22:29 +0200
Subject: [PATCH] appops: skip ops for invalid null package during state
serialization
There's a bug that leads to construction of ops for invalid null package name.
Package name should always be non-null, it's defined and treated as such in AppOpsService.
It being null leads to crashes in system_server when appops state is serialized.
Previous commit reverted a buggy workaround for this bug, add a new workaround to prevent these
crashes.
---
services/core/java/com/android/server/appop/AppOpsService.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 2d26cc53832f..425b36da5ed9 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -5231,6 +5231,9 @@ public class AppOpsService extends IAppOpsService.Stub {
String lastPkg = null;
for (int i=0; i<allOps.size(); i++) {
AppOpsManager.PackageOps pkg = allOps.get(i);
+ if (pkg.getPackageName() == null) {
+ continue;
+ }
if (!pkg.getPackageName().equals(lastPkg)) {
if (lastPkg != null) {
out.endTag(null, "pkg");