Merge "change thread policy to allow read disk" into main am: 0284610ba7

Original change: https://android-review.googlesource.com/c/platform/build/+/3208534

Change-Id: I1d6d663dad4b214e9c2b3f90be623044cb7c4b56
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-08-06 21:14:28 +00:00
committed by Automerger Merge Worker
5 changed files with 51 additions and 5 deletions

View File

@@ -176,6 +176,7 @@ java_library {
],
libs: [
"unsupportedappusage",
"strict_mode_stub",
],
static_libs: [
"aconfig_storage_file_java",
@@ -196,6 +197,7 @@ java_library {
],
libs: [
"unsupportedappusage-sdk-none",
"fake_device_config",
],
static_libs: [
"aconfig_storage_file_java_none",

View File

@@ -17,6 +17,7 @@
package android.aconfig.storage;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.StrictMode;
import java.io.Closeable;
import java.nio.MappedByteBuffer;
@@ -42,8 +43,10 @@ public class StorageInternalReader {
@UnsupportedAppUsage
public StorageInternalReader(String packageName, String packageMapFile, String flagValueFile) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
mPackageTable = PackageTable.fromBytes(mapStorageFile(packageMapFile));
mFlagValueList = FlagValueList.fromBytes(mapStorageFile(flagValueFile));
StrictMode.setThreadPolicy(oldPolicy);
mPackageBooleanStartOffset = getPackageBooleanStartOffset(packageName);
}

View File

@@ -13,10 +13,22 @@
// limitations under the License.
java_library {
name: "fake_device_config",
srcs: ["src/**/*.java"],
sdk_version: "none",
system_modules: "core-all-system-modules",
host_supported: true,
name: "fake_device_config",
srcs: [
"src/android/util/Log.java",
"src/android/provider/DeviceConfig.java",
"src/android/os/StrictMode.java",
],
sdk_version: "none",
system_modules: "core-all-system-modules",
host_supported: true,
}
java_library {
name: "strict_mode_stub",
srcs: [
"src/android/os/StrictMode.java",
],
sdk_version: "core_current",
host_supported: true,
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.os;
public class StrictMode {
public static ThreadPolicy allowThreadDiskReads() {
throw new UnsupportedOperationException("Stub!");
}
public static void setThreadPolicy(final ThreadPolicy policy) {
throw new UnsupportedOperationException("Stub!");
}
public static final class ThreadPolicy {}
}