Merge "Fix google-explicit-constructor warnings in common_time."
diff --git a/api/current.txt b/api/current.txt
index a219738..3cee0f5 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -56425,9 +56425,17 @@
ctor public HashMap();
ctor public HashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
+ method public V compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>);
+ method public V computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>);
+ method public V computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>);
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
+ method public V getOrDefault(java.lang.Object, V);
+ method public V merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>);
+ method public V putIfAbsent(K, V);
+ method public boolean remove(java.lang.Object, java.lang.Object);
method public boolean replace(K, V, V);
+ method public V replace(K, V);
method public void replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>);
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 9666f47..9c6d6f5 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -59043,9 +59043,17 @@
ctor public HashMap();
ctor public HashMap(java.util.Map<? extends K, ? extends V>);
method public java.lang.Object clone();
+ method public V compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>);
+ method public V computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>);
+ method public V computeIfPresent(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>);
method public java.util.Set<java.util.Map.Entry<K, V>> entrySet();
method public void forEach(java.util.function.BiConsumer<? super K, ? super V>);
+ method public V getOrDefault(java.lang.Object, V);
+ method public V merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>);
+ method public V putIfAbsent(K, V);
+ method public boolean remove(java.lang.Object, java.lang.Object);
method public boolean replace(K, V, V);
+ method public V replace(K, V);
method public void replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>);
}
diff --git a/libs/common_time/common_time_server.cpp b/libs/common_time/common_time_server.cpp
index f72ffaa..b1495ef 100644
--- a/libs/common_time/common_time_server.cpp
+++ b/libs/common_time/common_time_server.cpp
@@ -615,12 +615,11 @@
ssize_t recvBytes = recvfrom(
mSocket, buf, sizeof(buf), 0,
- reinterpret_cast<const sockaddr *>(&srcAddr), &srcAddrLen);
+ reinterpret_cast<sockaddr *>(&srcAddr), &srcAddrLen);
if (recvBytes < 0) {
- mBadPktLog.log(ANDROID_LOG_ERROR, LOG_TAG,
- "recvfrom failed (res %d, errno %d)",
- recvBytes, errno);
+ mBadPktLog.log(ANDROID_LOG_ERROR, LOG_TAG, "recvfrom failed (%s)",
+ strerror(errno));
return false;
}
diff --git a/services/usb/java/com/android/server/usb/UsbMidiDevice.java b/services/usb/java/com/android/server/usb/UsbMidiDevice.java
index 38ede87..46ce7a0 100644
--- a/services/usb/java/com/android/server/usb/UsbMidiDevice.java
+++ b/services/usb/java/com/android/server/usb/UsbMidiDevice.java
@@ -127,6 +127,14 @@
public void setReceiver(MidiReceiver receiver) {
mReceiver = receiver;
}
+
+ @Override
+ public void onFlush() throws IOException {
+ MidiReceiver receiver = mReceiver;
+ if (receiver != null) {
+ receiver.flush();
+ }
+ }
}
public static UsbMidiDevice create(Context context, Bundle properties, int card, int device) {
diff --git a/tools/aapt/ApkBuilder.h b/tools/aapt/ApkBuilder.h
index 0d7f06b..5d3abc6 100644
--- a/tools/aapt/ApkBuilder.h
+++ b/tools/aapt/ApkBuilder.h
@@ -32,7 +32,7 @@
class ApkBuilder : public android::RefBase {
public:
- ApkBuilder(const sp<WeakResourceFilter>& configFilter);
+ explicit ApkBuilder(const sp<WeakResourceFilter>& configFilter);
/**
* Tells the builder to generate a separate APK for resources that
diff --git a/tools/aapt/CacheUpdater.h b/tools/aapt/CacheUpdater.h
index 10a1bbc..6fa96d6 100644
--- a/tools/aapt/CacheUpdater.h
+++ b/tools/aapt/CacheUpdater.h
@@ -51,7 +51,7 @@
class SystemCacheUpdater : public CacheUpdater {
public:
// Constructor to set bundle to pass to preProcessImage
- SystemCacheUpdater (Bundle* b)
+ explicit SystemCacheUpdater (Bundle* b)
: bundle(b) { };
// Make sure all the directories along this path exist
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index ba4aac6..8eeb84b 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -248,7 +248,7 @@
}
static void printResolvedResourceAttribute(const ResTable& resTable, const ResXMLTree& tree,
- uint32_t attrRes, String8 attrLabel, String8* outError)
+ uint32_t attrRes, const String8& attrLabel, String8* outError)
{
Res_value value;
AaptXml::getResolvedResourceAttribute(resTable, tree, attrRes, &value, outError);
@@ -399,7 +399,7 @@
ResTable::normalizeForOutput(reason.string()).string());
}
-Vector<String8> getNfcAidCategories(AssetManager& assets, String8 xmlPath, bool offHost,
+Vector<String8> getNfcAidCategories(AssetManager& assets, const String8& xmlPath, bool offHost,
String8 *outError = NULL)
{
Asset* aidAsset = assets.openNonAsset(xmlPath, Asset::ACCESS_BUFFER);
diff --git a/tools/aapt/ConfigDescription.h b/tools/aapt/ConfigDescription.h
index 4f999a2..09430f2 100644
--- a/tools/aapt/ConfigDescription.h
+++ b/tools/aapt/ConfigDescription.h
@@ -29,7 +29,7 @@
size = sizeof(android::ResTable_config);
}
- ConfigDescription(const android::ResTable_config&o) {
+ ConfigDescription(const android::ResTable_config&o) { // NOLINT(implicit)
*static_cast<android::ResTable_config*>(this) = o;
size = sizeof(android::ResTable_config);
}
diff --git a/tools/aapt/CrunchCache.cpp b/tools/aapt/CrunchCache.cpp
index 0d574cf..7b8a576 100644
--- a/tools/aapt/CrunchCache.cpp
+++ b/tools/aapt/CrunchCache.cpp
@@ -94,7 +94,7 @@
delete dw;
}
-bool CrunchCache::needsUpdating(String8 relativePath) const
+bool CrunchCache::needsUpdating(const String8& relativePath) const
{
// Retrieve modification dates for this file entry under the source and
// cache directory trees. The vectors will return a modification date of 0
diff --git a/tools/aapt/CrunchCache.h b/tools/aapt/CrunchCache.h
index be3da5c..4d6a169 100644
--- a/tools/aapt/CrunchCache.h
+++ b/tools/aapt/CrunchCache.h
@@ -81,7 +81,7 @@
* // Recrunch sourceFile out to destFile.
*
*/
- bool needsUpdating(String8 relativePath) const;
+ bool needsUpdating(const String8& relativePath) const;
// DATA MEMBERS ====================================================
diff --git a/tools/aapt/FileFinder.cpp b/tools/aapt/FileFinder.cpp
index 18775c0..c9d0744 100644
--- a/tools/aapt/FileFinder.cpp
+++ b/tools/aapt/FileFinder.cpp
@@ -77,7 +77,7 @@
return true;
}
-void SystemFileFinder::checkAndAddFile(String8 path, const struct stat* stats,
+void SystemFileFinder::checkAndAddFile(const String8& path, const struct stat* stats,
Vector<String8>& extensions,
KeyedVector<String8,time_t>& fileStore)
{
diff --git a/tools/aapt/FileFinder.h b/tools/aapt/FileFinder.h
index 6974aee..f405381 100644
--- a/tools/aapt/FileFinder.h
+++ b/tools/aapt/FileFinder.h
@@ -72,7 +72,7 @@
* time as the value.
*
*/
- static void checkAndAddFile(String8 path, const struct stat* stats,
+ static void checkAndAddFile(const String8& path, const struct stat* stats,
Vector<String8>& extensions,
KeyedVector<String8,time_t>& fileStore);
diff --git a/tools/aapt/IndentPrinter.h b/tools/aapt/IndentPrinter.h
index 6fc94bc..bd0edcb 100644
--- a/tools/aapt/IndentPrinter.h
+++ b/tools/aapt/IndentPrinter.h
@@ -3,7 +3,7 @@
class IndentPrinter {
public:
- IndentPrinter(FILE* stream, int indentSize=2)
+ explicit IndentPrinter(FILE* stream, int indentSize=2)
: mStream(stream)
, mIndentSize(indentSize)
, mIndent(0)
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index d05ae3c..b6f9aaf 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -394,7 +394,7 @@
const DefaultKeyedVector<String8, sp<AaptGroup> >& groups = dir->getFiles();
int N = groups.size();
for (int i=0; i<N; i++) {
- String8 leafName = groups.keyAt(i);
+ const String8& leafName = groups.keyAt(i);
const sp<AaptGroup>& group = groups.valueAt(i);
const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& files
@@ -417,7 +417,7 @@
set->add(leafName, group);
resources->add(resType, set);
} else {
- sp<ResourceTypeSet> set = resources->valueAt(index);
+ const sp<ResourceTypeSet>& set = resources->valueAt(index);
index = set->indexOfKey(leafName);
if (index < 0) {
if (kIsDebug) {
@@ -452,7 +452,7 @@
int N = dirs.size();
for (int i=0; i<N; i++) {
- sp<AaptDir> d = dirs.itemAt(i);
+ const sp<AaptDir>& d = dirs.itemAt(i);
if (kIsDebug) {
printf("Collecting dir #%d %p: %s, leaf %s\n", i, d.get(), d->getPath().string(),
d->getLeaf().string());
@@ -610,7 +610,7 @@
// get the overlay resources of the requested type
ssize_t index = overlayRes->indexOfKey(resTypeString);
if (index >= 0) {
- sp<ResourceTypeSet> overlaySet = overlayRes->valueAt(index);
+ const sp<ResourceTypeSet>& overlaySet = overlayRes->valueAt(index);
// for each of the resources, check for a match in the previously built
// non-overlay "baseset".
@@ -760,7 +760,7 @@
return addTagAttribute(node, ns8, attr8, value, errorOnFailedInsert, false);
}
-static void fullyQualifyClassName(const String8& package, sp<XMLNode> node,
+static void fullyQualifyClassName(const String8& package, const sp<XMLNode>& node,
const String16& attrName) {
XMLNode::attribute_entry* attr = node->editAttribute(
String16("http://schemas.android.com/apk/res/android"), attrName);
@@ -1339,7 +1339,7 @@
ResourceDirIterator it(resources->valueAt(index), String8("values"));
ssize_t res;
while ((res=it.next()) == NO_ERROR) {
- sp<AaptFile> file = it.getFile();
+ const sp<AaptFile>& file = it.getFile();
res = compileResourceFile(bundle, assets, file, it.getParams(),
(current!=assets), &table);
if (res != NO_ERROR) {
@@ -2674,7 +2674,7 @@
String8 dest(bundle->getRClassDir());
if (bundle->getMakePackageDirs()) {
- String8 pkg(package);
+ const String8& pkg(package);
const char* last = pkg.string();
const char* s = last-1;
do {
diff --git a/tools/aapt/ResourceFilter.h b/tools/aapt/ResourceFilter.h
index d6430c0..40d5b75 100644
--- a/tools/aapt/ResourceFilter.h
+++ b/tools/aapt/ResourceFilter.h
@@ -78,7 +78,7 @@
class StrongResourceFilter : public ResourceFilter {
public:
StrongResourceFilter() {}
- StrongResourceFilter(const std::set<ConfigDescription>& configs)
+ explicit StrongResourceFilter(const std::set<ConfigDescription>& configs)
: mConfigs(configs) {}
android::status_t parse(const android::String8& str);
@@ -106,7 +106,7 @@
*/
class InverseResourceFilter : public ResourceFilter {
public:
- InverseResourceFilter(const android::sp<ResourceFilter>& filter)
+ explicit InverseResourceFilter(const android::sp<ResourceFilter>& filter)
: mFilter(filter) {}
bool match(const android::ResTable_config& config) const {
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index d5a09d8..6601872 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -4023,7 +4023,7 @@
j = 0;
for (i=0; i<N; i++) {
- sp<ConfigList> e = origOrder.itemAt(i);
+ const sp<ConfigList>& e = origOrder.itemAt(i);
// There will always be enough room for the remaining entries.
while (mOrderedConfigs.itemAt(j) != NULL) {
j++;
@@ -4145,7 +4145,7 @@
size_t j=0;
for (i=0; i<N; i++) {
- sp<Type> t = origOrder.itemAt(i);
+ const sp<Type>& t = origOrder.itemAt(i);
// There will always be enough room for the remaining types.
while (mOrderedTypes.itemAt(j) != NULL) {
j++;
@@ -4577,7 +4577,7 @@
c->getEntries();
const size_t entryCount = entries.size();
for (size_t ei = 0; ei < entryCount; ei++) {
- sp<Entry> e = entries.valueAt(ei);
+ const sp<Entry>& e = entries.valueAt(ei);
if (e == NULL || e->getType() != Entry::TYPE_BAG) {
continue;
}
diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h
index 4b0d920..625b0bf 100644
--- a/tools/aapt/StringPool.h
+++ b/tools/aapt/StringPool.h
@@ -41,7 +41,7 @@
public:
struct entry {
entry() : offset(0) { }
- entry(const String16& _value) : value(_value), offset(0), hasStyles(false) { }
+ explicit entry(const String16& _value) : value(_value), offset(0), hasStyles(false) { }
entry(const entry& o) : value(o.value), offset(o.offset),
hasStyles(o.hasStyles), indices(o.indices),
configTypeName(o.configTypeName), configs(o.configs) { }
diff --git a/tools/aapt/WorkQueue.h b/tools/aapt/WorkQueue.h
index d38f05d..ab5f969 100644
--- a/tools/aapt/WorkQueue.h
+++ b/tools/aapt/WorkQueue.h
@@ -47,7 +47,7 @@
};
/* Creates a work queue with the specified maximum number of work threads. */
- WorkQueue(size_t maxThreads, bool canCallJava = true);
+ explicit WorkQueue(size_t maxThreads, bool canCallJava = true);
/* Destroys the work queue.
* Cancels pending work and waits for all remaining threads to complete.
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index dc08eb8..e87a05f 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -67,7 +67,7 @@
static const String16 RESOURCES_PRV_PREFIX(RESOURCES_ROOT_PRV_NAMESPACE);
static const String16 RESOURCES_TOOLS_NAMESPACE("http://schemas.android.com/tools");
-String16 getNamespaceResourcePackage(String16 appPackage, String16 namespaceUri, bool* outIsPublic)
+String16 getNamespaceResourcePackage(const String16& appPackage, const String16& namespaceUri, bool* outIsPublic)
{
//printf("%s starts with %s?\n", String8(namespaceUri).string(),
// String8(RESOURCES_PREFIX).string());
@@ -98,7 +98,7 @@
status_t hasSubstitutionErrors(const char* fileName,
ResXMLTree* inXml,
- String16 str16)
+ const String16& str16)
{
const char16_t* str = str16.string();
const char16_t* p = str;
diff --git a/tools/aapt/XMLNode.h b/tools/aapt/XMLNode.h
index b9e5cd5..d9d86ec 100644
--- a/tools/aapt/XMLNode.h
+++ b/tools/aapt/XMLNode.h
@@ -176,7 +176,7 @@
XMLNode(const String8& filename, const String16& s1, const String16& s2, bool isNamespace);
// Creating a CDATA node.
- XMLNode(const String8& filename);
+ explicit XMLNode(const String8& filename);
status_t collect_strings(StringPool* dest, Vector<uint32_t>* outResIds,
bool stripComments, bool stripRawValues) const;
diff --git a/tools/aapt/pseudolocalize.h b/tools/aapt/pseudolocalize.h
index 1faecd1..9bb1fd8 100644
--- a/tools/aapt/pseudolocalize.h
+++ b/tools/aapt/pseudolocalize.h
@@ -43,7 +43,7 @@
class Pseudolocalizer {
public:
- Pseudolocalizer(PseudolocalizationMethod m);
+ explicit Pseudolocalizer(PseudolocalizationMethod m);
~Pseudolocalizer() { if (mImpl) delete mImpl; }
void setMethod(PseudolocalizationMethod m);
String16 start() { return mImpl->start(); }
diff --git a/tools/aapt2/BigBuffer.h b/tools/aapt2/BigBuffer.h
index 8b6569c..b4b42b4 100644
--- a/tools/aapt2/BigBuffer.h
+++ b/tools/aapt2/BigBuffer.h
@@ -62,7 +62,7 @@
* Create a BigBuffer with block allocation sizes
* of blockSize.
*/
- BigBuffer(size_t blockSize);
+ explicit BigBuffer(size_t blockSize);
BigBuffer(const BigBuffer&) = delete; // No copying.
diff --git a/tools/aapt2/BindingXmlPullParser.h b/tools/aapt2/BindingXmlPullParser.h
index cfb16ef..b34c00b 100644
--- a/tools/aapt2/BindingXmlPullParser.h
+++ b/tools/aapt2/BindingXmlPullParser.h
@@ -27,7 +27,7 @@
class BindingXmlPullParser : public XmlPullParser {
public:
- BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
+ explicit BindingXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
BindingXmlPullParser(const BindingXmlPullParser& rhs) = delete;
Event getEvent() const override;
diff --git a/tools/aapt2/ConfigDescription.h b/tools/aapt2/ConfigDescription.h
index 67b4b75..1250ad2 100644
--- a/tools/aapt2/ConfigDescription.h
+++ b/tools/aapt2/ConfigDescription.h
@@ -46,7 +46,7 @@
static void applyVersionForCompatibility(ConfigDescription* config);
ConfigDescription();
- ConfigDescription(const android::ResTable_config& o);
+ ConfigDescription(const android::ResTable_config& o); // NOLINT(implicit)
ConfigDescription(const ConfigDescription& o);
ConfigDescription(ConfigDescription&& o);
diff --git a/tools/aapt2/Flag.cpp b/tools/aapt2/Flag.cpp
index 76985da..774c1ba 100644
--- a/tools/aapt2/Flag.cpp
+++ b/tools/aapt2/Flag.cpp
@@ -32,20 +32,20 @@
}
void optionalFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action) {
+ const std::function<void(const StringPiece&)>& action) {
sFlags.push_back(Flag{
name.toString(), description.toString(), wrap(action),
false, nullptr, false, false });
}
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action) {
+ const std::function<void(const StringPiece&)>& action) {
sFlags.push_back(Flag{ name.toString(), description.toString(), wrap(action),
true, nullptr, false, false });
}
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<bool(const StringPiece&, std::string*)> action) {
+ const std::function<bool(const StringPiece&, std::string*)>& action) {
sFlags.push_back(Flag{ name.toString(), description.toString(), action,
true, nullptr, false, false });
}
diff --git a/tools/aapt2/Flag.h b/tools/aapt2/Flag.h
index e863742..57aceb4 100644
--- a/tools/aapt2/Flag.h
+++ b/tools/aapt2/Flag.h
@@ -11,13 +11,13 @@
namespace flag {
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action);
+ const std::function<void(const StringPiece&)>& action);
void requiredFlag(const StringPiece& name, const StringPiece& description,
- std::function<bool(const StringPiece&, std::string*)> action);
+ const std::function<bool(const StringPiece&, std::string*)>& action);
void optionalFlag(const StringPiece& name, const StringPiece& description,
- std::function<void(const StringPiece&)> action);
+ const std::function<void(const StringPiece&)>& action);
void optionalSwitch(const StringPiece& name, const StringPiece& description, bool resultWhenSet,
bool* result);
diff --git a/tools/aapt2/JavaClassGenerator_test.cpp b/tools/aapt2/JavaClassGenerator_test.cpp
index b385ff4..3d1bf89 100644
--- a/tools/aapt2/JavaClassGenerator_test.cpp
+++ b/tools/aapt2/JavaClassGenerator_test.cpp
@@ -35,7 +35,7 @@
mTable->setPackageId(0x01);
}
- bool addResource(const ResourceNameRef& name, ResourceId id) {
+ bool addResource(const ResourceNameRef& name, const ResourceId& id) {
return mTable->addResource(name, id, {}, SourceLine{ "test.xml", 21 },
util::make_unique<Id>());
}
diff --git a/tools/aapt2/Logger.h b/tools/aapt2/Logger.h
index 1d437eb..27a79eb 100644
--- a/tools/aapt2/Logger.h
+++ b/tools/aapt2/Logger.h
@@ -56,7 +56,7 @@
class SourceLogger {
public:
- SourceLogger(const Source& source);
+ SourceLogger(const Source& source); // NOLINT(implicit)
std::ostream& error();
std::ostream& error(size_t line);
diff --git a/tools/aapt2/ManifestMerger.h b/tools/aapt2/ManifestMerger.h
index c6219db..9d34479 100644
--- a/tools/aapt2/ManifestMerger.h
+++ b/tools/aapt2/ManifestMerger.h
@@ -15,7 +15,7 @@
struct Options {
};
- ManifestMerger(const Options& options);
+ explicit ManifestMerger(const Options& options);
bool setAppManifest(const Source& source, const std::u16string& package,
std::unique_ptr<xml::Node> root);
diff --git a/tools/aapt2/ManifestParser.cpp b/tools/aapt2/ManifestParser.cpp
index b8f0a43..5b539c6 100644
--- a/tools/aapt2/ManifestParser.cpp
+++ b/tools/aapt2/ManifestParser.cpp
@@ -24,7 +24,7 @@
namespace aapt {
-bool ManifestParser::parse(const Source& source, std::shared_ptr<XmlPullParser> parser,
+bool ManifestParser::parse(const Source& source, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo) {
SourceLogger logger = { source };
@@ -70,7 +70,7 @@
return true;
}
-bool ManifestParser::parseManifest(SourceLogger& logger, std::shared_ptr<XmlPullParser> parser,
+bool ManifestParser::parseManifest(SourceLogger& logger, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo) {
auto attrIter = parser->findAttribute(u"", u"package");
if (attrIter == parser->endAttributes() || attrIter->value.empty()) {
diff --git a/tools/aapt2/ManifestParser.h b/tools/aapt2/ManifestParser.h
index f2e43d4..76201ab 100644
--- a/tools/aapt2/ManifestParser.h
+++ b/tools/aapt2/ManifestParser.h
@@ -33,10 +33,10 @@
ManifestParser() = default;
ManifestParser(const ManifestParser&) = delete;
- bool parse(const Source& source, std::shared_ptr<XmlPullParser> parser, AppInfo* outInfo);
+ bool parse(const Source& source, const std::shared_ptr<XmlPullParser>& parser, AppInfo* outInfo);
private:
- bool parseManifest(SourceLogger& logger, std::shared_ptr<XmlPullParser> parser,
+ bool parseManifest(SourceLogger& logger, const std::shared_ptr<XmlPullParser>& parser,
AppInfo* outInfo);
};
diff --git a/tools/aapt2/ManifestValidator.h b/tools/aapt2/ManifestValidator.h
index 3188784..ecbecde 100644
--- a/tools/aapt2/ManifestValidator.h
+++ b/tools/aapt2/ManifestValidator.h
@@ -28,7 +28,7 @@
class ManifestValidator {
public:
- ManifestValidator(const android::ResTable& table);
+ explicit ManifestValidator(const android::ResTable& table);
ManifestValidator(const ManifestValidator&) = delete;
bool validate(const Source& source, android::ResXMLParser* parser);
diff --git a/tools/aapt2/Maybe.h b/tools/aapt2/Maybe.h
index ff6625f..fe8e9a7 100644
--- a/tools/aapt2/Maybe.h
+++ b/tools/aapt2/Maybe.h
@@ -41,12 +41,12 @@
Maybe(const Maybe& rhs);
template <typename U>
- Maybe(const Maybe<U>& rhs);
+ Maybe(const Maybe<U>& rhs); // NOLINT(implicit)
Maybe(Maybe&& rhs);
template <typename U>
- Maybe(Maybe<U>&& rhs);
+ Maybe(Maybe<U>&& rhs); // NOLINT(implicit)
Maybe& operator=(const Maybe& rhs);
@@ -61,12 +61,12 @@
/**
* Construct a Maybe holding a value.
*/
- Maybe(const T& value);
+ Maybe(const T& value); // NOLINT(implicit)
/**
* Construct a Maybe holding a value.
*/
- Maybe(T&& value);
+ Maybe(T&& value); // NOLINT(implicit)
/**
* True if this holds a value, false if
diff --git a/tools/aapt2/Resource.h b/tools/aapt2/Resource.h
index fa9ac07..b948ea5 100644
--- a/tools/aapt2/Resource.h
+++ b/tools/aapt2/Resource.h
@@ -94,7 +94,7 @@
ResourceNameRef() = default;
ResourceNameRef(const ResourceNameRef&) = default;
ResourceNameRef(ResourceNameRef&&) = default;
- ResourceNameRef(const ResourceName& rhs);
+ ResourceNameRef(const ResourceName& rhs); // NOLINT(implicit)
ResourceNameRef(const StringPiece16& p, ResourceType t, const StringPiece16& e);
ResourceNameRef& operator=(const ResourceNameRef& rhs) = default;
ResourceNameRef& operator=(ResourceNameRef&& rhs) = default;
@@ -124,7 +124,7 @@
ResourceId();
ResourceId(const ResourceId& rhs);
- ResourceId(uint32_t resId);
+ ResourceId(uint32_t resId); // NOLINT(implicit)
ResourceId(size_t p, size_t t, size_t e);
bool isValid() const;
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 13f916b..ec7bfa5 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -391,7 +391,7 @@
std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& value, uint32_t typeMask,
- std::function<void(const ResourceName&)> onCreateReference) {
+ const std::function<void(const ResourceName&)>& onCreateReference) {
std::unique_ptr<BinaryPrimitive> nullOrEmpty = tryParseNullOrEmpty(value);
if (nullOrEmpty) {
return std::move(nullOrEmpty);
@@ -451,7 +451,7 @@
*/
std::unique_ptr<Item> ResourceParser::parseItemForAttribute(
const StringPiece16& str, const Attribute& attr,
- std::function<void(const ResourceName&)> onCreateReference) {
+ const std::function<void(const ResourceName&)>& onCreateReference) {
const uint32_t typeMask = attr.typeMask;
std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference);
if (value) {
diff --git a/tools/aapt2/ResourceParser.h b/tools/aapt2/ResourceParser.h
index 7618999..6fd58fa 100644
--- a/tools/aapt2/ResourceParser.h
+++ b/tools/aapt2/ResourceParser.h
@@ -133,11 +133,11 @@
*/
static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, const Attribute& attr,
- std::function<void(const ResourceName&)> onCreateReference = {});
+ const std::function<void(const ResourceName&)>& onCreateReference = {});
static std::unique_ptr<Item> parseItemForAttribute(
const StringPiece16& value, uint32_t typeMask,
- std::function<void(const ResourceName&)> onCreateReference = {});
+ const std::function<void(const ResourceName&)>& onCreateReference = {});
static uint32_t androidTypeToAttributeTypeMask(uint16_t type);
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index c93ecc7..eeec8da 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -151,7 +151,7 @@
return addResourceImpl(name, ResourceId{}, config, source, std::move(value), kValidNameChars);
}
-bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::addResource(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value) {
return addResourceImpl(name, resId, config, source, std::move(value), kValidNameChars);
@@ -165,7 +165,7 @@
kValidNameMangledChars);
}
-bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::addResourceImpl(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) {
@@ -255,17 +255,17 @@
return true;
}
-bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublic(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameChars);
}
-bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublicAllowMangled(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source) {
return markPublicImpl(name, resId, source, kValidNameMangledChars);
}
-bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
+bool ResourceTable::markPublicImpl(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source, const char16_t* validChars) {
if (!name.package.empty() && name.package != mPackage) {
Logger::error(source)
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 706f56a..e00fb3e 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -81,8 +81,8 @@
*/
std::vector<ResourceConfigValue> values;
- inline ResourceEntry(const StringPiece16& _name);
- inline ResourceEntry(const ResourceEntry* rhs);
+ inline explicit ResourceEntry(const StringPiece16& _name);
+ inline explicit ResourceEntry(const ResourceEntry* rhs);
};
/**
@@ -115,8 +115,8 @@
*/
std::vector<std::unique_ptr<ResourceEntry>> entries;
- ResourceTableType(const ResourceType _type);
- ResourceTableType(const ResourceTableType* rhs);
+ explicit ResourceTableType(const ResourceType _type);
+ explicit ResourceTableType(const ResourceTableType* rhs);
};
/**
@@ -151,12 +151,12 @@
bool addResourceAllowMangled(const ResourceNameRef& name, const ConfigDescription& config,
const SourceLine& source, std::unique_ptr<Value> value);
- bool addResource(const ResourceNameRef& name, const ResourceId resId,
+ bool addResource(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value);
- bool markPublic(const ResourceNameRef& name, const ResourceId resId, const SourceLine& source);
- bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId resId,
+ bool markPublic(const ResourceNameRef& name, const ResourceId& resId, const SourceLine& source);
+ bool markPublicAllowMangled(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source);
/*
@@ -186,10 +186,10 @@
std::unique_ptr<ResourceEntry>& findOrCreateEntry(std::unique_ptr<ResourceTableType>& type,
const StringPiece16& name);
- bool addResourceImpl(const ResourceNameRef& name, const ResourceId resId,
+ bool addResourceImpl(const ResourceNameRef& name, const ResourceId& resId,
const ConfigDescription& config, const SourceLine& source,
std::unique_ptr<Value> value, const char16_t* validChars);
- bool markPublicImpl(const ResourceNameRef& name, const ResourceId resId,
+ bool markPublicImpl(const ResourceNameRef& name, const ResourceId& resId,
const SourceLine& source, const char16_t* validChars);
std::u16string mPackage;
diff --git a/tools/aapt2/ResourceValues.h b/tools/aapt2/ResourceValues.h
index ef6594e..2635e34 100644
--- a/tools/aapt2/ResourceValues.h
+++ b/tools/aapt2/ResourceValues.h
@@ -128,8 +128,8 @@
bool privateReference = false;
Reference();
- Reference(const ResourceNameRef& n, Type type = Type::kResource);
- Reference(const ResourceId& i, Type type = Type::kResource);
+ Reference(const ResourceNameRef& n, Type type = Type::kResource); // NOLINT(implicit)
+ explicit Reference(const ResourceId& i, Type type = Type::kResource);
bool flatten(android::Res_value& outValue) const override;
Reference* clone(StringPool* newPool) const override;
@@ -154,7 +154,7 @@
struct RawString : public BaseItem<RawString> {
StringPool::Ref value;
- RawString(const StringPool::Ref& ref);
+ explicit RawString(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override;
RawString* clone(StringPool* newPool) const override;
@@ -164,7 +164,7 @@
struct String : public BaseItem<String> {
StringPool::Ref value;
- String(const StringPool::Ref& ref);
+ explicit String(const StringPool::Ref& ref);
bool flatten(android::Res_value& outValue) const override;
String* clone(StringPool* newPool) const override;
@@ -174,7 +174,7 @@
struct StyledString : public BaseItem<StyledString> {
StringPool::StyleRef value;
- StyledString(const StringPool::StyleRef& ref);
+ explicit StyledString(const StringPool::StyleRef& ref);
bool flatten(android::Res_value& outValue) const override;
StyledString* clone(StringPool* newPool) const override;
@@ -185,7 +185,7 @@
StringPool::Ref path;
FileReference() = default;
- FileReference(const StringPool::Ref& path);
+ explicit FileReference(const StringPool::Ref& path);
bool flatten(android::Res_value& outValue) const override;
FileReference* clone(StringPool* newPool) const override;
@@ -199,7 +199,7 @@
android::Res_value value;
BinaryPrimitive() = default;
- BinaryPrimitive(const android::Res_value& val);
+ explicit BinaryPrimitive(const android::Res_value& val);
bool flatten(android::Res_value& outValue) const override;
BinaryPrimitive* clone(StringPool* newPool) const override;
@@ -218,7 +218,7 @@
uint32_t maxInt;
std::vector<Symbol> symbols;
- Attribute(bool w, uint32_t t = 0u);
+ explicit Attribute(bool w, uint32_t t = 0u);
bool isWeak() const override;
virtual Attribute* clone(StringPool* newPool) const override;
@@ -388,7 +388,7 @@
struct ValueVisitorFunc : ValueVisitor {
TFunc func;
- ValueVisitorFunc(TFunc f) : func(f) {
+ explicit ValueVisitorFunc(TFunc f) : func(f) {
}
void visit(T& value, ValueVisitorArgs&) override {
@@ -403,7 +403,7 @@
struct ConstValueVisitorFunc : ConstValueVisitor {
TFunc func;
- ConstValueVisitorFunc(TFunc f) : func(f) {
+ explicit ConstValueVisitorFunc(TFunc f) : func(f) {
}
void visit(const T& value, ValueVisitorArgs&) override {
diff --git a/tools/aapt2/ScopedXmlPullParser.h b/tools/aapt2/ScopedXmlPullParser.h
index a040f60..5b6b321 100644
--- a/tools/aapt2/ScopedXmlPullParser.h
+++ b/tools/aapt2/ScopedXmlPullParser.h
@@ -47,7 +47,7 @@
*/
class ScopedXmlPullParser : public XmlPullParser {
public:
- ScopedXmlPullParser(XmlPullParser* parser);
+ explicit ScopedXmlPullParser(XmlPullParser* parser);
ScopedXmlPullParser(const ScopedXmlPullParser&) = delete;
ScopedXmlPullParser& operator=(const ScopedXmlPullParser&) = delete;
~ScopedXmlPullParser();
diff --git a/tools/aapt2/SdkConstants.cpp b/tools/aapt2/SdkConstants.cpp
index 9bdae49..cd75e98 100644
--- a/tools/aapt2/SdkConstants.cpp
+++ b/tools/aapt2/SdkConstants.cpp
@@ -48,7 +48,7 @@
return p.first < entryId;
}
-size_t findAttributeSdkLevel(ResourceId id) {
+size_t findAttributeSdkLevel(const ResourceId& id) {
if (id.packageId() != 0x01 && id.typeId() != 0x01) {
return 0;
}
diff --git a/tools/aapt2/SdkConstants.h b/tools/aapt2/SdkConstants.h
index 803da03..4a57828 100644
--- a/tools/aapt2/SdkConstants.h
+++ b/tools/aapt2/SdkConstants.h
@@ -44,7 +44,7 @@
SDK_LOLLIPOP_MR1 = 22,
};
-size_t findAttributeSdkLevel(ResourceId id);
+size_t findAttributeSdkLevel(const ResourceId& id);
size_t findAttributeSdkLevel(const ResourceName& name);
} // namespace aapt
diff --git a/tools/aapt2/SourceXmlPullParser.h b/tools/aapt2/SourceXmlPullParser.h
index d8ed459..66d54a8 100644
--- a/tools/aapt2/SourceXmlPullParser.h
+++ b/tools/aapt2/SourceXmlPullParser.h
@@ -30,7 +30,7 @@
class SourceXmlPullParser : public XmlPullParser {
public:
- SourceXmlPullParser(std::istream& in);
+ explicit SourceXmlPullParser(std::istream& in);
SourceXmlPullParser(const SourceXmlPullParser& rhs) = delete;
~SourceXmlPullParser();
diff --git a/tools/aapt2/StringPiece.h b/tools/aapt2/StringPiece.h
index e2a1597..2221e23 100644
--- a/tools/aapt2/StringPiece.h
+++ b/tools/aapt2/StringPiece.h
@@ -39,8 +39,8 @@
BasicStringPiece();
BasicStringPiece(const BasicStringPiece<TChar>& str);
- BasicStringPiece(const std::basic_string<TChar>& str);
- BasicStringPiece(const TChar* str);
+ BasicStringPiece(const std::basic_string<TChar>& str); // NOLINT(implicit)
+ BasicStringPiece(const TChar* str); // NOLINT(implicit)
BasicStringPiece(const TChar* str, size_t len);
BasicStringPiece<TChar>& operator=(const BasicStringPiece<TChar>& rhs);
diff --git a/tools/aapt2/StringPool.h b/tools/aapt2/StringPool.h
index 14304a6..610a553 100644
--- a/tools/aapt2/StringPool.h
+++ b/tools/aapt2/StringPool.h
@@ -65,7 +65,7 @@
private:
friend class StringPool;
- Ref(Entry* entry);
+ explicit Ref(Entry* entry);
Entry* mEntry;
};
@@ -88,7 +88,7 @@
private:
friend class StringPool;
- StyleRef(StyleEntry* entry);
+ explicit StyleRef(StyleEntry* entry);
StyleEntry* mEntry;
};
diff --git a/tools/aapt2/TableFlattener.h b/tools/aapt2/TableFlattener.h
index ccbb737..55914db 100644
--- a/tools/aapt2/TableFlattener.h
+++ b/tools/aapt2/TableFlattener.h
@@ -46,7 +46,7 @@
bool useExtendedChunks = true;
};
- TableFlattener(Options options);
+ explicit TableFlattener(Options options);
bool flatten(BigBuffer* out, const ResourceTable& table);
diff --git a/tools/aapt2/Util.h b/tools/aapt2/Util.h
index 9cdb152..b2b6d8e 100644
--- a/tools/aapt2/Util.h
+++ b/tools/aapt2/Util.h
@@ -311,7 +311,7 @@
* In the aapt namespace for lookup.
*/
inline ::std::ostream& operator<<(::std::ostream& out,
- ::std::function<::std::ostream&(::std::ostream&)> f) {
+ const ::std::function<::std::ostream&(::std::ostream&)>& f) {
return f(out);
}
diff --git a/tools/aapt2/XliffXmlPullParser.h b/tools/aapt2/XliffXmlPullParser.h
index 7791227..e89d8bb 100644
--- a/tools/aapt2/XliffXmlPullParser.h
+++ b/tools/aapt2/XliffXmlPullParser.h
@@ -30,7 +30,7 @@
*/
class XliffXmlPullParser : public XmlPullParser {
public:
- XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
+ explicit XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser);
XliffXmlPullParser(const XliffXmlPullParser& rhs) = delete;
Event getEvent() const override;
diff --git a/tools/aapt2/XmlDom.h b/tools/aapt2/XmlDom.h
index 035e7c4..105a074 100644
--- a/tools/aapt2/XmlDom.h
+++ b/tools/aapt2/XmlDom.h
@@ -52,7 +52,7 @@
std::u16string comment;
std::vector<std::unique_ptr<Node>> children;
- Node(NodeType type);
+ explicit Node(NodeType type);
void addChild(std::unique_ptr<Node> child);
virtual std::unique_ptr<Node> clone() const = 0;
virtual void accept(Visitor* visitor) = 0;
@@ -65,7 +65,7 @@
*/
template <typename Derived>
struct BaseNode : public Node {
- BaseNode(NodeType t);
+ explicit BaseNode(NodeType t);
virtual void accept(Visitor* visitor) override;
};
diff --git a/tools/split-select/SplitSelector.h b/tools/split-select/SplitSelector.h
index 193fda7..120354f 100644
--- a/tools/split-select/SplitSelector.h
+++ b/tools/split-select/SplitSelector.h
@@ -29,7 +29,7 @@
class SplitSelector {
public:
SplitSelector();
- SplitSelector(const android::Vector<SplitDescription>& splits);
+ explicit SplitSelector(const android::Vector<SplitDescription>& splits);
android::Vector<SplitDescription> getBestSplits(const SplitDescription& target) const;