Compare commits

...

6 Commits

Author SHA1 Message Date
Caten
0971059111 backup 2023-10-10 18:16:56 +08:00
Caten
2cf19179f9 Fix keyboard plug in, streaming don't close 2023-10-09 06:47:57 +08:00
Caten
b6d4d2f11b Adjust ads watch settings, add saf documents provider, camera stream, more permission 2023-10-08 16:40:51 +08:00
Caten
5a6f04d094 Update help message 2023-10-03 21:50:59 +08:00
Caten
195a2f50a3 Fix boot options 2023-10-03 20:51:29 +08:00
Caten
16a14c8a3e Adjust help message 2023-10-03 13:15:11 +08:00
10 changed files with 777 additions and 123 deletions

View File

@@ -23,6 +23,7 @@ assets的文件来源如下:
- [proot](https://github.com/Cateners/proot), 使用[build-proot-android](https://github.com/green-green-avk/build-proot-android)脚本编译 - [proot](https://github.com/Cateners/proot), 使用[build-proot-android](https://github.com/green-green-avk/build-proot-android)脚本编译
- [busybox](https://github.com/meefik/busybox) - [busybox](https://github.com/meefik/busybox)
- [mediamtx相关](https://github.com/bluenviron/mediamtx)
- [tar](https://github.com/Rprop/tar-android-static) - [tar](https://github.com/Rprop/tar-android-static)
- [Xserver XSDL, pulseaudio相关文件](https://github.com/pelya/commandergenius/tree/sdl_android/project/jni/application/xserver) - [Xserver XSDL, pulseaudio相关文件](https://github.com/pelya/commandergenius/tree/sdl_android/project/jni/application/xserver)
- [Tmoe Linux, debian包来源](https://github.com/2moe/tmoe) - [Tmoe Linux, debian包来源](https://github.com/2moe/tmoe)
@@ -34,10 +35,10 @@ assets的文件来源如下:
- 使用kali-undercover提供的Win10主题美化xfce - 使用kali-undercover提供的Win10主题美化xfce
- (使用tmoe)安装了fcitx输入法和云拼音组件。按<Ctrl+空格>切换输入法。 - (使用tmoe)安装了fcitx输入法和云拼音组件。按<Ctrl+空格>切换输入法。
- 强烈建议**不要**使用安卓中文输入法直接输入中文,而是使用英文键盘通过容器的输入法输入中文,避免丢字错字。 - 强烈建议**不要**使用安卓中文输入法直接输入中文,而是使用英文键盘通过容器的输入法输入中文,避免丢字错字。
- 对noVNC进行[修改](https://github.com/Cateners/noVNC)添加了scale factor滑块控制缩放(scale_factor分支)添加了上下左右shift等按键(arrow_key分支) - 对noVNC进行[修改](https://github.com/Cateners/noVNC)添加了scale factor滑块控制缩放(scale_factor分支)添加了上下左右shift等按键(arrow_key分支),添加了强制显示原系统光标的功能(force_cursor分支),添加了中文翻译(translation_zh_cn分支)
- 在主目录下可以方便地访问手机存储(如果提供了存储权限的话) - 在主目录下可以方便地访问手机存储(如果提供了存储权限的话)
- 启动时会尝试挂载手机的一些字体目录(AppFiles/Fonts、Fonts和/system/fonts), 如果这些目录下有字体文件的话会一并加载到系统中,无需额外安装 - 启动时会尝试挂载手机的一些字体目录(AppFiles/Fonts、Fonts和/system/fonts), 如果这些目录下有字体文件的话会一并加载到系统中,无需额外安装
- 最后采用tar.xz压缩用split命令分成了xa*等多个文件 - 最后采用tar.xz压缩用split命令分成了xa*等多个文件(低内存设备一次性拷贝大文件会导致软件闪退)。
数据包不再在assets中更新而是随releases提供主要是为了避免git越来越大 数据包不再在assets中更新而是随releases提供主要是为了避免git越来越大

View File

@@ -38,6 +38,7 @@ android {
sourceSets { sourceSets {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
main.java.srcDirs += 'src/main/java'
} }
defaultConfig { defaultConfig {
@@ -45,7 +46,7 @@ android {
applicationId "com.fct.tiny" applicationId "com.fct.tiny"
// You can update the following values to match your application needs. // 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. // 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 targetSdkVersion 28 //https://github.com/termux/termux-app/issues/1072; native; linker; flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

View File

@@ -2,6 +2,9 @@
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_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 <application
android:label="小小电脑" android:label="小小电脑"
android:name="${applicationName}" android:name="${applicationName}"
@@ -12,7 +15,7 @@
android:exported="true" android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/LaunchTheme" 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:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as <!-- Specifies an Android theme to apply to this Activity as soon as
@@ -28,6 +31,16 @@
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </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. <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data <meta-data

View File

@@ -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.

View File

@@ -23,7 +23,11 @@ import 'dart:math';
//import 'package:flutter/services.dart'; //import 'package:flutter/services.dart';
import 'package:clipboard/clipboard.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_pty/flutter_pty.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:saf/saf.dart';
//import 'package:flutter/services.dart'; //import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -33,6 +37,8 @@ import 'package:tiny_computer/workflow.dart';
import 'package:unity_ads_plugin/unity_ads_plugin.dart'; import 'package:unity_ads_plugin/unity_ads_plugin.dart';
import 'package:ffmpeg_kit_flutter_full_gpl/ffmpeg_kit.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
} }
@@ -122,6 +128,10 @@ class _InfoPageState extends State<InfoPage> {
如果是说明卡在什么地方了 如果是说明卡在什么地方了
建议清除本软件数据重来一次 建议清除本软件数据重来一次
(有一位网友提到过
自己无论怎么清软件数据都装不上
但在重启手机之后就装上了)
一些注意事项: 一些注意事项:
此软件以GPL协议免费开源 此软件以GPL协议免费开源
如果是买的就是被骗了, 请举报 如果是买的就是被骗了, 请举报
@@ -141,6 +151,13 @@ class _InfoPageState extends State<InfoPage> {
那么通过主目录下的文件夹 那么通过主目录下的文件夹
就可以访问手机存储 就可以访问手机存储
有一些设备做了更多访问限制
比如下载文件夹可能不可写入
这样会导致把文件保存到下载目录时出现问题
(火狐浏览器可能因此无法下载文件)
不过这个很好解决
换个文件夹保存就行了
如果认为界面大小比例不合适 如果认为界面大小比例不合适
可以通过调整图形界面左栏设置-高级里的屏幕缩放比例 可以通过调整图形界面左栏设置-高级里的屏幕缩放比例
如果感觉界面卡卡的 如果感觉界面卡卡的
@@ -148,6 +165,7 @@ class _InfoPageState extends State<InfoPage> {
如果你想安装其他软件 如果你想安装其他软件
可以使用容器自带的tmoe 可以使用容器自带的tmoe
但并不保证安装了能用哦
(事实上, 目前容器里的 (事实上, 目前容器里的
VSCode、输入法 VSCode、输入法
都是用tmoe安装的 都是用tmoe安装的
@@ -179,7 +197,7 @@ VSCode、输入法
红米Note 12, 安卓13miui14, 黑屏 红米Note 12, 安卓13miui14, 黑屏
红米Note 11T Pro+ miui13.0.4,“无法连接” 红米Note 11T Pro+ miui13.0.4,“无法连接”
Vivo Pad安卓13看不见鼠标移动可以去左栏设置开启显示原系统光标替代 Vivo Pad安卓13看不见鼠标移动可以去左栏设置开启显示原系统光标替代
关于这 关于这
我目前没有什么好的解决办法 我目前没有什么好的解决办法
(毕竟我没有这些设备 (毕竟我没有这些设备
也不方便定位原因) 也不方便定位原因)
@@ -187,6 +205,11 @@ Vivo Pad安卓13看不见鼠标移动可以去左栏设置开启显示
不管解没解决 不管解没解决
都可以去https://github.com/Cateners/tiny_computer/issues/1留个言 都可以去https://github.com/Cateners/tiny_computer/issues/1留个言
如果软件里有程序正在正常运行
请不要强行关闭本软件
否则可能会损坏本容器
特别是在安装某些比较大的软件的时候
感谢使用! 感谢使用!
(顺带一提, 全部解压完大概需要4~5GB空间 (顺带一提, 全部解压完大概需要4~5GB空间
@@ -604,6 +627,11 @@ SOFTWARE.
return const ListTile(title: Text("隐私政策")); return const ListTile(title: Text("隐私政策"));
}), body: const Padding(padding: EdgeInsets.all(8), child: Text(""" }), body: const Padding(padding: EdgeInsets.all(8), child: Text("""
除由Unity提供的广告功能外, 本软件不会收集你的隐私信息。 除由Unity提供的广告功能外, 本软件不会收集你的隐私信息。
申请的权限用于以下目的:
文件相关权限:用于系统访问手机目录;
相机和麦克风:用于推流,默认不会开启。
关于广告获取隐私信息的说明, 在第一次看广告时Unity会向你做出告知。 关于广告获取隐私信息的说明, 在第一次看广告时Unity会向你做出告知。
届时你可以选择要向Unity提供哪些信息。 届时你可以选择要向Unity提供哪些信息。
"""))), """))),
@@ -628,7 +656,7 @@ SOFTWARE.
不管怎么说,我希望这不是一个问题... 不管怎么说,我希望这不是一个问题...
...但是 ...当然
我还是不想看到你们去编译一个不含广告的版本>< 我还是不想看到你们去编译一个不含广告的版本><
"""))), """))),
ExpansionPanel( ExpansionPanel(
@@ -639,14 +667,7 @@ SOFTWARE.
children: [ children: [
const Padding(padding: EdgeInsets.all(8), child: Text(""" const Padding(padding: EdgeInsets.all(8), child: Text("""
这个软件预计会有一些广告 这个软件预计会有一些广告
之前的版本中说过 分为横幅广告和视频广告
如果完整地看了"隐私政策""服务条款"的话
就可以选择关闭广告
但因为那两个玩意一直都不知道怎么写
想想还是算了
但软件里的广告还是可以关闭的
本软件的广告分为横幅广告和视频广告
横幅广告在终端和控制页面的顶端出现 横幅广告在终端和控制页面的顶端出现
(但不知道是不是因为代码没写对 (但不知道是不是因为代码没写对
反正我从没见横幅广告成功加载过) 反正我从没见横幅广告成功加载过)
@@ -657,19 +678,23 @@ SOFTWARE.
启用小键盘: 观看3个广告 启用小键盘: 观看3个广告
关闭横幅广告: 观看5个广告 关闭横幅广告: 观看5个广告
终端最大行数修改: 观看6个广告 终端最大行数修改: 观看6个广告
推流参数修改: 观看8个广告
我设置了每天最多可以看5个广告。 我设置了每天最多可以看5个广告。
只要看满5个广告, 就可以临时解锁全部功能。 只要看满1个广告, 就可以在本次使用期间临时解锁全部功能。
只要看满2个广告, 就可以在当日使用期间临时解锁全部功能。
(本来最开始设置是看一个广告就能全部解锁的
然后我自己测试的时候
看了17个广告才差不多赚1毛钱
不得已才出此下策...)
总之为了良好的体验 总之为了良好的体验
在图形界面是不会出现广告的 在图形界面是不会出现广告的
这点还请放心 这点还请放心
---注意事项---
我注意到Unity提供了一些不那么合适的广告
一般如果我看到这些广告就在后台直接禁了
不过也可能有漏网之鱼
你们可以联系我禁掉
---下面是赛博乞讨环节--- ---下面是赛博乞讨环节---
(*>ω<*) (*>ω<*)
@@ -769,7 +794,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
//高级设置,全局设置 //高级设置,全局设置
final List<bool> _expandState = [false, false, false]; final List<bool> _expandState = [false, false, false, false, false];
bool bannerAdsFailedToLoad = false; bool bannerAdsFailedToLoad = false;
@@ -813,7 +838,7 @@ class _MyHomePageState extends State<MyHomePage> {
title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title), title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title),
), ),
body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [ body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [
G.prefs.getBool("isBannerAdsClosed")!||bannerAdsFailedToLoad?SizedBox.fromSize(size: const Size.square(0)):UnityBannerAd( (Util.getGlobal("isBannerAdsClosed") as bool)||bannerAdsFailedToLoad?SizedBox.fromSize(size: const Size.square(0)):UnityBannerAd(
placementId: AdManager.bannerAdPlacementId, placementId: AdManager.bannerAdPlacementId,
onLoad: (placementId) => debugPrint('Banner loaded: $placementId'), onLoad: (placementId) => debugPrint('Banner loaded: $placementId'),
onClick: (placementId) => debugPrint('Banner clicked: $placementId'), onClick: (placementId) => debugPrint('Banner clicked: $placementId'),
@@ -828,13 +853,13 @@ class _MyHomePageState extends State<MyHomePage> {
child: [ child: [
Column(children: [Expanded(child: forceScaleGestureDetector(onScaleUpdate: (details) { Column(children: [Expanded(child: forceScaleGestureDetector(onScaleUpdate: (details) {
setState(() { setState(() {
G.termFontScale = (details.scale * G.prefs.getDouble("termFontScale")!).clamp(0.2, 5); G.termFontScale = (details.scale * (Util.getGlobal("termFontScale") as double)).clamp(0.2, 5);
}); });
}, onScaleEnd: (details) async { }, onScaleEnd: (details) async {
await G.prefs.setDouble("termFontScale", G.termFontScale); await G.prefs.setDouble("termFontScale", G.termFontScale);
}, child: TerminalView(G.termPtys[G.currentContainer]!.terminal, textScaleFactor: G.termFontScale, keyboardType: TextInputType.multiline,))), }, child: TerminalView(G.termPtys[G.currentContainer]!.terminal, textScaleFactor: G.termFontScale, keyboardType: TextInputType.multiline,))),
G.prefs.getBool("isTerminalCommandsEnabled")!?Padding(padding: const EdgeInsets.all(8), child: (Util.getGlobal("isTerminalCommandsEnabled") as bool)?Padding(padding: const EdgeInsets.all(8), child:
SingleChildScrollView(scrollDirection: Axis.horizontal, child: Row(children: [AnimatedBuilder( SingleChildScrollView(restorationId: "commands-bar", scrollDirection: Axis.horizontal, child: Row(children: [AnimatedBuilder(
animation: G.keyboard, animation: G.keyboard,
builder: (context, child) => ToggleButtons( builder: (context, child) => ToggleButtons(
constraints: const BoxConstraints(minWidth: 32, minHeight: 24), constraints: const BoxConstraints(minWidth: 32, minHeight: 24),
@@ -906,7 +931,7 @@ class _MyHomePageState extends State<MyHomePage> {
}, child: const Text("F12")), SizedBox.fromSize(size: const Size(72, 0))]))):SizedBox.fromSize(size: const Size.square(0)) }, child: const Text("F12")), SizedBox.fromSize(size: const Size(72, 0))]))):SizedBox.fromSize(size: const Size.square(0))
]), Padding( ]), Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: Scrollbar(child: SingleChildScrollView(child: Column( child: Scrollbar(child: SingleChildScrollView(restorationId: "control-scroll", child: Column(
children: [ children: [
const Padding( const Padding(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
@@ -986,6 +1011,20 @@ class _MyHomePageState extends State<MyHomePage> {
}, child: const Text("添加")), }, child: const Text("添加")),
]); ]);
},); },);
}, onLongPress: () {
showDialog(context: context, builder: (context) {
return AlertDialog(content: const Text("是否重置所有快捷指令?"), actions: [
TextButton(onPressed:() {
Navigator.of(context).pop();
}, child: const Text("取消")),
TextButton(onPressed:() async {
await Util.setCurrentProp("commands", D.commands);
setState(() {});
if (!context.mounted) return;
Navigator.of(context).pop();
}, child: const Text("")),
]);
});
}, child: const Text("添加快捷指令")))), }, child: const Text("添加快捷指令")))),
Padding(padding: const EdgeInsets.all(8), child: Card(child: Padding(padding: const EdgeInsets.all(8), child: Padding(padding: const EdgeInsets.all(8), child: Card(child: Padding(padding: const EdgeInsets.all(8), child:
Column(children: [ Column(children: [
@@ -1024,10 +1063,10 @@ class _MyHomePageState extends State<MyHomePage> {
headerBuilder: ((context, isExpanded) { headerBuilder: ((context, isExpanded) {
return const ListTile(title: Text("全局设置"), subtitle: Text("在这里关广告、开启终端编辑")); return const ListTile(title: Text("全局设置"), subtitle: Text("在这里关广告、开启终端编辑"));
}), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [ }), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [
TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction, initialValue: G.prefs.getInt("termMaxLines")!.toString(), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "终端最大行数(重启软件生效)"), readOnly: Util.shouldWatchAds(6), TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction, initialValue: (Util.getGlobal("termMaxLines") as int).toString(), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "终端最大行数(重启软件生效)"), readOnly: Util.shouldWatchAds(G.adsRequired["changeTermMaxLines"]!),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
onTap: () { onTap: () {
if (Util.shouldWatchAds(6)) { if (Util.shouldWatchAds(G.adsRequired["changeTermMaxLines"]!)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("观看六次视频广告永久解锁><")) const SnackBar(content: Text("观看六次视频广告永久解锁><"))
@@ -1040,7 +1079,7 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
},), },),
SizedBox.fromSize(size: const Size.square(16)), SizedBox.fromSize(size: const Size.square(16)),
TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction, initialValue: G.prefs.getInt("defaultAudioPort")!.toString(), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "pulseaudio接收端口"), TextFormField(autovalidateMode: AutovalidateMode.onUserInteraction, initialValue: (Util.getGlobal("defaultAudioPort") as int).toString(), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "pulseaudio接收端口"),
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
validator: (value) { validator: (value) {
return Util.validateBetween(value, 0, 65535, () async { return Util.validateBetween(value, 0, 65535, () async {
@@ -1049,8 +1088,8 @@ class _MyHomePageState extends State<MyHomePage> {
} }
), ),
SizedBox.fromSize(size: const Size.square(16)), SizedBox.fromSize(size: const Size.square(16)),
SwitchListTile(title: const Text("关闭横幅广告"), value: G.prefs.getBool("isBannerAdsClosed")!, onChanged:(value) { SwitchListTile(title: const Text("关闭横幅广告"), value: Util.getGlobal("isBannerAdsClosed") as bool, onChanged:(value) {
if (value && Util.shouldWatchAds(5)) { if (value && Util.shouldWatchAds(G.adsRequired["closeBannerAds"]!)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("观看五次视频广告永久解锁><")) const SnackBar(content: Text("观看五次视频广告永久解锁><"))
@@ -1061,8 +1100,8 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {}); setState(() {});
},), },),
SizedBox.fromSize(size: const Size.square(8)), SizedBox.fromSize(size: const Size.square(8)),
SwitchListTile(title: const Text("启用终端"), value: G.prefs.getBool("isTerminalWriteEnabled")!, onChanged:(value) { SwitchListTile(title: const Text("启用终端"), value: Util.getGlobal("isTerminalWriteEnabled") as bool, onChanged:(value) {
if (value && Util.shouldWatchAds(2)) { if (value && Util.shouldWatchAds(G.adsRequired["enableTerminalWrite"]!)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: const Text("观看两次视频广告永久解锁><"), action: SnackBarAction(label: "啊?", onPressed: () { SnackBar(content: const Text("观看两次视频广告永久解锁><"), action: SnackBarAction(label: "啊?", onPressed: () {
@@ -1076,8 +1115,8 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {}); setState(() {});
},), },),
SizedBox.fromSize(size: const Size.square(8)), SizedBox.fromSize(size: const Size.square(8)),
SwitchListTile(title: const Text("启用终端小键盘"), value: G.prefs.getBool("isTerminalCommandsEnabled")!, onChanged:(value) { SwitchListTile(title: const Text("启用终端小键盘"), value: Util.getGlobal("isTerminalCommandsEnabled") as bool, onChanged:(value) {
if (value && Util.shouldWatchAds(3)) { if (value && Util.shouldWatchAds(G.adsRequired["enableTerminalCommands"]!)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("观看三次视频广告永久解锁><")) const SnackBar(content: Text("观看三次视频广告永久解锁><"))
@@ -1088,12 +1127,12 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {}); setState(() {});
},), },),
SizedBox.fromSize(size: const Size.square(8)), SizedBox.fromSize(size: const Size.square(8)),
SwitchListTile(title: const Text("终端粘滞键"), value: G.prefs.getBool("isStickyKey")!, onChanged:(value) { SwitchListTile(title: const Text("终端粘滞键"), value: Util.getGlobal("isStickyKey") as bool, onChanged:(value) {
G.prefs.setBool("isStickyKey", value); G.prefs.setBool("isStickyKey", value);
setState(() {}); setState(() {});
},), },),
SizedBox.fromSize(size: const Size.square(8)), SizedBox.fromSize(size: const Size.square(8)),
SwitchListTile(title: const Text("开启时启动图形界面"), value: G.prefs.getBool("autoLaunchVnc")!, onChanged:(value) { SwitchListTile(title: const Text("开启时启动图形界面"), value: Util.getGlobal("autoLaunchVnc") as bool, onChanged:(value) {
G.prefs.setBool("autoLaunchVnc", value); G.prefs.setBool("autoLaunchVnc", value);
setState(() {}); setState(() {});
},), },),
@@ -1101,7 +1140,233 @@ class _MyHomePageState extends State<MyHomePage> {
ExpansionPanel( ExpansionPanel(
isExpanded: _expandState[2], isExpanded: _expandState[2],
headerBuilder: ((context, isExpanded) { headerBuilder: ((context, isExpanded) {
return const ListTile(title: Text("广告记录")); return const ListTile(title: Text("相机推流"), subtitle: Text("实验性功能"));
}), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [
const Text("成功启动推流后可以点击快捷指令\"拉流测试\"并前往图形界面查看效果。\n注意这并不能为系统创建一个虚拟相机;\n另外使用相机是高耗电行为,不用时需及时关闭。"),
const SizedBox.square(dimension: 16),
Wrap(alignment: WrapAlignment.center, spacing: 4.0, runSpacing: 4.0, children: [
OutlinedButton(style: commandButtonStyle, child: const Text("申请相机权限"), onPressed: () {
Permission.camera.request();
}),
OutlinedButton(style: commandButtonStyle, child: const Text("申请麦克风权限"), onPressed: () {
Permission.microphone.request();
}),
OutlinedButton(style: commandButtonStyle, child: const Text("查看输出"), onPressed: () {
if (G.streamingOutput == "") {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("无输出"))
);
return;
}
showDialog(context: context, builder: (context) {
return AlertDialog(content: SingleChildScrollView(child:
Text(G.streamingOutput)), actions: [
TextButton(onPressed:() {
FlutterClipboard.copy(G.streamingOutput).then(( value ) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("已复制")));
});
Navigator.of(context).pop();
}, child: const Text("复制")),
TextButton(onPressed:() {
Navigator.of(context).pop();
}, child: const Text("取消")),
]);
});
}),
]),
const SizedBox.square(dimension: 16),
TextFormField(maxLines: null, initialValue: Util.getGlobal("defaultFFmpegCommand") as String, decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "ffmpeg推流命令"), readOnly: Util.shouldWatchAds(G.adsRequired["changeFFmpegCommand"]!),
onTap: () {
if (Util.shouldWatchAds(G.adsRequired["changeFFmpegCommand"]!)) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("观看八次视频广告永久解锁><"))
);
}
},
onChanged: (value) async {
await G.prefs.setString("defaultFFmpegCommand", value);
},
),
const SizedBox.square(dimension: 16),
SwitchListTile(title: const Text("启动推流服务器"), subtitle: const Text("mediamtx"), value: G.isStreamServerStarted, onChanged:(value) {
switch (value) {
case true: {
G.streamServerPty = Pty.start("/system/bin/sh");
G.streamServerPty.write(const Utf8Encoder().convert("${G.dataPath}/bin/mediamtx ${G.dataPath}/bin/mediamtx.yml & pid=\$(echo \$!)\n"));
G.streamServerPty.exitCode.then((value) {
G.isStreamServerStarted = false;
setState(() {});
});
}
break;
case false: {
G.streamServerPty.write(const Utf8Encoder().convert("kill \$pid\nexit\n"));
}
break;
}
G.isStreamServerStarted = value;
setState(() {});
},),
SizedBox.fromSize(size: const Size.square(8)),
SwitchListTile(title: const Text("启动推流"), value: G.isStreaming, onChanged:(value) {
switch (value) {
case true: {
FFmpegKit.execute(Util.getGlobal("defaultFFmpegCommand") as String).then((session) {
session.getOutput().then((value) async {
G.isStreaming = false;
G.streamingOutput = value??"";
setState(() {});
});
});
}
break;
case false: {
FFmpegKit.cancel();
}
break;
}
G.isStreaming = value;
setState(() {});
},),
SizedBox.fromSize(size: const Size.square(8))
],))),
ExpansionPanel(
isExpanded: _expandState[3],
headerBuilder: ((context, isExpanded) {
return const ListTile(title: Text("文件访问"));
}), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [
const Text("通过这里获取更多文件权限,以实现对特殊目录的访问。"),
SizedBox.fromSize(size: const Size.square(16)),
Wrap(alignment: WrapAlignment.center, spacing: 4.0, runSpacing: 4.0, children: [
OutlinedButton(style: commandButtonStyle, child: const Text("申请存储权限"), onPressed: () {
Permission.storage.request();
}),
OutlinedButton(style: commandButtonStyle, child: const Text("申请所有文件访问权限"), onPressed: () {
Permission.manageExternalStorage.request();
}),
]),
const Text("这里可以将设备上的文件夹与软件容器内的文件夹绑定,在下次启动软件时生效。"),
ListView.builder(itemBuilder: (context, index) {
final Map<String, dynamic> e = jsonDecode(Util.getGlobal("customMounts")[index]);
return GestureDetector(onLongPress: () {
String name = e["name"]!;
bool isNameValid = false;
Saf pathSaf = Saf(e["path"]!);
bool isPathValid = false;
showDialog(context: context, builder: (context) {
return AlertDialog(title: const Text("选项编辑"), content: SingleChildScrollView(child: Column(children: [
TextFormField(initialValue: name, decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "挂载到主文件夹的名称"), validator: (value) {
if (!RegExp("[^\\s\\\\/:\\*\\?\\\"<>\\|](\\x20|[^\\s\\\\/:\\*\\?\\\"<>\\|])*[^\\s\\\\/:\\*\\?\\\"<>\\|\\.]\$").hasMatch(value!)) {
return "非法文件名";
}
isNameValid = true;
return null;
}),
SizedBox.fromSize(size: const Size.square(8)),
TextFormField(maxLines: null, initialValue: pathSaf.directory, decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "在本机的路径"), readOnly: true, onTap: () async {
isPathValid = (await pathSaf.getDirectoryPermission(isDynamic: true))??false;
}),
])), actions: [
TextButton(onPressed:() async {
await G.prefs.setStringList("customMounts", Util.getGlobal("customMounts")
..removeAt(index));
setState(() {});
if (!context.mounted) return;
Navigator.of(context).pop();
}, child: const Text("删除该项")),
TextButton(onPressed:() {
Navigator.of(context).pop();
}, child: const Text("取消")),
TextButton(onPressed:() async {
if (!isNameValid || !isPathValid) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("名称非法或路径无效"))
);
return;
}
await G.prefs.setStringList("customMounts", Util.getGlobal("customMounts")
..setAll(index, [{"name": name, "path": pathSaf.directory, "isEnabled": e["isEnabled"]}]));
setState(() {});
if (!context.mounted) return;
Navigator.of(context).pop();
}, child: const Text("保存")),
]);
},);
}, child: CheckboxListTile(title: Text(e["name"]), subtitle: Text(e["path"]), value: e["isEnabled"], onChanged: (value) async {
await G.prefs.setStringList("customMounts", Util.getGlobal("customMounts")..setAll(index, [jsonEncode(e..update("isEnabled", (v) {
return value!;
}))]));
setState(() {});
}));
}, shrinkWrap: true, itemCount: Util.getGlobal("customMounts").length),
ListTile(title: const Text("添加路径"), onTap: () async {
Saf pathSaf = Saf("/storage/self/primary/Download");
bool hasPermission = (await pathSaf.getDirectoryPermission(isDynamic: true))??false;
if (!hasPermission) {
return;
}
String name = "新路径";
bool isNameValid = false;
bool isPathValid = false;
if (!context.mounted) return;
showDialog(context: context, builder: (context) {
return AlertDialog(title: const Text("选项编辑"), content: SingleChildScrollView(child: Column(children: [
TextFormField(initialValue: name, decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "挂载到主文件夹的名称"), validator: (value) {
if (!RegExp("[^\\s\\\\/:\\*\\?\\\"<>\\|](\\x20|[^\\s\\\\/:\\*\\?\\\"<>\\|])*[^\\s\\\\/:\\*\\?\\\"<>\\|\\.]\$").hasMatch(value!)) {
return "非法文件名";
}
isNameValid = true;
return null;
}),
SizedBox.fromSize(size: const Size.square(8)),
TextFormField(maxLines: null, initialValue: pathSaf.directory, decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "在本机的路径"), readOnly: true, onTap: () async {
isPathValid = (await pathSaf.getDirectoryPermission(isDynamic: true))??false;
}),
])), actions: [
TextButton(onPressed:() {
Navigator.of(context).pop();
}, child: const Text("取消")),
TextButton(onPressed:() async {
if (!isNameValid || !isPathValid) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("名称非法或路径无效"))
);
return;
}
await G.prefs.setStringList("customMounts", Util.getGlobal("customMounts")
..add({"name": name, "path": pathSaf.directory, "isEnabled": true}));
setState(() {});
if (!context.mounted) return;
Navigator.of(context).pop();
}, child: const Text("保存")),
]);
});
}, onLongPress: () {
showDialog(context: context, builder: (context) {
return AlertDialog(content: const Text("是否清空所有路径?"), actions: [
TextButton(onPressed:() {
Navigator.of(context).pop();
}, child: const Text("取消")),
TextButton(onPressed:() async {
await G.prefs.setStringList("customMounts", []);
setState(() {});
if (!context.mounted) return;
Navigator.of(context).pop();
}, child: const Text("")),
]);
});
})
],))),
ExpansionPanel(
isExpanded: _expandState[4],
headerBuilder: ((context, isExpanded) {
return const ListTile(title: Text("广告记录"), subtitle: Text("在这里看广告"));
}), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [ }), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [
OutlinedButton(child: const Text("看一个广告"), onPressed: () { OutlinedButton(child: const Text("看一个广告"), onPressed: () {
if (AdManager.placements[AdManager.rewardedVideoAdPlacementId]!) { if (AdManager.placements[AdManager.rewardedVideoAdPlacementId]!) {
@@ -1124,7 +1389,7 @@ class _MyHomePageState extends State<MyHomePage> {
} }
}), }),
const SizedBox.square(dimension: 8), const SizedBox.square(dimension: 8),
Text(G.prefs.getStringList("adsBonus")!.map((element) { Text(Util.getGlobal("adsBonus").map((element) {
final e = jsonDecode(element); final e = jsonDecode(element);
return e["amount"]==0?"":"${e["name"]}*${e["amount"]}\n"; return e["amount"]==0?"":"${e["name"]}*${e["amount"]}\n";
}).join()) }).join())

View File

@@ -68,16 +68,65 @@ class Util {
G.termPtys[G.currentContainer]!.pty.write(const Utf8Encoder().convert("$str\n")); 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"},
// bind:[{name:"U盘", src:"/storage/xxxx", dst:"/media/meow"}]...]}
//String[] adsBonus: 观看广告获取的奖励(json)
//{name: "xxx", amount: xxx}
//String[] customMounts: 自定义挂载地址(json)
//{name: "xxx", path: "xxx", isEnabled: true}
//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 "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>());
case "customMounts" : return b ? G.prefs.getStringList(key)! : (value){G.prefs.setStringList(key, value); return value;}([].cast<String>());
}
}
static dynamic getCurrentProp(String key) { 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等 //用来设置name, boot, vnc, vncUrl等
static Future<void> setCurrentProp(String key, dynamic value) async { static Future<void> setCurrentProp(String key, dynamic value) async {
await G.prefs.setStringList("containersInfo", await G.prefs.setStringList("containersInfo",
G.prefs.getStringList("containersInfo")!..setAll(G.currentContainer, Util.getGlobal("containersInfo")..setAll(G.currentContainer,
[jsonEncode((jsonDecode( [jsonEncode((jsonDecode(
G.prefs.getStringList("containersInfo")![G.currentContainer] Util.getGlobal("containersInfo")[G.currentContainer]
))..update(key, (v) => value))] ))..update(key, (v) => value))]
) )
); );
@@ -101,14 +150,14 @@ class Util {
//由getRandomBonus返回的数据 //由getRandomBonus返回的数据
static Future<void> applyBonus(Map<String, dynamic> bonus) async { static Future<void> applyBonus(Map<String, dynamic> bonus) async {
bool flag = false; 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); Map<String, dynamic> item = jsonDecode(e);
return (item["name"] == bonus["name"])? return (item["name"] == bonus["name"])?
jsonEncode(item..update("amount", (v) { jsonEncode(item..update("amount", (v) {
flag = true; flag = true;
return v + bonus["amount"]; return v + bonus["amount"];
})):e; })):e;
}).toList(); }).toList().cast<String>();
if (!flag) { if (!flag) {
ret.add("""{"name": "${bonus["name"]}", "amount": ${bonus["amount"]}}"""); ret.add("""{"name": "${bonus["name"]}", "amount": ${bonus["amount"]}}""");
} }
@@ -117,7 +166,7 @@ class Util {
//根据已看广告量判断是否应该继续看广告 //根据已看广告量判断是否应该继续看广告
static bool shouldWatchAds(int expectNum) { 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 //限定字符串在min和max之间, 给文本框的validator
@@ -185,8 +234,7 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
alt: event.alt || _alt, alt: event.alt || _alt,
)); ));
G.maybeCtrlJ = event.key.name == "keyJ"; G.maybeCtrlJ = event.key.name == "keyJ";
print(G.maybeCtrlJ); if (!(Util.getGlobal("isStickyKey") as bool)) {
if (!G.prefs.getBool("isStickyKey")!) {
G.keyboard.ctrl = false; G.keyboard.ctrl = false;
G.keyboard.shift = false; G.keyboard.shift = false;
G.keyboard.alt = false; G.keyboard.alt = false;
@@ -201,7 +249,7 @@ class TermPty {
late final Pty pty; late final Pty pty;
TermPty() { 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( pty = Pty.start(
"/system/bin/sh", "/system/bin/sh",
workingDirectory: G.dataPath, workingDirectory: G.dataPath,
@@ -249,7 +297,7 @@ class TermPty {
} }
}); });
terminal.onOutput = (data) { terminal.onOutput = (data) {
if (!G.prefs.getBool("isTerminalWriteEnabled")!) { if (!(Util.getGlobal("isTerminalWriteEnabled") as bool)) {
return; return;
} }
//由于对回车的处理似乎存在问题,所以拿出来单独处理 //由于对回车的处理似乎存在问题,所以拿出来单独处理
@@ -269,6 +317,34 @@ class TermPty {
} }
//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/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 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"}];
}
// Global variables // Global variables
class G { class G {
static late final String dataPath; static late final String dataPath;
@@ -281,6 +357,12 @@ class G {
static late VirtualKeyboard keyboard; //存储ctrl, shift, alt状态 static late VirtualKeyboard keyboard; //存储ctrl, shift, alt状态
static bool maybeCtrlJ = false; //为了区分按下的ctrl+J和enter而准备的变量 static bool maybeCtrlJ = false; //为了区分按下的ctrl+J和enter而准备的变量
static double termFontScale = 1; //终端字体大小存储为G.prefs的termFontScale 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 +378,20 @@ class G {
{"name": "Bonus Reward", "subtitle": "会有极好的事情发生", "description": "来自记忆空间的传说。\n使用后一天内必有极好的事情...\n就是你想象的那种事情...\n就会发生。\n不过, 大概只是个传说吧。", "weight": 1, "amount": 1, "singleUse": 1}, {"name": "Bonus Reward", "subtitle": "会有极好的事情发生", "description": "来自记忆空间的传说。\n使用后一天内必有极好的事情...\n就是你想象的那种事情...\n就会发生。\n不过, 大概只是个传说吧。", "weight": 1, "amount": 1, "singleUse": 1},
]; ];
//所有key //某项功能开启需要的广告数。
//int defaultContainer = 0: 默认启动第0个容器 static const Map<String, int> adsRequired = {
//int defaultAudioPort = 4718: 默认pulseaudio端口(为了避免和其它软件冲突改成4718了原默认4713) "closeBannerAds" : 5,
//bool autoLaunchVnc = true: 是否自动启动VNC并跳转 "enableTerminalWrite" : 2,
//String lastDate: 上次启动软件的日期yyyy-MM-dd "enableTerminalCommands" : 3,
//int adsWatchedToday: 今日视频广告观看数量 "changeTermMaxLines" : 6,
//int adsWatchedTotal: 视频广告观看数量 "changeFFmpegCommand" : 8,
//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;
"unlockOnce" : 1, //临时解锁需要看的广告数
"unlockToday" : 2, //当日解锁需要看的广告数
};
static late SharedPreferences prefs;
} }
class AdManager { class AdManager {
@@ -347,7 +420,7 @@ class AdManager {
static void showAd(String placementId, Function completeExtra, Function full) { static void showAd(String placementId, Function completeExtra, Function full) {
if (G.prefs.getInt("adsWatchedToday")!>=5) { if ((Util.getGlobal("adsWatchedToday") as int) >= 5) {
full(); full();
return; return;
} }
@@ -358,8 +431,9 @@ class AdManager {
onComplete: (placementId) async { onComplete: (placementId) async {
debugPrint('Video Ad $placementId completed'); debugPrint('Video Ad $placementId completed');
loadAd(placementId); loadAd(placementId);
await G.prefs.setInt("adsWatchedTotal", G.prefs.getInt("adsWatchedTotal")!+1); G.adsWatchedThisTime++;
await G.prefs.setInt("adsWatchedToday", G.prefs.getInt("adsWatchedToday")!+1); await G.prefs.setInt("adsWatchedTotal", (Util.getGlobal("adsWatchedTotal") as int)+1);
await G.prefs.setInt("adsWatchedToday", (Util.getGlobal("adsWatchedToday") as int)+1);
completeExtra(); completeExtra();
}, },
onFailed: (placementId, error, message) { onFailed: (placementId, error, message) {
@@ -396,7 +470,7 @@ class Workflow {
static Future<void> grantPermissions() async { static Future<void> grantPermissions() async {
Permission.storage.request(); Permission.storage.request();
Permission.manageExternalStorage.request(); //Permission.manageExternalStorage.request();
} }
static Future<void> setupBootstrap() async { static Future<void> setupBootstrap() async {
@@ -455,7 +529,7 @@ export PATH=\$DATA_DIR/bin:\$PATH
export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
export PROOT_LOADER=\$DATA_DIR/libexec/proot/loader export PROOT_LOADER=\$DATA_DIR/libexec/proot/loader
export PROOT_LOADER_32=\$DATA_DIR/libexec/proot/loader32 export PROOT_LOADER_32=\$DATA_DIR/libexec/proot/loader32
export PROOT_L2S_DIR=\$CONTAINER_DIR/.l2s #export PROOT_L2S_DIR=\$CONTAINER_DIR/.l2s
\$DATA_DIR/bin/proot --link2symlink sh -c "cat xa* | \$DATA_DIR/bin/tar x -J --delay-directory-restore --preserve-permissions -v -C containers/0" \$DATA_DIR/bin/proot --link2symlink sh -c "cat xa* | \$DATA_DIR/bin/tar x -J --delay-directory-restore --preserve-permissions -v -C containers/0"
#Script from proot-distro #Script from proot-distro
chmod u+rw "\$CONTAINER_DIR/etc/passwd" "\$CONTAINER_DIR/etc/shadow" "\$CONTAINER_DIR/etc/group" "\$CONTAINER_DIR/etc/gshadow" chmod u+rw "\$CONTAINER_DIR/etc/passwd" "\$CONTAINER_DIR/etc/shadow" "\$CONTAINER_DIR/etc/group" "\$CONTAINER_DIR/etc/gshadow"
@@ -477,40 +551,23 @@ done
//$DATA_DIR是数据文件夹, $CONTAINER_DIR是容器根目录 //$DATA_DIR是数据文件夹, $CONTAINER_DIR是容器根目录
await G.prefs.setStringList("containersInfo", ["""{ await G.prefs.setStringList("containersInfo", ["""{
"name":"Debian Bookworm", "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-linuxproot_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=/data/data/com.termux/files/home/.local/share/tmoe-linux/containersproot/debian-bookworm_arm64/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 &", "vnc":"startnovnc &",
"vncUrl":"http://localhost:36082/vnc.html?host=localhost&port=36082&autoconnect=true&resize=remote&password=12345678", "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"}, "commands":${jsonEncode(D.commands)}
{"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":"修复无法编译C语言程序", "command":"sudo apt update && sudo apt reinstall -y libc6-dev"},
{"name":"启用回收站", "command":"sudo apt update && sudo apt install -y gvfs && echo '安装完成, 重启软件即可使用回收站。'"},
{"name":"???", "command":"timeout 8 cmatrix"}]
}"""]); }"""]);
await G.prefs.setStringList("adsBonus", []); // await G.prefs.setStringList("adsBonus", []);
await G.prefs.setInt("adsWatchedTotal", 0); // await G.prefs.setInt("adsWatchedTotal", 0);
await G.prefs.setBool("isTerminalCommandsEnabled", false); // await G.prefs.setBool("isTerminalCommandsEnabled", false);
await G.prefs.setBool("isTerminalWriteEnabled", false); // await G.prefs.setBool("isTerminalWriteEnabled", false);
await G.prefs.setBool("isBannerAdsClosed", false); // await G.prefs.setBool("isBannerAdsClosed", false);
await G.prefs.setBool("autoLaunchVnc", true); // await G.prefs.setBool("autoLaunchVnc", true);
await G.prefs.setInt("defaultAudioPort", 4718); // await G.prefs.setInt("defaultAudioPort", 4718);
await G.prefs.setInt("defaultContainer", 0); // await G.prefs.setInt("defaultContainer", 0);
await G.prefs.setInt("termMaxLines", 4095); // await G.prefs.setInt("termMaxLines", 4095);
await G.prefs.setDouble("termFontScale", 1); // await G.prefs.setDouble("termFontScale", 1);
await G.prefs.setInt("vip", 0); // await G.prefs.setInt("vip", 0);
await G.prefs.setBool("isStickyKey", true); // await G.prefs.setBool("isStickyKey", true);
} }
static Future<void> initData() async { static Future<void> initData() async {
@@ -525,7 +582,7 @@ done
//限制一天内观看视频广告不超过5次 //限制一天内观看视频广告不超过5次
final String currentDate = DateFormat("yyyy-MM-dd").format(DateTime.now()); 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.setString("lastDate", currentDate);
await G.prefs.setInt("adsWatchedToday", 0); await G.prefs.setInt("adsWatchedToday", 0);
} }
@@ -534,12 +591,29 @@ done
if (!G.prefs.containsKey("defaultContainer")) { if (!G.prefs.containsKey("defaultContainer")) {
await initForFirstTime(); 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); G.controller = WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);
//恢复临时开启的功能
if (Util.shouldWatchAds(G.adsRequired["changeFFmpegCommand"]!)) {
await G.prefs.remove("defaultFFmpegCommand");
}
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 { static Future<void> initTerminalForCurrent() async {
@@ -574,7 +648,7 @@ export TMPDIR=\$PWD/cache
cd \$DATA_DIR cd \$DATA_DIR
export HOME=\$DATA_DIR/share export HOME=\$DATA_DIR/share
export LD_LIBRARY_PATH=\$DATA_DIR/bin 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 \$DATA_DIR/bin/pulseaudio -F \$DATA_DIR/bin/pulseaudio.conf.tmp
exit exit
""")); """));
@@ -586,13 +660,13 @@ exit
""" """
export DATA_DIR=${G.dataPath} export DATA_DIR=${G.dataPath}
export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer} export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer}
export PROOT_L2S_DIR=\$DATA_DIR/containers/0/.l2s #export PROOT_L2S_DIR=\$DATA_DIR/containers/0/.l2s
cd \$DATA_DIR cd \$DATA_DIR
export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
export PROOT_LOADER=\$DATA_DIR/libexec/proot/loader export PROOT_LOADER=\$DATA_DIR/libexec/proot/loader
export PROOT_LOADER_32=\$DATA_DIR/libexec/proot/loader32 export PROOT_LOADER_32=\$DATA_DIR/libexec/proot/loader32
${Util.getCurrentProp("boot")} ${Util.getCurrentProp("boot")}
${G.prefs.getBool("autoLaunchVnc")!?Util.getCurrentProp("vnc"):""} ${(Util.getGlobal("autoLaunchVnc") as bool)?Util.getCurrentProp("vnc"):""}
clear"""); clear""");
} }
@@ -643,7 +717,7 @@ clear""");
await initTerminalForCurrent(); await initTerminalForCurrent();
setupAudio(); setupAudio();
launchCurrentContainer(); launchCurrentContainer();
if (G.prefs.getBool("autoLaunchVnc")!) { if (Util.getGlobal("autoLaunchVnc") as bool) {
waitForConnection().then((value) => launchBrowser()); waitForConnection().then((value) => launchBrowser());
} }
} }

View File

@@ -5,11 +5,13 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import ffmpeg_kit_flutter_full_gpl
import path_provider_foundation import path_provider_foundation
import shared_preferences_foundation import shared_preferences_foundation
import url_launcher_macos import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FFmpegKitFlutterPlugin.register(with: registry.registrar(forPlugin: "FFmpegKitFlutterPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))

View File

@@ -81,6 +81,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" 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: file:
dependency: transitive dependency: transitive
description: description:
@@ -312,6 +328,15 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.2" version: "3.1.2"
saf:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: e3aa3fcbd031f2645688e97ebd5a4f14a014bd42
url: "https://github.com/Cateners/saf"
source: git
version: "1.0.3+3"
shared_preferences: shared_preferences:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -521,18 +546,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: webview_flutter name: webview_flutter
sha256: "82f6787d5df55907aa01e49bd9644f4ed1cc82af7a8257dd9947815959d2e755" sha256: c1ab9b81090705c6069197d9fdc1625e587b52b8d70cdde2339d177ad0dbb98e
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.2.4" version: "4.4.1"
webview_flutter_android: webview_flutter_android:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_android name: webview_flutter_android
sha256: ddc167c6676f57c8b367d19fcbee267d6dc6adf81bd6c3cb87981d30746e0a6d sha256: b0cd33dd7d3dd8e5f664e11a19e17ba12c352647269921a3b568406b001f1dff
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.10.1" version: "3.12.0"
webview_flutter_platform_interface: webview_flutter_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -545,10 +570,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_wkwebview name: webview_flutter_wkwebview
sha256: "485af05f2c5f83c7f78c20e236b170ad02df7153b299ae9917345be43871d29f" sha256: "30b9af6bdd457b44c08748b9190d23208b5165357cc2eb57914fee1366c42974"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.8.0" version: "3.9.1"
win32: win32:
dependency: transitive dependency: transitive
description: description:

View File

@@ -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 # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.8+4 version: 1.0.10+1
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'
@@ -42,6 +42,9 @@ dependencies:
intl: ^0.18.1 #日期字符串转换 intl: ^0.18.1 #日期字符串转换
unity_ads_plugin: ^0.3.8 unity_ads_plugin: ^0.3.8
clipboard: ^0.1.3 clipboard: ^0.1.3
ffmpeg_kit_flutter_full_gpl: ^6.0.3
saf:
git: https://github.com/Cateners/saf
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.