0%

Flutter UI容器

承载Flutter的Android容器

Flutter容器包含有FlutterActivity和FlutterFragmentActivity。他们分别实现了Provider, PluginRegistry, ViewFactory,二者的方法主要通过FlutterActivityDelegate 代理出去

FlutterActivityDelegateFlutterActivityEventsProviderPluginRegistryFlutterActivityActivityViewFactoryFlutterFragmentActivityFragmentActivity
Read more »

Perpare Env

下载 repo 工具:

1
2
3
4
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

使用每月更新的初始化包

1
2
3
4
5
6
wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar
cd AOSP # 解压得到的 AOSP 工程目录
# 这时 ls 的话什么也看不到,因为只有一个隐藏的 .repo 目录
repo sync # 正常同步一遍即可得到完整目录
# 或 repo sync -l 仅checkout代码
Read more »

ViewModel

ViewModelProviders

1
2
3
class TestViewModel extends ViewModel

TestViewModel test = ViewModelProviders.of(this).get(TestViewModel.class);

在ViewModelProviders中会创建ViewModelProvider,通过ViewModelProvider来管理ViewModel。

1
2
3
4
5
6
7
8
9
10
@NonNull
@MainThread
public static ViewModelProvider of(@NonNull FragmentActivity activity, @Nullable Factory factory) {
Application application = checkApplication(activity);
if (factory == null) {
factory = AndroidViewModelFactory.getInstance(application);
}

return new ViewModelProvider(ViewModelStores.of(activity), (Factory)factory);
}
Read more »

主要包含:

1
2
3
settings.gradle
build.gradle
app/build.gradle

以及gradle wrapper下的gradle jar包和配置文件

Read more »

C++ Hook

LD_PRELOAD 预加载hook so

通过LD_PRELOAD

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
if( strcmp(argv[1], "password") )
{
printf("Incorrect password\n");
}
else
{
printf("Correct password\n");
}
return 0;
}
1
gcc -o main main.c
Read more »

1
2
3
4
5
6
7
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/home/zauther/Libraries/depot_tools
fetch --nohooks android

gclient sync
build/install-build-deps-android.sh
gclient runhooks
1
2
3
4
5
6
7
8
gn args out/Default

>>
target_os = "android"
target_cpu = "arm64"
treat_warnings_as_errors=false

autoninja -C out/Default chrome_public_apk
1
build/android/gradle/generate_gradle.py --output-directory out/Default --project-dir out/Chrome-Android
1
2
git checkout 92.0.4480.2
gclient sync --with_branch_heads
Read more »

1
2
3
help
-- SSL Proxing
-- Save Charles Root Certificate

得到 charles-ssl-proxying-certificate.pem

转化格式

1
openssl x509 -in charles-ssl-proxying-certificate.pem -inform PEM -out charles-ssl-proxying-certificate.crt

复制到ca证书目录(这里新建了一个目录)

1
2
sudo mkdir /usr/share/ca-certificates/extra
sudo cp charles-ssl-proxying-certificate.crt /usr/share/ca-certificates/extra/charles-ssl-proxying-certificate.crt

配置

1
sudo dpkg-reconfigure ca-certificates

选择Yes后,弹出证书列表,选择charles证书即可。

CUDA安装

NVIDIA® GPU 驱动程序

https://www.nvidia.com/drivers
根据显卡型号下载 NVIDIA-Linux-x86_64-460.73.01.run

1
2
sudo chmod +x NVIDIA-Linux-x86_64-460.73.01.run
sudo ./NVIDIA-Linux-x86_64-460.73.01.run

Ubuntu没必要安装这个版本,直接在“软件和更新”中选择NVIDIA的驱动更好

Read more »

1. 首次安装树莓派

1.1 安装树莓派

1.1.1 下载树莓派镜像(可跳过)

https://www.raspberrypi.org/software/operating-systems/ 下载树莓派镜像,为了快速下载,这里下载的是 Raspberry Pi OS Lite ,体积最小,后面主要在命令行环境使用。这里下载的版本是 2021-03-04-raspios-buster-armhf-lite.zip
准备2张SD卡,一张安装树莓派系统(这里取代号A卡),另外一张(B卡)用于我们自己的构建系统。

1.1.2 安装树莓派系统

在Ubuntu主机上安装树莓派烧写工具 rpi-imager

1
sudo apt install rpi-imager

在命令行执行 rpi-imager 后会出现工具

1
rpi-imager
Read more »

SD卡分区

将SD卡分区,通过fdisk命令分区为2个区,100M的boot区,剩下的rootfs区,boot区
boot区格式化为fat格式,rootfs格式化为ext4
将boot挂在到/mnt/boot位置

1
2
sudo mkfs.vfat /dev/sdb1
sudo mount /dev/sdb1 /mnt/boot

准备树莓派Boot文件

1
2
3
git clone https://github.com/raspberrypi/firmware.git
cd firmware
cp -R boot/* /mnt/boot
Read more »