mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-20 08:35:46 +08:00
Adjust ads watch settings, add saf documents provider, camera stream, more permission
This commit is contained in:
@@ -68,16 +68,60 @@ class Util {
|
||||
G.termPtys[G.currentContainer]!.pty.write(const Utf8Encoder().convert("$str\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//所有key
|
||||
//int defaultContainer = 0: 默认启动第0个容器
|
||||
//int defaultAudioPort = 4718: 默认pulseaudio端口(为了避免和其它软件冲突改成4718了,原默认4713)
|
||||
//bool autoLaunchVnc = true: 是否自动启动VNC并跳转
|
||||
//String lastDate: 上次启动软件的日期,yyyy-MM-dd
|
||||
//int adsWatchedToday: 今日视频广告观看数量
|
||||
//int adsWatchedTotal: 视频广告观看数量
|
||||
//bool isBannerAdsClosed = false
|
||||
//bool isTerminalWriteEnabled = false
|
||||
//bool isTerminalCommandsEnabled = false
|
||||
//int termMaxLines = 4095 终端最大行数
|
||||
//double termFontScale = 1 终端字体大小
|
||||
//int vip = 0 用户等级,vip免广告,你要改吗?(ToT)
|
||||
//bool isStickyKey = true 终端ctrl, shift, alt键是否粘滞
|
||||
//String defaultFFmpegCommand 默认推流命令
|
||||
//? int bootstrapVersion: 启动包版本
|
||||
//String[] containersInfo: 所有容器信息(json)
|
||||
//{name, boot:"\$DATA_DIR/bin/proot ...", vnc:"startnovnc", vncUrl:"...", commands:[{name:"更新和升级", command:"apt update -y && apt upgrade -y"}, ...]}
|
||||
//String[] adsBonus: 观看广告获取的奖励(json)
|
||||
//{name: "xxx", amount: xxx}
|
||||
static dynamic getGlobal(String key) {
|
||||
bool b = G.prefs.containsKey(key);
|
||||
switch (key) {
|
||||
case "defaultContainer" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
||||
case "defaultAudioPort" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(4718);
|
||||
case "autoLaunchVnc" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
|
||||
case "lastDate" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("1970-01-01");
|
||||
case "adsWatchedToday" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
||||
case "adsWatchedTotal" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
||||
case "isBannerAdsClosed" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
case "isTerminalWriteEnabled" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
case "isTerminalCommandsEnabled" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
case "termMaxLines" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(4095);
|
||||
case "termFontScale" : return b ? G.prefs.getDouble(key)! : (value){G.prefs.setDouble(key, value); return value;}(1.0);
|
||||
case "vip" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
||||
case "isStickyKey" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
|
||||
case "defaultFFmpegCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("-hide_banner -an -max_delay 1000000 -r 30 -f android_camera -i 0:0 -vf scale=iw/2:-1 -rtsp_transport udp -f rtsp rtsp://127.0.0.1:8554/stream");
|
||||
case "containersInfo" : return G.prefs.getStringList(key)!;
|
||||
case "adsBonus" : return b ? G.prefs.getStringList(key)! : (value){G.prefs.setStringList(key, value); return value;}([].cast<String>());
|
||||
}
|
||||
}
|
||||
|
||||
static dynamic getCurrentProp(String key) {
|
||||
return jsonDecode(G.prefs.getStringList("containersInfo")![G.currentContainer])[key];
|
||||
return jsonDecode(Util.getGlobal("containersInfo")[G.currentContainer])[key];
|
||||
}
|
||||
|
||||
//用来设置name, boot, vnc, vncUrl等
|
||||
static Future<void> setCurrentProp(String key, dynamic value) async {
|
||||
await G.prefs.setStringList("containersInfo",
|
||||
G.prefs.getStringList("containersInfo")!..setAll(G.currentContainer,
|
||||
Util.getGlobal("containersInfo")..setAll(G.currentContainer,
|
||||
[jsonEncode((jsonDecode(
|
||||
G.prefs.getStringList("containersInfo")![G.currentContainer]
|
||||
Util.getGlobal("containersInfo")[G.currentContainer]
|
||||
))..update(key, (v) => value))]
|
||||
)
|
||||
);
|
||||
@@ -101,14 +145,14 @@ class Util {
|
||||
//由getRandomBonus返回的数据
|
||||
static Future<void> applyBonus(Map<String, dynamic> bonus) async {
|
||||
bool flag = false;
|
||||
List<String> ret = G.prefs.getStringList("adsBonus")!.map((e) {
|
||||
List<String> ret = Util.getGlobal("adsBonus").map((e) {
|
||||
Map<String, dynamic> item = jsonDecode(e);
|
||||
return (item["name"] == bonus["name"])?
|
||||
jsonEncode(item..update("amount", (v) {
|
||||
flag = true;
|
||||
return v + bonus["amount"];
|
||||
})):e;
|
||||
}).toList();
|
||||
}).toList().cast<String>();
|
||||
if (!flag) {
|
||||
ret.add("""{"name": "${bonus["name"]}", "amount": ${bonus["amount"]}}""");
|
||||
}
|
||||
@@ -117,7 +161,7 @@ class Util {
|
||||
|
||||
//根据已看广告量判断是否应该继续看广告
|
||||
static bool shouldWatchAds(int expectNum) {
|
||||
return (G.prefs.getInt("adsWatchedTotal")! < expectNum) && (G.prefs.getInt("vip")! < 1) && (G.prefs.getInt("adsWatchedToday")! < 5);
|
||||
return ((Util.getGlobal("adsWatchedTotal") as int) < expectNum) && ((Util.getGlobal("vip") as int) < 1) && ((Util.getGlobal("adsWatchedToday") as int) < G.adsRequired["unlockToday"]!) && (G.adsWatchedThisTime < G.adsRequired["unlockOnce"]!);
|
||||
}
|
||||
|
||||
//限定字符串在min和max之间, 给文本框的validator
|
||||
@@ -185,8 +229,7 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
alt: event.alt || _alt,
|
||||
));
|
||||
G.maybeCtrlJ = event.key.name == "keyJ";
|
||||
print(G.maybeCtrlJ);
|
||||
if (!G.prefs.getBool("isStickyKey")!) {
|
||||
if (!(Util.getGlobal("isStickyKey") as bool)) {
|
||||
G.keyboard.ctrl = false;
|
||||
G.keyboard.shift = false;
|
||||
G.keyboard.alt = false;
|
||||
@@ -201,7 +244,7 @@ class TermPty {
|
||||
late final Pty pty;
|
||||
|
||||
TermPty() {
|
||||
terminal = Terminal(inputHandler: G.keyboard, maxLines: G.prefs.getInt("termMaxLines")!);
|
||||
terminal = Terminal(inputHandler: G.keyboard, maxLines: Util.getGlobal("termMaxLines") as int);
|
||||
pty = Pty.start(
|
||||
"/system/bin/sh",
|
||||
workingDirectory: G.dataPath,
|
||||
@@ -249,7 +292,7 @@ class TermPty {
|
||||
}
|
||||
});
|
||||
terminal.onOutput = (data) {
|
||||
if (!G.prefs.getBool("isTerminalWriteEnabled")!) {
|
||||
if (!(Util.getGlobal("isTerminalWriteEnabled") as bool)) {
|
||||
return;
|
||||
}
|
||||
//由于对回车的处理似乎存在问题,所以拿出来单独处理
|
||||
@@ -281,6 +324,12 @@ class G {
|
||||
static late VirtualKeyboard keyboard; //存储ctrl, shift, alt状态
|
||||
static bool maybeCtrlJ = false; //为了区分按下的ctrl+J和enter而准备的变量
|
||||
static double termFontScale = 1; //终端字体大小,存储为G.prefs的termFontScale
|
||||
static int adsWatchedThisTime = 0; //本次启动应用看的广告数
|
||||
static bool isStreamServerStarted = false;
|
||||
static bool isStreaming = false;
|
||||
static int? streamingId;
|
||||
static String streamingOutput = "";
|
||||
static late Pty streamServerPty;
|
||||
|
||||
|
||||
//看广告可以获得的奖励。
|
||||
@@ -296,29 +345,20 @@ class G {
|
||||
{"name": "Bonus Reward", "subtitle": "会有极好的事情发生", "description": "来自记忆空间的传说。\n使用后一天内必有极好的事情...\n就是你想象的那种事情...\n就会发生。\n不过, 大概只是个传说吧。", "weight": 1, "amount": 1, "singleUse": 1},
|
||||
];
|
||||
|
||||
//所有key
|
||||
//int defaultContainer = 0: 默认启动第0个容器
|
||||
//int defaultAudioPort = 4718: 默认pulseaudio端口(为了避免和其它软件冲突改成4718了,原默认4713)
|
||||
//bool autoLaunchVnc = true: 是否自动启动VNC并跳转
|
||||
//String lastDate: 上次启动软件的日期,yyyy-MM-dd
|
||||
//int adsWatchedToday: 今日视频广告观看数量
|
||||
//int adsWatchedTotal: 视频广告观看数量
|
||||
//bool isBannerAdsClosed = false
|
||||
//bool bannerAdsCanBeClosed = false 看一次视频广告永久开启,历史遗留
|
||||
//bool isTerminalWriteEnabled = false
|
||||
//bool terminalWriteCanBeEnabled = false 看一次视频广告永久开启,历史遗留
|
||||
//bool isTerminalCommandsEnabled = false
|
||||
//int termMaxLines = 4095 终端最大行数
|
||||
//double termFontScale = 1 终端字体大小
|
||||
//int vip = 0 用户等级,vip免广告,你要改吗?(ToT)
|
||||
//bool isStickyKey = true 终端ctrl, shift, alt键是否粘滞
|
||||
//? int bootstrapVersion: 启动包版本
|
||||
//String[] containersInfo: 所有容器信息(json)
|
||||
//{name, boot:"\$DATA_DIR/bin/proot ...", vnc:"startnovnc", vncUrl:"...", commands:[{name:"更新和升级", command:"apt update -y && apt upgrade -y"}, ...]}
|
||||
//String[] adsBonus: 观看广告获取的奖励(json)
|
||||
//{name: "xxx", amount: xxx}
|
||||
static late SharedPreferences prefs;
|
||||
//某项功能开启需要的广告数。
|
||||
static const Map<String, int> adsRequired = {
|
||||
"closeBannerAds" : 5,
|
||||
"enableTerminalWrite" : 2,
|
||||
"enableTerminalCommands" : 3,
|
||||
"changeTermMaxLines" : 6,
|
||||
"changeFFmpegCommand" : 8,
|
||||
|
||||
"unlockOnce" : 1, //临时解锁需要看的广告数
|
||||
"unlockToday" : 2, //当日解锁需要看的广告数
|
||||
|
||||
};
|
||||
|
||||
static late SharedPreferences prefs;
|
||||
}
|
||||
|
||||
class AdManager {
|
||||
@@ -347,7 +387,7 @@ class AdManager {
|
||||
|
||||
static void showAd(String placementId, Function completeExtra, Function full) {
|
||||
|
||||
if (G.prefs.getInt("adsWatchedToday")!>=5) {
|
||||
if ((Util.getGlobal("adsWatchedToday") as int) >= 5) {
|
||||
full();
|
||||
return;
|
||||
}
|
||||
@@ -358,8 +398,9 @@ class AdManager {
|
||||
onComplete: (placementId) async {
|
||||
debugPrint('Video Ad $placementId completed');
|
||||
loadAd(placementId);
|
||||
await G.prefs.setInt("adsWatchedTotal", G.prefs.getInt("adsWatchedTotal")!+1);
|
||||
await G.prefs.setInt("adsWatchedToday", G.prefs.getInt("adsWatchedToday")!+1);
|
||||
G.adsWatchedThisTime++;
|
||||
await G.prefs.setInt("adsWatchedTotal", (Util.getGlobal("adsWatchedTotal") as int)+1);
|
||||
await G.prefs.setInt("adsWatchedToday", (Util.getGlobal("adsWatchedToday") as int)+1);
|
||||
completeExtra();
|
||||
},
|
||||
onFailed: (placementId, error, message) {
|
||||
@@ -396,7 +437,7 @@ class Workflow {
|
||||
|
||||
static Future<void> grantPermissions() async {
|
||||
Permission.storage.request();
|
||||
Permission.manageExternalStorage.request();
|
||||
//Permission.manageExternalStorage.request();
|
||||
}
|
||||
|
||||
static Future<void> setupBootstrap() async {
|
||||
@@ -477,7 +518,7 @@ done
|
||||
//$DATA_DIR是数据文件夹, $CONTAINER_DIR是容器根目录
|
||||
await G.prefs.setStringList("containersInfo", ["""{
|
||||
"name":"Debian Bookworm",
|
||||
"boot":"\$DATA_DIR/bin/proot --change-id=1000:1000 --pwd=/home/tiny --rootfs=\$CONTAINER_DIR --mount=/system --mount=/apex --kill-on-exit --mount=/storage:/storage --sysvipc -L --link2symlink --mount=/proc:/proc --mount=/dev:/dev --mount=\$CONTAINER_DIR/tmp:/dev/shm --mount=/dev/urandom:/dev/random --mount=/proc/self/fd:/dev/fd --mount=/proc/self/fd/0:/dev/stdin --mount=/proc/self/fd/1:/dev/stdout --mount=/proc/self/fd/2:/dev/stderr --mount=/dev/null:/dev/tty0 --mount=/dev/null:/proc/sys/kernel/cap_last_cap --mount=/storage/self/primary:/media/sd --mount=\$DATA_DIR/share:/home/tiny/公共 --mount=/storage/self/primary/Fonts:/usr/share/fonts/wpsm --mount=/storage/self/primary/AppFiles/Fonts:/usr/share/fonts/yozom --mount=/system/fonts:/usr/share/fonts/androidm --mount=/storage/self/primary/Pictures:/home/tiny/图片 --mount=/storage/self/primary/Music:/home/tiny/音乐 --mount=/storage/self/primary/Movies:/home/tiny/视频 --mount=/storage/self/primary/Download:/home/tiny/下载 --mount=/storage/self/primary/DCIM:/home/tiny/照片 --mount=/storage/self/primary/Documents:/home/tiny/文档 --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.stat:/proc/stat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.version:/proc/version --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/bus:/proc/bus --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/buddyinfo:/proc/buddyinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/cgroups:/proc/cgroups --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/consoles:/proc/consoles --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/crypto:/proc/crypto --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/devices:/proc/devices --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/diskstats:/proc/diskstats --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/execdomains:/proc/execdomains --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/fb:/proc/fb --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/filesystems:/proc/filesystems --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/interrupts:/proc/interrupts --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/iomem:/proc/iomem --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/ioports:/proc/ioports --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kallsyms:/proc/kallsyms --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/keys:/proc/keys --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/key-users:/proc/key-users --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kpageflags:/proc/kpageflags --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/loadavg:/proc/loadavg --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/locks:/proc/locks --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/misc:/proc/misc --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/modules:/proc/modules --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/pagetypeinfo:/proc/pagetypeinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/partitions:/proc/partitions --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/sched_debug:/proc/sched_debug --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/softirqs:/proc/softirqs --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/timer_list:/proc/timer_list --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/uptime:/proc/uptime --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmallocinfo:/proc/vmallocinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmstat:/proc/vmstat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/zoneinfo:/proc/zoneinfo /usr/bin/env -i HOSTNAME=TINY HOME=/home/tiny USER=tiny TERM=xterm-256color SDL_IM_MODULE=fcitx XMODIFIERS=@im=fcitx QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx TMOE_CHROOT=false TMOE_PROOT=true TMPDIR=/tmp MOZ_FAKE_NO_SANDBOX=1 DISPLAY=:4 PULSE_SERVER=tcp:127.0.0.1:4718 LANG=zh_CN.UTF-8 SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games /bin/bash -l",
|
||||
"boot":"\$DATA_DIR/bin/proot -H --change-id=1000:1000 --pwd=/home/tiny --rootfs=\$CONTAINER_DIR --mount=/system --mount=/apex --kill-on-exit --mount=/storage:/storage --sysvipc -L --link2symlink --mount=/proc:/proc --mount=/dev:/dev --mount=\$CONTAINER_DIR/tmp:/dev/shm --mount=/dev/urandom:/dev/random --mount=/proc/self/fd:/dev/fd --mount=/proc/self/fd/0:/dev/stdin --mount=/proc/self/fd/1:/dev/stdout --mount=/proc/self/fd/2:/dev/stderr --mount=/dev/null:/dev/tty0 --mount=/dev/null:/proc/sys/kernel/cap_last_cap --mount=/storage/self/primary:/media/sd --mount=\$DATA_DIR/share:/home/tiny/公共 --mount=/storage/self/primary/Fonts:/usr/share/fonts/wpsm --mount=/storage/self/primary/AppFiles/Fonts:/usr/share/fonts/yozom --mount=/system/fonts:/usr/share/fonts/androidm --mount=/storage/self/primary/Pictures:/home/tiny/图片 --mount=/storage/self/primary/Music:/home/tiny/音乐 --mount=/storage/self/primary/Movies:/home/tiny/视频 --mount=/storage/self/primary/Download:/home/tiny/下载 --mount=/storage/self/primary/DCIM:/home/tiny/照片 --mount=/storage/self/primary/Documents:/home/tiny/文档 --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.stat:/proc/stat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.version:/proc/version --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/bus:/proc/bus --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/buddyinfo:/proc/buddyinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/cgroups:/proc/cgroups --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/consoles:/proc/consoles --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/crypto:/proc/crypto --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/devices:/proc/devices --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/diskstats:/proc/diskstats --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/execdomains:/proc/execdomains --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/fb:/proc/fb --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/filesystems:/proc/filesystems --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/interrupts:/proc/interrupts --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/iomem:/proc/iomem --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/ioports:/proc/ioports --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kallsyms:/proc/kallsyms --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/keys:/proc/keys --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/key-users:/proc/key-users --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kpageflags:/proc/kpageflags --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/loadavg:/proc/loadavg --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/locks:/proc/locks --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/misc:/proc/misc --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/modules:/proc/modules --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/pagetypeinfo:/proc/pagetypeinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/partitions:/proc/partitions --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/sched_debug:/proc/sched_debug --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/softirqs:/proc/softirqs --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/timer_list:/proc/timer_list --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/uptime:/proc/uptime --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmallocinfo:/proc/vmallocinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmstat:/proc/vmstat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/zoneinfo:/proc/zoneinfo /usr/bin/env -i HOSTNAME=TINY HOME=/home/tiny USER=tiny TERM=xterm-256color SDL_IM_MODULE=fcitx XMODIFIERS=@im=fcitx QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx TMOE_CHROOT=false TMOE_PROOT=true TMPDIR=/tmp MOZ_FAKE_NO_SANDBOX=1 DISPLAY=:4 PULSE_SERVER=tcp:127.0.0.1:4718 LANG=zh_CN.UTF-8 SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games /bin/bash -l",
|
||||
"vnc":"startnovnc &",
|
||||
"vncUrl":"http://localhost:36082/vnc.html?host=localhost&port=36082&autoconnect=true&resize=remote&password=12345678",
|
||||
"commands":[{"name":"检查更新并升级", "command":"sudo apt update && sudo apt upgrade -y"},
|
||||
@@ -498,22 +539,24 @@ done
|
||||
{"name":"安装QQ", "command":"wget https://dldir1.qq.com/qqfile/qq/QQNT/b69de82d/linuxqq_3.2.1-17153_arm64.deb -O /tmp/qq.deb && sudo apt update && sudo apt install -y /tmp/qq.deb && sed -i 's#Exec=/opt/QQ/qq %U#Exec=/opt/QQ/qq --no-sandbox %U#g' /usr/share/applications/qq.desktop; rm /tmp/qq.deb"},
|
||||
{"name":"卸载QQ", "command":"sudo apt autoremove --purge -y linuxqq"},
|
||||
{"name":"修复无法编译C语言程序", "command":"sudo apt update && sudo apt reinstall -y libc6-dev"},
|
||||
{"name":"修复系统语言到中文", "command":"sudo localedef -c -i zh_CN -f UTF-8 zh_CN.UTF-8"},
|
||||
{"name":"启用回收站", "command":"sudo apt update && sudo apt install -y gvfs && echo '安装完成, 重启软件即可使用回收站。'"},
|
||||
{"name":"拉流测试", "command":"ffplay rtsp://127.0.0.1:8554/stream &"},
|
||||
{"name":"关机", "command":"stopvnc\\nexit\\nexit"},
|
||||
{"name":"???", "command":"timeout 8 cmatrix"}]
|
||||
}"""]);
|
||||
await G.prefs.setStringList("adsBonus", []);
|
||||
await G.prefs.setInt("adsWatchedTotal", 0);
|
||||
await G.prefs.setBool("isTerminalCommandsEnabled", false);
|
||||
await G.prefs.setBool("isTerminalWriteEnabled", false);
|
||||
await G.prefs.setBool("isBannerAdsClosed", false);
|
||||
await G.prefs.setBool("autoLaunchVnc", true);
|
||||
await G.prefs.setInt("defaultAudioPort", 4718);
|
||||
await G.prefs.setInt("defaultContainer", 0);
|
||||
await G.prefs.setInt("termMaxLines", 4095);
|
||||
await G.prefs.setDouble("termFontScale", 1);
|
||||
await G.prefs.setInt("vip", 0);
|
||||
await G.prefs.setBool("isStickyKey", true);
|
||||
// await G.prefs.setStringList("adsBonus", []);
|
||||
// await G.prefs.setInt("adsWatchedTotal", 0);
|
||||
// await G.prefs.setBool("isTerminalCommandsEnabled", false);
|
||||
// await G.prefs.setBool("isTerminalWriteEnabled", false);
|
||||
// await G.prefs.setBool("isBannerAdsClosed", false);
|
||||
// await G.prefs.setBool("autoLaunchVnc", true);
|
||||
// await G.prefs.setInt("defaultAudioPort", 4718);
|
||||
// await G.prefs.setInt("defaultContainer", 0);
|
||||
// await G.prefs.setInt("termMaxLines", 4095);
|
||||
// await G.prefs.setDouble("termFontScale", 1);
|
||||
// await G.prefs.setInt("vip", 0);
|
||||
// await G.prefs.setBool("isStickyKey", true);
|
||||
}
|
||||
|
||||
static Future<void> initData() async {
|
||||
@@ -528,7 +571,7 @@ done
|
||||
|
||||
//限制一天内观看视频广告不超过5次
|
||||
final String currentDate = DateFormat("yyyy-MM-dd").format(DateTime.now());
|
||||
if (currentDate != G.prefs.getString("lastDate")) {
|
||||
if (currentDate != (Util.getGlobal("lastDate") as String)) {
|
||||
await G.prefs.setString("lastDate", currentDate);
|
||||
await G.prefs.setInt("adsWatchedToday", 0);
|
||||
}
|
||||
@@ -537,12 +580,26 @@ done
|
||||
if (!G.prefs.containsKey("defaultContainer")) {
|
||||
await initForFirstTime();
|
||||
}
|
||||
G.currentContainer = G.prefs.getInt("defaultContainer")!;
|
||||
G.currentContainer = Util.getGlobal("defaultContainer") as int;
|
||||
|
||||
G.termFontScale = G.prefs.getDouble("termFontScale")!;
|
||||
G.termFontScale = Util.getGlobal("termFontScale") as double;
|
||||
|
||||
G.controller = WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
|
||||
//恢复临时开启的功能
|
||||
if (Util.shouldWatchAds(G.adsRequired["changeTermMaxLines"]!)) {
|
||||
await G.prefs.setInt("termMaxLines", 4095);
|
||||
}
|
||||
if (Util.shouldWatchAds(G.adsRequired["closeBannerAds"]!)) {
|
||||
await G.prefs.setBool("isBannerAdsClosed", false);
|
||||
}
|
||||
if (Util.shouldWatchAds(G.adsRequired["enableTerminalWrite"]!)) {
|
||||
await G.prefs.setBool("isTerminalWriteEnabled", false);
|
||||
}
|
||||
if (Util.shouldWatchAds(G.adsRequired["enableTerminalCommands"]!)) {
|
||||
await G.prefs.setBool("isTerminalCommandsEnabled", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Future<void> initTerminalForCurrent() async {
|
||||
@@ -577,7 +634,7 @@ export TMPDIR=\$PWD/cache
|
||||
cd \$DATA_DIR
|
||||
export HOME=\$DATA_DIR/share
|
||||
export LD_LIBRARY_PATH=\$DATA_DIR/bin
|
||||
\$DATA_DIR/busybox sed "s/4713/${G.prefs.getInt("defaultAudioPort")!}/g" \$DATA_DIR/bin/pulseaudio.conf > \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||
\$DATA_DIR/busybox sed "s/4713/${Util.getGlobal("defaultAudioPort") as int}/g" \$DATA_DIR/bin/pulseaudio.conf > \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||
\$DATA_DIR/bin/pulseaudio -F \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||
exit
|
||||
"""));
|
||||
@@ -595,7 +652,7 @@ export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
|
||||
export PROOT_LOADER=\$DATA_DIR/libexec/proot/loader
|
||||
export PROOT_LOADER_32=\$DATA_DIR/libexec/proot/loader32
|
||||
${Util.getCurrentProp("boot")}
|
||||
${G.prefs.getBool("autoLaunchVnc")!?Util.getCurrentProp("vnc"):""}
|
||||
${(Util.getGlobal("autoLaunchVnc") as bool)?Util.getCurrentProp("vnc"):""}
|
||||
clear""");
|
||||
}
|
||||
|
||||
@@ -646,7 +703,7 @@ clear""");
|
||||
await initTerminalForCurrent();
|
||||
setupAudio();
|
||||
launchCurrentContainer();
|
||||
if (G.prefs.getBool("autoLaunchVnc")!) {
|
||||
if (Util.getGlobal("autoLaunchVnc") as bool) {
|
||||
waitForConnection().then((value) => launchBrowser());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user