From 2db6ff2c70c2d6e88ed8059f679bd9d264c65009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Mon, 10 May 2021 07:17:00 +0000 Subject: [PATCH 1/4] OMS: update shell command --help Include the 'fabricate' sub-command. Correct the instructions for how to limit 'dump' output to a given field. Bug: 189963636 Test: adb exec-out cmd overlay -h Change-Id: I154783ff6bb9c6c8a1377685aec770c7fe8ad178 --- .../server/om/OverlayManagerShellCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/om/OverlayManagerShellCommand.java b/services/core/java/com/android/server/om/OverlayManagerShellCommand.java index ba1bf933ca58..89939a31321f 100644 --- a/services/core/java/com/android/server/om/OverlayManagerShellCommand.java +++ b/services/core/java/com/android/server/om/OverlayManagerShellCommand.java @@ -35,12 +35,9 @@ import android.os.ShellCommand; import android.os.UserHandle; import android.util.TypedValue; -import com.android.internal.util.ArrayUtils; - import java.io.PrintWriter; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -103,9 +100,8 @@ final class OverlayManagerShellCommand extends ShellCommand { out.println(" Print debugging information about the overlay manager."); out.println(" With optional parameters PACKAGE and NAME, limit output to the specified"); out.println(" overlay or target. With optional parameter FIELD, limit output to"); - out.println(" the value of that SettingsItem field. Field names are"); - out.println(" case insensitive and out.println the m prefix can be omitted,"); - out.println(" so the following are equivalent: mState, mstate, State, state."); + out.println(" the corresponding SettingsItem field. Field names are all lower case"); + out.println(" and omit the m prefix, i.e. 'userid' for SettingsItem.mUserId."); out.println(" list [--user USER_ID] [PACKAGE[:NAME]]"); out.println(" Print information about target and overlay packages."); out.println(" Overlay packages are printed in priority order. With optional"); @@ -129,6 +125,11 @@ final class OverlayManagerShellCommand extends ShellCommand { out.println(" Load a package and print the value of a given resource"); out.println(" applying the current configuration and enabled overlays."); out.println(" For a more fine-grained alternative, use 'idmap2 lookup'."); + out.println(" fabricate [--user USER_ID] [--target-name OVERLAYABLE] --target PACKAGE"); + out.println(" --name NAME PACKAGE:TYPE/NAME ENCODED-TYPE-ID ENCODED-VALUE"); + out.println(" Create an overlay from a single resource. Caller must be root. Example:"); + out.println(" fabricate --target android --name LighterGray \\"); + out.println(" android:color/lighter_gray 0x1c 0xffeeeeee"); } private int runList() throws RemoteException { From a384fb763717ac0b841605b0b16b23784c09fc90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Mon, 10 May 2021 08:34:54 +0000 Subject: [PATCH 2/4] idmap2: create in-memory FRRO before creating file Re-order the serialization of an FRRO and creation of the backing file. This prevents a dangling (empty) file if the serialization fails. Bug: 189963636 Test: manual: cmd overlay fabricate , verify no file created in /data/resource-cache Change-Id: I1af88c6d2d1c3a881beecfb50ccaf541a249f39b --- cmds/idmap2/idmap2d/Idmap2Service.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 05336baf9217..4f775aa52195 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -262,17 +262,17 @@ Status Idmap2Service::createFabricatedOverlay( path.c_str(), uid)); } + const auto frro = builder.Build(); + if (!frro) { + return error(StringPrintf("failed to serialize '%s:%s': %s", overlay.packageName.c_str(), + overlay.overlayName.c_str(), frro.GetErrorMessage().c_str())); + } // Persist the fabricated overlay. umask(kIdmapFilePermissionMask); std::ofstream fout(path); if (fout.fail()) { return error("failed to open frro path " + path); } - const auto frro = builder.Build(); - if (!frro) { - return error(StringPrintf("failed to serialize '%s:%s': %s", overlay.packageName.c_str(), - overlay.overlayName.c_str(), frro.GetErrorMessage().c_str())); - } auto result = frro->ToBinaryStream(fout); if (!result) { unlink(path.c_str()); From 99ae898d3cc484de91bd8df6c93514c25f0b0dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Mon, 10 May 2021 11:00:17 +0000 Subject: [PATCH 3/4] OMS: include idmap data in dump Teach the overlay manager to ask the idmap service to pretty print the contents of each idmap file as part of OMS dump. This creates a single entry point for dumping both OMS and idmap data, and circumvents the problem of accessing the idmap service if it has been killed due to inactivity. Example idmap section: ---- 8< ---- IDMAP OF com.android.theme.color.sand Paths: target path : /system/framework/framework-res.apk overlay path : /product/overlay/AccentColorSand/AccentColorSandOverlay.apk Debug info: W failed to find resource 'string/accent_color_overlay' Mapping: 0x0106006e -> 0x7f010000 (color/accent_device_default_dark -> color/accent_device_default_dark) 0x01060070 -> 0x7f010001 (color/accent_device_default_light -> color/accent_device_default_light) ---- >8 ---- Bug: 189963636 Test: adb exec-out dumpsys Test: adb exec-out cmd overlay dump Test: adb exec-out cmd overlay dump Change-Id: I9de6ba646ad4714c9d0f0d8081fbf632577107e7 --- cmds/idmap2/idmap2d/Idmap2Service.cpp | 22 ++++++++++++ cmds/idmap2/idmap2d/Idmap2Service.h | 2 ++ .../aidl/services/android/os/IIdmap2.aidl | 3 +- .../com/android/server/om/IdmapDaemon.java | 10 ++++++ .../com/android/server/om/IdmapManager.java | 9 ++++- .../server/om/OverlayManagerServiceImpl.java | 34 ++++++++++++++++++- .../server/om/OverlayManagerSettings.java | 7 ++++ 7 files changed, 84 insertions(+), 3 deletions(-) diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 4f775aa52195..73a7240219af 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -33,6 +33,7 @@ #include "idmap2/BinaryStreamVisitor.h" #include "idmap2/FileUtils.h" #include "idmap2/Idmap.h" +#include "idmap2/PrettyPrintVisitor.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" @@ -45,6 +46,7 @@ using android::idmap2::FabricatedOverlayContainer; using android::idmap2::Idmap; using android::idmap2::IdmapHeader; using android::idmap2::OverlayResourceContainer; +using android::idmap2::PrettyPrintVisitor; using android::idmap2::TargetResourceContainer; using android::idmap2::utils::kIdmapCacheDir; using android::idmap2::utils::kIdmapFilePermissionMask; @@ -352,4 +354,24 @@ binder::Status Idmap2Service::deleteFabricatedOverlay(const std::string& overlay return ok(); } +binder::Status Idmap2Service::dumpIdmap(const std::string& overlay_path, + std::string* _aidl_return) { + assert(_aidl_return); + + const auto idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_path); + std::ifstream fin(idmap_path); + const auto idmap = Idmap::FromBinaryStream(fin); + fin.close(); + if (!idmap) { + return error(idmap.GetErrorMessage()); + } + + std::stringstream stream; + PrettyPrintVisitor visitor(stream); + (*idmap)->accept(&visitor); + *_aidl_return = stream.str(); + + return ok(); +} + } // namespace android::os diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h index 4d16ff39884b..40843f75a3ab 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.h +++ b/cmds/idmap2/idmap2d/Idmap2Service.h @@ -60,6 +60,8 @@ class Idmap2Service : public BinderService, public BnIdmap2 { binder::Status getFabricatedOverlayInfos( std::vector* _aidl_return) override; + binder::Status dumpIdmap(const std::string& overlay_path, std::string* _aidl_return) override; + private: // idmap2d is killed after a period of inactivity, so any information stored on this class should // be able to be recalculated if idmap2 dies and restarts. diff --git a/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl b/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl index 35bca98bcf69..48cee69ca779 100644 --- a/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl +++ b/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl @@ -16,8 +16,8 @@ package android.os; -import android.os.FabricatedOverlayInternal; import android.os.FabricatedOverlayInfo; +import android.os.FabricatedOverlayInternal; /** * @hide @@ -40,4 +40,5 @@ interface IIdmap2 { @nullable FabricatedOverlayInfo createFabricatedOverlay(in FabricatedOverlayInternal overlay); List getFabricatedOverlayInfos(); boolean deleteFabricatedOverlay(@utf8InCpp String path); + @utf8InCpp String dumpIdmap(@utf8InCpp String overlayApkPath); } diff --git a/services/core/java/com/android/server/om/IdmapDaemon.java b/services/core/java/com/android/server/om/IdmapDaemon.java index 2ebc8edb6740..f2b6b1d53988 100644 --- a/services/core/java/com/android/server/om/IdmapDaemon.java +++ b/services/core/java/com/android/server/om/IdmapDaemon.java @@ -170,6 +170,16 @@ class IdmapDaemon { } } + String dumpIdmap(@NonNull String overlayPath) { + try (Connection c = connect()) { + String dump = mService.dumpIdmap(overlayPath); + return TextUtils.nullIfEmpty(dump); + } catch (Exception e) { + Slog.wtf(TAG, "failed to dump idmap", e); + return null; + } + } + private IBinder getIdmapService() throws TimeoutException, RemoteException { SystemService.start(IDMAP_DAEMON); diff --git a/services/core/java/com/android/server/om/IdmapManager.java b/services/core/java/com/android/server/om/IdmapManager.java index 64362c9b1d69..157a1fc4d12c 100644 --- a/services/core/java/com/android/server/om/IdmapManager.java +++ b/services/core/java/com/android/server/om/IdmapManager.java @@ -22,7 +22,6 @@ import static com.android.server.om.OverlayManagerService.TAG; import android.annotation.NonNull; import android.content.om.OverlayInfo; import android.content.om.OverlayableInfo; -import android.content.pm.PackageParser; import android.os.Build.VERSION_CODES; import android.os.FabricatedOverlayInfo; import android.os.FabricatedOverlayInternal; @@ -141,6 +140,14 @@ final class IdmapManager { return mIdmapDaemon.deleteFabricatedOverlay(path); } + /** + * Gets the idmap data associated with an overlay, in dump format. + * Only indented for debugging. + */ + String dumpIdmap(@NonNull String overlayPath) { + return mIdmapDaemon.dumpIdmap(overlayPath); + } + /** * Checks if overlayable and policies should be enforced on the specified overlay for backwards * compatibility with pre-Q overlays. diff --git a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java index 799ab4633b2a..e4ca5b6d04bb 100644 --- a/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java +++ b/services/core/java/com/android/server/om/OverlayManagerServiceImpl.java @@ -22,6 +22,7 @@ import static android.content.om.OverlayInfo.STATE_MISSING_TARGET; import static android.content.om.OverlayInfo.STATE_NO_IDMAP; import static android.content.om.OverlayInfo.STATE_OVERLAY_IS_BEING_REPLACED; import static android.content.om.OverlayInfo.STATE_TARGET_IS_BEING_REPLACED; +import static android.os.UserHandle.USER_SYSTEM; import static com.android.server.om.OverlayManagerService.DEBUG; import static com.android.server.om.OverlayManagerService.TAG; @@ -38,6 +39,7 @@ import android.os.FabricatedOverlayInternal; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.Pair; import android.util.Slog; import com.android.internal.content.om.OverlayConfig; @@ -682,8 +684,38 @@ final class OverlayManagerServiceImpl { } void dump(@NonNull final PrintWriter pw, @NonNull DumpState dumpState) { + Pair overlayIdmap = null; + if (dumpState.getPackageName() != null) { + OverlayIdentifier id = new OverlayIdentifier(dumpState.getPackageName(), + dumpState.getOverlayName()); + OverlayInfo oi = mSettings.getNullableOverlayInfo(id, USER_SYSTEM); + if (oi != null) { + overlayIdmap = new Pair<>(id, oi.baseCodePath); + } + } + + // settings mSettings.dump(pw, dumpState); - if (dumpState.getPackageName() == null) { + + // idmap data + if (dumpState.getField() == null) { + Set> allIdmaps = (overlayIdmap != null) + ? Set.of(overlayIdmap) : mSettings.getAllIdentifiersAndBaseCodePaths(); + for (Pair pair : allIdmaps) { + pw.println("IDMAP OF " + pair.first); + String dump = mIdmapManager.dumpIdmap(pair.second); + if (dump != null) { + pw.println(dump); + } else { + OverlayInfo oi = mSettings.getNullableOverlayInfo(pair.first, USER_SYSTEM); + pw.println((oi != null && !mIdmapManager.idmapExists(oi)) + ? "" : ""); + } + } + } + + // default overlays + if (overlayIdmap == null) { pw.println("Default overlays: " + TextUtils.join(";", mDefaultOverlays)); } } diff --git a/services/core/java/com/android/server/om/OverlayManagerSettings.java b/services/core/java/com/android/server/om/OverlayManagerSettings.java index e3e090663a89..55bca1733d37 100644 --- a/services/core/java/com/android/server/om/OverlayManagerSettings.java +++ b/services/core/java/com/android/server/om/OverlayManagerSettings.java @@ -26,6 +26,7 @@ import android.content.om.OverlayInfo; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.Pair; import android.util.Slog; import android.util.TypedXmlPullParser; import android.util.TypedXmlSerializer; @@ -205,6 +206,12 @@ final class OverlayManagerSettings { return paths; } + Set> getAllIdentifiersAndBaseCodePaths() { + final Set> set = new ArraySet<>(); + mItems.forEach(item -> set.add(new Pair(item.mOverlay, item.mBaseCodePath))); + return set; + } + @NonNull List removeIf(@NonNull final Predicate predicate, final int userId) { return removeIf(info -> (predicate.test(info) && info.userId == userId)); From 1195a6bd465872639c9a7b83518affc1b1fcf485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Tue, 11 May 2021 12:57:01 +0000 Subject: [PATCH 4/4] idmap2: fix cpplint warnings Bug: 189963636 Test: frameworks/base/cmds/idmap2/static-checks.sh Change-Id: I6da18cdbbd2fc33db711696445230a9f316dc143 --- cmds/idmap2/CPPLINT.cfg | 2 +- cmds/idmap2/idmap2/CommandUtils.cpp | 1 + cmds/idmap2/idmap2/CommandUtils.h | 8 +++++--- cmds/idmap2/idmap2/Create.cpp | 1 + cmds/idmap2/idmap2d/Idmap2Service.cpp | 2 ++ cmds/idmap2/idmap2d/Idmap2Service.h | 2 ++ cmds/idmap2/include/idmap2/FabricatedOverlay.h | 11 +++++++---- cmds/idmap2/include/idmap2/ResourceContainer.h | 7 ++++--- cmds/idmap2/libidmap2/FabricatedOverlay.cpp | 12 ++++++++---- cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp | 1 + cmds/idmap2/libidmap2/RawPrintVisitor.cpp | 2 ++ cmds/idmap2/libidmap2/ResourceContainer.cpp | 7 ++++++- cmds/idmap2/libidmap2/ResourceUtils.cpp | 1 + cmds/idmap2/tests/FabricatedOverlayTests.cpp | 3 ++- cmds/idmap2/tests/IdmapTests.cpp | 4 ++-- cmds/idmap2/tests/R.h | 4 ++-- 16 files changed, 47 insertions(+), 21 deletions(-) diff --git a/cmds/idmap2/CPPLINT.cfg b/cmds/idmap2/CPPLINT.cfg index 20ed43c2a76a..eada694095d6 100644 --- a/cmds/idmap2/CPPLINT.cfg +++ b/cmds/idmap2/CPPLINT.cfg @@ -15,4 +15,4 @@ set noparent linelength=100 root=.. -filter=+build/include_alpha,-runtime/references,-build/c++ +filter=+build/include_alpha,-runtime/references,-build/c++,-build/include_alpha diff --git a/cmds/idmap2/idmap2/CommandUtils.cpp b/cmds/idmap2/idmap2/CommandUtils.cpp index bf30a76d581a..63235ff7d199 100644 --- a/cmds/idmap2/idmap2/CommandUtils.cpp +++ b/cmds/idmap2/idmap2/CommandUtils.cpp @@ -19,6 +19,7 @@ #include #include +#include "idmap2/CommandUtils.h" #include "idmap2/Idmap.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" diff --git a/cmds/idmap2/idmap2/CommandUtils.h b/cmds/idmap2/idmap2/CommandUtils.h index e06896784d6a..341fec84ce9a 100644 --- a/cmds/idmap2/idmap2/CommandUtils.h +++ b/cmds/idmap2/idmap2/CommandUtils.h @@ -14,8 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_ -#define IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#ifndef IDMAP2_IDMAP2_COMMANDUTILS_H_ +#define IDMAP2_IDMAP2_COMMANDUTILS_H_ + +#include #include "idmap2/PolicyUtils.h" #include "idmap2/Result.h" @@ -24,4 +26,4 @@ android::idmap2::Result Verify( const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, const std::string& overlay_name, PolicyBitmask fulfilled_policies, bool enforce_overlayable); -#endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#endif // IDMAP2_IDMAP2_COMMANDUTILS_H_ diff --git a/cmds/idmap2/idmap2/Create.cpp b/cmds/idmap2/idmap2/Create.cpp index 977a0bbadafb..d5f1b895facf 100644 --- a/cmds/idmap2/idmap2/Create.cpp +++ b/cmds/idmap2/idmap2/Create.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "androidfw/ResourceTypes.h" diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 73a7240219af..2cfbac3f2c26 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h index 40843f75a3ab..c16c3c52155f 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.h +++ b/cmds/idmap2/idmap2d/Idmap2Service.h @@ -24,7 +24,9 @@ #include #include +#include #include +#include namespace android::os { diff --git a/cmds/idmap2/include/idmap2/FabricatedOverlay.h b/cmds/idmap2/include/idmap2/FabricatedOverlay.h index be687d98081e..375671881e5f 100644 --- a/cmds/idmap2/include/idmap2/FabricatedOverlay.h +++ b/cmds/idmap2/include/idmap2/FabricatedOverlay.h @@ -14,15 +14,17 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H -#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ +#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ #include #include #include #include +#include #include +#include #include "idmap2/ResourceContainer.h" #include "idmap2/Result.h" @@ -68,7 +70,8 @@ struct FabricatedOverlay { Result InitializeData() const; Result GetCrc() const; - FabricatedOverlay(pb::FabricatedOverlay&& overlay, std::optional crc_from_disk = {}); + explicit FabricatedOverlay(pb::FabricatedOverlay&& overlay, + std::optional crc_from_disk = {}); pb::FabricatedOverlay overlay_pb_; std::optional crc_from_disk_; @@ -102,4 +105,4 @@ struct FabricatedOverlayContainer : public OverlayResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ diff --git a/cmds/idmap2/include/idmap2/ResourceContainer.h b/cmds/idmap2/include/idmap2/ResourceContainer.h index 74a6f5666c2a..c3ba4640bd77 100644 --- a/cmds/idmap2/include/idmap2/ResourceContainer.h +++ b/cmds/idmap2/include/idmap2/ResourceContainer.h @@ -14,9 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H -#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#include #include #include #include @@ -103,4 +104,4 @@ struct OverlayResourceContainer : public ResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ diff --git a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp index 4f61801aa594..8352dbb7b619 100644 --- a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp +++ b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp @@ -23,6 +23,10 @@ #include #include +#include +#include +#include +#include namespace android::idmap2 { @@ -89,7 +93,7 @@ Result FabricatedOverlay::Builder::Build() { auto package = entries.find(package_name); if (package == entries.end()) { package = entries - .insert(std::make_pair<>( + .insert(std::make_pair( package_name, std::map>())) .first; } @@ -98,13 +102,13 @@ Result FabricatedOverlay::Builder::Build() { if (type == package->second.end()) { type = package->second - .insert(std::make_pair<>(type_name.to_string(), std::map())) + .insert(std::make_pair(type_name.to_string(), std::map())) .first; } auto entry = type->second.find(entry_name.to_string()); if (entry == type->second.end()) { - entry = type->second.insert(std::make_pair<>(entry_name.to_string(), TargetValue())).first; + entry = type->second.insert(std::make_pair(entry_name.to_string(), TargetValue())).first; } entry->second = TargetValue{res_entry.data_type, res_entry.data_value}; @@ -299,4 +303,4 @@ Result FabContainer::GetResourceName(ResourceId /* id */) const { return Error("Fabricated overlay does not contain resources."); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp index 721612cc567b..d10a2785aaba 100644 --- a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp index a016a36a2e3d..779538c617f4 100644 --- a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp @@ -18,6 +18,8 @@ #include #include +#include +#include #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/ResourceContainer.cpp b/cmds/idmap2/libidmap2/ResourceContainer.cpp index 9147ccaaa17a..d11334d21ccd 100644 --- a/cmds/idmap2/libidmap2/ResourceContainer.cpp +++ b/cmds/idmap2/libidmap2/ResourceContainer.cpp @@ -16,6 +16,11 @@ #include "idmap2/ResourceContainer.h" +#include +#include +#include +#include + #include "androidfw/ApkAssets.h" #include "androidfw/AssetManager.h" #include "androidfw/Util.h" @@ -445,4 +450,4 @@ Result> OverlayResourceContainer::From return std::unique_ptr(result->release()); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/ResourceUtils.cpp b/cmds/idmap2/libidmap2/ResourceUtils.cpp index e809bf1f4b02..32c04d2a6cab 100644 --- a/cmds/idmap2/libidmap2/ResourceUtils.cpp +++ b/cmds/idmap2/libidmap2/ResourceUtils.cpp @@ -17,6 +17,7 @@ #include "idmap2/ResourceUtils.h" #include +#include #include "androidfw/StringPiece.h" #include "androidfw/Util.h" diff --git a/cmds/idmap2/tests/FabricatedOverlayTests.cpp b/cmds/idmap2/tests/FabricatedOverlayTests.cpp index 79ab2438af74..468ea0c634c1 100644 --- a/cmds/idmap2/tests/FabricatedOverlayTests.cpp +++ b/cmds/idmap2/tests/FabricatedOverlayTests.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace android::idmap2 { @@ -135,4 +136,4 @@ TEST(FabricatedOverlayTests, SerializeAndDeserialize) { EXPECT_EQ(Res_value::TYPE_INT_DEC, entry->data_type); } -} // namespace android::idmap2 \ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp index 9516ff83d718..9c6402a6e36e 100644 --- a/cmds/idmap2/tests/IdmapTests.cpp +++ b/cmds/idmap2/tests/IdmapTests.cpp @@ -83,7 +83,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentVersion) { std::stringstream stream; stream << android::kIdmapMagic; stream << 0xffffffffU; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } @@ -92,7 +92,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentMagic) { std::stringstream stream; stream << 0xffffffffU; stream << android::kIdmapCurrentVersion; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } diff --git a/cmds/idmap2/tests/R.h b/cmds/idmap2/tests/R.h index ac9b0580d2d9..89219c9c8213 100644 --- a/cmds/idmap2/tests/R.h +++ b/cmds/idmap2/tests/R.h @@ -66,8 +66,8 @@ namespace R::overlay { constexpr ResourceId str1 = 0x7f02000b; constexpr ResourceId str3 = 0x7f02000c; constexpr ResourceId str4 = 0x7f02000d; - } -} + } // namespace string +} // namespace R::overlay // clang-format on } // namespace android::idmap2