From 2e6743176a385a94d42f40ad8b3ee5bc74308dad Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 29 May 2018 13:56:37 +0900 Subject: [PATCH 1/2] Recovery partition has same layout as system Recovery partition has same layout as system. In other words, executables are installed to /system/bin and libs are installed to ../system/lib. This is made possible because the recovery partition is now self-contained, i.e., shell, adbd, etc. are hosted in the recovery partition and thus we no longer has to mount the real system.img to /system. So /system is now available to executables built for recovery mode. Bug: 63673171 Test: `adb reboot recovery; adb devices` shows the device ID Test: Select 'mount /system' in the recovery mode, then `adb shell`. $ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from the /lib directory. Change-Id: I6c4f903ad21fd3dd10a07c4588be85d3d678c099 --- android/paths.go | 3 ++- cc/binary.go | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/android/paths.go b/android/paths.go index 8cc31826b..af2f9567a 100644 --- a/android/paths.go +++ b/android/paths.go @@ -950,7 +950,8 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string if ctx.InstallInData() { partition = "data" } else if ctx.InstallInRecovery() { - partition = "recovery/root" + // the layout of recovery partion is the same as that of system partition + partition = "recovery/root/system" } else if ctx.SocSpecific() { partition = ctx.DeviceConfig().VendorPath() } else if ctx.DeviceSpecific() { diff --git a/cc/binary.go b/cc/binary.go index 04b912a69..4a6eb9313 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -357,11 +357,6 @@ func (binary *binaryDecorator) link(ctx ModuleContext, } func (binary *binaryDecorator) install(ctx ModuleContext, file android.Path) { - // /bin is a symlink to /system/bin. Recovery binaries are all in /sbin. - if ctx.inRecovery() { - binary.baseInstaller.dir = "sbin" - } - binary.baseInstaller.install(ctx, file) for _, symlink := range binary.Properties.Symlinks { binary.symlinks = append(binary.symlinks, From d54aee574d525e8ab8581cafdc54fcdcb55477b1 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Sat, 9 Jun 2018 01:32:54 +0900 Subject: [PATCH 2/2] Recovery variants are built with -D__ANDROID_RECOVERY__ Recovery variant of a module is now by default built with -D__ANDROID_RECOVERY__, thus eliminating the need to define a custom macro to conditionally compile the module for the recovery mode. (Of course, they can define their own macro if needed) Bug: 63673171 Test: m -j Change-Id: I1d1b990329793472b93c2f56080e72d690eef9ec --- cc/compiler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index 10cec8cea..8d034c9e0 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -332,6 +332,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps "-D__ANDROID_API__="+version, "-D__ANDROID_VNDK__") } + if ctx.inRecovery() { + flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_RECOVERY__") + } + instructionSet := String(compiler.Properties.Instruction_set) if flags.RequiredInstructionSet != "" { instructionSet = flags.RequiredInstructionSet