From 62995e0a5d726924f3dfd6aee6c1d53802f365ab Mon Sep 17 00:00:00 2001 From: Caten Date: Sun, 11 Aug 2024 10:49:28 +0800 Subject: [PATCH] Signal9Page Change & More --- android/app/src/main/AndroidManifest.xml | 1 + .../com/example/tiny_computer/MainActivity.kt | 4 + .../example/tiny_computer/Signal9Activity.kt | 130 ++++++++++++++++++ lib/main.dart | 39 +++--- lib/workflow.dart | 59 ++------ pubspec.lock | 64 ++++----- pubspec.yaml | 2 +- 7 files changed, 200 insertions(+), 99 deletions(-) create mode 100644 android/app/src/main/kotlin/com/example/tiny_computer/Signal9Activity.kt diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6457f86..738f1ba 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ + diff --git a/android/app/src/main/kotlin/com/example/tiny_computer/MainActivity.kt b/android/app/src/main/kotlin/com/example/tiny_computer/MainActivity.kt index e264442..72227e0 100644 --- a/android/app/src/main/kotlin/com/example/tiny_computer/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/tiny_computer/MainActivity.kt @@ -45,6 +45,10 @@ class MainActivity: FlutterActivity() { startActivity(Intent(this, com.gaurav.avnc.ui.about.AboutActivity::class.java)) result.success(0) } + "launchSignal9Page" -> { + startActivity(Intent(this, Signal9Activity::class.java)) + result.success(0) + } else -> { // 不支持的方法名 result.notImplemented() diff --git a/android/app/src/main/kotlin/com/example/tiny_computer/Signal9Activity.kt b/android/app/src/main/kotlin/com/example/tiny_computer/Signal9Activity.kt new file mode 100644 index 0000000..e712ef0 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/tiny_computer/Signal9Activity.kt @@ -0,0 +1,130 @@ +package com.example.tiny_computer + +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context +import android.content.Intent +import android.graphics.Color +import android.net.Uri +import android.os.Bundle +import android.view.Gravity +import android.view.View +import android.widget.Button +import android.widget.ScrollView +import android.widget.TextView +import android.widget.Toast +import android.widget.LinearLayout +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat.startActivity + +class Signal9Activity : AppCompatActivity() { + + private val helperLink = "https://www.vmos.cn/zhushou.htm" + private val helperLink2 = "https://b23.tv/WwqOqW6" + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val rootLayout = LinearLayout(this).apply { + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.WRAP_CONTENT + ) + gravity = Gravity.CENTER + orientation = LinearLayout.VERTICAL + setPadding(16, 16, 16, 16) + setBackgroundColor(Color.parseColor("#4A148C")) + } + + val scrollView = ScrollView(this).apply { + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + 0 + ).apply { + weight = 1f + } + } + + val fullScreen = LinearLayout(this).apply { + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT + ) + orientation = LinearLayout.VERTICAL + } + + val text1 = TextView(this).apply { + text = ":(\n发生了什么?" + textSize = 32f + setTextColor(Color.WHITE) + textAlignment = View.TEXT_ALIGNMENT_CENTER + } + + val text2 = TextView(this).apply { + text = "终端异常退出, 返回错误码9\n此错误通常是高版本安卓系统(12+)限制进程造成的, \n可以使用以下工具修复:" + textSize = 16f + setTextColor(Color.WHITE) + textAlignment = View.TEXT_ALIGNMENT_CENTER + setPadding(0, 16, 0, 0) + } + + val helperLinkText = TextView(this).apply { + text = helperLink + textSize = 16f + setTextColor(Color.WHITE) + textAlignment = View.TEXT_ALIGNMENT_CENTER + setPadding(0, 16, 0, 0) + setOnClickListener { copyToClipboard(helperLink) } + } + + val copyHintText = TextView(this).apply { + text = "(复制链接到浏览器查看)" + textSize = 16f + setTextColor(Color.WHITE) + textAlignment = View.TEXT_ALIGNMENT_CENTER + setPadding(0, 8, 0, 0) + } + + val copyButton = Button(this).apply { + text = "复制" + textSize = 16f + setOnClickListener { copyToClipboard(helperLink) } + } + + val tutorialText = TextView(this).apply { + text = "如果你的设备版本大于等于安卓14,可以在开发者选项里开启“停止限制子进程”选项即可,无需额外修复。\n\n如果不能解决请参考此教程: " + textSize = 16f + setTextColor(Color.WHITE) + textAlignment = View.TEXT_ALIGNMENT_CENTER + setPadding(0, 16, 0, 0) + } + + val viewButton = Button(this).apply { + text = "查看" + textSize = 16f + setOnClickListener { copyToClipboard(helperLink2) } + } + + rootLayout.addView(text1) + rootLayout.addView(text2) + rootLayout.addView(helperLinkText) + rootLayout.addView(copyHintText) + rootLayout.addView(copyButton) + rootLayout.addView(tutorialText) + rootLayout.addView(viewButton) + + scrollView.addView(rootLayout) + fullScreen.addView(scrollView) + + setContentView(fullScreen) + } + + private fun copyToClipboard(text: String) { + val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip = ClipData.newPlainText("Copied Text", text) + clipboard.setPrimaryClip(clip) + Toast.makeText(this, "已复制", Toast.LENGTH_SHORT).show() + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(text)) + startActivity(this, intent, null) + } +} diff --git a/lib/main.dart b/lib/main.dart index 193159b..4b510c7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -132,21 +132,26 @@ class _SettingPageState extends State { headerBuilder: ((context, isExpanded) { return const ListTile(title: Text("高级设置"), subtitle: Text("修改后重启生效")); }), body: Padding(padding: const EdgeInsets.all(12), child: Column(children: [ - OutlinedButton(style: D.commandButtonStyle, child: const Text("重置启动命令"), onPressed: () { - showDialog(context: context, builder: (context) { - return AlertDialog(title: const Text("注意"), content: const Text("是否重置启动命令?"), actions: [ - TextButton(onPressed:() { - Navigator.of(context).pop(); - }, child: const Text("取消")), - TextButton(onPressed:() async { - await Util.setCurrentProp("boot", D.boot); - G.bootTextChange.value = !G.bootTextChange.value; - if (!context.mounted) return; - Navigator.of(context).pop(); - }, child: const Text("是")), - ]); - }); - }), + Wrap(alignment: WrapAlignment.center, spacing: 4.0, runSpacing: 4.0, children: [ + OutlinedButton(style: D.commandButtonStyle, child: const Text("重置启动命令"), onPressed: () { + showDialog(context: context, builder: (context) { + return AlertDialog(title: const Text("注意"), content: const Text("是否重置启动命令?"), actions: [ + TextButton(onPressed:() { + Navigator.of(context).pop(); + }, child: const Text("取消")), + TextButton(onPressed:() async { + await Util.setCurrentProp("boot", D.boot); + G.bootTextChange.value = !G.bootTextChange.value; + if (!context.mounted) return; + Navigator.of(context).pop(); + }, child: const Text("是")), + ]); + }); + }), + OutlinedButton(style: D.commandButtonStyle, child: const Text("Signal9错误页面"), onPressed: () async { + await D.avncChannel.invokeMethod("launchSignal9Page", {}); + }), + ]), const SizedBox.square(dimension: 8), TextFormField(maxLines: null, initialValue: Util.getCurrentProp("name"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "容器名称"), onChanged: (value) async { await Util.setCurrentProp("name", value); @@ -484,7 +489,7 @@ Virgl可为使用OpenGL ES的应用提供加速。"""), const SizedBox.square(dimension: 16), const Divider(height: 2, indent: 8, endIndent: 8), const SizedBox.square(dimension: 16), - const Text("""搭载Adreno GPU的设备通常可以使用Turnip驱动加速使用Vulkan的软件。 + const Text("""搭载Adreno GPU的设备通常可以使用Turnip驱动加速使用Vulkan的软件。配合Zink驱动可实现加速使用OpenGL的软件。 (也就是搭载不太新也不太旧的骁龙处理器的设备)"""), const SizedBox.square(dimension: 8), @@ -494,7 +499,7 @@ Virgl可为使用OpenGL ES的应用提供加速。"""), }, ), const SizedBox.square(dimension: 8), - SwitchListTile(title: const Text("启用Turnip驱动"), subtitle: const Text("下次启动时生效"), value: Util.getGlobal("turnip") as bool, onChanged:(value) async { + SwitchListTile(title: const Text("启用Turnip+Zink驱动"), subtitle: const Text("下次启动时生效"), value: Util.getGlobal("turnip") as bool, onChanged:(value) async { G.prefs.setBool("turnip", value); setState(() {}); },), diff --git a/lib/workflow.dart b/lib/workflow.dart index 4689d78..e25b4ad 100644 --- a/lib/workflow.dart +++ b/lib/workflow.dart @@ -28,7 +28,6 @@ import 'package:retry/retry.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:xterm/xterm.dart'; @@ -39,8 +38,6 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:clipboard/clipboard.dart'; - import 'package:wakelock_plus/wakelock_plus.dart'; class Util { @@ -123,7 +120,7 @@ class Util { 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"); - case "defaultTurnipOpt" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("VK_ICD_FILENAMES=/home/tiny/.local/share/tiny/extra/freedreno_icd.aarch64.json TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw"); + case "defaultTurnipOpt" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("MESA_LOADER_DRIVER_OVERRIDE=zink VK_ICD_FILENAMES=/home/tiny/.local/share/tiny/extra/freedreno_icd.aarch64.json TU_DEBUG=noconform MESA_VK_WSI_DEBUG=sw"); case "defaultHidpiOpt" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("GDK_SCALE=2 QT_FONT_DPI=192"); case "containersInfo" : return G.prefs.getStringList(key)!; } @@ -274,45 +271,7 @@ class TermPty { } //Signal 9 hint if (code == -9) { - 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: - SingleChildScrollView( - child: Column(children: [ - const Text(":(\n发生了什么?", textScaler: TextScaler.linear(2), style: ts, textAlign: TextAlign.center,), - const Text("终端异常退出, 返回错误码9\n此错误通常是高版本安卓系统(12+)限制进程造成的, \n可以使用以下工具修复:", style: ts, textAlign: TextAlign.center), - const SelectableText(helperLink, style: ts, textAlign: TextAlign.center), - const Text("(复制链接到浏览器查看)", style: ts, textAlign: TextAlign.center), - OutlinedButton(onPressed: () { - FlutterClipboard.copy(helperLink).then(( value ) { - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: const Text("已复制"), action: SnackBarAction(label: "跳转", onPressed: () { - launchUrl(Uri.parse(helperLink), mode: LaunchMode.externalApplication); - },)) - ); - }); - }, 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)) - ]), - ) - ) - )); - })); + D.avncChannel.invokeMethod("launchSignal9Page", {}); } }); terminal.onOutput = (data) { @@ -341,20 +300,22 @@ class D { //帮助信息 static const faq = [ - {"q":"错误码9", "a":"""如果你的系统版本大于等于android 12 + {"q":"安卓12及以上注意事项:错误码9", "a":"""如果你的系统版本大于等于android 12 可能会在使用过程中异常退出(返回错误码9) 届时本软件会提供方案指引你修复 并不难 但是软件没有权限 -不能帮你修复"""}, - {"q":"用一会就断掉", "a":"""这应该是出现了错误9的情况 -下次出现此情况时 -按设备的返回键(或用返回手势) -应该能看到软件提供的修复引导"""}, +不能帮你修复 + +你也可以在高级设置里手动前往错误页面"""}, {"q":"安卓13注意事项", "a":"""如果你的系统版本大于等于android 13 那么很可能一些网页应用如jupyter notebook bilibili客户端等等不可用 可以去全局设置开启getifaddrs桥接"""}, + {"q":"用一会就断掉", "a":"""这应该是出现了错误9的情况 +下次出现此情况时 +按设备的返回键(或用返回手势) +应该能看到软件提供的修复引导"""}, {"q":"如何访问设备文件?", "a":"""如果你给了存储权限 那么通过主目录下的文件夹 就可以访问设备存储 diff --git a/pubspec.lock b/pubspec.lock index e5a35a7..6686da8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -276,10 +276,10 @@ packages: dependency: transitive description: name: package_info_plus - sha256: "4de6c36df77ffbcef0a5aefe04669d33f2d18397fea228277b852a2d4e58e860" + sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918 url: "https://pub.dev" source: hosted - version: "8.0.1" + version: "8.0.2" package_info_plus_platform_interface: dependency: transitive description: @@ -300,10 +300,10 @@ packages: dependency: "direct main" description: name: path_provider - sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" path_provider_android: dependency: transitive description: @@ -356,10 +356,10 @@ packages: dependency: transitive description: name: permission_handler_android - sha256: b29a799ca03be9f999aa6c39f7de5209482d638e6f857f6b93b0875c618b7e54 + sha256: eaf2a1ec4472775451e88ca6a7b86559ef2f1d1ed903942ed135e38ea0097dca url: "https://pub.dev" source: hosted - version: "12.0.7" + version: "12.0.8" permission_handler_apple: dependency: transitive description: @@ -380,10 +380,10 @@ packages: dependency: transitive description: name: permission_handler_platform_interface - sha256: "48d4fcf201a1dad93ee869ab0d4101d084f49136ec82a8a06ed9cfeacab9fd20" + sha256: fe0ffe274d665be8e34f9c59705441a7d248edebbe5d9e3ec2665f88b79358ea url: "https://pub.dev" source: hosted - version: "4.2.1" + version: "4.2.2" permission_handler_windows: dependency: transitive description: @@ -436,58 +436,58 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 + sha256: c272f9cabca5a81adc9b0894381e9c1def363e980f960fa903c604c471b22f68 url: "https://pub.dev" source: hosted - version: "2.2.3" + version: "2.3.1" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "3d4571b3c5eb58ce52a419d86e655493d0bc3020672da79f72fa0c16ca3a8ec1" + sha256: a7e8467e9181cef109f601e3f65765685786c1a738a83d7fbbde377589c0d974 url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.3.1" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7" + sha256: "776786cff96324851b656777648f36ac772d88bc4c669acff97b7fce5de3c849" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.5.1" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.1" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - sha256: "034650b71e73629ca08a0bd789fd1d83cc63c2d1e405946f7cef7bc37432f93a" + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" + sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.4.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.1" sky_engine: dependency: transitive description: flutter @@ -561,10 +561,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "678979703e10d7862c551c736fe6b9f185261bddf141b46672063b99790bc700" + sha256: "94d8ad05f44c6d4e2ffe5567ab4d741b82d62e3c8e288cc1fcea45965edf47c9" url: "https://pub.dev" source: hosted - version: "6.3.7" + version: "6.3.8" url_launcher_ios: dependency: transitive description: @@ -577,10 +577,10 @@ packages: dependency: transitive description: name: url_launcher_linux - sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 + sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.2.0" url_launcher_macos: dependency: transitive description: @@ -601,10 +601,10 @@ packages: dependency: transitive description: name: url_launcher_web - sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" + sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.3" url_launcher_windows: dependency: transitive description: @@ -665,10 +665,10 @@ packages: dependency: transitive description: name: webview_flutter_android - sha256: "060e1a621add859dc822f3e4c59b01468e8515ea78cfc5ac4c6b28bc903b5f74" + sha256: c66651fba15f9d7ddd31daec42da8d6bce46c85610a7127e3ebcb39a4395c3c9 url: "https://pub.dev" source: hosted - version: "3.16.5" + version: "3.16.6" webview_flutter_platform_interface: dependency: transitive description: @@ -689,10 +689,10 @@ packages: dependency: transitive description: name: win32 - sha256: a79dbe579cb51ecd6d30b17e0cae4e0ea15e2c0e66f69ad4198f22a6789e94f4 + sha256: "015002c060f1ae9f41a818f2d5640389cc05283e368be19dc8d77cecb43c40c9" url: "https://pub.dev" source: hosted - version: "5.5.1" + version: "5.5.3" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 34b2391..7c14750 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.16+12 +version: 1.0.17+13 environment: sdk: '>=3.1.0 <4.0.0'