Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 818d5220 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Return null if key is not found in map" into main

parents 9964b7ee b3e92d28
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
"/system/etc/aconfig_flags.pb",
"/system_ext/etc/aconfig_flags.pb",
"/product/etc/aconfig_flags.pb",
"/vendor/etc/aconfig_flags.pb",
+9 −2
Original line number Diff line number Diff line
@@ -37,9 +37,16 @@ public class FlagTable {
    public Node get(int packageId, String flagName) {
        int numBuckets = (mHeader.mNodeOffset - mHeader.mBucketOffset) / 4;
        int bucketIndex = TableUtils.getBucketIndex(makeKey(packageId, flagName), numBuckets);
        int newPosition = mHeader.mBucketOffset + bucketIndex * 4;
        if (newPosition >= mHeader.mNodeOffset) {
            return null;
        }

        mReader.position(mHeader.mBucketOffset + bucketIndex * 4);
        mReader.position(newPosition);
        int nodeIndex = mReader.readInt();
        if (nodeIndex < mHeader.mNodeOffset || nodeIndex >= mHeader.mFileSize) {
            return null;
        }

        while (nodeIndex != -1) {
            mReader.position(nodeIndex);
@@ -50,7 +57,7 @@ public class FlagTable {
            nodeIndex = node.mNextOffset;
        }

        throw new AconfigStorageException("get cannot find flag: " + flagName);
        return null;
    }

    public Header getHeader() {
+10 −4
Original line number Diff line number Diff line
@@ -35,13 +35,19 @@ public class PackageTable {
    }

    public Node get(String packageName) {

        int numBuckets = (mHeader.mNodeOffset - mHeader.mBucketOffset) / 4;
        int bucketIndex = TableUtils.getBucketIndex(packageName.getBytes(UTF_8), numBuckets);

        mReader.position(mHeader.mBucketOffset + bucketIndex * 4);
        int newPosition = mHeader.mBucketOffset + bucketIndex * 4;
        if (newPosition >= mHeader.mNodeOffset) {
            return null;
        }
        mReader.position(newPosition);
        int nodeIndex = mReader.readInt();

        if (nodeIndex < mHeader.mNodeOffset || nodeIndex >= mHeader.mFileSize) {
            return null;
        }

        while (nodeIndex != -1) {
            mReader.position(nodeIndex);
            Node node = Node.fromBytes(mReader);
@@ -51,7 +57,7 @@ public class PackageTable {
            nodeIndex = node.mNextOffset;
        }

        throw new AconfigStorageException("get cannot find package: " + packageName);
        return null;
    }

    public Header getHeader() {
+0 −3
Original line number Diff line number Diff line
@@ -53,9 +53,6 @@ public class StorageInternalReader {
    @UnsupportedAppUsage
    public boolean getBooleanFlagValue(int index) {
        index += mPackageBooleanStartOffset;
        if (index >= mFlagValueList.size()) {
            throw new AconfigStorageException("Fail to get boolean flag value");
        }
        return mFlagValueList.getBoolean(index);
    }

+1 −3
Original line number Diff line number Diff line
@@ -15,9 +15,7 @@
java_library {
    name: "fake_device_config",
    srcs: [
        "src/android/util/Log.java",
        "src/android/provider/DeviceConfig.java",
        "src/android/os/StrictMode.java",
        "src/**/*.java",
    ],
    sdk_version: "none",
    system_modules: "core-all-system-modules",
Loading