mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-20 16:35:47 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87beedef68 | ||
|
|
c6afc4d468 | ||
|
|
6dbe710fdc | ||
|
|
cf8ce47662 | ||
|
|
86ce2315d4 | ||
|
|
6e51e5b2d2 | ||
|
|
0971059111 | ||
|
|
2cf19179f9 | ||
|
|
b6d4d2f11b |
19
README.md
19
README.md
@@ -23,12 +23,15 @@ assets的文件来源如下:
|
||||
|
||||
- [proot](https://github.com/Cateners/proot), 使用[build-proot-android](https://github.com/green-green-avk/build-proot-android)脚本编译
|
||||
- [busybox](https://github.com/meefik/busybox)
|
||||
- [mediamtx相关](https://github.com/bluenviron/mediamtx)
|
||||
- [tar](https://github.com/Rprop/tar-android-static)
|
||||
- [Xserver XSDL, pulseaudio相关文件](https://github.com/pelya/commandergenius/tree/sdl_android/project/jni/application/xserver)
|
||||
- [Tmoe Linux, debian包来源](https://github.com/2moe/tmoe)
|
||||
|
||||
其中tar、busybox和pulseaudio相关文件都是直接用了二进制文件。
|
||||
|
||||
更多信息可以在[这里](extra/readme)找到。
|
||||
|
||||
对debian容器进行了如下修改:
|
||||
- 使用tmoe安装了xfce环境和全套VNC;
|
||||
- 使用kali-undercover提供的Win10主题美化xfce;
|
||||
@@ -39,6 +42,8 @@ assets的文件来源如下:
|
||||
- 启动时会尝试挂载手机的一些字体目录(AppFiles/Fonts、Fonts和/system/fonts), 如果这些目录下有字体文件的话会一并加载到系统中,无需额外安装;
|
||||
- 最后采用tar.xz压缩,用split命令分成了xa*等多个文件(低内存设备一次性拷贝大文件会导致软件闪退)。
|
||||
|
||||
完整的容器制作过程可以在[这里](extra/build-tiny-rootfs.md)看到。
|
||||
|
||||
数据包不再在assets中更新,而是随releases提供,主要是为了避免git越来越大
|
||||
|
||||
lib目录:
|
||||
@@ -50,6 +55,20 @@ lib目录:
|
||||
- G 全局变量类
|
||||
- Workflow 从软件点开到容器启动的所有步骤
|
||||
|
||||
## 编译
|
||||
|
||||
你需要配置好flutter和安卓sdk,然后克隆此项目。
|
||||
|
||||
在编译之前,需要在release中下载系统rootfs(或者[自行制作](extra/build-tiny-rootfs.md)),之后使用split命令分割,拷贝到assets。一般我将其分为98MB。
|
||||
|
||||
`split -b 98M debian.tar.xz`
|
||||
|
||||
然后修改workflow的代码,找到复制资源的部分,把生成的xa\*名字写进去(我还不知道怎么写代码识别有多少个xa*文件)
|
||||
|
||||
接下来就可以编译了。我使用的命令如下:
|
||||
|
||||
`flutter build apk --target-platform android-arm64 --split-per-abi --obfuscate --split-debug-info=tiny_computer/sdi`
|
||||
|
||||
## 目前已知bug
|
||||
|
||||
多用户/分身情形无法sudo, 其它见issue
|
||||
|
||||
@@ -38,6 +38,7 @@ android {
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
main.java.srcDirs += 'src/main/java'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
@@ -45,7 +46,7 @@ android {
|
||||
applicationId "com.fct.tiny"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
minSdkVersion 24 //ffmpeg_kit; flutter.minSdkVersion
|
||||
targetSdkVersion 28 //https://github.com/termux/termux-app/issues/1072; native; linker; flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<application
|
||||
android:label="小小电脑"
|
||||
android:name="${applicationName}"
|
||||
@@ -12,7 +15,7 @@
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:configChanges="navigation|orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
@@ -28,6 +31,16 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider
|
||||
android:name="com.example.tiny_computer.filepicker.TinyDocumentsProvider"
|
||||
android:authorities="com.example.tiny_computer.documents"
|
||||
android:exported="true"
|
||||
android:grantUriPermissions="true"
|
||||
android:permission="android.permission.MANAGE_DOCUMENTS">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
|
||||
</intent-filter>
|
||||
</provider>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.example.tiny_computer.filepicker;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.DocumentsContract.Document;
|
||||
import android.provider.DocumentsContract.Root;
|
||||
import android.provider.DocumentsProvider;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.example.tiny_computer.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
//This file is mainly copied from Termux :P
|
||||
|
||||
/**
|
||||
* A document provider for the Storage Access Framework which exposes the files in the
|
||||
* $HOME/ directory to other apps.
|
||||
* <p/>
|
||||
* Note that this replaces providing an activity matching the ACTION_GET_CONTENT intent:
|
||||
* <p/>
|
||||
* "A document provider and ACTION_GET_CONTENT should be considered mutually exclusive. If you
|
||||
* support both of them simultaneously, your app will appear twice in the system picker UI,
|
||||
* offering two different ways of accessing your stored data. This would be confusing for users."
|
||||
* - http://developer.android.com/guide/topics/providers/document-provider.html#43
|
||||
*/
|
||||
public class TinyDocumentsProvider extends DocumentsProvider {
|
||||
|
||||
private static final String ALL_MIME_TYPES = "*/*";
|
||||
|
||||
|
||||
|
||||
// The default columns to return information about a root if no specific
|
||||
// columns are requested in a query.
|
||||
private static final String[] DEFAULT_ROOT_PROJECTION = new String[]{
|
||||
Root.COLUMN_ROOT_ID,
|
||||
Root.COLUMN_MIME_TYPES,
|
||||
Root.COLUMN_FLAGS,
|
||||
Root.COLUMN_ICON,
|
||||
Root.COLUMN_TITLE,
|
||||
Root.COLUMN_SUMMARY,
|
||||
Root.COLUMN_DOCUMENT_ID,
|
||||
Root.COLUMN_AVAILABLE_BYTES
|
||||
};
|
||||
|
||||
// The default columns to return information about a document if no specific
|
||||
// columns are requested in a query.
|
||||
private static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[]{
|
||||
Document.COLUMN_DOCUMENT_ID,
|
||||
Document.COLUMN_MIME_TYPE,
|
||||
Document.COLUMN_DISPLAY_NAME,
|
||||
Document.COLUMN_LAST_MODIFIED,
|
||||
Document.COLUMN_FLAGS,
|
||||
Document.COLUMN_SIZE
|
||||
};
|
||||
|
||||
@Override
|
||||
public Cursor queryRoots(String[] projection) {
|
||||
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION);
|
||||
final String applicationName = "小小电脑";
|
||||
final File BASE_DIR = new File(getContext().getFilesDir(), "containers");
|
||||
final MatrixCursor.RowBuilder row = result.newRow();
|
||||
row.add(Root.COLUMN_ROOT_ID, getDocIdForFile(BASE_DIR));
|
||||
row.add(Root.COLUMN_DOCUMENT_ID, getDocIdForFile(BASE_DIR));
|
||||
row.add(Root.COLUMN_SUMMARY, null);
|
||||
row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_IS_CHILD);
|
||||
row.add(Root.COLUMN_TITLE, applicationName);
|
||||
row.add(Root.COLUMN_MIME_TYPES, ALL_MIME_TYPES);
|
||||
row.add(Root.COLUMN_AVAILABLE_BYTES, BASE_DIR.getFreeSpace());
|
||||
row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
|
||||
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
|
||||
includeFile(result, documentId, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException {
|
||||
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
|
||||
final File parent = getFileForDocId(parentDocumentId);
|
||||
for (File file : parent.listFiles()) {
|
||||
includeFile(result, null, file);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor openDocument(final String documentId, String mode, CancellationSignal signal) throws FileNotFoundException {
|
||||
final File file = getFileForDocId(documentId);
|
||||
final int accessMode = ParcelFileDescriptor.parseMode(mode);
|
||||
return ParcelFileDescriptor.open(file, accessMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssetFileDescriptor openDocumentThumbnail(String documentId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException {
|
||||
final File file = getFileForDocId(documentId);
|
||||
final ParcelFileDescriptor pfd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
return new AssetFileDescriptor(pfd, 0, file.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createDocument(String parentDocumentId, String mimeType, String displayName) throws FileNotFoundException {
|
||||
File newFile = new File(parentDocumentId, displayName);
|
||||
int noConflictId = 2;
|
||||
while (newFile.exists()) {
|
||||
newFile = new File(parentDocumentId, displayName + " (" + noConflictId++ + ")");
|
||||
}
|
||||
try {
|
||||
boolean succeeded;
|
||||
if (Document.MIME_TYPE_DIR.equals(mimeType)) {
|
||||
succeeded = newFile.mkdir();
|
||||
} else {
|
||||
succeeded = newFile.createNewFile();
|
||||
}
|
||||
if (!succeeded) {
|
||||
throw new FileNotFoundException("Failed to create document with id " + newFile.getPath());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new FileNotFoundException("Failed to create document with id " + newFile.getPath());
|
||||
}
|
||||
return newFile.getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDocument(String documentId) throws FileNotFoundException {
|
||||
File file = getFileForDocId(documentId);
|
||||
if (!file.delete()) {
|
||||
throw new FileNotFoundException("Failed to delete document with id " + documentId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDocumentType(String documentId) throws FileNotFoundException {
|
||||
File file = getFileForDocId(documentId);
|
||||
return getMimeType(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor querySearchDocuments(String rootId, String query, String[] projection) throws FileNotFoundException {
|
||||
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION);
|
||||
final File parent = getFileForDocId(rootId);
|
||||
|
||||
// This example implementation searches file names for the query and doesn't rank search
|
||||
// results, so we can stop as soon as we find a sufficient number of matches. Other
|
||||
// implementations might rank results and use other data about files, rather than the file
|
||||
// name, to produce a match.
|
||||
final LinkedList<File> pending = new LinkedList<>();
|
||||
pending.add(parent);
|
||||
|
||||
final int MAX_SEARCH_RESULTS = 50;
|
||||
while (!pending.isEmpty() && result.getCount() < MAX_SEARCH_RESULTS) {
|
||||
final File file = pending.removeFirst();
|
||||
// Avoid directories outside the $HOME directory linked with symlinks (to avoid e.g. search
|
||||
// through the whole SD card).
|
||||
boolean isInsideHome;
|
||||
try {
|
||||
isInsideHome = file.getCanonicalPath().startsWith(new File(getContext().getFilesDir(), "containers").getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
isInsideHome = true;
|
||||
}
|
||||
if (isInsideHome) {
|
||||
if (file.isDirectory()) {
|
||||
Collections.addAll(pending, file.listFiles());
|
||||
} else {
|
||||
if (file.getName().toLowerCase().contains(query)) {
|
||||
includeFile(result, null, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildDocument(String parentDocumentId, String documentId) {
|
||||
return documentId.startsWith(parentDocumentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document id given a file. This document id must be consistent across time as other
|
||||
* applications may save the ID and use it to reference documents later.
|
||||
* <p/>
|
||||
* The reverse of @{link #getFileForDocId}.
|
||||
*/
|
||||
private static String getDocIdForFile(File file) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file given a document id (the reverse of {@link #getDocIdForFile(File)}).
|
||||
*/
|
||||
private static File getFileForDocId(String docId) throws FileNotFoundException {
|
||||
final File f = new File(docId);
|
||||
if (!f.exists()) throw new FileNotFoundException(f.getAbsolutePath() + " not found");
|
||||
return f;
|
||||
}
|
||||
|
||||
private static String getMimeType(File file) {
|
||||
if (file.isDirectory()) {
|
||||
return Document.MIME_TYPE_DIR;
|
||||
} else {
|
||||
final String name = file.getName();
|
||||
final int lastDot = name.lastIndexOf('.');
|
||||
if (lastDot >= 0) {
|
||||
final String extension = name.substring(lastDot + 1).toLowerCase();
|
||||
final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
if (mime != null) return mime;
|
||||
}
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a representation of a file to a cursor.
|
||||
*
|
||||
* @param result the cursor to modify
|
||||
* @param docId the document ID representing the desired file (may be null if given file)
|
||||
* @param file the File object representing the desired file (may be null if given docID)
|
||||
*/
|
||||
private void includeFile(MatrixCursor result, String docId, File file)
|
||||
throws FileNotFoundException {
|
||||
if (docId == null) {
|
||||
docId = getDocIdForFile(file);
|
||||
} else {
|
||||
file = getFileForDocId(docId);
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if (file.isDirectory()) {
|
||||
if (file.canWrite()) flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
|
||||
} else if (file.canWrite()) {
|
||||
flags |= Document.FLAG_SUPPORTS_WRITE;
|
||||
}
|
||||
if (file.getParentFile().canWrite()) flags |= Document.FLAG_SUPPORTS_DELETE;
|
||||
|
||||
final String displayName = file.getName();
|
||||
final String mimeType = getMimeType(file);
|
||||
if (mimeType.startsWith("image/")) flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
|
||||
|
||||
final MatrixCursor.RowBuilder row = result.newRow();
|
||||
row.add(Document.COLUMN_DOCUMENT_ID, docId);
|
||||
row.add(Document.COLUMN_DISPLAY_NAME, displayName);
|
||||
row.add(Document.COLUMN_SIZE, file.length());
|
||||
row.add(Document.COLUMN_MIME_TYPE, mimeType);
|
||||
row.add(Document.COLUMN_LAST_MODIFIED, file.lastModified());
|
||||
row.add(Document.COLUMN_FLAGS, flags);
|
||||
row.add(Document.COLUMN_ICON, R.mipmap.ic_launcher);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
BIN
assets/patch.tar.gz
Normal file
BIN
assets/patch.tar.gz
Normal file
Binary file not shown.
196
extra/build-tiny-rootfs.md
Normal file
196
extra/build-tiny-rootfs.md
Normal file
@@ -0,0 +1,196 @@
|
||||
# build-tiny-rootfs
|
||||
对小小电脑项目rootfs制作的说明
|
||||
|
||||
### 为什么不直接制作一个脚本呢?
|
||||
|
||||
因为我不会,所以只能用自然语言记录一下制作步骤。
|
||||
|
||||
## 制作步骤
|
||||
|
||||
### 安装Debian容器
|
||||
|
||||
- 安装Termux
|
||||
- 在Termux内安装tmoe
|
||||
- 在tmoe内安装Debian Bookworm的proot容器
|
||||
- 是否新建sudo用户-是-用户名tiny-密码tiny
|
||||
- 是否设置tiny为默认用户-是
|
||||
- 是否为root配置zsh-否
|
||||
- 是否删除zsh.sh等-是
|
||||
- 是否启动tmoe tools-是
|
||||
- 其余对话框默认直接按回车
|
||||
- 来到tmoe tool界面时取消,退出
|
||||
|
||||
### 安装其他软件
|
||||
|
||||
安装xfce部分是根据记忆写的,如果有误请指出。
|
||||
|
||||
桌面环境只安装一个。
|
||||
|
||||
#### 安装桌面环境(lxqt)
|
||||
|
||||
- 输入debian-i进入tmoe tools
|
||||
- 图形界面-rootless-lxqt-core
|
||||
- 不安装electron apps
|
||||
- 不安装chromium
|
||||
|
||||
- 按需调整
|
||||
|
||||
#### 安装桌面环境(xfce)
|
||||
|
||||
前面的部分和lxqt一致,只是选桌面环境时选了xfce-lite。
|
||||
|
||||
下面是额外的美化部分。推荐先安装软件再做这个,因为使用kali-undercover时可能有依赖报错,但我忘记是哪些依赖了。但后面安装的某个软件会帮我们把依赖补上。
|
||||
|
||||
- xfce美化
|
||||
- 前往kali源下载kali-undercover包并apt install安装
|
||||
- 修改kali-undercover脚本中检测xfce环境的地方,强制允许
|
||||
- 即注释第一个if里的exit 1
|
||||
- 执行kali-undercover
|
||||
- 按需调整
|
||||
- 注释.bashrc中把bash风格改为windows风格的语句
|
||||
- 调整状态栏
|
||||
- ......
|
||||
|
||||
#### 安装VNC
|
||||
|
||||
安装桌面环境后会自动进行这一步,使用tmoe tools全部安装即可。
|
||||
|
||||
- 选择tigervnc
|
||||
- 密码12345678
|
||||
|
||||
安装完成后,输入debian-i回到tmoe继续修改一些参数,主要目的是避免与termux的容器端口一致产生冲突
|
||||
|
||||
- 修改显示端口到5904
|
||||
- 远程桌面-tigervnc-显示端口-4
|
||||
- 修改novnc端口到36082
|
||||
- 远程桌面-novnc-端口-36082
|
||||
- 修改startnovnc启动脚本(避免每次启动novnc时打开浏览器,虽然不是windows)
|
||||
- 注释start_win10_edge_novnc_addr(大概在倒数第五行)
|
||||
|
||||
接下来对novnc应用补丁,以添加"通过滑块修改分辨率"等功能
|
||||
|
||||
- [下载novnc.patch](https://github.com/Cateners/noVNC/releases/tag/1.2)
|
||||
- 切换目录到/usr/local/etc/tmoe-linux/novnc
|
||||
- `patch -p1 < novnc.patch`
|
||||
- ```bash
|
||||
find . '(' \
|
||||
-name \*-baseline -o \
|
||||
-name \*-merge -o \
|
||||
-name \*-original -o \
|
||||
-name \*.orig -o \
|
||||
-name \*.rej \
|
||||
')' -delete
|
||||
```
|
||||
|
||||
|
||||
#### 修复tmoe不能下载软件
|
||||
|
||||
在我发布的xfce版本中,我给每个aria2c调用都添加了--async-dns=false参数。
|
||||
|
||||
先切换到tmoe目录`/usr/local/etc/tmoe-linux/git/share`,然后执行脚本`./replace.sh old-version`:
|
||||
```shell
|
||||
#!/bin/bash
|
||||
# 用法: ./replace.sh 目录
|
||||
# 该脚本会递归地在给定目录下的所有文件中替换文本
|
||||
# 原文本: aria2c --console-log-level
|
||||
# 新文本: aria2c --async-dns=false --console-log-level
|
||||
|
||||
# 检查参数是否正确
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "错误: 需要一个目录作为参数"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查目录是否存在
|
||||
if [ ! -d "$1" ]; then
|
||||
echo "错误: 目录 $1 不存在"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 遍历目录下的所有文件
|
||||
find "$1" -type f | while read file; do
|
||||
# 使用sed命令替换文本
|
||||
sed -i 's/aria2c --console-log-level/aria2c --async-dns=false --console-log-level/g' "$file"
|
||||
echo
|
||||
done
|
||||
```
|
||||
|
||||
用完后删除replace.sh;
|
||||
|
||||
另外现在tmoe官方给出了[解决办法](https://gitee.com/mo2/linux/issues/I8BQG3),不过我测试似乎还是不行,所以就先这样了
|
||||
|
||||
#### 修改apt源
|
||||
|
||||
按需修改/etc/apt/sources.list,另外把non-free改为non-free-firmware
|
||||
|
||||
#### 安装火狐浏览器
|
||||
|
||||
`sudo apt install firefox-esr firefox-esr-l10n-zh-cn`
|
||||
|
||||
#### 安装输入法
|
||||
|
||||
- debian-i
|
||||
- 03秘密花园-10输入法-fcitx4-安装4libpinyin和6云拼音模块
|
||||
- 在图形界面应用找到fcitx配置-附加组件-云拼音-配置-云拼音来源,把Google改为百度,确认
|
||||
- 启动图形界面:输入startnovnc,会出现一个类似xxx.xxx.xxx.xxx:36082/vnc.html的网址,复制到本机的浏览器中输入vnc密码12345678就可以访问了。
|
||||
|
||||
#### 安装gdebi
|
||||
|
||||
这个软件包能使用户通过图形界面安装deb安装包
|
||||
|
||||
安装:`sudo apt install gdebi`
|
||||
|
||||
修改启动器:在/usr/share/applications/gdebi.desktop的Exec=后加上sudo
|
||||
|
||||
#### 安装VSCode
|
||||
|
||||
VSCode使用tmoe安装,正好测试一下不能下载软件的问题是否存在
|
||||
|
||||
- 2软件-2开发-1VSCode-1Official
|
||||
|
||||
tmoe还会安装gnome-keyring,由于之前我做xfce包时会造成VSCode反复弹窗更新密钥环所以被我卸载了,这个按需决定是否保留吧
|
||||
|
||||
#### 安装ffmpeg
|
||||
|
||||
这个是为了预览推流用的,按需安装
|
||||
|
||||
`sudo apt install ffmpeg`
|
||||
|
||||
### 其他修补
|
||||
|
||||
#### cmatrix
|
||||
|
||||
这个是给快捷指令的彩蛋。下载cmatrix的包,并将cmatrix文件提取放到/home/tiny/.local/bin里即可,记得添加执行权限
|
||||
|
||||
#### WPS
|
||||
|
||||
- 软件设置修改
|
||||
- 从官网下载WPS linux arm64 deb安装包,直接在图形界面点开用gdebi安装(正好测试一下gdebi是否能用)
|
||||
- 打开WPS-右上角设置-其他-切换窗口管理模式-整合模式改为多组件模式(否则一些设备在新建文档等操作时卡死,目前原因不明)
|
||||
- 使用gdebi(或自行)卸载WPS
|
||||
- 字体修补
|
||||
- 在你的Windows电脑里的C:\Windows\Fonts文件夹找到symbol.ttf、webdings.ttf、wingding.ttf、WINGDNG2.TTF、WINGDNG3.TTF、MTEXTRA.TTF字体并放到容器/usr/share/fonts的某个文件夹下(我新建了extra文件夹并把这些字体放到里面)
|
||||
- libtiff.so.5库修补
|
||||
- 切换到/lib/aarch64-linux-gnu文件夹,创建软链把libtiff.so.6链接到libtiff.so.5
|
||||
- 或者找libtiff.so.5的包并安装,这样可能更好一些
|
||||
|
||||
### 打包
|
||||
|
||||
- 首先退出容器,在容器挂载选项里取消对sd和termux的挂载,之后进入容器删除termux软连接
|
||||
- 在后面使用tar打包时,即使指定了exclude,tar也会尝试把它们打包进去
|
||||
- 这个很可能因为我自己没用对参数,如果你非常自信的话就不需要这么做,自行打包即可=v=
|
||||
- 在[这里](https://github.com/meefik/busybox/releases)下载提取busybox的可执行文件,并放到系统根目录
|
||||
- 我使用busybox的tar来打包,而不是容器自带的tar,原因是容器自带的tar会把硬链接打包成单独的文件,导致打包解包后占用多出1GB
|
||||
- 这个也很可能是我自己没用对参数,如果你非常自信就不用这么做......
|
||||
- 尽可能多地删除使用痕迹,包括但不限于
|
||||
- apt clean
|
||||
- /tmp下的文件,退出容器后删
|
||||
- tiny和root目录下的
|
||||
- .cache
|
||||
- .vnc/vnc.log, .vnc/x.log
|
||||
- .bash_history
|
||||
- .ICEauthority
|
||||
- .Xauthority
|
||||
- 等等
|
||||
- 切换到root用户,切换到根目录,`/busybox tar -Jcpvf /debian.tar.xz --exclude=debian.tar.xz --exclude=dev --exclude=proc --exclude=system --exclude=storage --exclude=apex --exclude=sys --exclude=media/sd --exclude=busybox --exclude=".l2s.*" /`
|
||||
|
||||
243
extra/getifaddrs_bridge/getifaddrs_bridge_client_lib.c
Normal file
243
extra/getifaddrs_bridge/getifaddrs_bridge_client_lib.c
Normal file
@@ -0,0 +1,243 @@
|
||||
// getifaddrs_bridge_client_lib.c -- This file is part of tiny_computer.
|
||||
|
||||
// Copyright (C) 2023 Caten Hu
|
||||
|
||||
// Tiny Computer is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License,
|
||||
// or any later version.
|
||||
|
||||
// Tiny Computer is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
/* this file is mainly generated by Bing */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#define BUFSIZE 1024 // 定义缓冲区大小
|
||||
|
||||
// 定义一个反序列化函数,将字节数组转换为ifaddrs结构体
|
||||
int TINY_deserialize_ifaddrs(char *buf, int size, struct ifaddrs **ifap) {
|
||||
int len = 0; // 记录已经读取的字节数
|
||||
struct ifaddrs *head = NULL; // 链表头指针
|
||||
struct ifaddrs *tail = NULL; // 链表尾指针
|
||||
while (len < size) {
|
||||
// 为当前接口分配内存
|
||||
struct ifaddrs *ifa = (struct ifaddrs *)malloc(sizeof(struct ifaddrs));
|
||||
if (ifa == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
// 读取接口名称
|
||||
int namelen = strlen(buf + len) + 1; // 包括结束符
|
||||
if (len + namelen > size) break; // 缓冲区不足
|
||||
ifa->ifa_name = (char *)malloc(namelen); // 为名称分配内存
|
||||
if (ifa->ifa_name == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
free(ifa);
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
memcpy(ifa->ifa_name, buf + len, namelen); // 复制名称
|
||||
len += namelen;
|
||||
// 读取接口标志
|
||||
if (len + sizeof(unsigned int) > size) break; // 缓冲区不足
|
||||
memcpy(&ifa->ifa_flags, buf + len, sizeof(unsigned int)); // 复制标志
|
||||
len += sizeof(unsigned int);
|
||||
// 读取接口地址
|
||||
if (buf[len] != '\0') {
|
||||
// 如果有地址
|
||||
int addrlen = sizeof(struct sockaddr); // 地址结构体长度
|
||||
if (len + addrlen > size) break; // 缓冲区不足
|
||||
ifa->ifa_addr = (struct sockaddr *)malloc(addrlen); // 为地址分配内存
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
free(ifa->ifa_name);
|
||||
free(ifa);
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
memcpy(ifa->ifa_addr, buf + len, addrlen); // 复制地址
|
||||
len += addrlen;
|
||||
} else {
|
||||
// 如果没有地址,跳过一个空字节
|
||||
ifa->ifa_addr = NULL;
|
||||
len += 1;
|
||||
}
|
||||
// 读取接口掩码
|
||||
if (buf[len] != '\0') {
|
||||
// 如果有掩码
|
||||
int masklen = sizeof(struct sockaddr); // 掩码结构体长度
|
||||
if (len + masklen > size) break; // 缓冲区不足
|
||||
ifa->ifa_netmask = (struct sockaddr *)malloc(masklen); // 为掩码分配内存
|
||||
if (ifa->ifa_netmask == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
free(ifa->ifa_addr);
|
||||
free(ifa->ifa_name);
|
||||
free(ifa);
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
memcpy(ifa->ifa_netmask, buf + len, masklen); // 复制
|
||||
len += masklen;
|
||||
} else {
|
||||
// 如果没有掩码,跳过一个空字节
|
||||
ifa->ifa_netmask = NULL;
|
||||
len += 1;
|
||||
}
|
||||
// 读取接口广播地址或点对点地址
|
||||
if (ifa->ifa_flags & IFF_BROADCAST) {
|
||||
// 如果有广播地址
|
||||
if (buf[len] != '\0') {
|
||||
// 如果有广播地址
|
||||
int broadlen = sizeof(struct sockaddr); // 广播地址结构体长度
|
||||
if (len + broadlen > size) break; // 缓冲区不足
|
||||
ifa->ifa_broadaddr = (struct sockaddr *)malloc(broadlen); // 为广播地址分配内存
|
||||
if (ifa->ifa_broadaddr == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
free(ifa->ifa_netmask);
|
||||
free(ifa->ifa_addr);
|
||||
free(ifa->ifa_name);
|
||||
free(ifa);
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
memcpy(ifa->ifa_broadaddr, buf + len, broadlen); // 复制广播地址
|
||||
len += broadlen;
|
||||
} else {
|
||||
// 如果没有广播地址,跳过一个空字节
|
||||
ifa->ifa_broadaddr = NULL;
|
||||
len += 1;
|
||||
}
|
||||
} else if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||
// 如果有点对点地址
|
||||
if (buf[len] != '\0') {
|
||||
// 如果有点对点地址
|
||||
int dstlen = sizeof(struct sockaddr); // 点对点地址结构体长度
|
||||
if (len + dstlen > size) break; // 缓冲区不足
|
||||
ifa->ifa_dstaddr = (struct sockaddr *)malloc(dstlen); // 为点对点地址分配内存
|
||||
if (ifa->ifa_dstaddr == NULL) {
|
||||
// 分配失败,释放已分配的内存
|
||||
free(ifa->ifa_netmask);
|
||||
free(ifa->ifa_addr);
|
||||
free(ifa->ifa_name);
|
||||
free(ifa);
|
||||
freeifaddrs(head);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
memcpy(ifa->ifa_dstaddr, buf + len, dstlen); // 复制点对点地址
|
||||
len += dstlen;
|
||||
} else {
|
||||
// 如果没有点对点地址,跳过一个空字节
|
||||
ifa->ifa_dstaddr = NULL;
|
||||
len += 1;
|
||||
}
|
||||
} else {
|
||||
// 如果没有广播地址或点对点地址,跳过两个空字节
|
||||
ifa->ifa_broadaddr = NULL;
|
||||
ifa->ifa_dstaddr = NULL;
|
||||
len += 2;
|
||||
}
|
||||
// 读取接口数据
|
||||
if (buf[len] != '\0') {
|
||||
// 如果有数据
|
||||
// TODO: 根据不同的地址族,读取不同的数据
|
||||
// 这里暂时省略,只跳过一个空字节
|
||||
ifa->ifa_data = NULL;
|
||||
len += 1;
|
||||
} else {
|
||||
// 如果没有数据,跳过一个空字节
|
||||
ifa->ifa_data = NULL;
|
||||
len += 1;
|
||||
}
|
||||
// 将当前接口插入链表
|
||||
ifa->ifa_next = NULL;
|
||||
if (head == NULL) {
|
||||
// 如果是第一个接口,设置头指针
|
||||
head = ifa;
|
||||
} else {
|
||||
// 如果不是第一个接口,设置尾指针的下一个指针
|
||||
tail->ifa_next = ifa;
|
||||
}
|
||||
// 更新尾指针
|
||||
tail = ifa;
|
||||
}
|
||||
*ifap = head; // 返回链表头指针
|
||||
return len; // 返回读取的总字节数
|
||||
}
|
||||
|
||||
// 定义一个发送信号的函数,向服务器发送一个信号
|
||||
int TINY_send_signal(int sockfd) {
|
||||
char sig = 'S'; // 定义信号为一个字符S
|
||||
int n = write(sockfd, &sig, 1); // 向套接字写入一个字节
|
||||
if (n < 0) {
|
||||
perror("write");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
return 0; // 返回成功
|
||||
}
|
||||
|
||||
// 定义一个接收数据的函数,从服务器接收数据并反序列化
|
||||
int TINY_receive_data(int sockfd, struct ifaddrs **ifap) {
|
||||
char buf[BUFSIZE]; // 定义缓冲区
|
||||
int n = read(sockfd, buf, BUFSIZE); // 从套接字读取数据
|
||||
if (n < 0) {
|
||||
perror("read");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
int len = TINY_deserialize_ifaddrs(buf, n, ifap); // 反序列化数据
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "deserialize_ifaddrs failed\n");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
return 0; // 返回成功
|
||||
}
|
||||
|
||||
// 主函数
|
||||
int getifaddrs(struct ifaddrs **ifap) {
|
||||
// 创建一个套接字
|
||||
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
// 定义服务器地址结构体
|
||||
struct sockaddr_un un;
|
||||
memset(&un, 0, sizeof(un));
|
||||
un.sun_family = AF_UNIX;
|
||||
snprintf(un.sun_path, sizeof(un.sun_path), "%s", "/tmp/.getifaddrs-bridge");
|
||||
// 连接到服务器
|
||||
if (connect(sockfd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
||||
perror("connect");
|
||||
exit(1);
|
||||
}
|
||||
// 发送信号给服务器
|
||||
if (TINY_send_signal(sockfd) < 0) {
|
||||
fprintf(stderr, "send_signal failed\n");
|
||||
exit(1);
|
||||
}
|
||||
// 接收数据并反序列化
|
||||
if (TINY_receive_data(sockfd, ifap) < 0) {
|
||||
fprintf(stderr, "receive_data failed\n");
|
||||
exit(1);
|
||||
}
|
||||
// 关闭套接字
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
222
extra/getifaddrs_bridge/getifaddrs_bridge_server.c
Normal file
222
extra/getifaddrs_bridge/getifaddrs_bridge_server.c
Normal file
@@ -0,0 +1,222 @@
|
||||
// getifaddrs_bridge_server.c -- This file is part of tiny_computer.
|
||||
|
||||
// Copyright (C) 2023 Caten Hu
|
||||
|
||||
// Tiny Computer is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation, either version 3 of the License,
|
||||
// or any later version.
|
||||
|
||||
// Tiny Computer is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
/* this file is mainly generated by Bing */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#define BUFSIZE 1024 // 定义缓冲区大小
|
||||
|
||||
// 定义一个序列化函数,将ifaddrs结构体转换为字节数组
|
||||
int serialize_ifaddrs(struct ifaddrs *ifa, char *buf, int size) {
|
||||
int len = 0; // 记录已经写入的字节数
|
||||
while (ifa != NULL && len < size) {
|
||||
// 写入接口名称
|
||||
int namelen = strlen(ifa->ifa_name) + 1; // 包括结束符
|
||||
if (len + namelen > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, ifa->ifa_name, namelen);
|
||||
len += namelen;
|
||||
// 写入接口标志
|
||||
if (len + sizeof(unsigned int) > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, &ifa->ifa_flags, sizeof(unsigned int));
|
||||
len += sizeof(unsigned int);
|
||||
// 写入接口地址
|
||||
if (ifa->ifa_addr != NULL) {
|
||||
int addrlen = sizeof(struct sockaddr); // 地址结构体长度
|
||||
if (len + addrlen > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, ifa->ifa_addr, addrlen);
|
||||
len += addrlen;
|
||||
} else {
|
||||
// 如果没有地址,写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
}
|
||||
// 写入接口掩码
|
||||
if (ifa->ifa_netmask != NULL) {
|
||||
int masklen = sizeof(struct sockaddr); // 掩码结构体长度
|
||||
if (len + masklen > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, ifa->ifa_netmask, masklen);
|
||||
len += masklen;
|
||||
} else {
|
||||
// 如果没有掩码,写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
}
|
||||
// 写入接口广播地址或点对点地址
|
||||
if (ifa->ifa_flags & IFF_BROADCAST) {
|
||||
// 如果有广播地址
|
||||
if (ifa->ifa_broadaddr != NULL) {
|
||||
int broadlen = sizeof(struct sockaddr); // 广播地址结构体长度
|
||||
if (len + broadlen > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, ifa->ifa_broadaddr, broadlen);
|
||||
len += broadlen;
|
||||
} else {
|
||||
// 如果没有广播地址,写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
}
|
||||
} else if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||
// 如果有点对点地址
|
||||
if (ifa->ifa_dstaddr != NULL) {
|
||||
int dstlen = sizeof(struct sockaddr); // 点对点地址结构体长度
|
||||
if (len + dstlen > size) break; // 缓冲区不足
|
||||
memcpy(buf + len, ifa->ifa_dstaddr, dstlen);
|
||||
len += dstlen;
|
||||
} else {
|
||||
// 如果没有点对点地址,写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
}
|
||||
} else {
|
||||
// 如果没有广播地址或点对点地址,写入两个空字节
|
||||
if (len + 2 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
buf[len + 1] = '\0';
|
||||
len += 2;
|
||||
}
|
||||
// 写入接口数据
|
||||
if (ifa->ifa_data != NULL) {
|
||||
// TODO: 根据不同的地址族,写入不同的数据
|
||||
// 这里暂时省略,只写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
} else {
|
||||
// 如果没有数据,写入一个空字节
|
||||
if (len + 1 > size) break; // 缓冲区不足
|
||||
buf[len] = '\0';
|
||||
len += 1;
|
||||
}
|
||||
// 跳到下一个接口
|
||||
ifa = ifa->ifa_next;
|
||||
}
|
||||
return len; // 返回写入的总字节数
|
||||
}
|
||||
|
||||
// 定义一个接收信号的函数,从客户端接收一个信号
|
||||
int receive_signal(int sockfd) {
|
||||
char sig; // 定义信号变量
|
||||
int n = read(sockfd, &sig, 1); // 从套接字读取一个字节
|
||||
if (n < 0) {
|
||||
perror("read");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
if (sig == 'S') {
|
||||
// 如果收到信号S,表示客户端需要数据
|
||||
return 0; // 返回成功
|
||||
} else {
|
||||
// 如果收到其他信号,表示无效信号
|
||||
fprintf(stderr, "invalid signal: %c\n", sig);
|
||||
return -1; // 返回错误
|
||||
}
|
||||
}
|
||||
|
||||
// 定义一个发送数据的函数,向客户端发送数据并序列化
|
||||
int send_data(int sockfd) {
|
||||
struct ifaddrs *ifap = NULL; // 定义ifaddrs结构体指针
|
||||
// 调用getifaddrs函数,获取本地接口信息
|
||||
if (getifaddrs(&ifap) < 0) {
|
||||
perror("getifaddrs");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
char buf[BUFSIZE]; // 定义缓冲区
|
||||
// 调用序列化函数,将ifaddrs结构体转换为字节数组
|
||||
int len = serialize_ifaddrs(ifap, buf, BUFSIZE);
|
||||
if (len < 0) {
|
||||
fprintf(stderr, "serialize_ifaddrs failed\n");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
// 向套接字写入数据
|
||||
int n = write(sockfd, buf, len);
|
||||
if (n < 0) {
|
||||
perror("write");
|
||||
return -1; // 返回错误
|
||||
}
|
||||
// 释放ifaddrs结构体
|
||||
freeifaddrs(ifap);
|
||||
return 0; // 返回成功
|
||||
}
|
||||
|
||||
// 主函数
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <socket_path>\n", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
// 创建一个套接字
|
||||
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
perror("socket");
|
||||
exit(1);
|
||||
}
|
||||
// 定义服务器地址结构体
|
||||
struct sockaddr_un un;
|
||||
memset(&un, 0, sizeof(un));
|
||||
un.sun_family = AF_UNIX;
|
||||
snprintf(un.sun_path, sizeof(un.sun_path), "%s", argv[1]);
|
||||
unlink(un.sun_path);
|
||||
// 绑定套接字到服务器地址
|
||||
if (bind(sockfd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
||||
perror("bind");
|
||||
exit(1);
|
||||
}
|
||||
// 监听套接字
|
||||
if (listen(sockfd, 5) < 0) {
|
||||
perror("listen");
|
||||
exit(1);
|
||||
}
|
||||
// 循环接受客户端连接
|
||||
while (1) {
|
||||
int connfd = accept(sockfd, NULL, NULL);
|
||||
if (connfd < 0) {
|
||||
perror("accept");
|
||||
continue; // 如果接受失败,继续循环
|
||||
}
|
||||
// 循环接收和发送数据
|
||||
while (1) {
|
||||
// 接收信号
|
||||
if (receive_signal(connfd) < 0) {
|
||||
fprintf(stderr, "receive_signal failed\n");
|
||||
close(connfd); // 如果接收失败,关闭连接套接字
|
||||
break; // 跳出循环
|
||||
}
|
||||
// 发送数据
|
||||
if (send_data(connfd) < 0) {
|
||||
fprintf(stderr, "send_data failed\n");
|
||||
close(connfd); // 如果发送失败,关闭连接套接字
|
||||
break; // 跳出循环
|
||||
}
|
||||
}
|
||||
}
|
||||
// 关闭监听套接字
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
19
extra/getifaddrs_bridge/readme
Normal file
19
extra/getifaddrs_bridge/readme
Normal file
@@ -0,0 +1,19 @@
|
||||
### 编译
|
||||
|
||||
使用NDK编译getifaddrs_bridge_server.c:
|
||||
|
||||
`aarch64-linux-android-clang getifaddrs_bridge_server.c -o getifaddrs_bridge_server`
|
||||
|
||||
在小小电脑上编译getifaddrs_bridge_client_lib.c:
|
||||
|
||||
`gcc getifaddrs_bridge_client_lib.c -o getifaddrs_bridge_client_lib.so -shared`
|
||||
|
||||
### 使用
|
||||
|
||||
在安卓端:
|
||||
|
||||
`getifaddrs_bridge_server /path/to/container/tmp/.getifaddrs-bridge`
|
||||
|
||||
在proot容器:
|
||||
|
||||
`LD_PRELOAD=/path/to/getifaddrs_bridge_client_lib.so <your_program>`
|
||||
24
extra/readme
Normal file
24
extra/readme
Normal file
@@ -0,0 +1,24 @@
|
||||
## 这个readme介绍assets文件夹中文件的制作方式。
|
||||
|
||||
### assets.zip中的文件:
|
||||
|
||||
#### [容器文件xa*](build-tiny-rootfs.md)
|
||||
|
||||
### patch.tar.gz中的文件:
|
||||
|
||||
#### extra/getifaddrs_bridge_client_lib.so:
|
||||
|
||||
在安卓13以上的系统中,proot容器无权使用默认的getifaddrs,而这个库包含了一个getifaddrs实现。
|
||||
|
||||
linux在需要数据时,使用socket通知位于安卓的getifaddrs_bridge_server,让getifaddrs_bridge_server执行getifaddrs函数,并将结构体数据序列化后发送回linux端,这边接收数据并反序列化还原成指针结构体。简单来说就是用安卓的getifaddrs代替linux的getifaddrs。
|
||||
|
||||
源码和编译信息在getifaddrs_bridge文件夹查看。
|
||||
|
||||
#### caj, edraw
|
||||
|
||||
这些分别是cajviewer,亿图图示的补丁
|
||||
|
||||
- 亿图图示补丁的库文件是在小小电脑上下载了Qt对应版本源码后编译得到的;
|
||||
- 编译进行了两次,第一次直接编译,可以得到Gui和Widgets两个库。第二次编译带上XcbQpa,虽然会编译失败,但在这之前就可以得到XcbQpa的库。
|
||||
|
||||
|
||||
1021
lib/main.dart
1021
lib/main.dart
File diff suppressed because it is too large
Load Diff
@@ -56,28 +56,84 @@ class Util {
|
||||
Directory.fromRawPath(const Utf8Encoder().convert(dir)).createSync(recursive: true);
|
||||
}
|
||||
|
||||
static Future<void> execute(String str) async {
|
||||
static Future<int> execute(String str) async {
|
||||
Pty pty = Pty.start(
|
||||
"/system/bin/sh"
|
||||
);
|
||||
pty.write(const Utf8Encoder().convert("$str\nexit\n"));
|
||||
await pty.exitCode;
|
||||
pty.write(const Utf8Encoder().convert("$str\nexit \$!\n"));
|
||||
return await pty.exitCode;
|
||||
}
|
||||
|
||||
static void termWrite(String str) {
|
||||
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 默认推流命令
|
||||
//String defaultVirglCommand 默认virgl参数
|
||||
//String defaultVirglOpt 默认virgl环境变量
|
||||
//bool reinstallBootstrap = false 下次启动是否重装引导包
|
||||
//bool getifaddrsBridge = false 下次启动是否桥接getifaddrsBridge
|
||||
//bool virgl = false 下次启动是否启用virgl
|
||||
//? int bootstrapVersion: 启动包版本
|
||||
//String[] containersInfo: 所有容器信息(json)
|
||||
//{name, boot:"\$DATA_DIR/bin/proot ...", vnc:"startnovnc", vncUrl:"...", commands:[{name:"更新和升级", command:"apt update -y && apt upgrade -y"},
|
||||
// bind:[{name:"U盘", src:"/storage/xxxx", dst:"/media/meow"}]...]}
|
||||
//String[] adsBonus: 观看广告获取的奖励(json)
|
||||
//{name: "xxx", amount: xxx}
|
||||
//TODO: 这么写还是不对劲,有空改成类试试?
|
||||
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 "reinstallBootstrap" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
case "getifaddrsBridge" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
case "virgl" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||
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 -camera_index 0 -i 0:0 -vf scale=iw/2:-1 -rtsp_transport udp -f rtsp rtsp://127.0.0.1:8554/stream");
|
||||
case "defaultVirglCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("--socket-path=\$CONTAINER_DIR/tmp/.virgl_test");
|
||||
case "defaultVirglOpt" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0");
|
||||
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))]
|
||||
)
|
||||
);
|
||||
@@ -86,29 +142,29 @@ class Util {
|
||||
//返回单个G.bonusTable定义的item
|
||||
static Map<String, dynamic> getRandomBonus() {
|
||||
final random = Random();
|
||||
final totalWeight = G.bonusTable.fold(0.0, (sum, item) => sum + item['weight']);
|
||||
final totalWeight = D.bonusTable.fold(0.0, (sum, item) => sum + item['weight']);
|
||||
final randomIndex = random.nextDouble() * totalWeight;
|
||||
var cumulativeWeight = 0.0;
|
||||
for (final item in G.bonusTable) {
|
||||
for (final item in D.bonusTable) {
|
||||
cumulativeWeight += item['weight'];
|
||||
if (randomIndex <= cumulativeWeight) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return G.bonusTable[0];
|
||||
return D.bonusTable[0];
|
||||
}
|
||||
|
||||
//由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 +173,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) < D.adsRequired["unlockToday"]!) && (G.adsWatchedThisTime < D.adsRequired["unlockOnce"]!);
|
||||
}
|
||||
|
||||
//限定字符串在min和max之间, 给文本框的validator
|
||||
@@ -184,9 +240,8 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
shift: event.shift || _shift,
|
||||
alt: event.alt || _alt,
|
||||
));
|
||||
G.maybeCtrlJ = event.key.name == "keyJ";
|
||||
print(G.maybeCtrlJ);
|
||||
if (!G.prefs.getBool("isStickyKey")!) {
|
||||
G.maybeCtrlJ = event.key.name == "keyJ"; //这个是为了稍后区分按键到底是Enter还是Ctrl+J
|
||||
if (!(Util.getGlobal("isStickyKey") as bool)) {
|
||||
G.keyboard.ctrl = false;
|
||||
G.keyboard.shift = false;
|
||||
G.keyboard.alt = false;
|
||||
@@ -201,7 +256,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,
|
||||
@@ -222,6 +277,7 @@ class TermPty {
|
||||
Navigator.push(G.homePageStateContext, MaterialPageRoute(builder: (context) {
|
||||
const TextStyle ts = TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.normal);
|
||||
const String helperLink = "https://www.vmos.cn/zhushou.htm";
|
||||
const String helperLink2 = "https://b23.tv/WwqOqW6";
|
||||
return Scaffold(backgroundColor: Colors.deepPurple,
|
||||
body: Center(
|
||||
child: Scrollbar(child:
|
||||
@@ -240,7 +296,18 @@ class TermPty {
|
||||
},))
|
||||
);
|
||||
});
|
||||
}, child: const Text("复制", style: ts, textAlign: TextAlign.center))
|
||||
}, child: const Text("复制", style: ts, textAlign: TextAlign.center)),
|
||||
const Text("如果不能解决请参考此教程: ", style: ts, textAlign: TextAlign.center),
|
||||
OutlinedButton(onPressed: () {
|
||||
FlutterClipboard.copy(helperLink2).then(( value ) {
|
||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: const Text("已复制"), action: SnackBarAction(label: "跳转", onPressed: () {
|
||||
launchUrl(Uri.parse(helperLink2), mode: LaunchMode.externalApplication);
|
||||
},))
|
||||
);
|
||||
});
|
||||
}, child: const Text("查看", style: ts, textAlign: TextAlign.center))
|
||||
]),
|
||||
)
|
||||
)
|
||||
@@ -249,7 +316,7 @@ class TermPty {
|
||||
}
|
||||
});
|
||||
terminal.onOutput = (data) {
|
||||
if (!G.prefs.getBool("isTerminalWriteEnabled")!) {
|
||||
if (!(Util.getGlobal("isTerminalWriteEnabled") as bool)) {
|
||||
return;
|
||||
}
|
||||
//由于对回车的处理似乎存在问题,所以拿出来单独处理
|
||||
@@ -269,19 +336,59 @@ class TermPty {
|
||||
|
||||
}
|
||||
|
||||
// Global variables
|
||||
class G {
|
||||
static late final String dataPath;
|
||||
static Pty? audioPty;
|
||||
static late WebViewController controller;
|
||||
static late BuildContext homePageStateContext;
|
||||
static late int currentContainer; //目前运行第几个容器
|
||||
static late Map<int, TermPty> termPtys; //为容器<int>存放TermPty数据
|
||||
static late AdManager ads; //广告实例
|
||||
static late VirtualKeyboard keyboard; //存储ctrl, shift, alt状态
|
||||
static bool maybeCtrlJ = false; //为了区分按下的ctrl+J和enter而准备的变量
|
||||
static double termFontScale = 1; //终端字体大小,存储为G.prefs的termFontScale
|
||||
//default values
|
||||
class D {
|
||||
//默认快捷指令
|
||||
static const commands = [{"name":"检查更新并升级", "command":"sudo apt update && sudo apt upgrade -y"},
|
||||
{"name":"查看系统信息", "command":"neofetch -L && neofetch --off"},
|
||||
{"name":"清屏", "command":"clear"},
|
||||
{"name":"安装图形处理软件Krita", "command":"sudo apt update && sudo apt install -y krita krita-l10n"},
|
||||
{"name":"卸载图形处理软件Krita", "command":"sudo apt autoremove --purge -y krita krita-l10n"},
|
||||
{"name":"安装视频剪辑软件Kdenlive", "command":"sudo apt update && sudo apt install -y kdenlive"},
|
||||
{"name":"卸载视频剪辑软件Kdenlive", "command":"sudo apt autoremove --purge -y kdenlive"},
|
||||
{"name":"安装科学计算软件Octave", "command":"sudo apt update && sudo apt install -y octave"},
|
||||
{"name":"卸载科学计算软件Octave", "command":"sudo apt autoremove --purge -y octave"},
|
||||
{"name":"安装WPS", "command":"wget https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/11708/wps-office_11.1.0.11708_arm64.deb -O /tmp/wps.deb && sudo apt update && sudo apt install -y /tmp/wps.deb; rm /tmp/wps.deb"},
|
||||
{"name":"卸载WPS", "command":"sudo apt autoremove --purge -y wps-office"},
|
||||
{"name":"安装CAJViewer", "command":"wget https://download.cnki.net/net.cnki.cajviewer_1.3.20-1_arm64.deb -O /tmp/caj.deb && sudo apt update && sudo apt install -y /tmp/caj.deb && bash /home/tiny/.local/share/tiny/caj/postinst; rm /tmp/caj.deb"},
|
||||
{"name":"卸载CAJViewer", "command":"sudo apt autoremove --purge -y net.cnki.cajviewer && bash /home/tiny/.local/share/tiny/caj/postrm"},
|
||||
{"name":"安装亿图图示", "command":"wget https://www.edrawsoft.cn/2download/aarch64/edrawmax_11.5.6-3_arm64.deb -O /tmp/edraw.deb && sudo apt update && sudo apt install -y /tmp/edraw.deb && bash /home/tiny/.local/share/tiny/edraw/postinst; rm /tmp/edraw.deb"},
|
||||
{"name":"卸载亿图图示", "command":"sudo apt autoremove --purge -y edrawmax libldap-2.4-2"},
|
||||
{"name":"安装QQ", "command":"wget https://dldir1.qq.com/qqfile/qq/QQNT/fd2e886e/linuxqq_3.2.2-18394_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"}];
|
||||
//默认小键盘
|
||||
static const termCommands = [
|
||||
{"name": "Esc", "key": TerminalKey.escape},
|
||||
{"name": "Tab", "key": TerminalKey.tab},
|
||||
{"name": "↑", "key": TerminalKey.arrowUp},
|
||||
{"name": "↓", "key": TerminalKey.arrowDown},
|
||||
{"name": "←", "key": TerminalKey.arrowLeft},
|
||||
{"name": "→", "key": TerminalKey.arrowRight},
|
||||
{"name": "Del", "key": TerminalKey.delete},
|
||||
{"name": "PgUp", "key": TerminalKey.pageUp},
|
||||
{"name": "PgDn", "key": TerminalKey.pageDown},
|
||||
{"name": "Home", "key": TerminalKey.home},
|
||||
{"name": "End", "key": TerminalKey.end},
|
||||
{"name": "F1", "key": TerminalKey.f1},
|
||||
{"name": "F2", "key": TerminalKey.f2},
|
||||
{"name": "F3", "key": TerminalKey.f3},
|
||||
{"name": "F4", "key": TerminalKey.f4},
|
||||
{"name": "F5", "key": TerminalKey.f5},
|
||||
{"name": "F6", "key": TerminalKey.f6},
|
||||
{"name": "F7", "key": TerminalKey.f7},
|
||||
{"name": "F8", "key": TerminalKey.f8},
|
||||
{"name": "F9", "key": TerminalKey.f9},
|
||||
{"name": "F10", "key": TerminalKey.f10},
|
||||
{"name": "F11", "key": TerminalKey.f11},
|
||||
{"name": "F12", "key": TerminalKey.f12},
|
||||
|
||||
];
|
||||
|
||||
//看广告可以获得的奖励。
|
||||
//weight抽奖权重,singleUse使用一次花费的数量,amount抽中可以获得的数量
|
||||
@@ -296,29 +403,68 @@ 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,
|
||||
"enableVirgl" : 10,
|
||||
|
||||
"unlockOnce" : 1, //临时解锁需要看的广告数
|
||||
"unlockToday" : 2, //当日解锁需要看的广告数
|
||||
|
||||
};
|
||||
|
||||
static const String 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=\$DATA_DIR/tiny:/home/tiny/.local/share/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 \$EXTRA_OPT /bin/bash -l";
|
||||
|
||||
static final ButtonStyle commandButtonStyle = OutlinedButton.styleFrom(
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
minimumSize: const Size(0, 0),
|
||||
padding: const EdgeInsets.fromLTRB(4, 2, 4, 2)
|
||||
);
|
||||
|
||||
|
||||
static final ButtonStyle controlButtonStyle = OutlinedButton.styleFrom(
|
||||
textStyle: const TextStyle(fontWeight: FontWeight.w400),
|
||||
side: const BorderSide(color: Color(0x1F000000)),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
minimumSize: const Size(0, 0),
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 8, 4)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Global variables
|
||||
class G {
|
||||
static late final String dataPath;
|
||||
static Pty? audioPty;
|
||||
static late WebViewController controller;
|
||||
static late BuildContext homePageStateContext;
|
||||
static late int currentContainer; //目前运行第几个容器
|
||||
static late Map<int, TermPty> termPtys; //为容器<int>存放TermPty数据
|
||||
static late AdManager ads; //广告实例
|
||||
static late VirtualKeyboard keyboard; //存储ctrl, shift, alt状态
|
||||
static bool maybeCtrlJ = false; //为了区分按下的ctrl+J和enter而准备的变量
|
||||
static ValueNotifier<double> termFontScale = ValueNotifier(1); //终端字体大小,存储为G.prefs的termFontScale
|
||||
static int adsWatchedThisTime = 0; //本次启动应用看的广告数
|
||||
static bool isStreamServerStarted = false;
|
||||
static bool isStreaming = false;
|
||||
//static int? streamingPid;
|
||||
static String streamingOutput = "";
|
||||
static late Pty streamServerPty;
|
||||
static bool isVirglServerStarted = false;
|
||||
static late Pty virglServerPty;
|
||||
//static int? virglPid;
|
||||
static ValueNotifier<int> pageIndex = ValueNotifier(0); //主界面索引
|
||||
static ValueNotifier<bool> terminalPageChange = ValueNotifier(true); //更改值,用于刷新小键盘
|
||||
static ValueNotifier<bool> bannerAdsChange = ValueNotifier(true); //更改值,用于刷新banner广告
|
||||
static ValueNotifier<bool> bootTextChange = ValueNotifier(true); //更改值,用于刷新启动命令
|
||||
static ValueNotifier<String> updateText = ValueNotifier("小小电脑"); //加载界面的说明文字
|
||||
|
||||
|
||||
static late SharedPreferences prefs;
|
||||
}
|
||||
|
||||
class AdManager {
|
||||
@@ -347,7 +493,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 +504,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 +543,7 @@ class Workflow {
|
||||
|
||||
static Future<void> grantPermissions() async {
|
||||
Permission.storage.request();
|
||||
Permission.manageExternalStorage.request();
|
||||
//Permission.manageExternalStorage.request();
|
||||
}
|
||||
|
||||
static Future<void> setupBootstrap() async {
|
||||
@@ -406,6 +553,8 @@ class Workflow {
|
||||
Util.createDirFromString("${G.dataPath}/tmp");
|
||||
//给proot的tmp文件夹,虽然我不知道为什么proot要这个
|
||||
Util.createDirFromString("${G.dataPath}/proot_tmp");
|
||||
//给pulseaudio的tmp文件夹
|
||||
Util.createDirFromString("${G.dataPath}/pulseaudio_tmp");
|
||||
//解压后得到bin文件夹和libexec文件夹
|
||||
//bin存放了proot, pulseaudio, tar等
|
||||
//libexec存放了proot loader
|
||||
@@ -413,6 +562,12 @@ class Workflow {
|
||||
"assets/assets.zip",
|
||||
"${G.dataPath}/assets.zip",
|
||||
);
|
||||
//patch.tar.gz存放了tiny文件夹
|
||||
//里面是一些补丁,会被挂载到~/.local/share/tiny
|
||||
await Util.copyAsset(
|
||||
"assets/patch.tar.gz",
|
||||
"${G.dataPath}/patch.tar.gz",
|
||||
);
|
||||
//dddd
|
||||
await Util.copyAsset(
|
||||
"assets/busybox",
|
||||
@@ -423,33 +578,40 @@ class Workflow {
|
||||
export DATA_DIR=${G.dataPath}
|
||||
cd \$DATA_DIR
|
||||
chmod +x busybox
|
||||
\$DATA_DIR/busybox unzip assets.zip
|
||||
\$DATA_DIR/busybox unzip -o assets.zip
|
||||
chmod -R +x bin/*
|
||||
chmod -R +x libexec/proot/*
|
||||
chmod 1777 tmp
|
||||
ln -s \$DATA_DIR/busybox \$DATA_DIR/bin/xz
|
||||
\$DATA_DIR/busybox rm -rf assets.zip
|
||||
ln -sf \$DATA_DIR/busybox \$DATA_DIR/bin/xz
|
||||
ln -sf \$DATA_DIR/busybox \$DATA_DIR/bin/gzip
|
||||
\$DATA_DIR/bin/tar zxf patch.tar.gz
|
||||
\$DATA_DIR/busybox rm -rf assets.zip patch.tar.gz
|
||||
""");
|
||||
}
|
||||
|
||||
//初次启动要做的事情
|
||||
static Future<void> initForFirstTime() async {
|
||||
//首先设置bootstrap
|
||||
G.updateText.value = "正在安装引导包";
|
||||
await setupBootstrap();
|
||||
|
||||
G.updateText.value = "正在复制容器系统";
|
||||
//存放容器的文件夹0和存放硬链接的文件夹.l2s
|
||||
Util.createDirFromString("${G.dataPath}/containers/0/.l2s");
|
||||
//这个是容器rootfs,被split命令分成了xa*
|
||||
//首次启动,就用这个,别让用户另选了
|
||||
//TODO: 这个字符串列表太丑陋了
|
||||
for (String name in ["xaa", "xab", "xac", "xad", "xae", "xaf", "xag", "xah", "xai"]) {
|
||||
for (String name in ["xaa", "xab", "xac", "xad", "xae", "xaf", "xag", "xah", "xai", "xaj"]) {
|
||||
//for (String name in ["xaa", "xab", "xac", "xad", "xae", "xaf", "xag", "xah", "xai", "xaj", "xak", "xal", "xam", "xan", "xao", "xap", "xaq"]) {
|
||||
await Util.copyAsset("assets/$name", "${G.dataPath}/$name");
|
||||
}
|
||||
//-J
|
||||
G.updateText.value = "正在安装容器系统";
|
||||
await Util.execute(
|
||||
"""
|
||||
export DATA_DIR=${G.dataPath}
|
||||
export CONTAINER_DIR=\$DATA_DIR/containers/0
|
||||
export EXTRA_OPT=""
|
||||
cd \$DATA_DIR
|
||||
export PATH=\$DATA_DIR/bin:\$PATH
|
||||
export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
|
||||
@@ -477,43 +639,12 @@ 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":"${D.boot}",
|
||||
"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"},
|
||||
{"name":"查看系统信息", "command":"neofetch -L && neofetch --off"},
|
||||
{"name":"清屏", "command":"clear"},
|
||||
{"name":"安装图形处理软件Krita", "command":"sudo apt update && sudo apt install -y krita krita-l10n"},
|
||||
{"name":"卸载图形处理软件Krita", "command":"sudo apt autoremove --purge -y krita krita-l10n"},
|
||||
{"name":"安装视频剪辑软件Kdenlive", "command":"sudo apt update && sudo apt install -y kdenlive"},
|
||||
{"name":"卸载视频剪辑软件Kdenlive", "command":"sudo apt autoremove --purge -y kdenlive"},
|
||||
{"name":"安装科学计算软件Octave", "command":"sudo apt update && sudo apt install -y octave"},
|
||||
{"name":"卸载科学计算软件Octave", "command":"sudo apt autoremove --purge -y octave"},
|
||||
{"name":"安装WPS", "command":"wget https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/11704/wps-office_11.1.0.11704_arm64.deb -O /tmp/wps.deb && sudo apt update && sudo apt install -y /tmp/wps.deb; rm /tmp/wps.deb"},
|
||||
{"name":"卸载WPS", "command":"sudo apt autoremove --purge -y wps-office"},
|
||||
{"name":"安装CAJViewer", "command":"wget https://download.cnki.net/net.cnki.cajviewer_1.3.20-1_arm64.deb -O /tmp/caj.deb && sudo apt update && sudo apt install -y /tmp/caj.deb && bash /home/tiny/.local/share/tiny/caj/postinst; rm /tmp/caj.deb"},
|
||||
{"name":"卸载CAJViewer", "command":"sudo apt autoremove --purge -y net.cnki.cajviewer && bash /home/tiny/.local/share/tiny/caj/postrm"},
|
||||
{"name":"安装亿图图示", "command":"wget https://www.edrawsoft.cn/2download/aarch64/edrawmax_11.5.6-3_arm64.deb -O /tmp/edraw.deb && sudo apt update && sudo apt install -y /tmp/edraw.deb && bash /home/tiny/.local/share/tiny/edraw/postinst; rm /tmp/edraw.deb"},
|
||||
{"name":"卸载亿图图示", "command":"sudo apt autoremove --purge -y edrawmax libldap-2.4-2"},
|
||||
{"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 apt update && sudo apt install -y gvfs && echo '安装完成, 重启软件即可使用回收站。'"},
|
||||
{"name":"关机", "command":"stopvnc\\nexit\\nexit"},
|
||||
{"name":"???", "command":"timeout 8 cmatrix"}]
|
||||
"commands":${jsonEncode(D.commands)}
|
||||
}"""]);
|
||||
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);
|
||||
G.updateText.value = "安装完成";
|
||||
}
|
||||
|
||||
static Future<void> initData() async {
|
||||
@@ -528,7 +659,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 +668,39 @@ 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")!;
|
||||
//是否需要重新安装引导包?
|
||||
if (Util.getGlobal("reinstallBootstrap")) {
|
||||
G.updateText.value = "正在重新安装引导包";
|
||||
await setupBootstrap();
|
||||
G.prefs.setBool("reinstallBootstrap", false);
|
||||
}
|
||||
|
||||
G.termFontScale.value = Util.getGlobal("termFontScale") as double;
|
||||
|
||||
G.controller = WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
|
||||
//恢复临时开启的功能
|
||||
if (Util.shouldWatchAds(D.adsRequired["changeFFmpegCommand"]!)) {
|
||||
await G.prefs.remove("defaultFFmpegCommand");
|
||||
}
|
||||
if (Util.shouldWatchAds(D.adsRequired["changeTermMaxLines"]!)) {
|
||||
await G.prefs.setInt("termMaxLines", 4095);
|
||||
}
|
||||
if (Util.shouldWatchAds(D.adsRequired["closeBannerAds"]!)) {
|
||||
await G.prefs.setBool("isBannerAdsClosed", false);
|
||||
}
|
||||
if (Util.shouldWatchAds(D.adsRequired["enableTerminalWrite"]!)) {
|
||||
await G.prefs.setBool("isTerminalWriteEnabled", false);
|
||||
}
|
||||
if (Util.shouldWatchAds(D.adsRequired["enableTerminalCommands"]!)) {
|
||||
await G.prefs.setBool("isTerminalCommandsEnabled", false);
|
||||
}
|
||||
if (Util.shouldWatchAds(D.adsRequired["enableVirgl"]!)) {
|
||||
await G.prefs.setBool("virgl", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Future<void> initTerminalForCurrent() async {
|
||||
@@ -572,30 +730,38 @@ done
|
||||
//pulseaudio还需要一个文件夹放配置,这里用share
|
||||
G.audioPty!.write(const Utf8Encoder().convert("""
|
||||
export DATA_DIR=${G.dataPath}
|
||||
cd \$DATA_DIR/..
|
||||
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/bin/pulseaudio -F \$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
|
||||
TMPDIR=\$DATA_DIR/pulseaudio_tmp HOME=\$DATA_DIR/pulseaudio_tmp XDG_CONFIG_HOME=\$DATA_DIR/pulseaudio_tmp LD_LIBRARY_PATH=\$DATA_DIR/bin \$DATA_DIR/bin/pulseaudio -F \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||
exit
|
||||
"""));
|
||||
await G.audioPty?.exitCode;
|
||||
}
|
||||
|
||||
static Future<void> launchCurrentContainer() async {
|
||||
String extraOpt = "";
|
||||
if (Util.getGlobal("getifaddrsBridge")) {
|
||||
Util.execute("${G.dataPath}/bin/getifaddrs_bridge_server ${G.dataPath}/containers/${G.currentContainer}/tmp/.getifaddrs-bridge");
|
||||
extraOpt += "LD_PRELOAD=/home/tiny/.local/share/tiny/extra/getifaddrs_bridge_client_lib.so ";
|
||||
}
|
||||
if (Util.getGlobal("virgl")) {
|
||||
Util.execute("""
|
||||
export DATA_DIR=${G.dataPath}
|
||||
export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer}
|
||||
${G.dataPath}/bin/virgl_test_server ${Util.getGlobal("defaultVirglCommand")}""");
|
||||
extraOpt += "${Util.getGlobal("defaultVirglOpt")} ";
|
||||
}
|
||||
Util.termWrite(
|
||||
"""
|
||||
export DATA_DIR=${G.dataPath}
|
||||
export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer}
|
||||
export EXTRA_OPT="$extraOpt"
|
||||
#export PROOT_L2S_DIR=\$DATA_DIR/containers/0/.l2s
|
||||
cd \$DATA_DIR
|
||||
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""");
|
||||
}
|
||||
|
||||
@@ -627,7 +793,8 @@ clear""");
|
||||
LogicalKeyboardKey.arrowLeft,
|
||||
LogicalKeyboardKey.arrowRight,
|
||||
LogicalKeyboardKey.arrowUp,
|
||||
LogicalKeyboardKey.arrowDown
|
||||
LogicalKeyboardKey.arrowDown,
|
||||
LogicalKeyboardKey.tab
|
||||
}.contains(event.logicalKey)) {
|
||||
return KeyEventResult.skipRemainingHandlers;
|
||||
}
|
||||
@@ -646,7 +813,7 @@ clear""");
|
||||
await initTerminalForCurrent();
|
||||
setupAudio();
|
||||
launchCurrentContainer();
|
||||
if (G.prefs.getBool("autoLaunchVnc")!) {
|
||||
if (Util.getGlobal("autoLaunchVnc") as bool) {
|
||||
waitForConnection().then((value) => launchBrowser());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import ffmpeg_kit_flutter_full_gpl
|
||||
import path_provider_foundation
|
||||
import shared_preferences_foundation
|
||||
import url_launcher_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FFmpegKitFlutterPlugin.register(with: registry.registrar(forPlugin: "FFmpegKitFlutterPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
|
||||
92
pubspec.lock
92
pubspec.lock
@@ -81,14 +81,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
ffmpeg_kit_flutter_full_gpl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: ffmpeg_kit_flutter_full_gpl
|
||||
sha256: "4f269bcb636bfcb544e5b4d65c706a3d311839970cb42638e72406410c1b5b7b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
ffmpeg_kit_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffmpeg_kit_flutter_platform_interface
|
||||
sha256: addf046ae44e190ad0101b2fde2ad909a3cd08a2a109f6106d2f7048b7abedee
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
version: "7.0.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -196,10 +212,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1"
|
||||
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
version: "2.2.1"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -260,10 +276,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2
|
||||
sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.11.5"
|
||||
version: "3.12.0"
|
||||
permission_handler_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -276,10 +292,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
|
||||
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
version: "3.1.3"
|
||||
platform_info:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -316,10 +332,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: b7f41bad7e521d205998772545de63ff4e6c97714775902c199353f8bf1511ac
|
||||
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
version: "2.2.2"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -340,10 +356,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_linux
|
||||
sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a
|
||||
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
version: "2.3.2"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -364,10 +380,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_windows
|
||||
sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f
|
||||
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
version: "2.3.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -433,74 +449,74 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: unity_ads_plugin
|
||||
sha256: "2b19ff02089e5a0d1a6549a2cd9d2baf5f8733bdda296d947d411a293f0bffda"
|
||||
sha256: "75b0b87697a9601971eacd2cd37458b88cf88f062af6f21c67c9fb28a11699d9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.8"
|
||||
version: "0.3.10"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27"
|
||||
sha256: b1c9e98774adf8820c96fbc7ae3601231d324a7d5ebd8babe27b6dfac91357ba
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.14"
|
||||
version: "6.2.1"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_android
|
||||
sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330
|
||||
sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
version: "6.2.0"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_ios
|
||||
sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f"
|
||||
sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.5"
|
||||
version: "6.2.0"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e
|
||||
sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.6"
|
||||
version: "3.1.0"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88
|
||||
sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.7"
|
||||
version: "3.1.0"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618"
|
||||
sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
version: "2.2.0"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5"
|
||||
sha256: "7fd2f55fe86cea2897b963e864dc01a7eb0719ecc65fcef4c1cc3d686d718bb2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.20"
|
||||
version: "2.2.0"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069"
|
||||
sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.8"
|
||||
version: "3.1.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -521,18 +537,18 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: webview_flutter
|
||||
sha256: "82f6787d5df55907aa01e49bd9644f4ed1cc82af7a8257dd9947815959d2e755"
|
||||
sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.4"
|
||||
version: "4.4.2"
|
||||
webview_flutter_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
sha256: ddc167c6676f57c8b367d19fcbee267d6dc6adf81bd6c3cb87981d30746e0a6d
|
||||
sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.10.1"
|
||||
version: "3.12.1"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -545,10 +561,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
sha256: "485af05f2c5f83c7f78c20e236b170ad02df7153b299ae9917345be43871d29f"
|
||||
sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.8.0"
|
||||
version: "3.9.4"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.9+3
|
||||
version: 1.0.11+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.1.0 <4.0.0'
|
||||
@@ -42,6 +42,7 @@ dependencies:
|
||||
intl: ^0.18.1 #日期字符串转换
|
||||
unity_ads_plugin: ^0.3.8
|
||||
clipboard: ^0.1.3
|
||||
ffmpeg_kit_flutter_full_gpl: ^6.0.3
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
|
||||
Reference in New Issue
Block a user