summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/Command.cpp6
-rw-r--r--tools/aapt/ResourceTable.cpp8
-rw-r--r--tools/aapt2/SdkConstants.cpp2
-rw-r--r--tools/aapt2/format/Container.cpp4
-rw-r--r--tools/aapt2/io/Util.h3
-rw-r--r--tools/bit/adb.cpp4
-rw-r--r--tools/bit/main.cpp126
-rw-r--r--tools/lint/Android.bp7
-rw-r--r--tools/lint/OWNERS1
-rw-r--r--tools/localedata/OWNERS2
-rwxr-xr-xtools/localedata/extract_icu_data.py68
-rw-r--r--tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java2
-rw-r--r--tools/processors/intdef_mappings/Android.bp22
-rw-r--r--tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt2
-rw-r--r--tools/processors/view_inspector/Android.bp18
-rw-r--r--tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt2
-rw-r--r--tools/stringslint/stringslint.py234
-rwxr-xr-xtools/stringslint/stringslint_sha.sh6
-rw-r--r--tools/validatekeymaps/OWNERS3
-rw-r--r--tools/xmlpersistence/src/main/kotlin/Generator.kt1
20 files changed, 157 insertions, 364 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index fecc7b3cbf37..d02fd83df6af 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1028,7 +1028,6 @@ int doDump(Bundle* bundle)
// These permissions are required by services implementing services
// the system binds to (IME, Accessibility, PrintServices, etc.)
bool hasBindDeviceAdminPermission = false;
- bool hasBindInputMethodPermission = false;
bool hasBindAccessibilityServicePermission = false;
bool hasBindPrintServicePermission = false;
bool hasBindNfcServicePermission = false;
@@ -1757,7 +1756,6 @@ int doDump(Bundle* bundle)
hasMetaHostPaymentCategory = false;
hasMetaOffHostPaymentCategory = false;
hasBindDeviceAdminPermission = false;
- hasBindInputMethodPermission = false;
hasBindAccessibilityServicePermission = false;
hasBindPrintServicePermission = false;
hasBindNfcServicePermission = false;
@@ -1871,9 +1869,7 @@ int doDump(Bundle* bundle)
String8 permission = AaptXml::getAttribute(tree, PERMISSION_ATTR,
&error);
if (error == "") {
- if (permission == "android.permission.BIND_INPUT_METHOD") {
- hasBindInputMethodPermission = true;
- } else if (permission ==
+ if (permission ==
"android.permission.BIND_ACCESSIBILITY_SERVICE") {
hasBindAccessibilityServicePermission = true;
} else if (permission ==
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index b9de11b0026b..47750fc11a6e 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -2970,14 +2970,6 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<const ResourceFilter>&
}
e->setNameIndex(keyStrings.add(e->getName(), true));
- // If this entry has no values for other configs,
- // and is the default config, then it is special. Otherwise
- // we want to add it with the config info.
- ConfigDescription* valueConfig = NULL;
- if (N != 1 || config == nullConfig) {
- valueConfig = &config;
- }
-
status_t err = e->prepareFlatten(&valueStrings, this,
&configTypeName, &config);
if (err != NO_ERROR) {
diff --git a/tools/aapt2/SdkConstants.cpp b/tools/aapt2/SdkConstants.cpp
index 8ea43abff895..34e8edb0a47f 100644
--- a/tools/aapt2/SdkConstants.cpp
+++ b/tools/aapt2/SdkConstants.cpp
@@ -27,7 +27,7 @@ namespace aapt {
static ApiVersion sDevelopmentSdkLevel = 10000;
static const auto sDevelopmentSdkCodeNames =
- std::unordered_set<StringPiece>({"Q", "R", "S", "Sv2", "Tiramisu"});
+ std::unordered_set<StringPiece>({"Q", "R", "S", "Sv2", "Tiramisu", "UpsideDownCake"});
static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = {
{0x021c, 1},
diff --git a/tools/aapt2/format/Container.cpp b/tools/aapt2/format/Container.cpp
index 9cef7b3d2ce3..1ff6c4996b91 100644
--- a/tools/aapt2/format/Container.cpp
+++ b/tools/aapt2/format/Container.cpp
@@ -76,7 +76,7 @@ bool ContainerWriter::AddResTableEntry(const pb::ResourceTable& table) {
coded_out.WriteLittleEndian32(kResTable);
// Write the aligned size.
- const ::google::protobuf::uint64 size = table.ByteSize();
+ const size_t size = table.ByteSizeLong();
const int padding = CalculatePaddingForAlignment(size);
coded_out.WriteLittleEndian64(size);
@@ -109,7 +109,7 @@ bool ContainerWriter::AddResFileEntry(const pb::internal::CompiledFile& file,
coded_out.WriteLittleEndian32(kResFile);
// Write the aligned size.
- const ::google::protobuf::uint32 header_size = file.ByteSize();
+ const size_t header_size = file.ByteSizeLong();
const int header_padding = CalculatePaddingForAlignment(header_size);
const ::google::protobuf::uint64 data_size = in->TotalSize();
const int data_padding = CalculatePaddingForAlignment(data_size);
diff --git a/tools/aapt2/io/Util.h b/tools/aapt2/io/Util.h
index 5cb8206db23c..1b48a288d255 100644
--- a/tools/aapt2/io/Util.h
+++ b/tools/aapt2/io/Util.h
@@ -131,8 +131,7 @@ class ProtoInputStreamReader {
template <typename T> bool ReadMessage(T *message) {
ZeroCopyInputAdaptor adapter(in_);
google::protobuf::io::CodedInputStream coded_stream(&adapter);
- coded_stream.SetTotalBytesLimit(std::numeric_limits<int32_t>::max(),
- coded_stream.BytesUntilTotalBytesLimit());
+ coded_stream.SetTotalBytesLimit(std::numeric_limits<int32_t>::max());
return message->ParseFromCodedStream(&coded_stream);
}
diff --git a/tools/bit/adb.cpp b/tools/bit/adb.cpp
index f521a63255e1..201028ba900a 100644
--- a/tools/bit/adb.cpp
+++ b/tools/bit/adb.cpp
@@ -73,7 +73,7 @@ string
get_system_property(const string& name, int* err)
{
Command cmd("adb");
- cmd.AddArg("shell");
+ cmd.AddArg("exec-out");
cmd.AddArg("getprop");
cmd.AddArg(name);
@@ -278,7 +278,7 @@ run_instrumentation_test(const string& packageName, const string& runner, const
InstrumentationCallbacks* callbacks)
{
Command cmd("adb");
- cmd.AddArg("shell");
+ cmd.AddArg("exec-out");
cmd.AddArg("am");
cmd.AddArg("instrument");
cmd.AddArg("-w");
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp
index fd184f50091a..0d48070fd0c6 100644
--- a/tools/bit/main.cpp
+++ b/tools/bit/main.cpp
@@ -52,24 +52,22 @@ struct Target {
int testPassCount;
int testFailCount;
+ int testIgnoreCount;
int unknownFailureCount; // unknown failure == "Process crashed", etc.
- bool actionsWithNoTests;
Target(bool b, bool i, bool t, const string& p);
};
Target::Target(bool b, bool i, bool t, const string& p)
- :build(b),
- install(i),
- test(t),
- pattern(p),
- testActionCount(0),
- testPassCount(0),
- testFailCount(0),
- unknownFailureCount(0),
- actionsWithNoTests(false)
-{
-}
+ : build(b),
+ install(i),
+ test(t),
+ pattern(p),
+ testActionCount(0),
+ testPassCount(0),
+ testFailCount(0),
+ testIgnoreCount(0),
+ unknownFailureCount(0) {}
/**
* Command line options.
@@ -188,13 +186,12 @@ struct TestAction {
// The number of tests that failed
int failCount;
+
+ // The number of tests that were ignored (because of @Ignore)
+ int ignoreCount;
};
-TestAction::TestAction()
- :passCount(0),
- failCount(0)
-{
-}
+TestAction::TestAction() : passCount(0), failCount(0), ignoreCount(0) {}
/**
* Record for an activity that is going to be launched.
@@ -278,7 +275,7 @@ TestResults::OnTestStatus(TestStatus& status)
line << " of " << testCount;
}
}
- line << ": " << m_currentAction->target->name << ':' << className << "\\#" << testName;
+ line << ": " << m_currentAction->target->name << ':' << className << "#" << testName;
print_one_line("%s", line.str().c_str());
} else if ((resultCode == -1) || (resultCode == -2)) {
// test failed
@@ -286,9 +283,9 @@ TestResults::OnTestStatus(TestStatus& status)
// all as "failures".
m_currentAction->failCount++;
m_currentAction->target->testFailCount++;
- printf("%s\n%sFailed: %s:%s\\#%s%s\n", g_escapeClearLine, g_escapeRedBold,
- m_currentAction->target->name.c_str(), className.c_str(),
- testName.c_str(), g_escapeEndColor);
+ printf("%s\n%sFailed: %s:%s#%s%s\n", g_escapeClearLine, g_escapeRedBold,
+ m_currentAction->target->name.c_str(), className.c_str(), testName.c_str(),
+ g_escapeEndColor);
bool stackFound;
string stack = get_bundle_string(results, &stackFound, "stack", NULL);
@@ -300,6 +297,13 @@ TestResults::OnTestStatus(TestStatus& status)
} else if (stackFound) {
printf("%s\n", stack.c_str());
}
+ } else if (resultCode == -3) {
+ // test ignored
+ m_currentAction->ignoreCount++;
+ m_currentAction->target->testIgnoreCount++;
+ printf("%s\n%sIgnored: %s:%s#%s%s\n", g_escapeClearLine, g_escapeYellowBold,
+ m_currentAction->target->name.c_str(), className.c_str(), testName.c_str(),
+ g_escapeEndColor);
}
}
@@ -403,11 +407,14 @@ print_usage(FILE* out) {
fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs all the\n");
fprintf(out, " tests in the ProtoOutputStreamBoolTest class.\n");
fprintf(out, "\n");
- fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest\\#testWrite\n");
+ fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest#testWrite\n");
fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs the testWrite\n");
fprintf(out, " test method on that class.\n");
fprintf(out, "\n");
- fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest\\#testWrite,.ProtoOutputStreamBoolTest\\#testRepeated\n");
+ fprintf(out,
+ " bit "
+ "CtsProtoTestCases:.ProtoOutputStreamBoolTest#testWrite,.ProtoOutputStreamBoolTest#"
+ "testRepeated\n");
fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs the testWrite\n");
fprintf(out, " and testRepeated test methods on that class.\n");
fprintf(out, "\n");
@@ -450,6 +457,35 @@ print_usage(FILE* out) {
fprintf(out, "\n");
}
+/**
+ * Prints a possibly color-coded summary of test results. Example output:
+ *
+ * "34 passed, 0 failed, 1 ignored\n"
+ */
+static void print_results(int passed, int failed, int ignored) {
+ char const* nothing = "";
+ char const* cp = nothing;
+ char const* cf = nothing;
+ char const* ci = nothing;
+
+ if (failed > 0) {
+ cf = g_escapeRedBold;
+ } else if (passed > 0 || ignored > 0) {
+ cp = passed > 0 ? g_escapeGreenBold : nothing;
+ ci = ignored > 0 ? g_escapeYellowBold : nothing;
+ } else {
+ cp = g_escapeYellowBold;
+ cf = g_escapeYellowBold;
+ }
+
+ if (ignored > 0) {
+ printf("%s%d passed%s, %s%d failed%s, %s%d ignored%s\n", cp, passed, g_escapeEndColor, cf,
+ failed, g_escapeEndColor, ci, ignored, g_escapeEndColor);
+ } else {
+ printf("%s%d passed%s, %s%d failed%s\n", cp, passed, g_escapeEndColor, cf, failed,
+ g_escapeEndColor);
+ }
+}
/**
* Sets the appropriate flag* variables. If there is a problem with the
@@ -812,7 +848,7 @@ run_phases(vector<Target*> targets, const Options& options)
// Stop & Sync
if (!options.noRestart) {
- err = run_adb("shell", "stop", NULL);
+ err = run_adb("exec-out", "stop", NULL);
check_error(err);
}
err = run_adb("remount", NULL);
@@ -831,9 +867,9 @@ run_phases(vector<Target*> targets, const Options& options)
} else {
print_status("Restarting the runtime");
- err = run_adb("shell", "setprop", "sys.boot_completed", "0", NULL);
+ err = run_adb("exec-out", "setprop", "sys.boot_completed", "0", NULL);
check_error(err);
- err = run_adb("shell", "start", NULL);
+ err = run_adb("exec-out", "start", NULL);
check_error(err);
}
@@ -846,7 +882,7 @@ run_phases(vector<Target*> targets, const Options& options)
sleep(2);
}
sleep(1);
- err = run_adb("shell", "wm", "dismiss-keyguard", NULL);
+ err = run_adb("exec-out", "wm", "dismiss-keyguard", NULL);
check_error(err);
}
}
@@ -863,7 +899,7 @@ run_phases(vector<Target*> targets, const Options& options)
continue;
}
// TODO: if (!apk.file.fileInfo.exists || apk.file.HasChanged())
- err = run_adb("shell", "mkdir", "-p", dir.c_str(), NULL);
+ err = run_adb("exec-out", "mkdir", "-p", dir.c_str(), NULL);
check_error(err);
err = run_adb("push", pushed.file.filename.c_str(), pushed.dest.c_str(), NULL);
check_error(err);
@@ -945,9 +981,9 @@ run_phases(vector<Target*> targets, const Options& options)
}
}
if (runAll) {
- err = run_adb("shell", installedPath.c_str(), NULL);
+ err = run_adb("exec-out", installedPath.c_str(), NULL);
} else {
- err = run_adb("shell", installedPath.c_str(), filterArg.c_str(), NULL);
+ err = run_adb("exec-out", installedPath.c_str(), filterArg.c_str(), NULL);
}
if (err == 0) {
target->testPassCount++;
@@ -1035,22 +1071,10 @@ run_phases(vector<Target*> targets, const Options& options)
err = run_instrumentation_test(action.packageName, action.runner, action.className,
&testResults);
check_error(err);
- if (action.passCount == 0 && action.failCount == 0) {
- action.target->actionsWithNoTests = true;
- }
int total = action.passCount + action.failCount;
printf("%sRan %d test%s for %s. ", g_escapeClearLine,
total, total > 1 ? "s" : "", action.target->name.c_str());
- if (action.passCount == 0 && action.failCount == 0) {
- printf("%s%d passed, %d failed%s\n", g_escapeYellowBold, action.passCount,
- action.failCount, g_escapeEndColor);
- } else if (action.failCount > 0) {
- printf("%d passed, %s%d failed%s\n", action.passCount, g_escapeRedBold,
- action.failCount, g_escapeEndColor);
- } else {
- printf("%s%d passed%s, %d failed\n", g_escapeGreenBold, action.passCount,
- g_escapeEndColor, action.failCount);
- }
+ print_results(action.passCount, action.failCount, action.ignoreCount);
if (!testResults.IsSuccess()) {
printf("\n%sTest didn't finish successfully: %s%s\n", g_escapeRedBold,
testResults.GetErrorMessage().c_str(), g_escapeEndColor);
@@ -1073,7 +1097,7 @@ run_phases(vector<Target*> targets, const Options& options)
const ActivityAction& action = activityActions[0];
string componentName = action.packageName + "/" + action.className;
- err = run_adb("shell", "am", "start", componentName.c_str(), NULL);
+ err = run_adb("exec-out", "am", "start", componentName.c_str(), NULL);
check_error(err);
}
@@ -1147,17 +1171,11 @@ run_phases(vector<Target*> targets, const Options& options)
printf(" %sUnknown failure, see above message.%s\n",
g_escapeRedBold, g_escapeEndColor);
hasErrors = true;
- } else if (target->actionsWithNoTests) {
- printf(" %s%d passed, %d failed%s\n", g_escapeYellowBold,
- target->testPassCount, target->testFailCount, g_escapeEndColor);
- hasErrors = true;
- } else if (target->testFailCount > 0) {
- printf(" %d passed, %s%d failed%s\n", target->testPassCount,
- g_escapeRedBold, target->testFailCount, g_escapeEndColor);
- hasErrors = true;
} else {
- printf(" %s%d passed%s, %d failed\n", g_escapeGreenBold,
- target->testPassCount, g_escapeEndColor, target->testFailCount);
+ printf(" %s%s ", target->name.c_str(),
+ padding.c_str() + target->name.length());
+ print_results(target->testPassCount, target->testFailCount,
+ target->testIgnoreCount);
}
}
}
diff --git a/tools/lint/Android.bp b/tools/lint/Android.bp
index 17547ef8b561..260104145505 100644
--- a/tools/lint/Android.bp
+++ b/tools/lint/Android.bp
@@ -29,10 +29,17 @@ java_library_host {
"auto_service_annotations",
"lint_api",
],
+ kotlincflags: ["-Xjvm-default=all"],
}
java_test_host {
name: "AndroidFrameworkLintCheckerTest",
+ // TODO(b/239881504): Since this test was written, Android
+ // Lint was updated, and now includes classes that were
+ // compiled for java 15. The soong build doesn't support
+ // java 15 yet, so we can't compile against "lint". Disable
+ // the test until java 15 is supported.
+ enabled: false,
srcs: ["checks/src/test/java/**/*.kt"],
static_libs: [
"AndroidFrameworkLintChecker",
diff --git a/tools/lint/OWNERS b/tools/lint/OWNERS
index 7c0451900e32..2c526a1e239e 100644
--- a/tools/lint/OWNERS
+++ b/tools/lint/OWNERS
@@ -2,4 +2,5 @@ brufino@google.com
jsharkey@google.com
per-file *CallingSettingsNonUserGetterMethods* = file:/packages/SettingsProvider/OWNERS
+per-file *RegisterReceiverFlagDetector* = jacobhobbie@google.com
diff --git a/tools/localedata/OWNERS b/tools/localedata/OWNERS
new file mode 100644
index 000000000000..2501679784d6
--- /dev/null
+++ b/tools/localedata/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 24949
+include platform/external/icu:/OWNERS
diff --git a/tools/localedata/extract_icu_data.py b/tools/localedata/extract_icu_data.py
index ca1847af7d06..81ac897deae0 100755
--- a/tools/localedata/extract_icu_data.py
+++ b/tools/localedata/extract_icu_data.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2016 The Android Open Source Project. All Rights Reserved.
#
@@ -61,7 +61,7 @@ def read_likely_subtags(input_file_name):
# would be chosen.)
}
for line in input_file:
- line = unicode(line, 'UTF-8').strip(u' \n\uFEFF').encode('UTF-8')
+ line = line.strip(u' \n\uFEFF')
if line.startswith('//'):
continue
if '{' in line and '}' in line:
@@ -118,26 +118,26 @@ def pack_to_uint32(locale):
def dump_script_codes(all_scripts):
"""Dump the SCRIPT_CODES table."""
- print 'const char SCRIPT_CODES[][4] = {'
+ print('const char SCRIPT_CODES[][4] = {')
for index, script in enumerate(all_scripts):
- print " /* %-2d */ {'%c', '%c', '%c', '%c'}," % (
- index, script[0], script[1], script[2], script[3])
- print '};'
- print
+ print(" /* %-2d */ {'%c', '%c', '%c', '%c'}," % (
+ index, script[0], script[1], script[2], script[3]))
+ print('};')
+ print()
def dump_script_data(likely_script_dict, all_scripts):
"""Dump the script data."""
- print
- print 'const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({'
+ print()
+ print('const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({')
for locale in sorted(likely_script_dict.keys()):
script = likely_script_dict[locale]
- print ' {0x%08Xu, %2du}, // %s -> %s' % (
+ print(' {0x%08Xu, %2du}, // %s -> %s' % (
pack_to_uint32(locale),
all_scripts.index(script),
locale.replace('_', '-'),
- script)
- print '});'
+ script))
+ print('});')
def pack_to_uint64(locale):
@@ -152,13 +152,13 @@ def pack_to_uint64(locale):
def dump_representative_locales(representative_locales):
"""Dump the set of representative locales."""
- print
- print 'std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({'
+ print()
+ print('std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({')
for locale in sorted(representative_locales):
- print ' 0x%08XLLU, // %s' % (
+ print(' 0x%08XLLU, // %s' % (
pack_to_uint64(locale),
- locale)
- print '});'
+ locale))
+ print('});')
def read_and_dump_likely_data(icu_data_dir):
@@ -220,30 +220,30 @@ def get_likely_script(locale, likely_script_dict):
def dump_parent_data(script_organized_dict):
"""Dump information for parents of locales."""
sorted_scripts = sorted(script_organized_dict.keys())
- print
+ print()
for script in sorted_scripts:
parent_dict = script_organized_dict[script]
print ('const std::unordered_map<uint32_t, uint32_t> %s_PARENTS({'
% escape_script_variable_name(script.upper()))
for locale in sorted(parent_dict.keys()):
parent = parent_dict[locale]
- print ' {0x%08Xu, 0x%08Xu}, // %s -> %s' % (
+ print(' {0x%08Xu, 0x%08Xu}, // %s -> %s' % (
pack_to_uint32(locale),
pack_to_uint32(parent),
locale.replace('_', '-'),
- parent.replace('_', '-'))
- print '});'
- print
-
- print 'const struct {'
- print ' const char script[4];'
- print ' const std::unordered_map<uint32_t, uint32_t>* map;'
- print '} SCRIPT_PARENTS[] = {'
+ parent.replace('_', '-')))
+ print('});')
+ print()
+
+ print('const struct {')
+ print(' const char script[4];')
+ print(' const std::unordered_map<uint32_t, uint32_t>* map;')
+ print('} SCRIPT_PARENTS[] = {')
for script in sorted_scripts:
- print " {{'%c', '%c', '%c', '%c'}, &%s_PARENTS}," % (
+ print(" {{'%c', '%c', '%c', '%c'}, &%s_PARENTS}," % (
script[0], script[1], script[2], script[3],
- escape_script_variable_name(script.upper()))
- print '};'
+ escape_script_variable_name(script.upper())))
+ print('};')
def dump_parent_tree_depth(parent_dict):
@@ -256,8 +256,8 @@ def dump_parent_tree_depth(parent_dict):
depth += 1
max_depth = max(max_depth, depth)
assert max_depth < 5 # Our algorithms assume small max_depth
- print
- print 'const size_t MAX_PARENT_DEPTH = %d;' % max_depth
+ print()
+ print('const size_t MAX_PARENT_DEPTH = %d;' % max_depth)
def read_and_dump_parent_data(icu_data_dir, likely_script_dict):
@@ -281,8 +281,8 @@ def main():
source_root,
'external', 'icu', 'icu4c', 'source', 'data')
- print '// Auto-generated by %s' % sys.argv[0]
- print
+ print('// Auto-generated by %s' % sys.argv[0])
+ print()
likely_script_dict = read_and_dump_likely_data(icu_data_dir)
read_and_dump_parent_data(icu_data_dir, likely_script_dict)
diff --git a/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java b/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java
index f1e84b1d8a33..b44e8b42f052 100644
--- a/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java
+++ b/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java
@@ -20,7 +20,7 @@ import java.util.List;
public class Utils {
- public static final int ASM_VERSION = Opcodes.ASM7;
+ public static final int ASM_VERSION = Opcodes.ASM9;
/**
* Reads a comma separated configuration similar to the Jack definition.
diff --git a/tools/processors/intdef_mappings/Android.bp b/tools/processors/intdef_mappings/Android.bp
index 82a5dac21160..7059c52ddc76 100644
--- a/tools/processors/intdef_mappings/Android.bp
+++ b/tools/processors/intdef_mappings/Android.bp
@@ -7,27 +7,33 @@ package {
default_applicable_licenses: ["frameworks_base_license"],
}
-java_plugin {
- name: "intdef-annotation-processor",
-
- processor_class: "android.processor.IntDefProcessor",
+java_library_host {
+ name: "libintdef-annotation-processor",
srcs: [
":framework-annotations",
"src/**/*.java",
- "src/**/*.kt"
+ "src/**/*.kt",
],
use_tools_jar: true,
}
+java_plugin {
+ name: "intdef-annotation-processor",
+
+ processor_class: "android.processor.IntDefProcessor",
+
+ static_libs: ["libintdef-annotation-processor"],
+}
+
java_test_host {
name: "intdef-annotation-processor-test",
srcs: [
"test/**/*.java",
- "test/**/*.kt"
- ],
+ "test/**/*.kt",
+ ],
java_resource_dirs: ["test/resources"],
static_libs: [
@@ -35,7 +41,7 @@ java_test_host {
"truth-prebuilt",
"junit",
"guava",
- "intdef-annotation-processor"
+ "libintdef-annotation-processor",
],
test_suites: ["general-tests"],
diff --git a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
index 2e60f64b21e8..27a8853a2219 100644
--- a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
+++ b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt
@@ -97,7 +97,7 @@ class StaleDataclassProcessor: AbstractProcessor() {
private fun elemToString(elem: Element): String {
return buildString {
- append(elem.modifiers.joinToString(" ") { it.name.toLowerCase() })
+ append(elem.modifiers.joinToString(" ") { it.name.lowercase() })
append(" ")
append(elem.annotationMirrors.joinToString(" ", transform = { annotationToString(it) }))
append(" ")
diff --git a/tools/processors/view_inspector/Android.bp b/tools/processors/view_inspector/Android.bp
index ea9974f06a64..877a1d2b5fb3 100644
--- a/tools/processors/view_inspector/Android.bp
+++ b/tools/processors/view_inspector/Android.bp
@@ -7,10 +7,8 @@ package {
default_applicable_licenses: ["frameworks_base_license"],
}
-java_plugin {
- name: "view-inspector-annotation-processor",
-
- processor_class: "android.processor.view.inspector.PlatformInspectableProcessor",
+java_library_host {
+ name: "libview-inspector-annotation-processor",
srcs: ["src/java/**/*.java"],
java_resource_dirs: ["src/resources"],
@@ -23,6 +21,16 @@ java_plugin {
use_tools_jar: true,
}
+java_plugin {
+ name: "view-inspector-annotation-processor",
+
+ processor_class: "android.processor.view.inspector.PlatformInspectableProcessor",
+
+ static_libs: [
+ "libview-inspector-annotation-processor",
+ ],
+}
+
java_test_host {
name: "view-inspector-annotation-processor-test",
@@ -32,7 +40,7 @@ java_test_host {
static_libs: [
"junit",
"guava",
- "view-inspector-annotation-processor"
+ "libview-inspector-annotation-processor",
],
test_suites: ["general-tests"],
diff --git a/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt b/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt
index a52c8042582b..451e514b8b33 100644
--- a/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt
+++ b/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt
@@ -29,7 +29,7 @@ object CodeUtils {
*/
fun hash(position: String, messageString: String, logLevel: LogLevel, logGroup: LogGroup): Int {
return (position + messageString + logLevel.name + logGroup.name)
- .map { c -> c.toInt() }.reduce { h, c -> h * 31 + c }
+ .map { c -> c.code }.reduce { h, c -> h * 31 + c }
}
fun checkWildcardStaticImported(code: CompilationUnit, className: String, fileName: String) {
diff --git a/tools/stringslint/stringslint.py b/tools/stringslint/stringslint.py
deleted file mode 100644
index 15088fc81e88..000000000000
--- a/tools/stringslint/stringslint.py
+++ /dev/null
@@ -1,234 +0,0 @@
-#!/usr/bin/env python3
-#-*- coding: utf-8 -*-
-
-# Copyright (C) 2018 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.
-
-"""
-Enforces common Android string best-practices. It ignores lint messages from
-a previous strings file, if provided.
-
-Usage: stringslint.py strings.xml
-Usage: stringslint.py strings.xml old_strings.xml
-
-In general:
-* Errors signal issues that must be fixed before submitting, and are only
- used when there are no false-positives.
-* Warnings signal issues that might need to be fixed, but need manual
- inspection due to risk of false-positives.
-* Info signal issues that should be fixed to match best-practices, such
- as providing comments to aid translation.
-"""
-
-import re, sys, codecs
-import lxml.etree as ET
-
-BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
-
-def format(fg=None, bg=None, bright=False, bold=False, dim=False, reset=False):
- # manually derived from http://en.wikipedia.org/wiki/ANSI_escape_code#Codes
- codes = []
- if reset: codes.append("0")
- else:
- if not fg is None: codes.append("3%d" % (fg))
- if not bg is None:
- if not bright: codes.append("4%d" % (bg))
- else: codes.append("10%d" % (bg))
- if bold: codes.append("1")
- elif dim: codes.append("2")
- else: codes.append("22")
- return "\033[%sm" % (";".join(codes))
-
-warnings = None
-
-def warn(tag, msg, actual, expected, color=YELLOW):
- global warnings
- key = "%s:%d" % (tag.attrib["name"], hash(msg))
- value = "%sLine %d: '%s':%s %s" % (format(fg=color, bold=True),
- tag.sourceline,
- tag.attrib["name"],
- format(reset=True),
- msg)
- if not actual is None: value += "\n\tActual: %s%s%s" % (format(dim=True),
- actual,
- format(reset=True))
- if not expected is None: value += "\n\tExample: %s%s%s" % (format(dim=True),
- expected,
- format(reset=True))
- warnings[key] = value
-
-
-def error(tag, msg, actual, expected):
- warn(tag, msg, actual, expected, RED)
-
-def info(tag, msg, actual, expected):
- warn(tag, msg, actual, expected, CYAN)
-
-# Escaping logic borrowed from https://stackoverflow.com/a/24519338
-ESCAPE_SEQUENCE_RE = re.compile(r'''
- ( \\U........ # 8-digit hex escapes
- | \\u.... # 4-digit hex escapes
- | \\x.. # 2-digit hex escapes
- | \\[0-7]{1,3} # Octal escapes
- | \\N\{[^}]+\} # Unicode characters by name
- | \\[\\'"abfnrtv] # Single-character escapes
- )''', re.UNICODE | re.VERBOSE)
-
-def decode_escapes(s):
- def decode_match(match):
- return codecs.decode(match.group(0), 'unicode-escape')
-
- s = re.sub(r"\n\s*", " ", s)
- s = ESCAPE_SEQUENCE_RE.sub(decode_match, s)
- s = re.sub(r"%(\d+\$)?[a-z]", "____", s)
- s = re.sub(r"\^\d+", "____", s)
- s = re.sub(r"<br/?>", "\n", s)
- s = re.sub(r"</?[a-z]+>", "", s)
- return s
-
-def sample_iter(tag):
- if not isinstance(tag, ET._Comment) and re.match("{.*xliff.*}g", tag.tag) and "example" in tag.attrib:
- yield tag.attrib["example"]
- elif tag.text:
- yield decode_escapes(tag.text)
- for e in tag:
- for v in sample_iter(e):
- yield v
- if e.tail:
- yield decode_escapes(e.tail)
-
-def lint(path):
- global warnings
- warnings = {}
-
- with open(path) as f:
- raw = f.read()
- if len(raw.strip()) == 0:
- return warnings
- tree = ET.fromstring(bytes(raw, encoding='utf-8'))
- root = tree #tree.getroot()
-
- last_comment = None
- for child in root:
- # TODO: handle plurals
- if isinstance(child, ET._Comment):
- last_comment = child
- elif child.tag == "string":
- # We always consume comment
- comment = last_comment
- last_comment = None
-
- # Prepare string for analysis
- text = "".join(child.itertext())
- sample = "".join(sample_iter(child)).strip().strip("'\"")
-
- # Validate comment
- if comment is None:
- info(child, "Missing string comment to aid translation",
- None, None)
- continue
- if "do not translate" in comment.text.lower():
- continue
- if "translatable" in child.attrib and child.attrib["translatable"].lower() == "false":
- continue
-
- misspelled_attributes = [
- ("translateable", "translatable"),
- ]
- for misspelling, expected in misspelled_attributes:
- if misspelling in child.attrib:
- error(child, "Misspelled <string> attribute.", misspelling, expected)
-
- limit = re.search("CHAR[ _-]LIMIT=(\d+|NONE|none)", comment.text)
- if limit is None:
- info(child, "Missing CHAR LIMIT to aid translation",
- repr(comment), "<!-- Description of string [CHAR LIMIT=32] -->")
- elif re.match("\d+", limit.group(1)):
- limit = int(limit.group(1))
- if len(sample) > limit:
- warn(child, "Expanded string length is larger than CHAR LIMIT",
- sample, None)
-
- # Look for common mistakes/substitutions
- if "'" in text:
- error(child, "Turned quotation mark glyphs are more polished",
- text, "This doesn\u2019t need to \u2018happen\u2019 today")
- if '"' in text and not text.startswith('"') and text.endswith('"'):
- error(child, "Turned quotation mark glyphs are more polished",
- text, "This needs to \u201chappen\u201d today")
- if "..." in text:
- error(child, "Ellipsis glyph is more polished",
- text, "Loading\u2026")
- if "wi-fi" in text.lower():
- error(child, "Non-breaking glyph is more polished",
- text, "Wi\u2011Fi")
- if "wifi" in text.lower():
- error(child, "Using non-standard spelling",
- text, "Wi\u2011Fi")
- if re.search("\d-\d", text):
- warn(child, "Ranges should use en dash glyph",
- text, "You will find this material in chapters 8\u201312")
- if "--" in text:
- warn(child, "Phrases should use em dash glyph",
- text, "Upon discovering errors\u2014all 124 of them\u2014they recalled.")
- if ". " in text:
- warn(child, "Only use single space between sentences",
- text, "First idea. Second idea.")
- if re.match(r"^[A-Z\s]{5,}$", text):
- warn(child, "Actions should use android:textAllCaps in layout; ignore if acronym",
- text, "Refresh data")
- if " phone " in text and "product" not in child.attrib:
- warn(child, "Strings mentioning phones should have variants for tablets",
- text, None)
-
- # When more than one substitution, require indexes
- if len(re.findall("%[^%]", text)) > 1:
- if len(re.findall("%[^\d]", text)) > 0:
- error(child, "Substitutions must be indexed",
- text, "Add %1$s to %2$s")
-
- # Require xliff substitutions
- for gc in child.iter():
- badsub = False
- if gc.tail and re.search("%[^%]", gc.tail): badsub = True
- if re.match("{.*xliff.*}g", gc.tag):
- if "id" not in gc.attrib:
- error(child, "Substitutions must define id attribute",
- None, "<xliff:g id=\"domain\" example=\"example.com\">%1$s</xliff:g>")
- if "example" not in gc.attrib:
- error(child, "Substitutions must define example attribute",
- None, "<xliff:g id=\"domain\" example=\"example.com\">%1$s</xliff:g>")
- else:
- if gc.text and re.search("%[^%]", gc.text): badsub = True
- if badsub:
- error(child, "Substitutions must be inside xliff tags",
- text, "<xliff:g id=\"domain\" example=\"example.com\">%1$s</xliff:g>")
-
- return warnings
-
-if len(sys.argv) > 2:
- before = lint(sys.argv[2])
-else:
- before = {}
-after = lint(sys.argv[1])
-
-for b in before:
- if b in after:
- del after[b]
-
-if len(after) > 0:
- for a in sorted(after.keys()):
- print(after[a])
- print()
- sys.exit(1)
diff --git a/tools/stringslint/stringslint_sha.sh b/tools/stringslint/stringslint_sha.sh
index bd0569873197..009a1f284bf0 100755
--- a/tools/stringslint/stringslint_sha.sh
+++ b/tools/stringslint/stringslint_sha.sh
@@ -1,5 +1,3 @@
#!/bin/bash
-LOCAL_DIR="$( dirname ${BASH_SOURCE} )"
-git show --name-only --pretty=format: $1 | grep values/strings.xml | while read file; do
- python3 $LOCAL_DIR/stringslint.py <(git show $1:$file) <(git show $1^:$file)
-done
+
+# NOTE: this script has been deprecated and replaced by AyeAye checks directly in Gerrit
diff --git a/tools/validatekeymaps/OWNERS b/tools/validatekeymaps/OWNERS
index 0313a40f7270..4c20c4dc9d35 100644
--- a/tools/validatekeymaps/OWNERS
+++ b/tools/validatekeymaps/OWNERS
@@ -1,2 +1 @@
-michaelwr@google.com
-svv@google.com
+include /INPUT_OWNERS
diff --git a/tools/xmlpersistence/src/main/kotlin/Generator.kt b/tools/xmlpersistence/src/main/kotlin/Generator.kt
index b2c5f4ac767b..8e62388c860f 100644
--- a/tools/xmlpersistence/src/main/kotlin/Generator.kt
+++ b/tools/xmlpersistence/src/main/kotlin/Generator.kt
@@ -149,6 +149,7 @@ private val ClassFieldInfo.allClassFields: List<ClassFieldInfo>
when (field) {
is ClassFieldInfo -> this += field.allClassFields
is ListFieldInfo -> this += field.element.allClassFields
+ else -> {}
}
}
}