summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--Android.mk20
-rw-r--r--alarm/alarm_blacklist.txt8
-rw-r--r--alarm/alarm_whitelist.txt5
-rw-r--r--android.software.google_atv.xml11
-rw-r--r--android.software.input_methods.xml4
-rw-r--r--android.software.leanback.xml18
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_in_bottom.xml25
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_in_top.xml25
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_out_bottom.xml25
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_out_top.xml25
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_wallpaper_enter.xml24
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/anim/atv_wallpaper_exit.xml24
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png3
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/drawable/progress_volume.xml41
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/layout/volume_adjust.xml49
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/layout/volume_adjust_item.xml44
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/values-sw600dp/dimens.xml22
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/values/config.xml65
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/values/dimens.xml31
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/values/styles.xml54
-rw-r--r--aosp_gms_overlay/frameworks/base/core/res/res/xml/global_keys.xml36
-rw-r--r--aosp_gms_overlay/frameworks/base/packages/SettingsLib/res/layout-television/settings_with_drawer.xml46
-rw-r--r--aosp_gms_overlay/packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_device.xml36
-rw-r--r--aosp_gms_overlay/packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_profile.xml26
-rw-r--r--aosp_gms_overlay/packages/apps/Provision/AndroidManifest.xml39
-rw-r--r--aosp_gms_overlay/vendor/amlogic/apps/MboxLauncher2/AndroidManifest.xml40
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_in_bottom.xml25
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_in_top.xml25
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_out_bottom.xml25
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_fade_out_top.xml25
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_wallpaper_enter.xml24
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/anim/atv_wallpaper_exit.xml24
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.png4
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/drawable/progress_volume.xml41
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/layout/volume_adjust.xml49
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/layout/volume_adjust_item.xml44
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values-sw600dp/dimens.xml22
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values-television/config.xml27
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values-television/dimens.xml24
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values-television/themes.xml30
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values/config.xml105
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values/dimens.xml31
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/values/styles.xml54
-rw-r--r--atv_gms_overlay/frameworks/base/core/res/res/xml/global_keys.xml36
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SettingsLib/res/layout-television/settings_with_drawer.xml46
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml34
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SystemUI/res/drawable-hdpi/recents_tv_bg_default.png6015
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SystemUI/res/drawable-mdpi/recents_tv_bg_default.png2462
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SystemUI/res/drawable-xhdpi/recents_tv_bg_default.png8975
-rw-r--r--atv_gms_overlay/frameworks/base/packages/SystemUI/res/values/config.xml31
-rw-r--r--atv_gms_overlay/packages/apps/Bluetooth/res/values/config.xml17
-rw-r--r--atv_gms_overlay/packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_device.xml36
-rw-r--r--atv_gms_overlay/packages/apps/ManagedProvisioning/res/values/vendor_required_apps_managed_profile.xml26
-rw-r--r--atv_gms_overlay/packages/apps/Provision/AndroidManifest.xml38
-rw-r--r--atv_gms_overlay/packages/providers/ContactsProvider/res/values/config.xml21
-rw-r--r--atv_gms_overlay/vendor/amlogic/apps/MboxLauncher2/AndroidManifest.xml40
-rw-r--r--audio.mk123
-rw-r--r--audio/a2dp_audio_policy_configuration.xml48
-rw-r--r--audio/audio_data.ko243
-rw-r--r--audio/audio_policy_configuration.xml184
-rw-r--r--audio/audio_policy_volumes.xml179
-rw-r--r--audio/default_volume_tables.xml70
-rw-r--r--audio/dia_remote_audio_policy_configuration.xml37
-rw-r--r--audio/r_submix_audio_policy_configuration.xml44
-rw-r--r--audio/usb_audio_policy_configuration.xml43
-rw-r--r--bluetooth.mk477
-rw-r--r--config/lowmemorykiller.txt3
-rw-r--r--config/lowmemorykiller_2G.txt3
-rw-r--r--config/lowmemorykiller_512M.txt3
-rw-r--r--core_amlogic.mk485
-rw-r--r--ddr/ddr_window_64.ko263
-rw-r--r--ddrtest.sh7
-rw-r--r--droidlogic.software.netflix.xml5
-rw-r--r--dumpstate/Android.mk39
-rw-r--r--dumpstate/DumpstateDevice.cpp76
-rw-r--r--dumpstate/DumpstateDevice.h50
-rw-r--r--dumpstate/NOTICE190
-rw-r--r--dumpstate/android.hardware.dumpstate@1.0-service.droidlogic.rc4
-rw-r--r--dumpstate/service.cpp41
-rw-r--r--dynamic_zygote_seondary/dynamic_zygote_64_bit.mk41
-rw-r--r--dynamic_zygote_seondary/init.zygote32_64.rc26
-rw-r--r--dynamic_zygote_seondary/init.zygote64_32.rc26
-rw-r--r--factory.mk306
-rw-r--r--gpu.mk17
-rw-r--r--gpu/mali450-kernel.mk17
-rw-r--r--gpu/mali450-user-arm.mk25
-rw-r--r--gpu/mali450-user-arm64.mk24
-rw-r--r--gpu/t82x-kernel.mk18
-rw-r--r--gpu/t82x-user-arm.mk26
-rw-r--r--gpu/t82x-user-arm64.mk26
-rw-r--r--gpu/t83x-kernel.mk18
-rw-r--r--gpu/t83x-user-arm.mk26
-rw-r--r--gpu/t83x-user-arm64.mk26
-rw-r--r--hdcp_rx22/arm_tools/aictool4274
-rw-r--r--hdcp_rx22/arm_tools/esm_swap3512
-rw-r--r--hdcp_rx22/arm_tools/hdcprxkeys4183
-rw-r--r--hdcp_rx22/firmware/esm_config.i1
-rw-r--r--hdcp_rx22/firmware/firmware.aic22
-rw-r--r--hdcp_rx22/firmware/firmware.le464
-rw-r--r--hdcp_rx22/firmware/firmware.rom0
-rw-r--r--hdcp_rx22/hdcp_rx22104
-rw-r--r--hdcp_tx22/hdcp_tx22209
-rw-r--r--hdcp_tx22/hdcp_tx22.contenttype1165
-rw-r--r--init.amlogic.media.rc29
-rw-r--r--init.amlogic.wifi.rc42
-rw-r--r--init.amlogic.wifi_bcm.rc21
-rw-r--r--init.amlogic.wifi_rtk.rc16
-rw-r--r--kernel_build_check.sh240
-rw-r--r--keyboards/Vendor_0484_Product_5738.kl441
-rw-r--r--keyboards/Vendor_0c45_Product_1109.kl36
-rw-r--r--keyboards/Vendor_7045_Product_1820.kl34
-rw-r--r--media.mk274
-rw-r--r--media_modules.mk23
-rw-r--r--mobile.mk14
-rw-r--r--optimization/config1
-rw-r--r--optimization/liboptimization_32.so66
-rw-r--r--optimization/liboptimization_64.so57
-rw-r--r--patch/Readme.txt12
-rw-r--r--patch/frameworks#base#0001.patch41
-rw-r--r--products/dongle/product_dongle.mk1
-rw-r--r--products/dvb/product_dvb.mk1
-rw-r--r--products/iptv/product_iptv.mk1
-rw-r--r--products/mbox/bootanimation.zip21947
-rw-r--r--products/mbox/default_wallpaper.png1406
-rw-r--r--products/mbox/init.amlogic.rc426
-rw-r--r--products/mbox/mbox.mp49032
-rw-r--r--products/mbox/product_mbox.mk97
-rw-r--r--products/mbox/ueventd.amlogic.rc106
-rw-r--r--products/mbox/upgrade_3.14/aml_emmc_logic_table.xml14
-rw-r--r--products/mbox/upgrade_3.14/aml_upgrade_package.conf25
-rw-r--r--products/mbox/upgrade_3.14/aml_upgrade_package_AB.conf24
-rw-r--r--products/mbox/upgrade_3.14/aml_upgrade_package_AB_enc.conf28
-rw-r--r--products/mbox/upgrade_3.14/aml_upgrade_package_enc.conf29
-rw-r--r--products/mbox/upgrade_4.9/aml_upgrade_package.conf27
-rw-r--r--products/mbox/upgrade_4.9/aml_upgrade_package_AB.conf26
-rw-r--r--products/mbox/upgrade_4.9/aml_upgrade_package_AB_enc.conf31
-rw-r--r--products/mbox/upgrade_4.9/aml_upgrade_package_enc.conf31
-rw-r--r--products/tablet/init.amlogic.rc366
-rw-r--r--products/tablet/product_tablet.mk48
-rw-r--r--products/tablet/ueventd.amlogic.rc76
-rw-r--r--products/tv/bootanimation.zip25778
-rw-r--r--products/tv/default_wallpaper.png1406
-rw-r--r--products/tv/init.amlogic.rc438
-rw-r--r--products/tv/product_tv.mk137
-rw-r--r--products/tv/tv.mp465398
-rw-r--r--products/tv/ueventd.amlogic.rc106
-rw-r--r--products/tv/upgrade_3.14/aml_emmc_logic_table.xml15
-rw-r--r--products/tv/upgrade_3.14/aml_upgrade_package.conf25
-rw-r--r--products/tv/upgrade_3.14/aml_upgrade_package_AB.conf24
-rw-r--r--products/tv/upgrade_3.14/aml_upgrade_package_AB_enc.conf28
-rw-r--r--products/tv/upgrade_3.14/aml_upgrade_package_enc.conf29
-rw-r--r--products/tv/upgrade_4.9/aml_upgrade_package.conf27
-rw-r--r--products/tv/upgrade_4.9/aml_upgrade_package_AB.conf26
-rw-r--r--products/tv/upgrade_4.9/aml_upgrade_package_AB_enc.conf31
-rw-r--r--products/tv/upgrade_4.9/aml_upgrade_package_enc.conf31
-rw-r--r--quick_build_kernel.sh58
-rw-r--r--recovery/Android.mk8
-rw-r--r--recovery/check/Android.mk25
-rw-r--r--recovery/check/dtbcheck.cpp860
-rw-r--r--recovery/check/dtbcheck.h15
-rw-r--r--recovery/check/security.cpp578
-rw-r--r--recovery/check/security.h158
-rw-r--r--recovery/fdt/Android.mk18
-rw-r--r--recovery/fdt/Makefile.libfdt10
-rw-r--r--recovery/fdt/fdt.c222
-rw-r--r--recovery/fdt/fdt.h60
-rw-r--r--recovery/fdt/fdt_empty_tree.c84
-rw-r--r--recovery/fdt/fdt_ro.c574
-rw-r--r--recovery/fdt/fdt_rw.c492
-rw-r--r--recovery/fdt/fdt_strerror.c96
-rw-r--r--recovery/fdt/fdt_sw.c256
-rw-r--r--recovery/fdt/fdt_wip.c118
-rw-r--r--recovery/fdt/libfdt.h1478
-rw-r--r--recovery/fdt/libfdt_env.h29
-rw-r--r--recovery/fdt/libfdt_internal.h95
-rw-r--r--recovery/init.rc112
-rw-r--r--recovery/recovery_extra/Android.mk29
-rw-r--r--recovery/recovery_extra/recovery_amlogic.cpp392
-rw-r--r--recovery/recovery_extra/recovery_amlogic.h25
-rw-r--r--recovery/ubootenv/Android.mk17
-rw-r--r--recovery/ubootenv/set_display_mode.cpp24
-rw-r--r--recovery/ubootenv/set_display_mode.h4
-rw-r--r--recovery/ubootenv/uboot_env.cpp107
-rw-r--r--recovery/ubootenv/uboot_env.h24
-rw-r--r--recovery/ui/Android.mk30
-rw-r--r--recovery/ui/amlogic_ui.cpp205
-rw-r--r--recovery/ui/amlogic_ui.h25
-rwxr-xr-xrecovery/updater-script10
-rw-r--r--recovery/updater_extra/Android.mk22
-rw-r--r--recovery/updater_extra/install_amlogic.cpp751
-rw-r--r--recovery/updater_extra/install_amlogic.h20
-rwxr-xr-xreleasetools.py230
-rw-r--r--rtk_bt_driver.mk11
-rw-r--r--scripts/check_patch.py268
-rwxr-xr-xscripts/checkpatch.pl45
-rw-r--r--seccomp/mediacodec.policy11
-rw-r--r--seccomp/mediaextractor.policy7
-rw-r--r--security/Android.mk13
-rw-r--r--security/verity.pk84
-rw-r--r--security/verity.x509.der9
-rw-r--r--security/verity.x509.pem24
-rw-r--r--security/verity_key2
-rw-r--r--sepolicy.mk3
-rw-r--r--sepolicy/adbd.te1
-rw-r--r--sepolicy/app.te80
-rw-r--r--sepolicy/audioserver.te7
-rw-r--r--sepolicy/bcmdl.te12
-rw-r--r--sepolicy/blkid_untrusted.te4
-rw-r--r--sepolicy/bootanim.te1
-rw-r--r--sepolicy/bootvideo.te36
-rw-r--r--sepolicy/charger.te2
-rw-r--r--sepolicy/device.te33
-rw-r--r--sepolicy/drmserver.te14
-rw-r--r--sepolicy/droidvold.te97
-rw-r--r--sepolicy/file.te42
-rw-r--r--sepolicy/file_contexts131
-rw-r--r--sepolicy/firmload.te10
-rw-r--r--sepolicy/fsck.te12
-rw-r--r--sepolicy/fsck_untrusted.te3
-rwxr-xr-xsepolicy/genfs_contexts9
-rw-r--r--sepolicy/hal_audio_default.te15
-rw-r--r--sepolicy/hal_bootctl_default.te7
-rw-r--r--sepolicy/hal_camera_default.te3
-rw-r--r--sepolicy/hal_drm_default.te4
-rw-r--r--sepolicy/hal_dumpstate_impl.te9
-rw-r--r--sepolicy/hal_graphics_allocator_default.te2
-rw-r--r--sepolicy/hal_graphics_composer_default.te13
-rw-r--r--sepolicy/hal_keymaster_default.te1
-rw-r--r--sepolicy/hal_memtrack_default.te39
-rw-r--r--sepolicy/hal_power_default.te2
-rw-r--r--sepolicy/hal_tv_cec_default.te2
-rw-r--r--sepolicy/hal_wifi_default.te18
-rw-r--r--sepolicy/hal_wifi_supplicant_default.te1
-rw-r--r--sepolicy/hdcp_rx22.te14
-rw-r--r--sepolicy/hdcp_tx22.te9
-rw-r--r--sepolicy/hdmicecd.te15
-rw-r--r--sepolicy/healthd.te3
-rw-r--r--sepolicy/hidraw_device.te1
-rw-r--r--sepolicy/hwservice.te3
-rw-r--r--sepolicy/hwservice_contexts3
-rw-r--r--sepolicy/hwservicemanager.te14
-rw-r--r--sepolicy/imageserver.te44
-rw-r--r--sepolicy/init.te111
-rw-r--r--sepolicy/kernel.te6
-rw-r--r--sepolicy/mediacodec.te18
-rw-r--r--sepolicy/mediadrmserver.te5
-rw-r--r--sepolicy/mediaextractor.te12
-rw-r--r--sepolicy/mediaserver.te34
-rw-r--r--sepolicy/netd.te10
-rw-r--r--sepolicy/ntfs-3g.te24
-rw-r--r--sepolicy/platform_app.te42
-rw-r--r--sepolicy/pppoe_wrapper.te31
-rw-r--r--sepolicy/priv_app.te16
-rw-r--r--sepolicy/property.te7
-rw-r--r--sepolicy/property_contexts9
-rw-r--r--sepolicy/recovery.te39
-rw-r--r--sepolicy/remotecfg.te7
-rw-r--r--sepolicy/sdcardd.te8
-rw-r--r--sepolicy/service.te10
-rw-r--r--sepolicy/service_contexts10
-rw-r--r--sepolicy/servicemanager.te1
-rw-r--r--sepolicy/sgdisk.te4
-rw-r--r--sepolicy/shell.te6
-rw-r--r--sepolicy/surfaceflinger.te6
-rw-r--r--sepolicy/system_app.te84
-rw-r--r--sepolicy/system_control.te105
-rw-r--r--sepolicy/system_server.te49
-rw-r--r--sepolicy/tee.te11
-rw-r--r--sepolicy/toolbox.te1
-rw-r--r--sepolicy/ueventd.te2
-rw-r--r--sepolicy/update_engine.te9
-rw-r--r--sepolicy/update_verifier.te5
-rw-r--r--sepolicy/vold.te35
-rw-r--r--sepolicy/webview_zygote.te1
-rw-r--r--sepolicy/wificond.te3
-rw-r--r--sepolicy/zygote.te13
-rw-r--r--software.mk75
-rw-r--r--t83x-armv8.mk26
-rw-r--r--t83x.mk17
-rw-r--r--tb_detect.mk28
-rw-r--r--tb_detect/tb_detect.ko266
-rw-r--r--tutorial-library-google.zip2457
-rw-r--r--vndk/Android.mk57
-rw-r--r--wifi.mk1690
-rw-r--r--wifi/config.txt3
-rw-r--r--wifi_driver.mk203
-rw-r--r--wifi_modules.mk5
287 files changed, 177798 insertions, 0 deletions
diff --git a/recovery/recovery_extra/recovery_amlogic.cpp b/recovery/recovery_extra/recovery_amlogic.cpp
new file mode 100644
index 0000000..249033f
--- a/dev/null
+++ b/recovery/recovery_extra/recovery_amlogic.cpp
@@ -0,0 +1,392 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <fs_mgr.h>
+#include "install.h"
+#include "ui.h"
+#include <dirent.h>
+#include "bootloader_message/bootloader_message.h"
+#include "recovery_amlogic.h"
+
+#include "ubootenv/set_display_mode.h"
+
+extern "C" {
+#include "ubootenv/uboot_env.h"
+}
+
+#define LOGE(...) ui_print("E:" __VA_ARGS__)
+#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
+#define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__)
+
+static const int MAX_ARGS = 100;
+static const int MAX_ARG_LENGTH = 4096;
+#define NUM_OF_BLKDEVICE_TO_ENUM 3
+#define NUM_OF_PARTITION_TO_ENUM 6
+
+static const char *UDISK_COMMAND_FILE = "/udisk/factory_update_param.aml";
+static const char *SDCARD_COMMAND_FILE = "/sdcard/factory_update_param.aml";
+
+void setup_cache_mounts() {
+ int ret = 0;
+ ret = ensure_path_mounted("/cache");
+ if (ret != 0) {
+ format_volume("/cache");
+ }
+}
+
+
+
+static int mount_fs_rdonly(char *device_name, Volume *vol, const char *fs_type) {
+ if (!mount(device_name, vol->mount_point, fs_type,
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY, 0)) {
+ LOGW("successful to mount %s on %s by read-only\n",
+ device_name, vol->mount_point);
+ return 0;
+ } else {
+ LOGE("failed to mount %s on %s by read-only (%s)\n",
+ device_name, vol->mount_point, strerror(errno));
+ }
+
+ return -1;
+}
+
+int auto_mount_fs(char *device_name, Volume *vol) {
+ if (access(device_name, F_OK)) {
+ return -1;
+ }
+
+ if (!strcmp(vol->fs_type, "auto")) {
+ if (!mount(device_name, vol->mount_point, "vfat",
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
+ goto auto_mounted;
+ } else {
+ if (strstr(vol->mount_point, "sdcard")) {
+ LOGW("failed to mount %s on %s (%s).try read-only ...\n",
+ device_name, vol->mount_point, strerror(errno));
+ if (!mount_fs_rdonly(device_name, vol, "vfat")) {
+ goto auto_mounted;
+ }
+ }
+ }
+
+ if (!mount(device_name, vol->mount_point, "ntfs",
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
+ goto auto_mounted;
+ } else {
+ if (strstr(vol->mount_point, "sdcard")) {
+ LOGW("failed to mount %s on %s (%s).try read-only ...\n",
+ device_name, vol->mount_point, strerror(errno));
+ if (!mount_fs_rdonly(device_name, vol, "ntfs")) {
+ goto auto_mounted;
+ }
+ }
+ }
+
+ if (!mount(device_name, vol->mount_point, "exfat",
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
+ goto auto_mounted;
+ } else {
+ if (strstr(vol->mount_point, "sdcard")) {
+ LOGW("failed to mount %s on %s (%s).try read-only ...\n",
+ device_name, vol->mount_point, strerror(errno));
+ if (!mount_fs_rdonly(device_name, vol, "exfat")) {
+ goto auto_mounted;
+ }
+ }
+ }
+ } else {
+ if(!mount(device_name, vol->mount_point, vol->fs_type,
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
+ goto auto_mounted;
+ } else {
+ if (strstr(vol->mount_point, "sdcard")) {
+ LOGW("failed to mount %s on %s (%s).try read-only ...\n",
+ device_name, vol->mount_point, strerror(errno));
+ if (!mount_fs_rdonly(device_name, vol, vol->fs_type)) {
+ goto auto_mounted;
+ }
+ }
+ }
+ }
+
+ return -1;
+
+auto_mounted:
+ return 0;
+}
+
+int customize_smart_device_mounted(
+ Volume *vol) {
+ int i = 0, j = 0;
+ int first_position = 0;
+ int second_position = 0;
+ char * tmp = NULL;
+ char *mounted_device = NULL;
+ char device_name[256] = {0};
+ char device_boot[256] = {0};
+ const char *usb_device = "/dev/block/sd";
+ const char *sdcard_device = "/dev/block/mmcblk";
+
+ if (vol->blk_device != NULL) {
+ int num = 0;
+ const char *blk_device = vol->blk_device;
+ for (; *blk_device != '\0'; blk_device ++) {
+ if (*blk_device == '#') {
+ num ++;
+ }
+ }
+
+ /*
+ * Contain two '#' for blk_device name in recovery.fstab
+ * such as /dev/block/sd## (udisk)
+ * such as /dev/block/mmcblk#p# (sdcard)
+ */
+ if (num != 2) {
+ return 1; // Don't contain two '#'
+ }
+
+ if (access(vol->mount_point, F_OK)) {
+ mkdir(vol->mount_point, 0755);
+ }
+
+ // find '#' position
+ if (strchr(vol->blk_device, '#')) {
+ tmp = strchr(vol->blk_device, '#');
+ first_position = tmp - vol->blk_device;
+ if (strlen(tmp+1) > 0 && strchr(tmp+1, '#')) {
+ tmp = strchr(tmp+1, '#');
+ second_position = tmp - vol->blk_device;
+ }
+ }
+
+ if (!first_position || !second_position) {
+ LOGW("decompose blk_device error(%s) in recovery.fstab\n",
+ vol->blk_device);
+ return -1;
+ }
+
+ int copy_len = (strlen(vol->blk_device) < sizeof(device_name)) ?
+ strlen(vol->blk_device) : sizeof(device_name);
+
+ for (i = 0; i < NUM_OF_BLKDEVICE_TO_ENUM; i ++) {
+ memset(device_name, '\0', sizeof(device_name));
+ strncpy(device_name, vol->blk_device, copy_len);
+
+ if (!strncmp(device_name, sdcard_device, strlen(sdcard_device))) {
+ // start from '0' for mmcblk0p#
+ device_name[first_position] = '0' + i;
+ } else if (!strncmp(device_name, usb_device, strlen(usb_device))) {
+ // start from 'a' for sda#
+ device_name[first_position] = 'a' + i;
+ }
+
+ for (j = 1; j <= NUM_OF_PARTITION_TO_ENUM; j ++) {
+ device_name[second_position] = '0' + j;
+ if (!access(device_name, F_OK)) {
+ LOGW("try mount %s ...\n", device_name);
+ if (!auto_mount_fs(device_name, vol)) {
+ mounted_device = device_name;
+ LOGW("successful to mount %s\n", device_name);
+ goto mounted;
+ }
+ }
+ }
+
+ if (!strncmp(device_name, sdcard_device, strlen(sdcard_device))) {
+ // mmcblk0p1->mmcblk0
+ device_name[strlen(device_name) - 2] = '\0';
+ sprintf(device_boot, "%s%s", device_name, "boot0");
+ // TODO: Here,need to distinguish between cards and flash at best
+ } else if (!strncmp(device_name, usb_device, strlen(usb_device))) {
+ // sda1->sda
+ device_name[strlen(device_name) - 1] = '\0';
+ }
+
+ if (!access(device_name, F_OK)) {
+ if (strlen(device_boot) && (!access(device_boot, F_OK))) {
+ continue;
+ }
+
+ LOGW("try mount %s ...\n", device_name);
+ if (!auto_mount_fs(device_name, vol)) {
+ mounted_device = device_name;
+ LOGW("successful to mount %s\n", device_name);
+ goto mounted;
+ }
+ }
+ }
+ } else {
+ LOGE("Can't get blk_device\n");
+ }
+
+ return -1;
+
+mounted:
+ return 0;
+}
+
+int smart_device_mounted(Volume *vol) {
+ int i = 0, len = 0;
+ char * tmp = NULL;
+ char device_name[256] = {0};
+ char *mounted_device = NULL;
+
+ mkdir(vol->mount_point, 0755);
+
+ if (vol->blk_device != NULL) {
+ int ret = customize_smart_device_mounted(vol);
+ if (ret <= 0) {
+ return ret;
+ }
+ }
+
+ if (vol->blk_device != NULL) {
+ tmp = strchr(vol->blk_device, '#');
+ len = tmp - vol->blk_device;
+ if (tmp && len < 255) {
+ strncpy(device_name, vol->blk_device, len);
+ for (i = 1; i <= NUM_OF_PARTITION_TO_ENUM; i++) {
+ device_name[len] = '0' + i;
+ device_name[len + 1] = '\0';
+ LOGW("try mount %s ...\n", device_name);
+ if (!access(device_name, F_OK)) {
+ if (!auto_mount_fs(device_name, vol)) {
+ mounted_device = device_name;
+ LOGW("successful to mount %s\n", device_name);
+ goto mounted;
+ }
+ }
+ }
+
+ const char *mmcblk = "/dev/block/mmcblk";
+ if (!strncmp(device_name, mmcblk, strlen(mmcblk))) {
+ device_name[len - 1] = '\0';
+ } else {
+ device_name[len] = '\0';
+ }
+
+ LOGW("try mount %s ...\n", device_name);
+ if (!access(device_name, F_OK)) {
+ if (!auto_mount_fs(device_name, vol)) {
+ mounted_device = device_name;
+ LOGW("successful to mount %s\n", device_name);
+ goto mounted;
+ }
+ }
+ } else {
+ LOGW("try mount %s ...\n", vol->blk_device);
+ strncpy(device_name, vol->blk_device, sizeof(device_name));
+ if (!access(device_name, F_OK)) {
+ if (!auto_mount_fs(device_name, vol)) {
+ mounted_device = device_name;
+ LOGW("successful to mount %s\n", device_name);
+ goto mounted;
+ }
+ }
+ }
+ }
+
+ return -1;
+
+mounted:
+ return 0;
+}
+
+
+//return value
+// 0 mount OK
+// -1 mount Faile
+// 2 ignorel
+int ensure_path_mounted_extra(Volume *v) {
+ Volume* vUsb = volume_for_path("/udisk");
+ char tmp[128] = {0};
+
+ if (strcmp(v->fs_type, "ext4") == 0) {
+ if (strstr(v->mount_point, "system")) {
+ if (!mount(v->blk_device, v->mount_point, v->fs_type,
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY, "")) {
+ return 0;
+ }
+ } else {
+ if (!mount(v->blk_device, v->mount_point, v->fs_type,
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "discard")) {
+ return 0;
+ }
+ }
+ LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno));
+ return -1;
+ } else if (strcmp(v->fs_type, "vfat") == 0 ||
+ strcmp(v->fs_type, "auto") == 0 ) {
+ if (strstr(v->mount_point, "sdcard") || strstr(v->mount_point, "udisk")) {
+ int time_out = 2000000;
+ while (time_out) {
+ if (!smart_device_mounted(v)) {
+ return 0;
+ }
+ usleep(100000);
+ time_out -= 100000;
+ }
+ } else {
+ if (!mount(v->blk_device, v->mount_point, v->fs_type,
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY, "")) {
+ return 0;
+ }
+ }
+ LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno));
+ return -1;
+ } else {
+ return 2;//not deal
+ }
+}
+
+void amlogic_init() {
+ set_display_mode("/etc/mesondisplay.cfg");
+ sleep(1);
+}
+
+void amlogic_get_args(std::vector<std::string>& args) {
+
+ if (args.size() == 1) {
+ std::string content;
+ if (ensure_path_mounted(UDISK_COMMAND_FILE) == 0 &&
+ android::base::ReadFileToString(UDISK_COMMAND_FILE, &content)) {
+
+ std::vector<std::string> tokens = android::base::Split(content, "\n");
+ for (auto it = tokens.begin(); it != tokens.end(); it++) {
+ // Skip empty and '\0'-filled tokens.
+ if (!it->empty() && (*it)[0] != '\0') {
+ args.push_back(std::move(*it));
+ }
+ }
+ LOG(INFO) << "Got " << args.size() << " arguments from " << UDISK_COMMAND_FILE;
+ }
+ }
+
+ if (args.size() == 1) {
+ std::string content;
+ if (ensure_path_mounted(SDCARD_COMMAND_FILE) == 0 &&
+ android::base::ReadFileToString(SDCARD_COMMAND_FILE, &content)) {
+
+ std::vector<std::string> tokens = android::base::Split(content, "\n");
+ for (auto it = tokens.begin(); it != tokens.end(); it++) {
+ // Skip empty and '\0'-filled tokens.
+ if (!it->empty() && (*it)[0] != '\0') {
+ args.push_back(std::move(*it));
+ }
+ }
+ LOG(INFO) << "Got " << args.size() << " arguments from " << SDCARD_COMMAND_FILE;
+ }
+ }
+
+ if (args.size() == 1) {
+ args.push_back(std::move("--show_text"));
+ }
+
+}