mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 07:57:39 +00:00
Enable avd hack for debug build
This commit is contained in:
parent
83d837d868
commit
68c2817d40
@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
using kv_pairs = std::vector<std::pair<std::string, std::string>>;
|
using kv_pairs = std::vector<std::pair<std::string, std::string>>;
|
||||||
|
|
||||||
// For API 28 AVD, it uses legacy SAR setup that requires
|
|
||||||
// special hacks in magiskinit to work properly. We do not
|
|
||||||
// necessarily want this enabled in production builds.
|
|
||||||
#define ENABLE_AVD_HACK 0
|
|
||||||
|
|
||||||
struct BootConfig {
|
struct BootConfig {
|
||||||
bool skip_initramfs;
|
bool skip_initramfs;
|
||||||
bool force_normal_boot;
|
bool force_normal_boot;
|
||||||
@ -64,12 +59,9 @@ private:
|
|||||||
bool hijack_sepolicy();
|
bool hijack_sepolicy();
|
||||||
void setup_tmp(const char *path);
|
void setup_tmp(const char *path);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
#if ENABLE_AVD_HACK
|
|
||||||
// When this boolean is set, this means we are currently
|
// When this boolean is set, this means we are currently
|
||||||
// running magiskinit on legacy SAR AVD emulator
|
// running magiskinit on legacy SAR AVD emulator
|
||||||
bool avd_hack = false;
|
bool avd_hack = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
void patch_rw_root();
|
void patch_rw_root();
|
||||||
void patch_ro_root();
|
void patch_ro_root();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
#include <base.hpp>
|
#include <base.hpp>
|
||||||
|
#include <flags.h>
|
||||||
#include <selinux.hpp>
|
#include <selinux.hpp>
|
||||||
#include <magisk.hpp>
|
#include <magisk.hpp>
|
||||||
|
|
||||||
@ -219,17 +220,18 @@ mount_root:
|
|||||||
bool is_two_stage = access("/apex", F_OK) == 0;
|
bool is_two_stage = access("/apex", F_OK) == 0;
|
||||||
LOGD("is_two_stage: [%d]\n", is_two_stage);
|
LOGD("is_two_stage: [%d]\n", is_two_stage);
|
||||||
|
|
||||||
#if ENABLE_AVD_HACK
|
#if MAGISK_DEBUG
|
||||||
if (!is_two_stage) {
|
// For API 28 AVD, it uses legacy SAR setup that requires
|
||||||
if (config->emulator) {
|
// special hacks in magiskinit to work properly. We do not
|
||||||
avd_hack = true;
|
// necessarily want this enabled in production builds.
|
||||||
// These values are hardcoded for API 28 AVD
|
if (!is_two_stage && config->emulator) {
|
||||||
xmkdir("/dev/block", 0755);
|
avd_hack = true;
|
||||||
strcpy(blk_info.block_dev, "/dev/block/vde1");
|
// These values are hardcoded for API 28 AVD
|
||||||
strcpy(blk_info.partname, "vendor");
|
xmkdir("/dev/block", 0755);
|
||||||
setup_block();
|
strcpy(blk_info.block_dev, "/dev/block/vde1");
|
||||||
xmount(blk_info.block_dev, "/vendor", "ext4", MS_RDONLY, nullptr);
|
strcpy(blk_info.partname, "vendor");
|
||||||
}
|
setup_block();
|
||||||
|
xmount(blk_info.block_dev, "/vendor", "ext4", MS_RDONLY, nullptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -244,7 +244,6 @@ void MagiskInit::patch_ro_root() {
|
|||||||
|
|
||||||
xrename("overlay.d", ROOTOVL);
|
xrename("overlay.d", ROOTOVL);
|
||||||
|
|
||||||
#if ENABLE_AVD_HACK
|
|
||||||
// Handle avd hack
|
// Handle avd hack
|
||||||
if (avd_hack) {
|
if (avd_hack) {
|
||||||
int src = xopen("/init", O_RDONLY | O_CLOEXEC);
|
int src = xopen("/init", O_RDONLY | O_CLOEXEC);
|
||||||
@ -257,7 +256,6 @@ void MagiskInit::patch_ro_root() {
|
|||||||
close(src);
|
close(src);
|
||||||
close(dest);
|
close(dest);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
load_overlay_rc(ROOTOVL);
|
load_overlay_rc(ROOTOVL);
|
||||||
if (access(ROOTOVL "/sbin", F_OK) == 0) {
|
if (access(ROOTOVL "/sbin", F_OK) == 0) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# AVD Magisk Setup
|
# AVD Magisk Setup
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# AVD MagiskInit Setup
|
# AVD MagiskInit Setup
|
||||||
#####################################################################
|
#####################################################################
|
||||||
@ -13,10 +12,6 @@
|
|||||||
# After patching ramdisk.img, close the emulator, then select
|
# After patching ramdisk.img, close the emulator, then select
|
||||||
# "Cold Boot Now" in AVD Manager to force a full reboot.
|
# "Cold Boot Now" in AVD Manager to force a full reboot.
|
||||||
#
|
#
|
||||||
# P.S. If running against the API 28 image, modify init.hpp and set
|
|
||||||
# ENABLE_AVD_HACK to 1 to enable special hacks designed specifically
|
|
||||||
# for this use case.
|
|
||||||
#
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# AVD Init Configurations:
|
# AVD Init Configurations:
|
||||||
#
|
#
|
||||||
|
@ -92,11 +92,6 @@ export -f wait_for_boot
|
|||||||
|
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
if grep -q 'ENABLE_AVD_HACK 0' native/src/init/init.hpp; then
|
|
||||||
echo -e '\n\033[41m! Please patch init.hpp\033[0m\n'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $(uname -m) in
|
case $(uname -m) in
|
||||||
'arm64'|'aarch64')
|
'arm64'|'aarch64')
|
||||||
arch=arm64-v8a
|
arch=arm64-v8a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user