Merge "system manifest: fix format"
diff --git a/Android.bp b/Android.bp
index 0f91348..fd750fa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -16,6 +16,7 @@
     name: "libhidl-defaults",
     cflags: [
         "-Wall",
+        "-Wdocumentation", // since some users use this
         "-Werror",
         "-Wextra-semi",
     ],
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 2d0dc25..43e84c0 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -997,12 +997,31 @@
             + details::toString(details::const_accessor<T, SIZE1, SIZE2, SIZES...>(a.data()));
 }
 
+namespace details {
+// Never instantiated. Used as a placeholder for template variables.
+template <typename T>
+struct hidl_invalid_type;
+
+// HIDL generates specializations of this for enums. See hidl_enum_range.
+template <typename T, typename = std::enable_if_t<std::is_enum<T>::value>>
+constexpr hidl_invalid_type<T> hidl_enum_values;
+}  // namespace details
+
 /**
- * Every HIDL generated enum generates an implementation of this function.
+ * Every HIDL generated enum supports this function.
  * E.x.: for(const auto v : hidl_enum_range<Enum>) { ... }
  */
 template <typename T, typename = std::enable_if_t<std::is_enum<T>::value>>
-struct hidl_enum_range;
+struct hidl_enum_range {
+    constexpr auto begin() const { return std::begin(details::hidl_enum_values<T>); }
+    constexpr auto cbegin() const { return begin(); }
+    constexpr auto rbegin() const { return std::rbegin(details::hidl_enum_values<T>); }
+    constexpr auto crbegin() const { return rbegin(); }
+    constexpr auto end() const { return std::end(details::hidl_enum_values<T>); }
+    constexpr auto cend() const { return end(); }
+    constexpr auto rend() const { return std::rend(details::hidl_enum_values<T>); }
+    constexpr auto crend() const { return rend(); }
+};
 
 template <typename T, typename = std::enable_if_t<std::is_enum<T>::value>>
 struct hidl_enum_iterator {
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 40a7ff5..e7bec41 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -238,9 +238,8 @@
     return gDefaultServiceManager;
 }
 
-std::vector<std::string> search(const std::string &path,
-                              const std::string &prefix,
-                              const std::string &suffix) {
+static std::vector<std::string> findFiles(const std::string& path, const std::string& prefix,
+                                          const std::string& suffix) {
     std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(path.c_str()), closedir);
     if (!dir) return {};
 
@@ -388,7 +387,7 @@
 #endif
 
         for (const std::string& path : paths) {
-            std::vector<std::string> libs = search(path, prefix, ".so");
+            std::vector<std::string> libs = findFiles(path, prefix, ".so");
 
             for (const std::string &lib : libs) {
                 const std::string fullPath = path + lib;
@@ -509,7 +508,7 @@
         for (const auto &pair : sAllPaths) {
             Arch arch = pair.first;
             for (const auto &path : pair.second) {
-                std::vector<std::string> libs = search(path, "", ".so");
+                std::vector<std::string> libs = findFiles(path, "", ".so");
                 for (const std::string &lib : libs) {
                     std::string matchedName;
                     std::string implName;
diff --git a/transport/current.txt b/transport/current.txt
index 3794dfe..322857a 100644
--- a/transport/current.txt
+++ b/transport/current.txt
@@ -21,6 +21,7 @@
 2e19301ceb87fb0696cd8268fab9c41f95d23c7392d35bc575daaa6eb32807eb android.hidl.memory.token@1.0::IMemoryToken
 
 # ABI preserving changes to HALs during Android Q
+85394f8a0d15e7fb2ee45c52d1fb8b8fd3c13c333e63c78c4aa1ff86840cf6dc android.hidl.manager@1.0::IServiceManager
 fcde1d0788066a62d5766f4dc19d4c1ec76967d5ddb636f59ccc66603460bcf8 android.hidl.manager@1.0::IServiceNotification
 
 # Clarification for b/67503915
diff --git a/transport/manager/1.0/IServiceManager.hal b/transport/manager/1.0/IServiceManager.hal
index 2b59a56..6eddefb 100644
--- a/transport/manager/1.0/IServiceManager.hal
+++ b/transport/manager/1.0/IServiceManager.hal
@@ -43,7 +43,7 @@
      * WARNING: This function is for libhidl/HwBinder use only. You are likely
      * looking for 'IMyInterface::getService("name")' instead.
      *
-     * @param iface    Fully-qualified interface name.
+     * @param fqName   Fully-qualified interface name.
      * @param name     Instance name. Same as in IServiceManager::add.
      *
      * @return service Handle to requested service, same as provided in
diff --git a/transport/manager/1.2/IServiceManager.hal b/transport/manager/1.2/IServiceManager.hal
index ae3fdfd..e1629d6 100644
--- a/transport/manager/1.2/IServiceManager.hal
+++ b/transport/manager/1.2/IServiceManager.hal
@@ -21,11 +21,6 @@
 import IClientCallback;
 
 interface IServiceManager extends @1.1::IServiceManager {
-    // TODO(b/66921961): additional functionality for the next release:
-    // - Better notifications (onRegistration will contain the interface)
-    // - Method to list interfaces in the manifest (for b/76108617, since if they are
-    //     lazy, they will no longer show up in listByInterface)
-
     /**
      * Adds a callback that must be called when the specified server has no clients.
      *
@@ -66,4 +61,16 @@
      * @return success Whether or not the service was registered.
      */
     addWithChain(string name, interface service, vec<string> chain) generates (bool success);
+
+    /**
+     * List all instances of a particular service from the manifest. Must be sorted. These HALs
+     * may not be started if they are lazy.
+     *
+     * See also @1.0::IServiceManager's listByInterface function.
+     *
+     * @param fqName         Fully-qualified interface name.
+     *
+     * @return instanceNames List of instance names running the particular service.
+     */
+    listManifestByInterface(string fqName) generates (vec<string> instanceNames);
 };