Android 脚本操作
一、实现 APK 拷贝功能的mk文件操作
########################################################### ## Find all of the apk files under the named directories. ## Meant to be used like: ## SRC_FILES := $(call all-apk-files-under,src tests) ########################################################### define all-apk-files-under $(patsubst ./%,%, \ $(shell cd $(LOCAL_PATH)/$(1) ; \ find ./ -maxdepth 1 -name "*.apk" -and -not -name ".*") \ ) endef ######################################################### ######################## add apk ######################## ######################################################### COPY_APK_TARGET := $(call all-apk-files-under,apk) PRODUCT_COPY_FILES += $(foreach apkName, $(COPY_APK_TARGET), \ $(addprefix $(LOCAL_PATH)/apk/, $(apkName)):$(addprefix system/app/, $(apkName)))
首先是定义 all-apk-files-under函数,进入到第一个参数$(1)路径下,使用find命令进行查找到所有APK文件,利用foreach提取出每个文件名,拷贝到 system/app目录下
二、shell脚本选择编译不同版本的固件
#! /bin/bash echo "请选择编译的版本:" echo -e "1. "A" echo -e "2. "B" echo -e "3. 退出" echo -n "选择版本(1,2,3):" read WHO case $WHO in 1) echo -e "A --- 拷贝对应目录到device下 \n" rm -f ./device/amlogic/f16ref/apk/* cp ./device/amlogic/A/apk/* ./device/amlogic/f16ref/apk/ cp ./device/amlogic/A/ui/* ./device/amlogic/f16ref/ ;; 2) echo -e "B --- 拷贝对应目录到device下 \n" rm -f ./device/amlogic/f16ref/apk/* cp ./device/amlogic/B/apk/* ./device/amlogic/f16ref/apk/ cp ./device/amlogic/B/ui/* ./device/amlogic/f16ref/ ;; *) echo "退出" exit ;; esac echo -e "************** 拷贝结束,开始编译 ***************\n" . build/envsetup.sh lunch 19 make -j4 echo "************** 编译结束 ****************\n"
三、wildcard、notdir、patsubst
1、wildcard : 扩展通配符
2、notdir:去除路径
3、patsubst :替换通配符相关推荐
yangChong 2020-08-03
zyygive 2020-07-29
yangChong 2020-07-29
绿豆饼 2020-07-28
adb shell cd system/app rm *.apk21. 获取管理员权限: adb root22. 启动Activity: adb shell am start -n 包名/包名+类名。
蓝天梦 2020-07-28
rookieding 2020-07-26
zyygive 2020-06-11
zyygive 2020-06-09
安辉 2020-05-27
KarlMarxs 2020-05-15
xilove0 2020-04-20
laijunfeng 2020-04-07
KarlMarxs 2020-02-23
Soinice 2020-02-18
zyygive 2020-02-17
ProgrammerFan00 2020-02-16
Ubuntu黑客 2020-02-14
89590098 2020-02-01