From 457e39b38cb1b512adda3071671d74d9a9672d56 Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Fri, 12 May 2023 12:41:32 -0700 Subject: [PATCH] [SettingsProvider] do not close MemoryIntArray if in system server When a DeviceConfig instantce is created in the system server process, when its cache gets evicted, it can close the MemoryIntArrays kept in the SettingsProvider in the system server. BUG: 282206516 Test: presubmit Change-Id: I8df55412aaae12c959ef7222d62602235c060b92 --- core/java/android/provider/Settings.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index fd5e206990db7..5c79f697ba13d 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3036,7 +3036,9 @@ public final class Settings { public void destroy() { try { - if (!mArray.isClosed()) { + // If this process is the system server process, mArray is the same object as + // the memory int array kept inside SettingsProvider, so skipping the close() + if (!Settings.isInSystemServer() && !mArray.isClosed()) { mArray.close(); } } catch (IOException e) {