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

Commit 189cc594 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Move convertToResPath from libutils to aapt." into main am: 0637b02c...

Merge "Move convertToResPath from libutils to aapt." into main am: 0637b02c am: ca6f0875 am: 5e49797a am: c623d605

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2721353



Change-Id: I70d3231bf180a77d3992df0f64bc36283b3d7125
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7adaa2d7 c623d605
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ cc_library_host_static {
        "ResourceTable.cpp",
        "SourcePos.cpp",
        "StringPool.cpp",
        "Utils.cpp",
        "WorkQueue.cpp",
        "XMLNode.cpp",
        "ZipEntry.cpp",
+2 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "OutputSet.h"
#include "ResourceTable.h"
#include "ResourceFilter.h"
#include "Utils.h"

#include <androidfw/misc.h>

@@ -226,7 +227,7 @@ ssize_t processAssets(Bundle* bundle, ZipFile* zip, const sp<const OutputSet>& o
            fprintf(stderr, "warning: null file being processed.\n");
        } else {
            String8 storagePath(entry.getPath());
            storagePath.convertToResPath();
            convertToResPath(storagePath);
            if (!processFile(bundle, zip, storagePath, entry.getFile())) {
                return UNKNOWN_ERROR;
            }
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include "ResourceTable.h"
#include "StringPool.h"
#include "Symbol.h"
#include "Utils.h"
#include "WorkQueue.h"
#include "XMLNode.h"

@@ -321,7 +322,7 @@ static status_t makeFileResources(Bundle* bundle, const sp<AaptAssets>& assets,
            str++;
        }
        String8 resPath = it.getPath();
        resPath.convertToResPath();
        convertToResPath(resPath);
        status_t result = table->addEntry(SourcePos(it.getPath(), 0),
                        String16(assets->getPackage()),
                        type16,
+3 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include "ResourceFilter.h"
#include "ResourceIdCache.h"
#include "SdkConstants.h"
#include "Utils.h"

#include <algorithm>
#include <androidfw/ResourceTypes.h>
@@ -4803,7 +4804,7 @@ bool ResourceTable::versionForCompat(const Bundle* bundle, const String16& resou
    String8 resPath = String8::format("res/%s/%s.xml",
            newFile->getGroupEntry().toDirName(target->getResourceType()).c_str(),
            String8(resourceName).c_str());
    resPath.convertToResPath();
    convertToResPath(resPath);

    // Add a resource table entry.
    addEntry(SourcePos(),
@@ -4927,7 +4928,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
        String8 resPath = String8::format("res/%s/%s.xml",
                newFile->getGroupEntry().toDirName(target->getResourceType()).c_str(),
                String8(resourceName).c_str());
        resPath.convertToResPath();
        convertToResPath(resPath);

        // Add a resource table entry.
        if (bundle->getVerbose()) {

tools/aapt/Utils.cpp

0 → 100644
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2005 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.
 */

#include "Utils.h"

#include <utils/Compat.h>

// Separator used by resource paths. This is not platform dependent contrary
// to OS_PATH_SEPARATOR.
#define RES_PATH_SEPARATOR '/'

using android::String8;

void convertToResPath([[maybe_unused]] String8& s) {
#if OS_PATH_SEPARATOR != RES_PATH_SEPARATOR
    size_t len = s.length();
    if (len > 0) {
        char* buf = s.lockBuffer(len);
        for (char* end = buf + len; buf < end; ++buf) {
            if (*buf == OS_PATH_SEPARATOR) *buf = RES_PATH_SEPARATOR;
        }
        s.unlockBuffer(len);
    }
#endif
}
Loading