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

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

Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw"

parents 62a5d424 5c541f6e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -43,8 +43,10 @@ cc_library {
        "AssetManager2.cpp",
        "AttributeResolution.cpp",
        "ChunkIterator.cpp",
        "ConfigDescription.cpp",
        "Idmap.cpp",
        "LoadedArsc.cpp",
        "Locale.cpp",
        "LocaleData.cpp",
        "misc.cpp",
        "ObbFile.cpp",
@@ -135,9 +137,11 @@ cc_test {
        "tests/AttributeResolution_test.cpp",
        "tests/ByteBucketArray_test.cpp",
        "tests/Config_test.cpp",
        "tests/ConfigDescription_test.cpp",
        "tests/ConfigLocale_test.cpp",
        "tests/Idmap_test.cpp",
        "tests/LoadedArsc_test.cpp",
        "tests/Locale_test.cpp",
        "tests/ResourceUtils_test.cpp",
        "tests/ResTable_test.cpp",
        "tests/Split_test.cpp",
+8 −14
Original line number Diff line number Diff line
@@ -14,22 +14,16 @@
 * limitations under the License.
 */

#include "ConfigDescription.h"

#include <string>
#include <vector>

#include "androidfw/ConfigDescription.h"
#include "androidfw/Locale.h"
#include "androidfw/ResourceTypes.h"
#include "androidfw/StringPiece.h"
#include "androidfw/Util.h"

#include "Locale.h"
#include "SdkConstants.h"
#include "util/Util.h"

using android::ResTable_config;
using android::StringPiece;
#include <string>
#include <vector>

namespace aapt {
namespace android {

static const char* kWildcardName = "any";

@@ -883,7 +877,7 @@ std::string ConfigDescription::GetBcp47LanguageTag(bool canonicalize) const {
}

std::string ConfigDescription::to_string() const {
  const android::String8 str = toString();
  const String8 str = toString();
  return std::string(str.string(), str.size());
}

@@ -996,4 +990,4 @@ bool ConfigDescription::IsCompatibleWith(const ConfigDescription& o) const {
  return !ConflictsWith(o) && !Dominates(o) && !o.Dominates(*this);
}

}  // namespace aapt
}  // namespace android
+4 −5
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@
 * limitations under the License.
 */

#include "Locale.h"
#include "androidfw/Locale.h"
#include "androidfw/Util.h"

#include <ctype.h>

@@ -22,12 +23,10 @@
#include <string>
#include <vector>

#include "util/Util.h"

using ::android::ResTable_config;
using ::android::StringPiece;

namespace aapt {
namespace android {

void LocaleValue::set_language(const char* language_chars) {
  size_t i = 0;
@@ -258,4 +257,4 @@ void LocaleValue::WriteTo(ResTable_config* out) const {
  }
}

}  // namespace aapt
}  // namespace android
+24 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include "androidfw/Util.h"

#include <algorithm>
#include <string>

#include "utils/ByteOrder.h"
@@ -67,5 +68,28 @@ std::string Utf16ToUtf8(const StringPiece16& utf16) {
  return utf8;
}

static std::vector<std::string> SplitAndTransform(
    const StringPiece& str, char sep, const std::function<char(char)>& f) {
  std::vector<std::string> parts;
  const StringPiece::const_iterator end = std::end(str);
  StringPiece::const_iterator start = std::begin(str);
  StringPiece::const_iterator current;
  do {
    current = std::find(start, end, sep);
    parts.emplace_back(str.substr(start, current).to_string());
    if (f) {
      std::string& part = parts.back();
      std::transform(part.begin(), part.end(), part.begin(), f);
    }
    start = current + 1;
  } while (current != end);
  return parts;
}

std::vector<std::string> SplitAndLowercase(const StringPiece& str, char sep) {
  return SplitAndTransform(str, sep, ::tolower);
}


} // namespace util
} // namespace android
+37 −6
Original line number Diff line number Diff line
@@ -14,21 +14,52 @@
 * limitations under the License.
 */

#ifndef AAPT_CONFIG_DESCRIPTION_H
#define AAPT_CONFIG_DESCRIPTION_H
#ifndef ANDROIDFW_CONFIG_DESCRIPTION_H
#define ANDROIDFW_CONFIG_DESCRIPTION_H

#include <ostream>

#include "androidfw/ResourceTypes.h"
#include "androidfw/StringPiece.h"

namespace aapt {
namespace android {

using ApiVersion = int;

enum : ApiVersion {
  SDK_CUPCAKE = 3,
  SDK_DONUT = 4,
  SDK_ECLAIR = 5,
  SDK_ECLAIR_0_1 = 6,
  SDK_ECLAIR_MR1 = 7,
  SDK_FROYO = 8,
  SDK_GINGERBREAD = 9,
  SDK_GINGERBREAD_MR1 = 10,
  SDK_HONEYCOMB = 11,
  SDK_HONEYCOMB_MR1 = 12,
  SDK_HONEYCOMB_MR2 = 13,
  SDK_ICE_CREAM_SANDWICH = 14,
  SDK_ICE_CREAM_SANDWICH_MR1 = 15,
  SDK_JELLY_BEAN = 16,
  SDK_JELLY_BEAN_MR1 = 17,
  SDK_JELLY_BEAN_MR2 = 18,
  SDK_KITKAT = 19,
  SDK_KITKAT_WATCH = 20,
  SDK_LOLLIPOP = 21,
  SDK_LOLLIPOP_MR1 = 22,
  SDK_MARSHMALLOW = 23,
  SDK_NOUGAT = 24,
  SDK_NOUGAT_MR1 = 25,
  SDK_O = 26,
  SDK_O_MR1 = 27,
  SDK_P = 28,
};

/*
 * Subclass of ResTable_config that adds convenient
 * initialization and comparison methods.
 */
struct ConfigDescription : public android::ResTable_config {
struct ConfigDescription : public ResTable_config {
  /**
   * Returns an immutable default config.
   */
@@ -180,6 +211,6 @@ inline ::std::ostream& operator<<(::std::ostream& out,
  return out << o.toString().string();
}

}  // namespace aapt
}  // namespace android

#endif  // AAPT_CONFIG_DESCRIPTION_H
#endif  // ANDROIDFW_CONFIG_DESCRIPTION_H
Loading