From 16c8d3c47ac799ea33ce5252e14ef1aae6dc9a76 Mon Sep 17 00:00:00 2001 From: Priyanka Advani Date: Thu, 11 Jul 2024 19:59:24 +0000 Subject: [PATCH] Revert "add storage java internal reader" This reverts commit 70b9ac0dddf5d48a087f0e5ec7d19d19463dd8c8. Reason for revert: Droidmonitor created revert due to build breakages in b/352582602. Change-Id: I8a8e38ccf3e715e9b4746ac333aed0cc13d11969 --- .../storage/StorageInternalReader.java | 75 ------------------- 1 file changed, 75 deletions(-) delete mode 100644 tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java diff --git a/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java deleted file mode 100644 index ddb86dc330..0000000000 --- a/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/StorageInternalReader.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.aconfig.storage; - -public class StorageInternalReader { - - private static final String MAP_PATH = "/metadata/aconfig/maps/"; - private static final String BOOT_PATH = "/metadata/aconfig/boot/"; - - private PackageTable mPackageTable; - private FlagValueList mFlagValueList; - - private int mPackageBooleanStartOffset; - - public StorageInternalReader(String container, String packageName) { - this(container, packageName, MAP_PATH, BOOT_PATH); - } - - public StorageInternalReader( - String container, String packageName, String mapPath, String bootPath) { - - String packageMapFile = mapPath + container + ".package.map"; - String flagValueFile = bootPath + container + ".val"; - - mPackageTable = PackageTable.fromBytes(mapStorageFile(packageMapFile)); - mFlagValueList = FlagValueList.fromBytes(mapStorageFile(flagValueFile)); - mPackageBooleanStartOffset = getPackageBooleanStartOffset(packageName); - } - - public boolean getBooleanFlagValue(int index) { - index += mPackageBooleanStartOffset; - if (index >= mFlagValueList.size()) { - throw new AconfigStorageException("Fail to get boolean flag value"); - } - return mFlagValueList.get(index); - } - - private int getPackageBooleanStartOffset(String packageName) { - PackageTable.Node pNode = mPackageTable.get(packageName); - if (pNode == null) { - PackageTable.Header header = mPackageTable.getHeader(); - throw new AconfigStorageException( - String.format( - "Fail to get package %s from container %s", - packageName, header.getContainer())); - } - return pNode.getBooleanStartIndex(); - } - - // Map a storage file given file path - private static MappedByteBuffer mapStorageFile(String file) { - try { - FileInputStream stream = new FileInputStream(file); - FileChannel channel = stream.getChannel(); - return channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); - } catch (IOException e) { - throw new AconfigStorageException( - String.format("Fail to mmap storage file %s", file), e); - } - } -}