DO NOT MERGE - Merge pi-dev@5234907 into stage-aosp-master
Bug: 120848293
Change-Id: I4fea88387af1efa56dc29c688041ecc782b49f19
diff --git a/Android.bp b/Android.bp
index f31b444..6477ee9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15,4 +15,5 @@
subdirs = [
"bluetooth",
+ "recovery",
]
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 45cdcee..a7ed59e 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -29,7 +29,7 @@
TARGET_NO_BOOTLOADER := true
TARGET_NO_KERNEL := false
-TARGET_NO_RECOVERY := true
+TARGET_NO_RECOVERY ?= true
TARGET_HARDWARE_3D := true
BOARD_USES_GENERIC_AUDIO := true
USE_CAMERA_STUB := true
@@ -56,3 +56,6 @@
BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := squashfs
endif
endif
+
+TARGET_RECOVERY_PIXEL_FORMAT := BGRA_8888
+TARGET_RECOVERY_UI_LIB := librecovery_ui_hikey
diff --git a/fstab.ramdisk b/fstab.ramdisk
new file mode 100644
index 0000000..f64417e
--- /dev/null
+++ b/fstab.ramdisk
@@ -0,0 +1,2 @@
+/dev/block/by-name/system /system ext4 ro,errors=panic wait,first_stage_mount
+/dev/block/by-name/vendor /vendor ext4 ro,errors=panic wait,first_stage_mount
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index 360c777..0ba3dd8 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -6,14 +6,21 @@
TARGET_CPU_VARIANT := cortex-a53
TARGET_2ND_CPU_VARIANT := cortex-a53
-BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime
+BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime init=/init
+BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc/f723d000.dwmmc0
+BOARD_KERNEL_CMDLINE += console=ttyAMA3,115200 androidboot.console=ttyAMA3
-# Enable dtb fstab for treble, with verity and system-as-root
-# NOTE: Disabled by default until b/111829702 is fixed
+# On kernels before 4.19, enable dtb fstab with android-verity. On kernels >=
+# 4.19, both dtb fstab and android-verity are deprecated, so until we have
+# avb2 support in the bootloader, don't enable either feature. The ramdisk
+# fstab needed for the new mechanism will be installed unconditionally; if
+# dtb fstab is present, it will override it automatically.
+ifneq ($(TARGET_KERNEL_USE),4.19)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab_v2
-BOARD_KERNEL_CMDLINE += rootwait ro init=/init root=/dev/dm-0
+BOARD_KERNEL_CMDLINE += rootwait ro root=/dev/dm-0
BOARD_KERNEL_CMDLINE += dm=\"system none ro,0 1 android-verity 179:9\"
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+endif
ifneq ($(TARGET_SENSOR_MEZZANINE),)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
@@ -43,3 +50,5 @@
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_VENDORIMAGE_JOURNAL_SIZE := 0
BOARD_VENDORIMAGE_EXTFS_INODE_COUNT := 2048
+
+TARGET_RECOVERY_FSTAB := device/linaro/hikey/hikey/$(TARGET_FSTAB)
diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk
index f04561d..99fdb50 100644
--- a/hikey/device-hikey.mk
+++ b/hikey/device-hikey.mk
@@ -17,6 +17,7 @@
PRODUCT_COPY_FILES += $(TARGET_PREBUILT_KERNEL):kernel \
$(TARGET_PREBUILT_DTB):hi6220-hikey.dtb \
$(LOCAL_PATH)/$(TARGET_FSTAB):$(TARGET_COPY_OUT_VENDOR)/etc/fstab.hikey \
+ device/linaro/hikey/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.hikey \
device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.rc \
device/linaro/hikey/init.hikey.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.power.rc \
device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.usb.rc \
@@ -52,3 +53,8 @@
# Include mali blobs from ARM
PRODUCT_PACKAGES += libGLES_mali.so END_USER_LICENCE_AGREEMENT.txt
+
+ifneq ($(TARGET_NO_RECOVERY),true)
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/init.recovery.common.rc:recovery/root/init.recovery.hikey.rc
+endif
diff --git a/hikey960.mk b/hikey960.mk
index 7847ff9..232150b 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -1,5 +1,5 @@
ifndef TARGET_KERNEL_USE
-TARGET_KERNEL_USE=4.9
+TARGET_KERNEL_USE=4.14
endif
TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image.gz-dtb-hikey960-$(TARGET_KERNEL_USE)
TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi3660-hikey960.dtb-$(TARGET_KERNEL_USE)
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 9a1e437..d382d42 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -8,28 +8,36 @@
TARGET_NO_DTIMAGE := false
-BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960
-BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware loglevel=15 efi=noruntime
+BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 firmware_class.path=/vendor/firmware efi=noruntime init=/init
+BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc/ff3b0000.ufs
+BOARD_KERNEL_CMDLINE += loglevel=15
ifeq ($(TARGET_BUILTIN_EDID), true)
BOARD_KERNEL_CMDLINE += drm_kms_helper.edid_firmware=edid/1920x1080.bin
endif
+# On kernels before 4.19, enable dtb fstab. On kernels >= 4.19, both dtb
+# fstab and android-verity are deprecated, so until we have avb2 support
+# in the bootloader, don't enable either feature. The ramdisk fstab
+# needed for the new mechanism will be installed unconditionally; if dtb
+# fstab is present, it will override it automatically.
+ifneq ($(TARGET_KERNEL_USE),4.19)
+# Enable treble dtb fstab with verity
ifneq ($(TARGET_ANDROID_VERITY),)
-# Enable dtb fstab for treble, with verity and system-as-root
-# NOTE: Disabled by default until b/111829702 is fixed
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab_v2
-BOARD_KERNEL_CMDLINE += rootwait ro init=/init root=/dev/dm-0
+BOARD_KERNEL_CMDLINE += rootwait ro root=/dev/dm-0
BOARD_KERNEL_CMDLINE += dm=\"system none ro,0 1 android-verity 8:58\"
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
else
-# Enable dtb fstab for treble
+# Enable treble dtb fstab without verity
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
endif
+endif
ifneq ($(TARGET_SENSOR_MEZZANINE),)
BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
endif
+
BOARD_MKBOOTIMG_ARGS := --base 0x0 --tags_offset 0x07a00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 4915724288 # 4688MB
@@ -42,3 +50,5 @@
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_VENDORIMAGE_JOURNAL_SIZE := 0
BOARD_VENDORIMAGE_EXTFS_INODE_COUNT := 2048
+
+TARGET_RECOVERY_FSTAB := device/linaro/hikey/hikey960/fstab.hikey960
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index 814dd64..c1d697a 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -18,6 +18,7 @@
$(TARGET_PREBUILT_DTB):hi3660-hikey960.dtb
PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.hikey960:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.hikey960 \
+ device/linaro/hikey/fstab.ramdisk:$(TARGET_COPY_OUT_RAMDISK)/fstab.hikey960 \
device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.rc \
device/linaro/hikey/init.hikey960.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.power.rc \
device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.usb.rc \
@@ -87,3 +88,8 @@
$(warning https://dl.google.com/dl/android/aosp/hisilicon-hikey960-OPR-3c243263.tgz )
$(warning And extract in the ANDROID_TOP_DIR)
endif
+
+ifneq ($(TARGET_NO_RECOVERY),true)
+PRODUCT_COPY_FILES += \
+ device/linaro/hikey/init.recovery.common.rc:recovery/root/init.recovery.hikey960.rc
+endif
diff --git a/init.common.usb.rc b/init.common.usb.rc
index f198a8b..16054ba 100644
--- a/init.common.usb.rc
+++ b/init.common.usb.rc
@@ -3,6 +3,7 @@
mkdir /config/usb_gadget/g1 0770 shell shell
mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell
write /config/usb_gadget/g1/bcdUSB 0x0200
+ write /config/usb_gadget/g1/driver_match_existing_only 0
write /config/usb_gadget/g1/idVendor 0x18d1
write /config/usb_gadget/g1/bcdDevice 0x0223
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
diff --git a/init.recovery.common.rc b/init.recovery.common.rc
new file mode 100644
index 0000000..40245d7
--- /dev/null
+++ b/init.recovery.common.rc
@@ -0,0 +1,33 @@
+service console /system/bin/sh
+ class core
+ console
+ disabled
+ user root
+ group shell log readproc
+ seclabel u:r:shell:s0
+ setenv HOSTNAME console
+
+on property:ro.debuggable=1
+ start console
+
+on init
+ mount configfs none /config
+ mkdir /config/usb_gadget/g1 0770 shell shell
+ write /config/usb_gadget/g1/driver_match_existing_only 0
+ write /config/usb_gadget/g1/idVendor 0x18d1
+ write /config/usb_gadget/g1/idProduct 0xd001
+ mkdir /config/usb_gadget/g1/strings/0x409 0770
+ write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
+ write /config/usb_gadget/g1/strings/0x409/manufacturer "HISILICON"
+ write /config/usb_gadget/g1/strings/0x409/product "ADB Gadget"
+ mkdir /config/usb_gadget/g1/functions/ffs.adb
+ write /config/usb_gadget/g1/os_desc/use 1
+ symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
+ setprop sys.usb.configfs 1
+
+on property:sys.usb.ffs.ready=1
+ mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
+ symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
+ mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
+ write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
+ symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
diff --git a/mali/bifrost/Android.mk b/mali/bifrost/Android.mk
index a4f6ace..4ea05a7 100644
--- a/mali/bifrost/Android.mk
+++ b/mali/bifrost/Android.mk
@@ -19,6 +19,7 @@
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/
LOCAL_MULTILIB := both
+LOCAL_SHARED_LIBRARIES := android.hardware.graphics.common@1.0 libz libnativewindow libc++ liblog libm libc libdl
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
@@ -28,6 +29,9 @@
LOCAL_SRC_FILES_arm64 := lib64/$(LOCAL_MODULE)
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/
LOCAL_MULTILIB := 64
+# Bypass prebuilt ELF check because libLLVM is not a module (it is copied by
+# PRODUCT_COPY_FILES instead).
+LOCAL_CHECK_ELF_FILES := false
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
@@ -39,6 +43,7 @@
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/
LOCAL_MULTILIB := both
+LOCAL_SHARED_LIBRARIES := libRS_internal libRSCpuRef liblog libnativewindow libbcinfo libdl libc++ libc libm
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
@@ -61,6 +66,10 @@
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/hw
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/hw
LOCAL_MULTILIB := both
+LOCAL_SHARED_LIBRARIES := android.hardware.graphics.common@1.0 libz libnativewindow libc++ liblog libm libc libdl
+# Bypass prebuilt ELF check because the DT_SONAME "libGLES_mali.so" is
+# different from LOCAL_MODULE "vulkan.hikey960.so".
+LOCAL_CHECK_ELF_FILES := false
include $(BUILD_PREBUILT)
endif
diff --git a/mali/utgard/Android.mk b/mali/utgard/Android.mk
index 071cdd2..3e9ccec 100644
--- a/mali/utgard/Android.mk
+++ b/mali/utgard/Android.mk
@@ -8,6 +8,7 @@
LOCAL_SRC_FILES_arm := $(LOCAL_MODULE)
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)
LOCAL_MULTILIB := 32
+LOCAL_SHARED_LIBRARIES := libc++ libc libdl liblog libm
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
@@ -19,6 +20,7 @@
LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib/egl/
LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64/egl/
LOCAL_MULTILIB := both
+LOCAL_SHARED_LIBRARIES := libc++ libc libdl liblog libm
include $(BUILD_PREBUILT)
endif
diff --git a/recovery/Android.bp b/recovery/Android.bp
new file mode 100644
index 0000000..17dde5f
--- /dev/null
+++ b/recovery/Android.bp
@@ -0,0 +1,32 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library_static {
+ name: "librecovery_ui_hikey",
+ owner: "linaro",
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ "-pedantic",
+ ],
+ srcs: [
+ "recovery_ui.cpp",
+ ],
+ include_dirs: [
+ "bootable/recovery"
+ ],
+}
diff --git a/recovery/recovery_ui.cpp b/recovery/recovery_ui.cpp
new file mode 100644
index 0000000..d67ff5f
--- /dev/null
+++ b/recovery/recovery_ui.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <device.h>
+#include <screen_ui.h>
+
+namespace android {
+namespace device {
+namespace linaro {
+namespace hikey {
+
+class HikeyUI : public ::ScreenRecoveryUI
+{
+ RecoveryUI::KeyAction CheckKey(int key, bool is_long_press) {
+ // Recovery core can't tolerate using KEY_POWER as an alias for
+ // KEY_DOWN, and a reboot is always triggered. Remap any power
+ // key press to KEY_DOWN to allow us to use the power key as
+ // a regular key.
+ if (key == KEY_POWER && !is_long_press) {
+ RecoveryUI::EnqueueKey(KEY_DOWN);
+ return RecoveryUI::IGNORE;
+ }
+
+ return RecoveryUI::CheckKey(key, is_long_press);
+ }
+};
+
+} // namespace hikey
+} // namespace linaro
+} // namespace device
+} // namespace android
+
+Device *make_device()
+{
+ return new Device(new ::android::device::linaro::hikey::HikeyUI());
+}
diff --git a/sepolicy/recovery.te b/sepolicy/recovery.te
new file mode 100644
index 0000000..e4677fe
--- /dev/null
+++ b/sepolicy/recovery.te
@@ -0,0 +1 @@
+allow recovery gpu_device:chr_file rw_file_perms;
diff --git a/sepolicy/shell.te b/sepolicy/shell.te
new file mode 100644
index 0000000..3f17a5b
--- /dev/null
+++ b/sepolicy/shell.te
@@ -0,0 +1,4 @@
+recovery_only(`
+allow shell tmpfs:file r_file_perms;
+allow shell sysfs:file r_file_perms;
+')
diff --git a/wpan/uim/Android.mk b/wpan/uim/Android.mk
index 8150174..a7bd83c 100644
--- a/wpan/uim/Android.mk
+++ b/wpan/uim/Android.mk
@@ -7,8 +7,6 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH)/
-LOCAL_MODULE_TAGS := eng
-
LOCAL_MODULE := uim
LOCAL_PROPRIETARY_MODULE := true