├── .gitignore ├── .metadata ├── README.md ├── adb_simulate_code.txt ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── flutter_mobile_command_tools │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets ├── apk.jks ├── apksigner.jar ├── apksigner.json ├── fonts │ └── SourceHanSansCN-Regular-2.otf ├── linux │ └── tools.zip ├── macos │ └── tools.zip └── windows │ └── tools.zip ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── base │ ├── base_command.dart │ └── base_dialog.dart ├── command │ └── adb_command.dart ├── constants.dart ├── enum │ ├── adb_command_type.dart │ ├── click_type.dart │ ├── dir_type.dart │ ├── file_name_type.dart │ ├── panel_type.dart │ └── sim_operation_type.dart ├── global.dart ├── main.dart ├── main_test.dart ├── mixin │ ├── android_panel_mixin.dart │ └── main_mixin.dart ├── model │ ├── command_result_model.dart │ ├── sim_operation_model.dart │ └── text_field_model.dart ├── notifier │ ├── devices_notifier.dart │ ├── dialog │ │ ├── android_input_notifier.dart │ │ └── android_sim_script_notifier.dart │ ├── log_change_notifier.dart │ └── panel │ │ └── android_panel_notifier.dart ├── theme.dart ├── utils │ ├── TimeUtils.dart │ ├── command_utils.dart │ ├── dialog_utils.dart │ ├── file_utils.dart │ ├── init_utils.dart │ ├── log_utils.dart │ ├── notifier_utils.dart │ ├── number_utils.dart │ ├── platform_utils.dart │ ├── style_utils.dart │ ├── toast_utils.dart │ └── window_utils.dart └── widgets │ ├── android_log_widget.dart │ ├── android_panel.dart │ └── dialog │ └── android_sim_script_dialog.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Podfile ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── screenshots ├── linux.png ├── macos.png ├── settings.png ├── simtool.png └── windows.png ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ └── Icon-512.png ├── index.html └── manifest.json └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── run_loop.cpp ├── run_loop.h ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: d79295af24c3ed621c33713ecda14ad196fd9c31 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MobileTool 2 | 超级方便的adb命令工具,支持所有桌面端,不管你是开发还是测试,都可以试试看。 3 | + [录制在b站的讲解视频](https://www.bilibili.com/video/BV1vY4y1J788?vd_source=62e17be4df670ba78219421e89af9bc9) 4 | 5 | ## 说明 6 | + 关于Android 7 | 8 | 请自行打开手机开发者模式中的USB调试,确保手机和电脑能连接上。确保能使用adb连接上。。本工具Android模块只是将adb的大部分命令进行了懒人模式,有问题欢迎提issues。[adb命令参考](https://github.com/mzlogin/awesome-adb) 9 | + [安卓手机开启开发者选项](https://jingyan.baidu.com/article/642c9d34e8a0d4254a46f7f8.html) 10 | 11 | + 关于IOS 12 | 13 | 使用[libimobiledevice](https://github.com/libimobiledevice/libimobiledevice),IOS意义不是很大。就写了几个小功能。还是爱思比较香。 14 | 15 | + 关于配置文件和工具 16 | 17 | - 本地文件路径 18 | 19 | 1. Windows:C:\Users\用户名\Documents\MobileTools 20 | 2. Linux:/home/用户名/Documents/MobileTools 21 | 3. Windows:/Users/用户名/Documents/MobileTools 22 | - MobileTools的目录结构 23 | 24 | 1. apksigner文件夹(签名文件) 25 | 2. config文件夹(用于保存一些信息) 26 | 3. tools文件夹(包含adb、反编译一些本地文件) 27 | + apktool文件夹(存放apktool.jar文件和FakerAndroid.jar,去云盘取) 28 | + uiautomatorviewer文件夹(存放获取焦点工具,去云盘取) 29 | + 一些adb以及fastboot文件 30 | 4. SETTING(本地路径的设置文件) 31 | 5. VERSION文件(当前软件的版本号) 32 | 33 | 如果需要使用反编译,以及获取当前界面的焦点的工具,几个工具太大。保存到了百度云盘,需要的可以放到tools文件夹下面。[链接](https://pan.baidu.com/s/12ns4VdU3xRYYmacXvUIKbw),提取码:xjwr。 34 | ## 功能 35 | 36 | ### 设置 37 | 38 | + adb(选择本机的adb文件,以防止和内部adb冲突) 39 | + java(部分命令需要java环境,如果你不想配置环境变量,可以选择java文件) 40 | + libimobiledevice(IOS的环境,感觉用处不是很大) 41 | 42 | ![](screenshots/settings.png) 43 | 44 | ### Android 45 | + 开启Root 46 | 如果手机有Root权限,可以打开,在获取信息的时候使用到。如果手机有Magisk,可以安装这个插件[adb_root](https://github.com/evdenis/adb_root),可以让所有的命令都走root权限。 47 | 48 | + 内置ADB 49 | 如果你的电脑没有adb,打开这个开关会使用内置的adb。如果你电脑本身有adb,点击右上角的配置,配置adb路径,以免内置的adb和你安装的adb冲突。 50 | 51 | + 基本操作 52 | - 获取设备 53 | 获取当前所有连接的Android设备,展示在下拉框里面(如果当前只有单一设备,也可以不获取) 54 | - 获取设备信息 55 | 选择,然后点击获取信息,部分信息在高版本的手机上面需要Root权限 56 | - 自定义adb命令(3.0新增) 57 | 本软件没有涉及带的命令,可以添加保存,下次使用 58 | - 自定义其他命令(3.0新增) 59 | 相关其他终端命令,可以添加保存,下次使用 60 | 61 | + 无线连接 62 | - 无线连接 63 | 选择真机,非自定义的情况下会去获取当前真机的ip,获取成功直接去连接,获取失败,需要自定义去填入ip:port。选择其他模拟器设备,默认内置了所有模拟器的第一台设备的端口。然后点击无线连接就ok了。 64 | - 断开 65 | 只能断开无线连接的设备和模拟器 66 | 67 | + 应用管理 68 | 69 | + 当前包名 70 | 获取当前展示的app包名,展示在上面的下拉框里面。 71 | + 冻结包名(3.0新增) 72 | 获取所有冻结的app包名,展示在上面的下拉框里面。 73 | + 第三方包名(2.0新增) 74 | 获取当前所有第三方的app包名,展示在上面的下拉框里面。 75 | + 系统包名(2.0新增) 76 | 获取当前所有系统的app包名,展示在上面的下拉框里面。 77 | + 冷冻(3.0新增) 78 | 对当前选择的包名对应的apk进行冷冻 79 | + 解冻(3.0新增) 80 | 先获取所有冻结的包名,然后选择包名,进行解冻 81 | + 安装apk 82 | 选择本地的apk文件安装到手机上面 83 | + 卸载apk 84 | 卸载当前获取到包名的apk。 85 | + 主Activity(3.0新增) 86 | 获取当前包名的启动Activity类名。 87 | + 当前Activity(3.0新增) 88 | 当前正在展示的Activity类名。 89 | + app包信息(2.0新增) 90 | 当前获取到包名的app信息,可以复制部分信息为应用交互做准备。 91 | + apk安装路径 92 | 当前获取到包名的app路径。 93 | + 清除数据 94 | 清除当前获取到包名的缓存数据。 95 | 96 | + 应用信息(3.0新增) 97 | 98 | + 内部包名和外部apk 99 | 选择内部包名需要先获取包名,然后点击下面的按钮,选择外部apk,点击下面的按钮会弹窗让你选择apk 100 | + apk包信息 101 | 获取app的包信息(包含app包名、app名字、app版本、app启动类) 102 | + apk权限 103 | 获取apk需要的权限信息 104 | 105 | + 应用交互(2.0新增) 106 | 107 | 以下3.0版本都对其进行了本地保存,可以自行添加,以供下次使用。存储在config文件夹下面。 108 | 109 | - 启动Activity 110 | 弹窗输入要启动的Activity名字,如果没有输入将启动当前获取包名的app。(关于启动类可以通过主Activity包信息获取) 111 | - 发送BroadcastReceiver 112 | 弹窗输入要启动的广播,下面也列出了部分系统广播,用于测试很难出现的广播。 113 | - 发送Service 114 | 弹出输入要启动的Service 115 | - 停止Service 116 | 弹出输入要通知的Service 117 | 118 | + 文件管理 119 | - 推送文件 120 | 选择文件推送到当前设备,默认推送位置/data/local/tmp。点击自定义路径,可以输入你想推送的路径。 121 | + 拉取文件 122 | 从当前设备拉取文件到桌面。 123 | 1. 手机crash 124 | 点击手机crash,将收集所有crash日志,展示出来,然后选择时间点点击拉取crash。会推送到桌面 125 | 2. 拉取文件 126 | 只是为了拉取文件。需要先配置搜索的文件路径,然后点击搜索,会搜索该路径下的所有文件。然后再点击拉取文件。也会推送到桌面。 127 | 3. 拉取anr 128 | 直接点击,会直接拉取anr日志到桌面(时间有点长,耐心等待) 129 | 130 | + 模拟操作 131 | 你可以使用大部分模拟命令。 132 | 133 | + 打开获取焦点工具(3.0新增,需要java环境。需要从云盘获取工具放到tools文件夹) 134 | ![](screenshots/simtool.png) 135 | + 添加指令文件 136 | 支持4类指令。滑动、点击、文本、所有按键(参考[adb_simulate_code.txt](adb_simulate_code.txt)文件) 137 | - 关于输入中文的问题,参考以下: 138 | + [ADBKeyBoard](https://github.com/senzhk/ADBKeyBoard) 139 | + [解决adb输入中文以及乱码的问题](https://blog.csdn.net/RHJlife/article/details/122202511) 140 | + 刷新指令文件(3.0新增) 141 | 修改之后。可以直接刷新指令,直接使用 142 | + 执行指令 143 | 用户执行指令的按钮 144 | + 停止指令 145 | 只有在开启循环时有效。表示停止执行循环 146 | 147 | + 逆向相关(3.0新增,需要java环境。需要从云盘获取工具放到tools文件夹) 148 | 149 | + Apktool拆包 150 | 使用apktool进行拆包。详情见[Apktool](https://ibotpeaches.github.io/Apktool/) 151 | + ApkTool合包 152 | 使用apktook进行合包。详情见[Apktool](https://ibotpeaches.github.io/Apktool/) 153 | + FakerAndroid 154 | 使用FakerAndroid进行拆包可以二次开发的gradle项目。详情见[FakerAndroid](https://github.com/Efaker/FakerAndroid) 155 | 156 | + 刷机相关 157 | 158 | + 重启手机 159 | 重新启动手机 160 | + 重启到fastboot 161 | 重启手机到fastboot模式 162 | + 重启到recovery 163 | 重启手机到recovery模式 164 | 165 | + 实用操作 166 | 167 | + 截屏(2.0修改) 168 | 截取当前设备的界面,并且推送到桌面(命名 当前时间.png) 169 | + 录屏(2.0修改) 170 | 录取当前屏幕,需要先设置时间,完成后推送到桌面(命名 当前时间.mp4) 171 | + v2签名 172 | 使用apksigner的签名。可以进行替换,保证文件名一样。apksigner.json为签名的key以及密码。替换记得修改。 173 | + 前面校验 174 | 校验apk的签名信息 175 | ### IOS 176 | 177 | IOS意义不是很大,简单写了几个命令。要下itunes,还有下面的工具,提供获取设备,获取包名,安装和卸载ipa。直接用爱思吧。 178 | 179 | + [libimobiledevice-windows](https://github.com/libimobiledevice-win32/imobiledevice-net) 180 | + [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice) 181 | 182 | ## 编译 183 | 所有平台应用都改成了占当前屏幕的2/3,采用居中显示,linux没有居中,GTK没搞过。 184 | + windows 185 | 186 | ``` 187 | 安装Visual Studio,c++桌面包。 188 | flutter build windows //进行编译。 189 | 在build/windows/runner 会生成Visual Studio的解决方案工程,可以导入进行开发。 190 | 生成的exe在build/windows/runner/Release/*.exe 191 | ``` 192 | 193 | + linux 194 | 195 | ``` 196 | //linux需要安装以下依赖 197 | sudo apt-get update 198 | sudo apt install clang 199 | sudo apt install cmake 200 | sudo apt install ninja-build 201 | sudo apt install libgtk-3-dev 202 | 203 | 204 | file INSTALL cannot copy file //出现这个问题 205 | flutter clean //执行这个然后重启AndroidStudio 206 | 207 | flutter build linux //生成release包,文件在build/linux/release/bundle下面 208 | 209 | 使用adb出现adb devices => no permissions (user in plugdev group; are your udev rules wrong?) [duplicate] 210 | 参考地址解决:https://stackoverflow.com/questions/53887322/adb-devices-no-permissions-user-in-plugdev-group-are-your-udev-rules-wrong 211 | 212 | ``` 213 | 214 | + macos 215 | 216 | ``` 217 | 安装Xcode,然后在编译的时候遇到很多小问题。然后百度解决了,其中一个 218 | [tool_crash] Invalid argument(s): Cannot find executable for /Users/imac/Documents/FlutterSDK/flutter/bin/cache/artifacts 219 | 解决方案:https://github.com/flutter/flutter/issues/85107 220 | 221 | flutter build macos //生成release包,文件在build/macos/Build/Products/Release/下面 222 | 将mac目录下的文件倒入xcode可进行开发 223 | ``` 224 | 225 | 226 | ## 截图展示 227 | + windows(1920*1080) 228 | ![screenshots/windows.png](screenshots/windows.png) 229 | 230 | + linux (1920*1080) 231 | ![screenshots/linux.png](screenshots/linux.png) 232 | 233 | + macos (1440*960) 234 | ![screenshots/macos.png](screenshots/macos.png) 235 | 236 | ## 其他 237 | 238 | + [关于Windows调用Process.start隐藏黑色弹窗](https://github.com/dart-lang/sdk/issues/39945) 239 | -------------------------------------------------------------------------------- /adb_simulate_code.txt: -------------------------------------------------------------------------------- 1 | //文件规则 2 | 0/1 //0表示当前是执行这个文件的所有指令,1表示可以执行单个指令 3 | swipe x1 y1 x2 y2 滑动名字 //滑动的格式,必须swipe开头,每个以单个空格隔开 4 | tap x1 y1 点击名字 //点击的格式,必须tap开头,每个以单个空格隔开 5 | text 文本 输入文字名字 //输入的格式,必须text开头,每个以单个空格隔开 6 | event 按键数字 按键名字 //按键的格式,必须event开头,每个以单个空格隔开 7 | adb 指令 指令名字 //其他adb命令,必须adb开头,每个以单个空格隔开 8 | other 指令 指令名字 //其他指令,必须other开头(不属于adb范畴的),每个以单个空格隔开 9 | 10 | //以下是各个按键的数字对应 11 | 0 KEYCODE_UNKNOWN 12 | 1 KEYCODE_MENU 13 | 2 KEYCODE_SOFT_RIGHT 14 | 3 KEYCODE_HOME 15 | 4 KEYCODE_BACK 16 | 5 KEYCODE_CALL 17 | 6 KEYCODE_ENDCALL 18 | 7 KEYCODE_0 19 | 8 KEYCODE_1 20 | 9 KEYCODE_2 21 | 10 KEYCODE_3 22 | 11 KEYCODE_4 23 | 12 KEYCODE_5 24 | 13 KEYCODE_6 25 | 14 KEYCODE_7 26 | 15 KEYCODE_8 27 | 16 KEYCODE_9 28 | 17 KEYCODE_STAR 29 | 18 KEYCODE_POUND 30 | 19 KEYCODE_DPAD_UP 31 | 20 KEYCODE_DPAD_DOWN 32 | 21 KEYCODE_DPAD_LEFT 33 | 22 KEYCODE_DPAD_RIGHT 34 | 23 KEYCODE_DPAD_CENTER 35 | 24 KEYCODE_VOLUME_UP 36 | 25 KEYCODE_VOLUME_DOWN 37 | 26 KEYCODE_POWER 38 | 27 KEYCODE_CAMERA 39 | 28 KEYCODE_CLEAR 40 | 29 KEYCODE_A 41 | 30 KEYCODE_B 42 | 31 KEYCODE_C 43 | 32 KEYCODE_D 44 | 33 KEYCODE_E 45 | 34 KEYCODE_F 46 | 35 KEYCODE_G 47 | 36 KEYCODE_H 48 | 37 KEYCODE_I 49 | 38 KEYCODE_J 50 | 39 KEYCODE_K 51 | 40 KEYCODE_L 52 | 41 KEYCODE_M 53 | 42 KEYCODE_N 54 | 43 KEYCODE_O 55 | 44 KEYCODE_P 56 | 45 KEYCODE_Q 57 | 46 KEYCODE_R 58 | 47 KEYCODE_S 59 | 48 KEYCODE_T 60 | 49 KEYCODE_U 61 | 50 KEYCODE_V 62 | 51 KEYCODE_W 63 | 52 KEYCODE_X 64 | 53 KEYCODE_Y 65 | 54 KEYCODE_Z 66 | 55 KEYCODE_COMMA 67 | 56 KEYCODE_PERIOD 68 | 57 KEYCODE_ALT_LEFT 69 | 58 KEYCODE_ALT_RIGHT 70 | 59 KEYCODE_SHIFT_LEFT 71 | 60 KEYCODE_SHIFT_RIGHT 72 | 61 KEYCODE_TAB 73 | 62 KEYCODE_SPACE 74 | 63 KEYCODE_SYM 75 | 64 KEYCODE_EXPLORER 76 | 65 KEYCODE_ENVELOPE 77 | 66 KEYCODE_ENTER 78 | 67 KEYCODE_DEL 79 | 68 KEYCODE_GRAVE 80 | 69 KEYCODE_MINUS 81 | 70 KEYCODE_EQUALS 82 | 71 KEYCODE_LEFT_BRACKET 83 | 72 KEYCODE_RIGHT_BRACKET 84 | 73 KEYCODE_BACKSLASH 85 | 74 KEYCODE_SEMICOLON 86 | 75 KEYCODE_APOSTROPHE 87 | 76 KEYCODE_SLASH 88 | 77 KEYCODE_AT 89 | 78 KEYCODE_NUM 90 | 79 KEYCODE_HEADSETHOOK 91 | 80 KEYCODE_FOCUS 92 | 81 KEYCODE_PLUS 93 | 82 KEYCODE_MENU 94 | 83 KEYCODE_NOTIFICATION 95 | 84 KEYCODE_SEARCH 96 | 85 TAG_LAST_KEYCODE -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 30 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 37 | applicationId "com.example.flutter_mobile_command_tools" 38 | minSdkVersion flutter.minSdkVersion 39 | targetSdkVersion 30 40 | versionCode flutterVersionCode.toInteger() 41 | versionName flutterVersionName 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 59 | } 60 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_mobile_command_tools/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_mobile_command_tools 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | tasks.register("clean", Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/apk.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/apk.jks -------------------------------------------------------------------------------- /assets/apksigner.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/apksigner.jar -------------------------------------------------------------------------------- /assets/apksigner.json: -------------------------------------------------------------------------------- 1 | { 2 | "alias": "key0", 3 | "ks_pass": "940706", 4 | "key_pass": "940706" 5 | } -------------------------------------------------------------------------------- /assets/fonts/SourceHanSansCN-Regular-2.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/fonts/SourceHanSansCN-Regular-2.otf -------------------------------------------------------------------------------- /assets/linux/tools.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/linux/tools.zip -------------------------------------------------------------------------------- /assets/macos/tools.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/macos/tools.zip -------------------------------------------------------------------------------- /assets/windows/tools.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/assets/windows/tools.zip -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_mobile_command_tools 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/base/base_command.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter_mobile_command_tools/model/command_result_model.dart'; 5 | import 'package:flutter_mobile_command_tools/utils/file_utils.dart'; 6 | import 'package:provider/provider.dart'; 7 | 8 | import '../global.dart'; 9 | import '../notifier/log_change_notifier.dart'; 10 | 11 | abstract class BaseCommand { 12 | ///检测命令路径 13 | bool checkCommandPath(String executable) { 14 | if (executable.isNotEmpty) { 15 | if (!FileUtils.isExistFile(executable)) { 16 | return false; 17 | } 18 | } 19 | return true; 20 | } 21 | 22 | ///处理参数 23 | List checkArguments(List arguments) { 24 | return arguments; 25 | } 26 | 27 | CommandResultModel parseData( 28 | String command, ProcessResult processResult); 29 | 30 | ///异步执行命令 31 | Future?> runCommand(String command, 32 | {String executable = "", 33 | String? workingDirectory, 34 | bool runInShell = false}) async { 35 | if (checkCommandPath(executable)) { 36 | List arguments = command.split(" "); 37 | arguments = checkArguments(arguments); 38 | 39 | Provider.of(Global.navigatorKey.currentContext!, 40 | listen: false) 41 | .addLog(">>>>>> 执行命令:${executable} ${arguments.join(" ")}"); 42 | 43 | ProcessResult processResult = await Process.run(executable, arguments, 44 | workingDirectory: workingDirectory, 45 | runInShell: runInShell, 46 | stdoutEncoding: Encoding.getByName("utf-8")); 47 | CommandResultModel? commandResultModel = 48 | parseData(command, processResult); 49 | if (commandResultModel.isSuccess) { 50 | Provider.of(Global.navigatorKey.currentContext!, 51 | listen: false) 52 | .addLog(">>>>>> 成功:${commandResultModel.data}"); 53 | return commandResultModel; 54 | } else { 55 | Provider.of(Global.navigatorKey.currentContext!, 56 | listen: false) 57 | .addLog(">>>>>> 失败:${commandResultModel.error}"); 58 | return null; 59 | } 60 | } else { 61 | Provider.of(Global.navigatorKey.currentContext!, 62 | listen: false) 63 | .addLog(">>>>>> 失败:路径不存在"); 64 | return null; 65 | } 66 | } 67 | 68 | ///同步执行命令 69 | CommandResultModel runCommandSync(String command, 70 | {String executable = "", String? workingDirectory}) { 71 | if (checkCommandPath(executable)) { 72 | List arguments = command.split(" "); 73 | arguments = checkArguments(arguments); 74 | 75 | Provider.of(Global.navigatorKey.currentContext!, 76 | listen: false) 77 | .addLog("${executable} ${arguments.join(" ")}"); 78 | 79 | ProcessResult processResult = Process.runSync(executable, arguments, 80 | workingDirectory: workingDirectory, 81 | stdoutEncoding: Encoding.getByName("utf-8")); 82 | CommandResultModel commandResultModel = parseData(command, processResult); 83 | if (commandResultModel.isSuccess) { 84 | Provider.of(Global.navigatorKey.currentContext!, 85 | listen: false) 86 | .addLog(commandResultModel.data); 87 | } else { 88 | Provider.of(Global.navigatorKey.currentContext!, 89 | listen: false) 90 | .addLog("错误信息:${commandResultModel.data}"); 91 | } 92 | return commandResultModel; 93 | } else { 94 | return CommandResultModel.error(false, null, '路径不存在'); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/base/base_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/utils/window_utils.dart'; 3 | 4 | /** 5 | * @Classname base_dialog 6 | * @Date 2025/3/14 22:54 7 | * @Created by jacky 8 | * @Description 所有弹窗的基类 9 | */ 10 | 11 | /// 确认、取消按钮弹窗基类 12 | class BaseConfirmCancelDialog extends StatelessWidget { 13 | final Widget contentWidget; 14 | 15 | /// 弹窗背景色 16 | final Color dialogBackgroundColor; 17 | 18 | /// 弹窗的圆角 19 | final double dialogRadius; 20 | 21 | /// 是否展示标题 22 | final bool isShowTitle; 23 | 24 | /// 弹窗标题 25 | final String dialogTitle; 26 | 27 | /// 弹窗长度 28 | final double dialogWidth = WindowUtils.getWindowWidth() / 3; 29 | 30 | /// 点击确认按钮 31 | final Function? onConfirm; 32 | 33 | /// 点击取消按钮 34 | final Function? onCancel; 35 | 36 | /// 是否只展示确认按钮 37 | final bool isOnlyConfirm; 38 | 39 | /// 确认按钮文本 40 | final String confirmText; 41 | 42 | /// 取消按钮文本 43 | final String cancelText; 44 | 45 | BaseConfirmCancelDialog({ 46 | Key? key, 47 | required this.contentWidget, 48 | this.onConfirm, 49 | this.onCancel, 50 | this.isOnlyConfirm = false, 51 | this.confirmText = "确认", 52 | this.cancelText = "取消", 53 | this.dialogBackgroundColor = Colors.white, 54 | this.dialogRadius = 12, 55 | this.isShowTitle = true, 56 | this.dialogTitle = "", 57 | }) : super(key: key); 58 | 59 | @override 60 | Widget build(BuildContext context) { 61 | return Align( 62 | alignment: AlignmentDirectional.center, 63 | child: Container( 64 | child: Column( 65 | mainAxisSize: MainAxisSize.min, 66 | crossAxisAlignment: CrossAxisAlignment.center, 67 | children: [ 68 | Visibility( 69 | child: Row( 70 | mainAxisSize: MainAxisSize.max, 71 | mainAxisAlignment: MainAxisAlignment.center, 72 | children: [ 73 | Padding( 74 | padding: EdgeInsets.all(10), 75 | child: Text( 76 | dialogTitle, 77 | style: TextStyle( 78 | fontSize: 20, 79 | fontWeight: FontWeight.w600, 80 | color: Colors.black), 81 | ), 82 | ) 83 | ], 84 | ), 85 | visible: isShowTitle && dialogTitle.length > 0, 86 | ), 87 | Padding( 88 | padding: EdgeInsets.all(10), 89 | child: contentWidget, 90 | ), 91 | Container( 92 | child: Row( 93 | mainAxisSize: MainAxisSize.max, 94 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 95 | children: [ 96 | Button( 97 | child: Text(cancelText), 98 | onPressed: () { 99 | Navigator.pop(context); 100 | onCancel?.call(); 101 | }, 102 | ), 103 | FilledButton( 104 | child: Text(confirmText), 105 | onPressed: () { 106 | if (onConfirm == null) { 107 | Navigator.pop(context); 108 | } 109 | onConfirm?.call(); 110 | }, 111 | ), 112 | ], 113 | ), 114 | padding: EdgeInsets.all(20), 115 | ) 116 | ], 117 | ), 118 | width: dialogWidth, 119 | decoration: BoxDecoration( 120 | color: dialogBackgroundColor, 121 | borderRadius: BorderRadius.all(Radius.circular(dialogRadius))), 122 | ), 123 | ); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /lib/constants.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | import 'dart:core'; 3 | 4 | import 'dart:io'; 5 | 6 | class Constants { 7 | static String APP_TITLE_NAME = APP_NAME + "_" + APP_VERSION; 8 | 9 | static const String APP_NAME = "MobileTools"; 10 | static const String APP_VERSION = "4.0"; 11 | 12 | static const String TOOLS_DIRECTORY_NAME = "tools"; //tools directory name 13 | static const String CONFIG_DIRECTORY_NAME = "config"; //config directory name 14 | static const String SCRIPT_DIRECTORY_NAME = "script"; //script directory name 15 | 16 | static bool isRoot = false; //是否开启root 17 | static bool isInnerAdb = false; //是否使用内部的adb 18 | 19 | static bool isInnerPackageName = true; 20 | static bool isOuterApk = false; 21 | 22 | static String adbPath = ""; //真正使用的adb路径 23 | static String javaPath = ""; //java路径 24 | static String libDevicePath = ""; //libimobiledevice目录 25 | 26 | static String innerAdbPath = ""; //内置的adb路径 27 | static String outerAdbPath = ""; //外置的adb路径 28 | 29 | static String innerKey = "innerAdbPath"; //innerAdbPath对应的key 30 | static String outerKey = "outerAdbPath"; //outerAdbPath对应的key 31 | static String javaKey = "javaPath"; 32 | static String libDeviceKey = "libDeviceKey"; 33 | static String isRootKey = "isRoot"; 34 | static String isInnerAdbKey = "isInnerAdb"; 35 | 36 | static String apksignerPath = ""; 37 | 38 | static String currentDevice = ""; //当前的安卓设备 39 | static String currentIOSDevice = ""; //当前的IOS设备 40 | 41 | static Map mapIOSInfo = HashMap(); 42 | 43 | static String currentPackageName = ""; 44 | static String currentIOSPackageName = "CFBundleIdentifier"; //当前IOS包名 45 | 46 | static String currentSimOpName = ""; //当前的模拟操作 47 | static int currentSimType = 1; 48 | 49 | static String desktopPath = ""; //桌面路径 50 | 51 | static String userPath = ""; //用户路径 52 | 53 | static const String LOG_SHOW_TEXT = "日志:"; 54 | 55 | static const String SCREEN_SHOOT_NAME = "shoot.png"; 56 | static const String SCREEN_RECORD_NAME = "record_screen.mp4"; 57 | 58 | //IOS的ideviceinstaller命令行 59 | 60 | static const String IOS_GET_DEVICE = "-l"; 61 | static const String IOS_GET_THIRD_PACKAGE = "-l -o list_user"; 62 | static const String IOS_GET_SYSTEM_PACKAGE = "-l -o list_system"; 63 | static const String IOS_INSTALL_APP = "-i *.ipa"; 64 | static const String IOS_UNINSTALL_APP = "-U bundleID"; 65 | 66 | //安卓的adb命令行 67 | 68 | static const String ADB_START_ACTIVITY_NO = 69 | "shell monkey -p package -c android.intent.category.LAUNCHER 1"; 70 | static const String ADB_START_ACTIVITY = "shell am start -n "; 71 | static const String ADB_START_BROADCAST_RECEIVER = "shell am broadcast -a "; 72 | static const String ADB_START_SERVICE = "shell am startservice -n "; 73 | static const String ADB_STOP_SERVICE = "shell am stopservice -n "; 74 | 75 | static const String ADB_CURRENT_ACTIVITY = "shell dumpsys activity"; 76 | static const String ADB_CLEAR_DATA = "shell pm clear"; 77 | static const String ADB_SCREEN_SHOT = 78 | "shell screencap -p /sdcard/" + Constants.SCREEN_SHOOT_NAME; 79 | 80 | /// --bit-rate 6000000 比特率,默认4Mbps 81 | /// --size 1280*720 分辨率,默认手机分辨率 82 | /// --time-limit 时间,默认180s 83 | /// --verbose 显示log信息 84 | static const String ADB_SCREEN_RECORD = 85 | "shell screenrecord --time-limit times /sdcard/" + SCREEN_RECORD_NAME; 86 | static const String ADB_PULL_SCREEN_SHOT = 87 | "pull /sdcard/" + Constants.SCREEN_SHOOT_NAME; 88 | static const String ADB_PULL_SCREEN_RECORD = 89 | "pull /sdcard/" + Constants.SCREEN_RECORD_NAME; 90 | static const String ADB_INSTALL_APK = "install"; 91 | static const String ADB_UNINSTALL_APK = 92 | "shell pm uninstall --user 0 package"; 93 | static const String ADB_APK_PATH = "shell pm path package"; 94 | static const String ADB_REBOOT = "reboot"; 95 | static const String ADB_REBOOT_BOOTLOADER = "reboot bootloader"; 96 | static const String ADB_REBOOT_RECOVERY = "reboot recovery"; 97 | 98 | static const String AAPT_GET_APK_INFO = "aapt dump badging apk"; 99 | static const String AAPT_GET_APK_PERMISSION = 100 | "aapt dump permissions apk | grep permission"; 101 | 102 | static const String FASTBOOT_UNLOCK = "flashing unlock"; 103 | static const String FASTBOOT_LOCK = "flashing lock"; 104 | static const String FASTBOOT_LOCK_STATE = "getvar devices-state"; 105 | 106 | static const String WIFI_MAC_ADDRESS = 107 | "shell cat /sys/class/net/wlan0/address"; 108 | static const String BLUE_MAC_ADDRESS = 109 | "shell settings get secure bluetooth_address"; 110 | static const String IP_ADDRESS = "shell ifconfig | grep Mask"; 111 | static const String WINDOW_INFO = 112 | "shell dumpsys window displays | grep init"; 113 | static const String CPU_INFO = "shell cat /proc/cpuinfo"; 114 | static const String BATTERY_INFO = "shell dumpsys battery"; 115 | static const String MEMORY_INFO = "shell cat /proc/meminfo"; 116 | static const String PHONE_INFO = "shell cat /system/build.prop"; 117 | 118 | static const String ADB_IP = "shell ifconfig | grep 192.168"; 119 | static const String ADB_FORWARD_PORT = "tcpip 5555"; 120 | static const String ADB_WIRELESS_CONNECT = "connect"; 121 | static const String ADB_WIRELESS_DISCONNECT = "disconnect"; 122 | static const String ADB_PUSH_FILE = "push"; 123 | static const String ADB_PULL_ANR = "bugreport"; 124 | static const String ADB_PULL_CRASH = "shell dumpsys dropbox | grep crash"; 125 | static const String ADB_PULL_CRASH_FILE = "shell dumpsys dropbox"; 126 | static const String ADB_SEARCH_ALL_FILE_PATH = "shell ls"; 127 | static const String ADB_PULL_FILE = "pull"; 128 | static const String ADB_SIM_SWIPE = "shell input swipe"; //滑动 129 | static const String ADB_SIM_TAP = "shell input tap"; //点击 130 | static const String ADB_SIM_INPUT = "shell input text"; //输入 131 | static const String ADB_SIM_BACK = "shell input keyevent 4"; //后退 132 | static const String ADB_SIM_KEY_EVENT = "shell input keyevent"; 133 | static const String APK_SIGNER = 134 | "java -jar apksign sign --ks jks_path --ks-key-alias myalias --ks-pass pass:mypass --key-pass pass:mykeypass --out outapk inputapk"; 135 | static const String VERIFY_APK_SIGNER = 136 | "java -jar apksign verify -v --print-certs inputapk"; 137 | 138 | static const String UI_TOOL_NAME = "uiautomatorviewer"; 139 | static const String APK_TOOL_NAME = "apktool"; 140 | 141 | static const String OPEN_UI_TOOL = 142 | "java -Djava.ext.dirs=. -Dcom.android.uiautomator.bindir=adb_path -jar uiautomatorviewer.jar"; 143 | 144 | static const String OPEN_UI_TOOL_MAC = 145 | "java -Djava.ext.dirs=. -Dcom.android.uiautomator.bindir=adb_path -XstartOnFirstThread -jar uiautomatorviewer.jar"; 146 | static const String APKTOOL_DECODE = 147 | "java -jar ApkTool_path d command Apk_path"; 148 | static const String APKTOOL_REBUILD = 149 | "java -jar ApkTool_path b command Apk_path -o new.apk"; 150 | static const String Faker_Android = 151 | "java -jar Faker_Android_path fk Apk_path -o new.apk"; 152 | 153 | static const List ALL_SIM_OPERATION = ["输入", "滑动", "点击", "后退"]; 154 | 155 | static late File signerPath; 156 | static late File jksPath; 157 | static late File signerJarPath; 158 | 159 | static String getPhoneInfo(int index) { 160 | switch (index) { 161 | case 0: 162 | return isRoot 163 | ? _shellRoot(Constants.BLUE_MAC_ADDRESS) 164 | : Constants.BLUE_MAC_ADDRESS; 165 | case 1: 166 | return isRoot 167 | ? _shellRoot(Constants.WIFI_MAC_ADDRESS) 168 | : Constants.WIFI_MAC_ADDRESS; 169 | case 2: 170 | return isRoot ? _shellRoot(Constants.IP_ADDRESS) : Constants.IP_ADDRESS; 171 | case 3: 172 | return isRoot 173 | ? _shellRoot(Constants.WINDOW_INFO) 174 | : Constants.WINDOW_INFO; 175 | case 4: 176 | return isRoot ? _shellRoot(Constants.CPU_INFO) : Constants.CPU_INFO; 177 | case 5: 178 | return isRoot 179 | ? _shellRoot(Constants.BATTERY_INFO) 180 | : Constants.BATTERY_INFO; 181 | case 6: 182 | return isRoot 183 | ? _shellRoot(Constants.MEMORY_INFO) 184 | : Constants.MEMORY_INFO; 185 | case 7: 186 | return isRoot ? _shellRoot(Constants.PHONE_INFO) : Constants.PHONE_INFO; 187 | } 188 | return ""; 189 | } 190 | 191 | static String _shellRoot(String command) { 192 | return command.replaceAll("shell", "shell su -c"); //有些命令需要使用-t su -c 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /lib/enum/adb_command_type.dart: -------------------------------------------------------------------------------- 1 | enum AdbCommandType { 2 | /// 版本 3 | ADB_VERSION, 4 | 5 | /// 连接的设备 6 | ADB_CONNECT_DEVICES, 7 | 8 | /// 获取包名 9 | ADB_GET_PACKAGE, 10 | 11 | /// 获取第三方包名 12 | ADB_GET_THIRD_PACKAGE, 13 | 14 | /// 获取系统包名 15 | ADB_GET_SYSTEM_PACKAGE, 16 | 17 | /// 获取冻结包名 18 | ADB_GET_FREEZE_PACKAGE, 19 | 20 | /// 获取包名信息 21 | ADB_GET_PACKAGE_INFO, 22 | 23 | /// 获取顶级Activity 24 | ADB_GET_PACKAGE_INFO_MAIN_ACTIVITY, 25 | 26 | ///关于冷冻/解冻app使用disable/enable命令, 27 | ///使用hide只是简单的从启动器移除图标而已 28 | ///https://www.v2ex.com/t/292092 pm hide 和 pm disable 有什么区别 29 | ///https://blog.csdn.net/zuiaikg703/article/details/72763825/ adb命令之pm hide 与 disable 30 | ///冻结app 31 | ADB_FREEZE_PACKAGE, 32 | 33 | /// 解冻app 34 | ADB_NOT_FREEZE_PACKAGE, 35 | 36 | /// 无线连接 37 | ADB_WIRELESS_CONNECT, 38 | 39 | /// 断开连接 40 | ADB_WIRELESS_DISCONNECT, 41 | 42 | /// 模拟指令滑动 43 | ADB_SIM_OPERATION_SWIPE, 44 | 45 | /// 模拟指令点击 46 | ADB_SIM_OPERATION_TAP, 47 | 48 | /// 模拟指令输入文本 49 | ADB_SIM_OPERATION_TEXT, 50 | 51 | /// 模拟指令事件 52 | ADB_SIM_OPERATION_EVENT, 53 | } 54 | 55 | extension AdbCommandTypeValue on AdbCommandType { 56 | String get value { 57 | String _value = ''; 58 | switch (this) { 59 | case AdbCommandType.ADB_VERSION: 60 | _value = 'version'; 61 | break; 62 | case AdbCommandType.ADB_CONNECT_DEVICES: 63 | _value = 'devices'; 64 | break; 65 | case AdbCommandType.ADB_GET_PACKAGE: 66 | _value = 'shell dumpsys activity'; 67 | break; 68 | case AdbCommandType.ADB_GET_THIRD_PACKAGE: 69 | _value = 'shell pm list packages -3'; 70 | break; 71 | case AdbCommandType.ADB_GET_SYSTEM_PACKAGE: 72 | _value = 'shell pm list packages -s'; 73 | break; 74 | case AdbCommandType.ADB_GET_FREEZE_PACKAGE: 75 | _value = 'shell pm list packages -d'; 76 | break; 77 | case AdbCommandType.ADB_GET_PACKAGE_INFO: 78 | _value = 'shell dumpsys package '; 79 | break; 80 | case AdbCommandType.ADB_GET_PACKAGE_INFO_MAIN_ACTIVITY: 81 | _value = 'shell dumpsys package top '; 82 | break; 83 | case AdbCommandType.ADB_FREEZE_PACKAGE: 84 | _value = 'shell dumpsys package top '; 85 | break; 86 | case AdbCommandType.ADB_GET_PACKAGE_INFO_MAIN_ACTIVITY: 87 | _value = 'shell pm disable package '; 88 | break; 89 | case AdbCommandType.ADB_NOT_FREEZE_PACKAGE: 90 | _value = 'shell pm enable package'; 91 | break; 92 | case AdbCommandType.ADB_WIRELESS_CONNECT: 93 | _value = 'connect'; 94 | break; 95 | case AdbCommandType.ADB_WIRELESS_DISCONNECT: 96 | _value = 'disconnect'; 97 | break; 98 | case AdbCommandType.ADB_SIM_OPERATION_SWIPE: 99 | _value = 'shell input swipe'; 100 | break; 101 | case AdbCommandType.ADB_SIM_OPERATION_TAP: 102 | _value = 'shell input tap'; 103 | break; 104 | case AdbCommandType.ADB_SIM_OPERATION_TEXT: 105 | _value = 'shell input text'; 106 | break; 107 | case AdbCommandType.ADB_SIM_OPERATION_EVENT: 108 | _value = 'shell input keyevent'; 109 | break; 110 | default: 111 | } 112 | return _value; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /lib/enum/click_type.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * @Classname click_type 3 | * @Date 2025/3/15 15:56 4 | * @Created by jacky 5 | * @Description 点击类型 6 | */ 7 | enum ClickType { 8 | REFRESH_DEVICE, 9 | WIRELESS_CONNECT, 10 | DISCONNECT_DEVICE, 11 | NEW_SIM_SCRIPT, 12 | } 13 | 14 | enum AndroidPanelClickType { 15 | SIM_OPERATION_START, 16 | SIM_OPERATION_STOP, 17 | } 18 | 19 | extension ClickTypeValue on ClickType { 20 | String get value { 21 | String _value = ''; 22 | switch (this) { 23 | case ClickType.REFRESH_DEVICE: 24 | _value = '刷新设备'; 25 | break; 26 | case ClickType.WIRELESS_CONNECT: 27 | _value = '无线连接'; 28 | break; 29 | case ClickType.DISCONNECT_DEVICE: 30 | _value = '断开连接'; 31 | break; 32 | case ClickType.NEW_SIM_SCRIPT: 33 | _value = '新建脚本'; 34 | break; 35 | default: 36 | } 37 | return _value; 38 | } 39 | } 40 | 41 | extension AndroidPanelClickValue on AndroidPanelClickType { 42 | String get value { 43 | String _value = ''; 44 | switch (this) { 45 | case AndroidPanelClickType.SIM_OPERATION_START: 46 | _value = '开始执行'; 47 | break; 48 | case AndroidPanelClickType.SIM_OPERATION_STOP: 49 | _value = '停止执行'; 50 | break; 51 | default: 52 | } 53 | return _value; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/enum/dir_type.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * @FileName : dir_type 3 | * @Author : lijie 4 | * @Time : 2025/3/11 09:48 5 | * @Description : 文件夹类型 6 | */ 7 | enum DirType { 8 | /// 当前的文件夹 9 | CURRENT_DIR, 10 | 11 | /// 下载的文件夹 12 | DOWNLOAD_DIR, 13 | 14 | /// 临时存储的文件夹 15 | TEMP_DIR, 16 | 17 | /// 文档的文件夹 18 | DOCUMENT_DIR 19 | } 20 | -------------------------------------------------------------------------------- /lib/enum/file_name_type.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * @Classname file_name_type 3 | * @Date 2025/3/15 17:50 4 | * @Created by jacky 5 | * @Description 文件名 6 | */ 7 | enum FileNameType { WIRELESS_CONNECT, SIM_OPERATION } 8 | 9 | extension FileNameTypeValue on FileNameType { 10 | String get value { 11 | String _value = ''; 12 | switch (this) { 13 | case FileNameType.WIRELESS_CONNECT: 14 | _value = 'WIRELESS_CONNECT'; 15 | break; 16 | case FileNameType.SIM_OPERATION: 17 | _value = 'SIM_OPERATION'; 18 | break; 19 | default: 20 | } 21 | return _value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/enum/panel_type.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * @Classname PanelType 3 | * @Date 2025/3/15 16:07 4 | * @Created by jacky 5 | * @Description 左边panel的类型 6 | */ 7 | enum PanelType { 8 | Android, 9 | Harmony, 10 | Setting, 11 | } 12 | 13 | extension PanelTypeValue on PanelType { 14 | String get value { 15 | String _value = ''; 16 | switch (this) { 17 | case PanelType.Android: 18 | _value = '安卓'; 19 | break; 20 | case PanelType.Harmony: 21 | _value = '鸿蒙'; 22 | break; 23 | case PanelType.Setting: 24 | _value = '设置'; 25 | break; 26 | default: 27 | } 28 | return _value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/enum/sim_operation_type.dart: -------------------------------------------------------------------------------- 1 | /// 模拟操作类型 2 | enum SimOperationType { SWIPE, TEXT, TAP, EVENT, ADB, OTHER } 3 | 4 | extension SimOperationTypeValue on SimOperationType { 5 | String get value { 6 | String _value = ''; 7 | switch (this) { 8 | case SimOperationType.SWIPE: 9 | _value = '滑动'; 10 | break; 11 | case SimOperationType.TEXT: 12 | _value = '输入'; 13 | break; 14 | case SimOperationType.TAP: 15 | _value = '点击'; 16 | break; 17 | case SimOperationType.EVENT: 18 | _value = '事件'; 19 | break; 20 | case SimOperationType.ADB: 21 | _value = 'ADB'; 22 | break; 23 | case SimOperationType.OTHER: 24 | _value = 'OTHER'; 25 | break; 26 | // case SimOperationType.NONE: 27 | // _value = 'NONE'; 28 | // break; 29 | default: 30 | } 31 | return _value; 32 | } 33 | 34 | // SimOperationType get type { 35 | // switch (this.value) { 36 | // case "滑动": 37 | // return SimOperationType.SWIPE; 38 | // case "输入": 39 | // return SimOperationType.TEXT; 40 | // case "点击": 41 | // return SimOperationType.TAP; 42 | // case "事件": 43 | // return SimOperationType.EVENT; 44 | // case "ADB": 45 | // return SimOperationType.ADB; 46 | // case "OTHER": 47 | // return SimOperationType.OTHER; 48 | // default: 49 | // } 50 | // return SimOperationType.SWIPE; 51 | // } 52 | } 53 | 54 | enum SwipeType { 55 | /// 上滑 56 | SWIPE_TOP, 57 | 58 | /// 下滑 59 | SWIPE_BOTTOM, 60 | 61 | /// 左滑 62 | SWIPE_LEFT, 63 | 64 | /// 右滑 65 | SWIPE_RIGHT, 66 | 67 | /// 自定义 68 | SWIPE_CUSTOM 69 | } 70 | 71 | extension SwipeTypeValue on SwipeType { 72 | String get value { 73 | String _value = ''; 74 | switch (this) { 75 | case SwipeType.SWIPE_TOP: 76 | _value = '上滑'; 77 | break; 78 | case SwipeType.SWIPE_BOTTOM: 79 | _value = '下滑'; 80 | break; 81 | case SwipeType.SWIPE_LEFT: 82 | _value = '左滑'; 83 | break; 84 | case SwipeType.SWIPE_RIGHT: 85 | _value = '右滑'; 86 | break; 87 | case SwipeType.SWIPE_LEFT: 88 | _value = '自定义'; 89 | break; 90 | default: 91 | } 92 | return _value; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/global.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:flutter_mobile_command_tools/enum/panel_type.dart'; 4 | 5 | class Global { 6 | static String adbPath = ""; //真正使用的adb路径 7 | 8 | static PanelType panelType = PanelType.Android; 9 | 10 | static final GlobalKey navigatorKey = 11 | GlobalKey(); 12 | 13 | static final GlobalKey scaffoldKey = 14 | GlobalKey(); 15 | } 16 | -------------------------------------------------------------------------------- /lib/mixin/android_panel_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter_mobile_command_tools/constants.dart'; 4 | import 'package:flutter_mobile_command_tools/enum/adb_command_type.dart'; 5 | import 'package:flutter_mobile_command_tools/enum/click_type.dart'; 6 | import 'package:flutter_mobile_command_tools/model/sim_operation_model.dart'; 7 | import 'package:flutter_mobile_command_tools/utils/log_utils.dart'; 8 | import 'package:flutter_mobile_command_tools/utils/number_utils.dart'; 9 | 10 | import '../enum/sim_operation_type.dart'; 11 | import '../utils/notifier_utils.dart'; 12 | import '../utils/platform_utils.dart'; 13 | 14 | /** 15 | * @Classname android_sim_operation_mixin 16 | * @Date 2025/3/16 18:43 17 | * @Created by jacky 18 | * @Description 安卓页面的混入类 19 | */ 20 | mixin AndroidPanelMixin { 21 | onClick(AndroidPanelClickType clickType, {dynamic params}) { 22 | switch (clickType) { 23 | case AndroidPanelClickType.SIM_OPERATION_START: 24 | _startSimOperation(params); 25 | break; 26 | case AndroidPanelClickType.SIM_OPERATION_STOP: 27 | _stopSimOperation(); 28 | break; 29 | } 30 | } 31 | 32 | _startSimOperation(SimOperationModel simOperationModel) { 33 | bool isRepeat = NotifierUtils.getAndroidPanelNotifier().isRepeat; 34 | String randomPeriod = NotifierUtils.getAndroidPanelNotifier().randomPeriod; 35 | 36 | ///间隔最小值 37 | int randomMin = NumberUtils.safeStrToInt(randomPeriod.split(',')[0]); 38 | 39 | ///间隔最大值 40 | int randomMax = NumberUtils.safeStrToInt(randomPeriod.split(',')[1]) == 0 41 | ? 1000 42 | : NumberUtils.safeStrToInt(randomPeriod.split(',')[1]); 43 | 44 | List futureList = []; 45 | List randomTimeList = []; 46 | for (int i = 0; i < simOperationModel.simOperationList.length; i++) { 47 | int randomTime = 0; 48 | //2种情况不随机延迟 49 | //1、当前是单条指令并且不重复 50 | //2、未开启指令随机 51 | if (simOperationModel.isSingle && !isRepeat) { 52 | randomTime = 0; 53 | } else { 54 | if (i == 0) { 55 | randomTime = NumberUtils.getRandom(randomMin, randomMax); 56 | randomTimeList.add(NumberUtils.getRandom(randomMin, randomMax)); 57 | } else { 58 | randomTime = NumberUtils.getRandom(randomMin, randomMax) + 59 | randomTimeList[i - 1]; 60 | randomTimeList.add(NumberUtils.getRandom(randomMin, randomMax) + 61 | randomTimeList[i - 1]); 62 | } 63 | } 64 | futureList.add(Future.delayed(Duration(milliseconds: randomTime), () { 65 | if (i == 0) { 66 | LogUtils.showLog('延迟时间:' + randomTimeList[0].toString()); 67 | } else { 68 | LogUtils.showLog( 69 | '延迟时间:' + "${randomTimeList[i] - randomTimeList[i - 1]}"); 70 | } 71 | List commandArguments = []; 72 | SimOperation simOperation = simOperationModel.simOperationList[i]; 73 | switch (simOperation.simOperationType) { 74 | case SimOperationType.SWIPE: 75 | commandArguments = 76 | AdbCommandType.ADB_SIM_OPERATION_SWIPE.value.split(' '); 77 | commandArguments.add(simOperation.x1.toString()); 78 | commandArguments.add(simOperation.y1.toString()); 79 | commandArguments.add(simOperation.x2.toString()); 80 | commandArguments.add(simOperation.y2.toString()); 81 | 82 | break; 83 | case SimOperationType.TEXT: 84 | commandArguments = 85 | AdbCommandType.ADB_SIM_OPERATION_TEXT.value.split(' '); 86 | commandArguments.add(simOperation.text); 87 | break; 88 | case SimOperationType.TAP: 89 | commandArguments = 90 | AdbCommandType.ADB_SIM_OPERATION_TAP.value.split(' '); 91 | commandArguments.add(simOperation.x1.toString()); 92 | commandArguments.add(simOperation.y1.toString()); 93 | break; 94 | case SimOperationType.EVENT: 95 | commandArguments = 96 | AdbCommandType.ADB_SIM_OPERATION_EVENT.value.split(' '); 97 | commandArguments.add(simOperation.text); 98 | break; 99 | case SimOperationType.ADB: 100 | case SimOperationType.OTHER: 101 | commandArguments = simOperation.text.split(' '); 102 | break; 103 | } 104 | 105 | if (simOperation.simOperationType == SimOperationType.OTHER) { 106 | LogUtils.showLog("执行指令:arguments:$commandArguments"); 107 | PlatformUtils.runCommand(commandArguments.join(' ')).then((value) { 108 | LogUtils.showLog("执行结束:" + value.stdout + value.stderr); 109 | }).catchError((e) { 110 | LogUtils.showLog("执行出错:"); 111 | }); 112 | } else { 113 | LogUtils.showLog( 114 | "执行指令:adb:${Constants.adbPath},arguments:$commandArguments"); 115 | Process.run(Constants.adbPath, commandArguments).then((value) { 116 | LogUtils.showLog("执行结束:" + value.stdout + value.stderr); 117 | }).catchError((e) { 118 | LogUtils.showLog("执行出错:"); 119 | }); 120 | } 121 | })); 122 | } 123 | 124 | Future.wait(futureList).then((value) { 125 | if (isRepeat) { 126 | NotifierUtils.getAndroidPanelNotifier().isRunning = true; 127 | _startSimOperation(simOperationModel); 128 | } else { 129 | LogUtils.showLog("停止模拟指令"); 130 | } 131 | }); 132 | } 133 | 134 | _stopSimOperation() { 135 | NotifierUtils.getAndroidPanelNotifier().isRunning = false; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /lib/mixin/main_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/enum/click_type.dart'; 3 | import 'package:flutter_mobile_command_tools/enum/file_name_type.dart'; 4 | import 'package:flutter_mobile_command_tools/global.dart'; 5 | import 'package:flutter_mobile_command_tools/mixin/android_panel_mixin.dart'; 6 | import 'package:flutter_mobile_command_tools/utils/toast_utils.dart'; 7 | import 'package:provider/provider.dart'; 8 | 9 | import '../notifier/panel/android_panel_notifier.dart'; 10 | import '../utils/command_utils.dart'; 11 | import '../utils/dialog_utils.dart'; 12 | 13 | /** 14 | * @Classname main_mixin 15 | * @Date 2025/3/15 16:17 16 | * @Created by jacky 17 | * @Description 主页的功能逻辑 18 | */ 19 | mixin MainMixin { 20 | onClick(ClickType clickType, {dynamic params}) { 21 | switch (clickType) { 22 | case ClickType.REFRESH_DEVICE: 23 | _refreshDevice(); 24 | break; 25 | case ClickType.WIRELESS_CONNECT: 26 | _wirelessConnectDevice(); 27 | break; 28 | case ClickType.DISCONNECT_DEVICE: 29 | _disconnectDevice(); 30 | break; 31 | case ClickType.NEW_SIM_SCRIPT: 32 | _newSimScript(); 33 | break; 34 | } 35 | } 36 | 37 | /// 刷新设备 38 | _refreshDevice() { 39 | AndroidCommandUtils.sendConnectDeviceOrder(); 40 | } 41 | 42 | /// 无线连接 43 | _wirelessConnectDevice() { 44 | DialogUtils.showInputDialog( 45 | title: "无线连接", 46 | fileNameType: FileNameType.WIRELESS_CONNECT, 47 | confirmText: '连接') 48 | .then((result) { 49 | if (result == null) { 50 | return; 51 | } 52 | AndroidCommandUtils.sendWirelessConnectDeviceOrder(result); 53 | }); 54 | } 55 | 56 | /// 断开连接设备 57 | _disconnectDevice() { 58 | if (!isExistDevice()) { 59 | return; 60 | } 61 | DialogUtils.showTextDialog( 62 | contents: [ 63 | "确定要断开设备", 64 | Global.navigatorKey.currentContext! 65 | .read() 66 | .deviceList[ 67 | Global.navigatorKey.currentContext! 68 | .read() 69 | .deviceIndex], 70 | "嘛?" 71 | ], 72 | colorChangeIndex: [ 73 | 1 74 | ], 75 | contentChangeColor: [ 76 | Colors.red 77 | ], 78 | title: ClickType.DISCONNECT_DEVICE.value, 79 | onConfirm: () { 80 | AndroidCommandUtils.sendDisConnectDeviceOrder(Global 81 | .navigatorKey.currentContext! 82 | .read() 83 | .deviceList[ 84 | Global.navigatorKey.currentContext! 85 | .read() 86 | .deviceIndex]); 87 | }); 88 | } 89 | 90 | /// 新建虚拟操作脚本 91 | _newSimScript() { 92 | DialogUtils.showNewOperationScriptDialog(); 93 | } 94 | 95 | /// 当前是否存在设备 96 | isExistDevice({bool isShowToast = true}) { 97 | if (Global.navigatorKey.currentContext! 98 | .read() 99 | .deviceList 100 | .isEmpty) { 101 | if (isShowToast) { 102 | showToast( 103 | message: '当前无连接设备,请先刷新设备再操作', 104 | title: "操作失败:", 105 | severity: InfoBarSeverity.error); 106 | } 107 | return false; 108 | } 109 | return true; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /lib/model/command_result_model.dart: -------------------------------------------------------------------------------- 1 | /// 命令的输出结果 2 | class CommandResultModel { 3 | bool isSuccess = false; 4 | T? data; 5 | String error = ""; 6 | 7 | CommandResultModel(this.isSuccess, this.data); 8 | 9 | CommandResultModel.error(this.isSuccess, this.data, this.error); 10 | 11 | @override 12 | String toString() { 13 | return 'CommandResultModel{isSuccess: $isSuccess, data: $data}'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/model/sim_operation_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_mobile_command_tools/enum/sim_operation_type.dart'; 2 | 3 | /// 操作指令的集合 4 | class SimOperationModel { 5 | /// 所有指令 6 | List simOperationList = []; 7 | 8 | /// 是否为单条指令,默认一个文件包含多条指令时候,将会执行文件中的所有指令 9 | bool isSingle = false; 10 | } 11 | 12 | class SimOperation { 13 | /// 滑动和点击第一个点的x坐标 14 | int x1 = 0; 15 | 16 | /// 滑动和点击第一个点的y坐标 17 | int y1 = 0; 18 | 19 | /// 滑动第二个点的x坐标 20 | int x2 = 0; 21 | 22 | /// 滑动第二个点的y坐标 23 | int y2 = 0; 24 | 25 | /// 滑动类型 26 | SwipeType swipeType = SwipeType.SWIPE_CUSTOM; 27 | 28 | /// 模拟指令类型 29 | SimOperationType simOperationType = SimOperationType.SWIPE; 30 | 31 | /// text、adb、other文本 32 | String text = ""; 33 | 34 | /// 指令别名 35 | String aliasName = ""; 36 | } 37 | -------------------------------------------------------------------------------- /lib/model/text_field_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class TextFieldModel { 4 | late ScrollController _scrollController; 5 | late TextEditingController _textEditingController; 6 | late FocusNode _focusNode; 7 | 8 | TextFieldModel( 9 | this._scrollController, this._textEditingController, this._focusNode); 10 | 11 | ScrollController get scrollController => _scrollController; 12 | 13 | set scrollController(ScrollController value) { 14 | _scrollController = value; 15 | } 16 | 17 | TextEditingController get textEditingController => _textEditingController; 18 | 19 | FocusNode get focusNode => _focusNode; 20 | 21 | set focusNode(FocusNode value) { 22 | _focusNode = value; 23 | } 24 | 25 | set textEditingController(TextEditingController value) { 26 | _textEditingController = value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/notifier/devices_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | class DevicesChangeNotifier extends ChangeNotifier { 4 | List _deviceList = []; 5 | 6 | int _index = 0; 7 | 8 | bool _isHidden = true; 9 | 10 | bool get isHidden => _isHidden; 11 | 12 | set isHidden(bool value) { 13 | _isHidden = value; 14 | notifyListeners(); 15 | } 16 | 17 | List get deviceList => _deviceList; 18 | 19 | set deviceList(List value) { 20 | _deviceList = value; 21 | index = 0; 22 | } 23 | 24 | int get index => _index; 25 | 26 | set index(int value) { 27 | _index = value; 28 | notifyListeners(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/notifier/dialog/android_input_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | /** 4 | * @Classname android_wireless_notifier 5 | * @Date 2025/3/15 19:37 6 | * @Created by jacky 7 | * @Description 无线连接的通知 8 | */ 9 | class AndroidInputNotifier extends ChangeNotifier { 10 | String _connectDevice = ''; 11 | List _connectDeviceList = []; 12 | 13 | List get connectDeviceList => _connectDeviceList; 14 | 15 | set connectDeviceList(List value) { 16 | _connectDeviceList = value; 17 | notifyListeners(); 18 | } 19 | 20 | String get connectDevice => _connectDevice; 21 | 22 | set connectDevice(String value) { 23 | _connectDevice = value; 24 | notifyListeners(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/notifier/dialog/android_sim_script_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/enum/sim_operation_type.dart'; 3 | 4 | import '../../model/sim_operation_model.dart'; 5 | 6 | /** 7 | * @FileName : android_sim_script_notifier 8 | * @Author : lijie 9 | * @Time : 2025/3/10 18:37 10 | * @Description : 模拟脚本的弹唱监听器 11 | */ 12 | class AndroidSimScriptNotifier extends ChangeNotifier { 13 | /// 类型 14 | SimOperationType _simOperationType = SimOperationType.SWIPE; 15 | 16 | /// 滑动类型 17 | SwipeType _swipeType = SwipeType.SWIPE_CUSTOM; 18 | 19 | /// 自定义文件名 20 | bool _isCustomFileName = false; 21 | 22 | bool get isCustomFileName => _isCustomFileName; 23 | 24 | set isCustomFileName(bool value) { 25 | _isCustomFileName = value; 26 | notifyListeners(); 27 | } 28 | 29 | SwipeType get swipeType => _swipeType; 30 | 31 | set swipeType(SwipeType value) { 32 | _swipeType = value; 33 | notifyListeners(); 34 | } 35 | 36 | /// 是否为单条指令,默认一个文件包含多条指令时候,将会执行文件中的所有指令 37 | bool _isSingle = false; 38 | 39 | /// 当前脚本的所有指令 40 | List _simOperationList = []; 41 | 42 | int _simOperationIndex = 0; 43 | 44 | int get simOperationIndex => _simOperationIndex; 45 | 46 | set simOperationIndex(int value) { 47 | _simOperationIndex = value; 48 | notifyListeners(); 49 | } 50 | 51 | SimOperationType get simOperationType => _simOperationType; 52 | 53 | set simOperationType(SimOperationType value) { 54 | _simOperationType = value; 55 | notifyListeners(); 56 | } 57 | 58 | List get simOperationList => _simOperationList; 59 | 60 | set simOperationList(List value) { 61 | _simOperationList = value; 62 | notifyListeners(); 63 | } 64 | 65 | bool get isSingle => _isSingle; 66 | 67 | set isSingle(bool value) { 68 | _isSingle = value; 69 | notifyListeners(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /lib/notifier/log_change_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_mobile_command_tools/utils/platform_utils.dart'; 3 | 4 | class LogChangeNotifier extends ChangeNotifier { 5 | ScrollController scrollController = ScrollController(); 6 | List _logList = []; 7 | 8 | List get logList => _logList; 9 | 10 | void addLog(dynamic log) { 11 | if (log is String) { 12 | _logList.add(log.replaceAll(PlatformUtils.getLineBreak(), '')); 13 | } else if (log is List) { 14 | _logList.add(log.join(" ")); 15 | } else { 16 | _logList.add(log); 17 | } 18 | notifyListeners(); 19 | 20 | Future.delayed(Duration(milliseconds: 500), () { 21 | scrollController.animateTo(scrollController.position.maxScrollExtent, 22 | duration: Duration(milliseconds: 100), curve: Curves.bounceInOut); 23 | }); 24 | } 25 | 26 | void clearLog() { 27 | _logList.clear(); 28 | notifyListeners(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/notifier/panel/android_panel_notifier.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | class AndroidPanelNotifier extends ChangeNotifier { 4 | /// 设备列表监听 5 | List _deviceList = []; 6 | 7 | /// 设备选择 8 | int _deviceIndex = 0; 9 | 10 | /// 包名列表监听 11 | List _packageList = []; 12 | 13 | /// 包名选择 14 | int _packageIndex = 0; 15 | 16 | /** 17 | * 模拟操作相关 18 | */ 19 | 20 | /// 脚本列表监听 21 | List _simOperationKeyList = []; 22 | 23 | /// 脚本选择 24 | int _simOperationKeyIndex = 0; 25 | 26 | /// 脚本是否在执行 27 | bool _isRunning = false; 28 | 29 | /// 是否循环执行 30 | bool _isRepeat = true; 31 | 32 | /// 随机间隔 33 | String _randomPeriod = '599,600'; 34 | 35 | bool get isRunning => _isRunning; 36 | 37 | set isRunning(bool value) { 38 | _isRunning = value; 39 | notifyListeners(); 40 | } 41 | 42 | int get simOperationKeyIndex => _simOperationKeyIndex; 43 | 44 | set simOperationKeyIndex(int value) { 45 | _simOperationKeyIndex = value; 46 | notifyListeners(); 47 | } 48 | 49 | List get simOperationKeyList => _simOperationKeyList; 50 | 51 | set simOperationKeyList(List value) { 52 | _simOperationKeyList = value; 53 | notifyListeners(); 54 | } 55 | 56 | List get packageList => _packageList; 57 | 58 | set packageList(List value) { 59 | _packageList = value; 60 | packageIndex = 0; 61 | notifyListeners(); 62 | } 63 | 64 | List get deviceList => _deviceList; 65 | 66 | set deviceList(List value) { 67 | _deviceList = value; 68 | deviceIndex = 0; 69 | notifyListeners(); 70 | } 71 | 72 | int get deviceIndex => _deviceIndex; 73 | 74 | set deviceIndex(int value) { 75 | _deviceIndex = value; 76 | } 77 | 78 | int get packageIndex => _packageIndex; 79 | 80 | set packageIndex(int value) { 81 | _packageIndex = value; 82 | } 83 | 84 | bool get isRepeat => _isRepeat; 85 | 86 | set isRepeat(bool value) { 87 | _isRepeat = value; 88 | notifyListeners(); 89 | } 90 | 91 | String get randomPeriod => _randomPeriod; 92 | 93 | set randomPeriod(String value) { 94 | _randomPeriod = value; 95 | notifyListeners(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter_acrylic/flutter_acrylic.dart'; 3 | import 'package:system_theme/system_theme.dart'; 4 | 5 | import 'package:fluent_ui/fluent_ui.dart'; 6 | 7 | enum NavigationIndicators { sticky, end } 8 | 9 | class AppTheme extends ChangeNotifier { 10 | AccentColor? _color; 11 | AccentColor get color => _color ?? systemAccentColor; 12 | set color(AccentColor color) { 13 | _color = color; 14 | notifyListeners(); 15 | } 16 | 17 | ThemeMode _mode = ThemeMode.system; 18 | ThemeMode get mode => _mode; 19 | set mode(ThemeMode mode) { 20 | _mode = mode; 21 | notifyListeners(); 22 | } 23 | 24 | PaneDisplayMode _displayMode = PaneDisplayMode.auto; 25 | PaneDisplayMode get displayMode => _displayMode; 26 | set displayMode(PaneDisplayMode displayMode) { 27 | _displayMode = displayMode; 28 | notifyListeners(); 29 | } 30 | 31 | NavigationIndicators _indicator = NavigationIndicators.sticky; 32 | NavigationIndicators get indicator => _indicator; 33 | set indicator(NavigationIndicators indicator) { 34 | _indicator = indicator; 35 | notifyListeners(); 36 | } 37 | 38 | WindowEffect _windowEffect = WindowEffect.disabled; 39 | WindowEffect get windowEffect => _windowEffect; 40 | set windowEffect(WindowEffect windowEffect) { 41 | _windowEffect = windowEffect; 42 | notifyListeners(); 43 | } 44 | 45 | void setEffect(WindowEffect effect, BuildContext context) { 46 | Window.setEffect( 47 | effect: effect, 48 | color: [ 49 | WindowEffect.solid, 50 | WindowEffect.acrylic, 51 | ].contains(effect) 52 | ? FluentTheme.of(context).micaBackgroundColor.withOpacity(0.05) 53 | : Colors.transparent, 54 | dark: FluentTheme.of(context).brightness.isDark, 55 | ); 56 | } 57 | 58 | TextDirection _textDirection = TextDirection.ltr; 59 | TextDirection get textDirection => _textDirection; 60 | set textDirection(TextDirection direction) { 61 | _textDirection = direction; 62 | notifyListeners(); 63 | } 64 | 65 | Locale? _locale; 66 | Locale? get locale => _locale; 67 | set locale(Locale? locale) { 68 | _locale = locale; 69 | notifyListeners(); 70 | } 71 | } 72 | 73 | AccentColor get systemAccentColor { 74 | if ((defaultTargetPlatform == TargetPlatform.windows || 75 | defaultTargetPlatform == TargetPlatform.android) && 76 | !kIsWeb) { 77 | return AccentColor.swatch({ 78 | 'darkest': SystemTheme.accentColor.darkest, 79 | 'darker': SystemTheme.accentColor.darker, 80 | 'dark': SystemTheme.accentColor.dark, 81 | 'normal': SystemTheme.accentColor.accent, 82 | 'light': SystemTheme.accentColor.light, 83 | 'lighter': SystemTheme.accentColor.lighter, 84 | 'lightest': SystemTheme.accentColor.lightest, 85 | }); 86 | } 87 | return Colors.blue; 88 | } -------------------------------------------------------------------------------- /lib/utils/TimeUtils.dart: -------------------------------------------------------------------------------- 1 | import 'package:date_format/date_format.dart'; 2 | 3 | class TimeUtils { 4 | static getCurrentTimeFormat() { 5 | return formatDate( 6 | DateTime.now(), [yyyy, "_", mm, "_", dd, "_", HH, '_', nn, '_', ss]); 7 | } 8 | 9 | static getCurrentTime() { 10 | return DateTime.now().microsecond; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/utils/command_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_mobile_command_tools/command/adb_command.dart'; 2 | import 'package:provider/provider.dart'; 3 | 4 | import '../enum/adb_command_type.dart'; 5 | import '../global.dart'; 6 | import '../notifier/panel/android_panel_notifier.dart'; 7 | 8 | class AndroidCommandUtils { 9 | static final _adbCommand = new AdbCommand(); 10 | 11 | static AdbCommand getAdbCommand() { 12 | return _adbCommand; 13 | } 14 | 15 | /// 发送连接设备的指令 16 | static sendConnectDeviceOrder() { 17 | _adbCommand 18 | .runCommand>(AdbCommandType.ADB_CONNECT_DEVICES.value) 19 | .then((value) { 20 | if (value != null) { 21 | if (value.isSuccess) { 22 | Provider.of(Global.navigatorKey.currentContext!, 23 | listen: false) 24 | .deviceList = value.data!; 25 | } 26 | } 27 | }); 28 | } 29 | 30 | /// 发送无线连接设备的指令 31 | static sendWirelessConnectDeviceOrder(String deviceName) { 32 | _adbCommand 33 | .runCommand( 34 | AdbCommandType.ADB_WIRELESS_CONNECT.value + " ${deviceName}") 35 | .then((value) { 36 | if (value != null) { 37 | if (value.isSuccess) { 38 | // Provider.of(Global.navigatorKey.currentContext!, 39 | // listen: false) 40 | // .deviceList = value.data!; 41 | } 42 | } 43 | }); 44 | } 45 | 46 | /// 发送断开设备的指令 47 | static sendDisConnectDeviceOrder(String? deviceName) { 48 | _adbCommand 49 | .runCommand(AdbCommandType.ADB_WIRELESS_DISCONNECT.value + 50 | " ${deviceName == null ? '' : deviceName}") 51 | .then((value) { 52 | if (value != null) { 53 | if (value.isSuccess) {} 54 | } 55 | }); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/utils/dialog_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/base/base_dialog.dart'; 3 | import 'package:flutter_mobile_command_tools/enum/file_name_type.dart'; 4 | import 'package:flutter_mobile_command_tools/global.dart'; 5 | import 'package:flutter_mobile_command_tools/notifier/dialog/android_input_notifier.dart'; 6 | import 'package:flutter_mobile_command_tools/utils/file_utils.dart'; 7 | import 'package:flutter_mobile_command_tools/utils/platform_utils.dart'; 8 | import 'package:flutter_mobile_command_tools/utils/toast_utils.dart'; 9 | import 'package:flutter_mobile_command_tools/widgets/dialog/android_sim_script_dialog.dart'; 10 | import 'package:provider/provider.dart'; 11 | 12 | /** 13 | * @FileName : dialog_utils 14 | * @Author : lijie 15 | * @Time : 2025/3/10 18:58 16 | * @Description : 弹窗工具类 17 | */ 18 | class DialogUtils { 19 | /// 展示通用文本的弹窗 20 | static Future showTextDialog({ 21 | required List contents, 22 | List colorChangeIndex = const [], 23 | List contentChangeColor = const [], 24 | String title = "", 25 | Function()? onConfirm, 26 | Function? onCancel, 27 | }) async { 28 | List contentColors = []; 29 | if (colorChangeIndex.isEmpty || contentChangeColor.isEmpty) { 30 | for (int i = 0; i < contents.length; i++) { 31 | contentColors[i] = Colors.black; 32 | } 33 | } else { 34 | for (int i = 0; i < contents.length; i++) { 35 | if (colorChangeIndex.contains(i)) { 36 | try { 37 | contentColors.add(contentChangeColor[colorChangeIndex.indexOf(i)]); 38 | } catch (e) { 39 | contentColors.add(Colors.black); 40 | } 41 | } else { 42 | contentColors.add(Colors.black); 43 | } 44 | } 45 | } 46 | return await showDialog( 47 | context: Global.scaffoldKey.currentContext!, 48 | builder: (context) => BaseConfirmCancelDialog( 49 | dialogTitle: title, 50 | onCancel: onCancel, 51 | onConfirm: onConfirm, 52 | contentWidget: Padding( 53 | padding: EdgeInsets.only( 54 | top: 10, 55 | bottom: 10, 56 | ), 57 | child: Wrap( 58 | alignment: WrapAlignment.center, 59 | children: [ 60 | RichText( 61 | text: TextSpan( 62 | children: contents.map((String content) { 63 | return TextSpan( 64 | text: content, 65 | style: TextStyle( 66 | color: contentColors[contents.indexOf(content)], 67 | fontSize: 16)); 68 | }).toList())) 69 | ], 70 | ), 71 | ))); 72 | } 73 | 74 | /// 展示输入类型的通用弹窗 75 | static Future showInputDialog({ 76 | required String title, 77 | required FileNameType fileNameType, 78 | required String confirmText, 79 | Function(String deviceName)? onConfirm, 80 | Function? onCancel, 81 | }) async { 82 | AndroidInputNotifier androidInputNotifier = new AndroidInputNotifier(); 83 | 84 | String filePath = await FileUtils.getConfigFileByName(fileNameType); 85 | List contentList = await FileUtils.readFileByLine(filePath); 86 | if (contentList.isEmpty) { 87 | contentList.add(' '); 88 | } 89 | androidInputNotifier.connectDeviceList = contentList; 90 | 91 | return await showDialog( 92 | context: Global.scaffoldKey.currentContext!, 93 | builder: (context) => BaseConfirmCancelDialog( 94 | dialogTitle: title, 95 | onCancel: onCancel, 96 | onConfirm: () { 97 | Navigator.pop(context, androidInputNotifier.connectDevice); 98 | }, 99 | confirmText: confirmText, 100 | contentWidget: ChangeNotifierProvider( 101 | create: (context) => androidInputNotifier, 102 | child: Padding( 103 | padding: EdgeInsets.only( 104 | top: 10, 105 | bottom: 10, 106 | ), 107 | child: Row( 108 | children: [ 109 | Expanded(child: Consumer( 110 | builder: (context, value, child) { 111 | return EditableComboBox( 112 | value: value.connectDevice, 113 | items: value.connectDeviceList 114 | .map>((e) { 115 | return ComboBoxItem( 116 | child: Text('$e'), 117 | value: e, 118 | ); 119 | }).toList(), 120 | onChanged: (deviceName) { 121 | value.connectDevice = deviceName ?? ''; 122 | }, 123 | onFieldSubmitted: (String text) { 124 | value.connectDevice = text; 125 | return text; 126 | }, 127 | ); 128 | })), 129 | SizedBox( 130 | width: 10, 131 | ), 132 | FilledButton( 133 | child: Text('保存记录'), 134 | onPressed: () { 135 | if (contentList.contains(' ') || 136 | contentList.contains('')) { 137 | contentList.remove(' '); 138 | contentList.remove(''); 139 | } 140 | if (contentList 141 | .contains(androidInputNotifier.connectDevice)) { 142 | showToast(message: '当前记录已存在', title: ''); 143 | return; 144 | } 145 | contentList.add(androidInputNotifier.connectDevice); 146 | FileUtils.writeFile( 147 | contentList.join(PlatformUtils.getLineBreak()), 148 | filePath); 149 | showToast(message: '保存记录成功', title: ''); 150 | }), 151 | SizedBox( 152 | width: 10, 153 | ), 154 | FilledButton( 155 | child: Text('删除记录'), 156 | onPressed: () { 157 | if (androidInputNotifier.connectDevice == ' ' || 158 | androidInputNotifier.connectDevice == ' ') { 159 | showToast(message: '删除记录不能为空', title: ''); 160 | return; 161 | } 162 | contentList 163 | .remove(androidInputNotifier.connectDevice); 164 | androidInputNotifier.connectDeviceList = contentList; 165 | FileUtils.writeFile( 166 | contentList.join(PlatformUtils.getLineBreak()), 167 | filePath); 168 | showToast(message: '删除记录成功', title: ''); 169 | }) 170 | ], 171 | ), 172 | ), 173 | ))); 174 | } 175 | 176 | /// 展示新建脚本弹窗 177 | static Future showNewOperationScriptDialog() async { 178 | GlobalKey globalKey = GlobalKey(); 179 | 180 | return await showDialog( 181 | context: Global.scaffoldKey.currentContext!, 182 | builder: (context) => BaseConfirmCancelDialog( 183 | dialogTitle: '新建脚本', 184 | onConfirm: () { 185 | if (globalKey.currentState != null) { 186 | if (globalKey.currentState!.simOperationModel.simOperationList 187 | .isEmpty) { 188 | showToast(message: '请先加指令添加到指令列表中', title: '保存失败'); 189 | } else { 190 | FileUtils.writeSimOperationFile( 191 | globalKey.currentState!.simOperationModel, 192 | globalKey.currentState?.fileName); 193 | showToast( 194 | message: '', 195 | title: '保存成功', 196 | severity: InfoBarSeverity.success); 197 | Navigator.pop(context); 198 | } 199 | } 200 | }, 201 | contentWidget: AndroidSimScriptDialog(globalKey), 202 | )); 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /lib/utils/init_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter/services.dart'; 5 | import 'package:flutter_mobile_command_tools/enum/dir_type.dart'; 6 | import 'package:flutter_mobile_command_tools/utils/platform_utils.dart'; 7 | 8 | import '../constants.dart'; 9 | import 'file_utils.dart'; 10 | 11 | class InitUtils { 12 | static Future init(Map map) async { 13 | await _initSetting(map); 14 | _initDesktop(); 15 | _initApkSigner(); 16 | _initInnerAdb(); 17 | _initMutualAppFile(); 18 | } 19 | 20 | //获取桌面路径 21 | static void _initDesktop() async { 22 | if (Platform.isWindows) { 23 | await Process.run(r"echo %USERPROFILE%", [], runInShell: true) 24 | .then((value) async { 25 | if (value.stdout != "") { 26 | Constants.userPath = 27 | value.stdout.toString().split(PlatformUtils.getLineBreak())[0]; 28 | Constants.desktopPath = Constants.userPath + r"\Desktop"; 29 | if (!await FileUtils.isExistFolder(Constants.userPath)) { 30 | Constants.desktopPath = Directory.current.path; 31 | } 32 | _initAdbPath(); 33 | } else { 34 | Constants.desktopPath = Directory.current.path; 35 | } 36 | }); 37 | } else if (Platform.isMacOS) { 38 | await Process.run(r"id", ["-un"], runInShell: true).then((value) async { 39 | if (value.stdout != "") { 40 | Constants.userPath = "/Users/" + 41 | value.stdout.toString().split(PlatformUtils.getLineBreak())[0]; 42 | Constants.desktopPath = Constants.userPath + r"/Desktop"; 43 | if (!await FileUtils.isExistFolder(Constants.userPath)) { 44 | String? path = await FileUtils.localPath(dirType: DirType.TEMP_DIR); 45 | Constants.desktopPath = path == null ? "" : path; 46 | } 47 | _initAdbPath(); 48 | } else { 49 | Constants.desktopPath = Directory.current.path; 50 | } 51 | }); 52 | } else if (Platform.isLinux) { 53 | await Process.run(r"id", ["-un"], runInShell: true).then((value) async { 54 | if (value.stdout != "") { 55 | Constants.userPath = "/home/" + 56 | value.stdout.toString().split(PlatformUtils.getLineBreak())[0]; 57 | Constants.desktopPath = Constants.userPath + r"/Desktop"; 58 | if (!await FileUtils.isExistFolder(Constants.userPath)) { 59 | Constants.desktopPath = Directory.current.path; 60 | } 61 | _initAdbPath(); 62 | } else { 63 | Constants.desktopPath = Directory.current.path; 64 | } 65 | }); 66 | } 67 | } 68 | 69 | //获取系统默认的adb目录 70 | static void _initAdbPath() { 71 | if (Constants.adbPath.isNotEmpty) { 72 | return; 73 | } 74 | if (Platform.isWindows) { 75 | Constants.adbPath = Constants.outerAdbPath = Constants.userPath + 76 | r"\AppData\Local\Android\sdk\platform-tools\adb.exe"; 77 | } else if (Platform.isMacOS) { 78 | Constants.adbPath = Constants.outerAdbPath = 79 | Constants.userPath + r"/Library/Android/sdk/platform-tools/adb"; 80 | } else if (Platform.isLinux) { 81 | Constants.adbPath = Constants.outerAdbPath = 82 | Constants.userPath + r"/Android/Sdk/platform-tools/adb"; 83 | } 84 | } 85 | 86 | //初始化配置 87 | static _initSetting(Map mapSettings) async { 88 | String value = await FileUtils.readSetting(); 89 | if (value.isNotEmpty) { 90 | Map map = jsonDecode(value); 91 | if (map[Constants.javaKey] != null) { 92 | Constants.javaPath = map[Constants.javaKey]; 93 | } 94 | if (map[Constants.libDeviceKey] != null) { 95 | Constants.libDevicePath = map[Constants.libDeviceKey]; 96 | } 97 | if (map[Constants.isInnerAdbKey] != null) { 98 | Constants.isInnerAdb = map[Constants.isInnerAdbKey]; 99 | } 100 | if (map[Constants.outerKey] != null) { 101 | Constants.outerAdbPath = map[Constants.outerKey]; 102 | if (!Constants.isInnerAdb) { 103 | Constants.adbPath = await FileUtils.getInnerAdbPath(); 104 | } 105 | } 106 | if (map[Constants.innerKey] != null) { 107 | Constants.innerAdbPath = map[Constants.innerKey]; 108 | if (Constants.isInnerAdb) { 109 | Constants.adbPath = await FileUtils.getInnerAdbPath(); 110 | } 111 | } 112 | if (map[Constants.isRootKey] != null) { 113 | Constants.isRoot = map[Constants.isRootKey]; 114 | } 115 | mapSettings.addAll(map); 116 | } 117 | } 118 | 119 | ///初始化签名文件 120 | static _initApkSigner() async { 121 | Constants.signerPath = 122 | await FileUtils.localFile("apksigner.json", subDir: "apksigner"); 123 | String signer = await FileUtils.readFile(Constants.signerPath); 124 | if (signer.isEmpty) { 125 | signer = await rootBundle.loadString('assets/apksigner.json'); 126 | FileUtils.writeFile(signer, Constants.signerPath.path); 127 | } 128 | 129 | Constants.jksPath = 130 | await FileUtils.localFile("apk.jks", subDir: "apksigner"); 131 | if (!await FileUtils.isExistFile(Constants.jksPath.path)) { 132 | var buffer = await rootBundle.load('assets/apk.jks'); 133 | FileUtils.writeBytesFile(buffer, Constants.jksPath); 134 | } 135 | 136 | Constants.signerJarPath = 137 | await FileUtils.localFile("apksigner.jar", subDir: "apksigner"); 138 | if (!await FileUtils.isExistFile(Constants.signerJarPath.path)) { 139 | var buffer = await rootBundle.load('assets/apksigner.jar'); 140 | FileUtils.writeBytesFile(buffer, Constants.signerJarPath); 141 | } 142 | } 143 | 144 | //初始化内部的adb 145 | static _initInnerAdb() async { 146 | File versionFile = File(await FileUtils.getBasePath() + 147 | PlatformUtils.getPathSeparator() + 148 | "VERSION"); 149 | String versionStr = await FileUtils.readFile(versionFile); 150 | 151 | String assetsAdbPath; 152 | if (Platform.isWindows) { 153 | assetsAdbPath = "assets/windows/tools.zip"; 154 | } else if (Platform.isMacOS) { 155 | assetsAdbPath = "assets/macos/tools.zip"; 156 | } else { 157 | assetsAdbPath = "assets/linux/tools.zip"; 158 | } 159 | Directory directoryAdb = Directory('${await FileUtils.getBasePath()}' + 160 | PlatformUtils.getPathSeparator() + 161 | Constants.TOOLS_DIRECTORY_NAME); 162 | var path = directoryAdb.path + ".zip"; 163 | if (!await directoryAdb.exists() || versionStr != Constants.APP_VERSION) { 164 | var buffer = await rootBundle.load(assetsAdbPath); 165 | await FileUtils.writeBytesFile(buffer, File(path)); 166 | FileUtils.unZipFiles(directoryAdb.path, path); 167 | } 168 | FileUtils.writeFile(Constants.APP_VERSION, versionFile.path); 169 | } 170 | 171 | static void _initMutualAppFile() async { 172 | FileUtils.createFile(await FileUtils.getMutualAppPath("Activity")); 173 | FileUtils.createFile(await FileUtils.getMutualAppPath("Service")); 174 | if (!await FileUtils.isExistFile( 175 | await FileUtils.getMutualAppPath("BroadcastReceiver"))) { 176 | FileUtils.createFile( 177 | await FileUtils.getMutualAppPath("BroadcastReceiver")); 178 | String content = ""; 179 | broadcastReceiver.forEach((element) { 180 | content = content + element + PlatformUtils.getLineBreak(); 181 | }); 182 | FileUtils.writeFile( 183 | content,await FileUtils.getMutualAppPath("BroadcastReceiver")); 184 | } 185 | } 186 | 187 | static List broadcastReceiver = [ 188 | "android.net.conn.CONNECTIVITY_CHANGE", 189 | //网络连接发生变化 190 | "android.intent.action.SCREEN_ON", 191 | //屏幕点亮 192 | "android.intent.action.SCREEN_OFF", 193 | //屏幕熄灭 194 | "android.intent.action.BATTERY_LOW", 195 | //电量低,会弹出电量低提示框 196 | "android.intent.action.BATTERY_OKAY", 197 | //电量恢复了 198 | "android.intent.action.BOOT_COMPLETED", 199 | //设备启动完毕 200 | "android.intent.action.DEVICE_STORAGE_LOW", 201 | //存储空间过低 202 | "android.intent.action.DEVICE_STORAGE_OK", 203 | //存储空间恢复 204 | "android.intent.action.PACKAGE_ADDED", 205 | //安装了新的应用 206 | "android.net.wifi.STATE_CHANGE", 207 | //WiFi 连接状态发生变化 208 | "android.net.wifi.WIFI_STATE_CHANGED", 209 | //WiFi 状态变为启用/关闭/正在启动/正在关闭/未知 210 | "android.intent.action.BATTERY_CHANGED", 211 | //电池电量发生变化 212 | "android.intent.action.INPUT_METHOD_CHANGED", 213 | //系统输入法发生变化 214 | "android.intent.action.ACTION_POWER_CONNECTED", 215 | //外部电源连接 216 | "android.intent.action.ACTION_POWER_DISCONNECTED", 217 | //外部电源断开连接 218 | "android.intent.action.DREAMING_STARTED", 219 | //系统开始休眠 220 | "android.intent.action.DREAMING_STOPPED", 221 | //系统停止休眠 222 | "android.intent.action.WALLPAPER_CHANGED", 223 | //壁纸发生变化 224 | "android.intent.action.HEADSET_PLUG", 225 | //插入耳机 226 | "android.intent.action.MEDIA_UNMOUNTED", 227 | //卸载外部介质 228 | "android.intent.action.MEDIA_MOUNTED", 229 | //挂载外部介质 230 | "android.os.action.POWER_SAVE_MODE_CHANGED", 231 | ]; 232 | } 233 | -------------------------------------------------------------------------------- /lib/utils/log_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_mobile_command_tools/global.dart'; 2 | import 'package:flutter_mobile_command_tools/notifier/log_change_notifier.dart'; 3 | import 'package:provider/provider.dart'; 4 | 5 | class LogUtils { 6 | ///Release:const bool.fromEnvironment("dart.vm.product") = true; 7 | /// Debug:assert(() { ...; return true; });断言语句会被执行; 8 | /// Profile:上面的两种情况均不会发生。 9 | static printLog(log) { 10 | const bool inProduction = const bool.fromEnvironment("dart.vm.product"); 11 | if (!inProduction) { 12 | print(log); 13 | } 14 | } 15 | 16 | /// 展示log日志 17 | static showLog(log) { 18 | Provider.of(Global.navigatorKey.currentContext!, 19 | listen: false) 20 | .addLog(">>>>>> ${log}"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/utils/notifier_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_mobile_command_tools/notifier/panel/android_panel_notifier.dart'; 2 | import 'package:provider/provider.dart'; 3 | 4 | import '../global.dart'; 5 | 6 | /** 7 | * @Classname notifier_utils 8 | * @Date 2025/3/16 21:18 9 | * @Created by jacky 10 | * @Description 获取通知器 11 | */ 12 | class NotifierUtils { 13 | static AndroidPanelNotifier getAndroidPanelNotifier() { 14 | return Provider.of( 15 | Global.navigatorKey.currentContext!, 16 | listen: false); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/utils/number_utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | /** 4 | * @Classname number_utils 5 | * @Date 2025/3/16 13:45 6 | * @Created by jacky 7 | * @Description 数字工具类 8 | */ 9 | class NumberUtils { 10 | /// 判断字符串是否为double或者int类型 11 | bool isNumber(String value) { 12 | double? numberDouble = double.tryParse(value); 13 | if (numberDouble == null) { 14 | int? numberInt = int.tryParse(value); 15 | if (numberInt == null) { 16 | return false; 17 | } 18 | } 19 | return true; 20 | } 21 | 22 | /// 安全字符串转int 23 | static int safeStrToInt(String value) { 24 | try { 25 | return int.parse(value); 26 | } catch (e) { 27 | return 0; 28 | } 29 | } 30 | 31 | /// 安全字符串转double 32 | static double safeStrToDouble(String value) { 33 | try { 34 | return double.parse(value); 35 | } catch (e) { 36 | return 0; 37 | } 38 | } 39 | 40 | /// 获取两个数之间的随机数 41 | static int getRandom(int min, int max) { 42 | if (min == max) { 43 | return min; 44 | } 45 | int random = min + Random().nextInt(max - min); 46 | return random; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/utils/platform_utils.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: slash_for_doc_comments 2 | 3 | import 'dart:convert'; 4 | import 'dart:io'; 5 | 6 | import 'package:flutter_mobile_command_tools/constants.dart'; 7 | 8 | class PlatformUtils { 9 | static String getLineBreak() { 10 | if (Platform.isWindows) { 11 | return "\r\n"; 12 | } else { 13 | return "\n"; 14 | } 15 | } 16 | 17 | static String getPathSeparator() { 18 | if (Platform.isWindows) { 19 | return r"\"; 20 | } 21 | return r"/"; 22 | } 23 | 24 | static String grepFindStr() { 25 | if (Platform.isWindows) { 26 | return "findstr"; 27 | } 28 | return "grep"; 29 | } 30 | 31 | ///windows和linux系统的命令行指令不一样 32 | ///使用run命令拿到的输出结果总是在运行完成了才全部输出 33 | static Future runCommand(String commandStr, 34 | {bool runInShell = true, 35 | String? workDirectory, 36 | bool isAdbCommand = false}) { 37 | if (isAdbCommand) { 38 | commandStr = adbCommand(commandStr); 39 | } 40 | commandStr = javaCommand(commandStr); 41 | if (Platform.isMacOS || Platform.isLinux) { 42 | String executable = commandStr.split(" ")[0]; 43 | List arguments = 44 | commandStr.replaceFirst(executable, "").trim().split(" "); 45 | return Process.run(executable, arguments, 46 | runInShell: runInShell, 47 | workingDirectory: workDirectory, 48 | stdoutEncoding: Encoding.getByName("utf-8")); 49 | } else { 50 | return Process.run(commandStr, [], 51 | runInShell: runInShell, 52 | workingDirectory: workDirectory, 53 | stdoutEncoding: Encoding.getByName("utf-8")); 54 | } 55 | } 56 | 57 | /// ProcessStartMode 可以设置开启进程模式,但是我测试没成功,没法重定向输出流到我的文本上面来 58 | /// 在命令行界面倒是可以实时输出,可以了,可以拿到输出流然后 59 | /** 60 | * 61 | var stream = value.stdout; 62 | stream.listen((event) { 63 | _showLog(utf8.decode(event)); 64 | } 65 | */ 66 | static Future startCommand(String commandStr, 67 | {bool runInShell = true, 68 | String? workDirectory, 69 | ProcessStartMode mode = ProcessStartMode.normal}) { 70 | commandStr = javaCommand(commandStr); 71 | print(commandStr); 72 | if (Platform.isMacOS || Platform.isLinux) { 73 | String executable = commandStr.split(" ")[0]; 74 | List arguments = 75 | commandStr.replaceFirst(executable, "").trim().split(" "); 76 | return Process.start(executable, arguments, 77 | runInShell: runInShell, workingDirectory: workDirectory, mode: mode); 78 | } else { 79 | return Process.start(commandStr, [], 80 | runInShell: runInShell, workingDirectory: workDirectory, mode: mode); 81 | } 82 | } 83 | 84 | static String javaCommand(String command) { 85 | if (!command.startsWith("java")) { 86 | return command; 87 | } 88 | if (Constants.javaPath.isNotEmpty) { 89 | return command.replaceFirst("java", Constants.javaPath); 90 | } 91 | return command; 92 | } 93 | 94 | static String adbCommand(String command) { 95 | if (!command.startsWith("adb")) { 96 | if (Constants.currentDevice.isNotEmpty) { 97 | return Constants.adbPath + 98 | " -s " + 99 | Constants.currentDevice + 100 | " " + 101 | command; 102 | } 103 | return Constants.adbPath + " " + command; 104 | } 105 | if (Constants.javaPath.isNotEmpty) { 106 | if (Constants.currentDevice.isNotEmpty) { 107 | return Constants.adbPath + 108 | " -s " + 109 | Constants.currentDevice + 110 | " " + 111 | command.replaceFirst("adb", ""); 112 | } 113 | return command.replaceFirst("adb", Constants.adbPath); 114 | } 115 | return command; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/utils/style_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | /** 4 | * @FileName : style_utils 5 | * @Author : lijie 6 | * @Time : 2025/3/11 09:32 7 | * @Description : 文本的风格工具类 8 | */ 9 | 10 | /// 弹窗标题的文本大小 11 | TextStyle getDialogTitleStyle() { 12 | return TextStyle(fontSize: 16); 13 | } 14 | 15 | /// 通用的文本大小 16 | TextStyle getCommonTitleStyle() { 17 | return TextStyle(fontSize: 12); 18 | } 19 | -------------------------------------------------------------------------------- /lib/utils/toast_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | 3 | import '../global.dart'; 4 | 5 | /** 6 | * @Classname toast_utils 7 | * @Date 2025/3/15 16:39 8 | * @Created by jacky 9 | * @Description 吐司 10 | */ 11 | Future showToast({ 12 | required String message, 13 | required String title, 14 | InfoBarSeverity severity = InfoBarSeverity.info, 15 | }) async { 16 | await displayInfoBar(Global.scaffoldKey.currentContext!, 17 | builder: (context, close) { 18 | return InfoBar( 19 | title: Text(title), 20 | content: Text(message), 21 | // action: IconButton( 22 | // icon: const Icon(FluentIcons.clear), 23 | // onPressed: close, 24 | // ), 25 | severity: severity, 26 | ); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /lib/utils/window_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/global.dart'; 3 | 4 | /** 5 | * @Classname screen_utils 6 | * @Date 2025/3/15 14:45 7 | * @Created by jacky 8 | * @Description 屏幕相关的工具类 9 | */ 10 | class WindowUtils { 11 | /// 获取长度 12 | static double getWindowWidth() { 13 | return MediaQuery.of(Global.navigatorKey.currentContext!).size.width; 14 | } 15 | 16 | /// 获取宽度 17 | static double getWindowHeight() { 18 | return MediaQuery.of(Global.navigatorKey.currentContext!).size.height; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/widgets/android_log_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluent_ui/fluent_ui.dart'; 2 | import 'package:flutter_mobile_command_tools/notifier/log_change_notifier.dart'; 3 | import 'package:provider/provider.dart'; 4 | 5 | class AndroidLogWidget extends StatelessWidget { 6 | @override 7 | Widget build(BuildContext context) { 8 | return TextBox( 9 | scrollController: 10 | Provider.of(context).scrollController, 11 | keyboardType: TextInputType.multiline, 12 | controller: TextEditingController( 13 | text: Provider.of(context).logList.join('\n')), 14 | 15 | /// focusNode: leftPanelFocus, 16 | readOnly: true, 17 | maxLines: null, 18 | //不限制行数 19 | autofocus: false, 20 | // 长按输入的文本, 设置是否显示剪切,复制,粘贴按钮, 默认是显示的 21 | enableInteractiveSelection: true, 22 | style: TextStyle(fontFamily: "simple", fontSize: 16, height: 2), 23 | padding: EdgeInsets.all(10), 24 | decoration: WidgetStateProperty.resolveWith((state) { 25 | return BoxDecoration( 26 | border: Border.all(), 27 | borderRadius: BorderRadius.all(Radius.circular(5))); 28 | }), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(runner LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "MobileTool") 5 | set(APPLICATION_ID "com.example.flutter_mobile_command_tools") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Root filesystem for cross-building. 12 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 13 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 14 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 19 | endif() 20 | 21 | # Configure build options. 22 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 23 | set(CMAKE_BUILD_TYPE "Debug" CACHE 24 | STRING "Flutter build mode" FORCE) 25 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 26 | "Debug" "Profile" "Release") 27 | endif() 28 | 29 | # Compilation settings that should be applied to most targets. 30 | function(APPLY_STANDARD_SETTINGS TARGET) 31 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 32 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 33 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 34 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 35 | endfunction() 36 | 37 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 38 | 39 | # Flutter library and tool build rules. 40 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 41 | 42 | # System-level dependencies. 43 | find_package(PkgConfig REQUIRED) 44 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 45 | 46 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 47 | 48 | # Application build 49 | add_executable(${BINARY_NAME} 50 | "main.cc" 51 | "my_application.cc" 52 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 53 | ) 54 | apply_standard_settings(${BINARY_NAME}) 55 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 56 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 57 | add_dependencies(${BINARY_NAME} flutter_assemble) 58 | # Only the install-generated bundle's copy of the executable will launch 59 | # correctly, since the resources must in the right relative locations. To avoid 60 | # people trying to run the unbundled copy, put it in a subdirectory instead of 61 | # the default top-level location. 62 | set_target_properties(${BINARY_NAME} 63 | PROPERTIES 64 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 65 | ) 66 | 67 | # Generated plugin build rules, which manage building the plugins and adding 68 | # them to the application. 69 | include(flutter/generated_plugins.cmake) 70 | 71 | 72 | # === Installation === 73 | # By default, "installing" just makes a relocatable bundle in the build 74 | # directory. 75 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 76 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 77 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 78 | endif() 79 | 80 | # Start with a clean build bundle directory every time. 81 | install(CODE " 82 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 83 | " COMPONENT Runtime) 84 | 85 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 86 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 87 | 88 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 89 | COMPONENT Runtime) 90 | 91 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 92 | COMPONENT Runtime) 93 | 94 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 95 | COMPONENT Runtime) 96 | 97 | if(PLUGIN_BUNDLED_LIBRARIES) 98 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 99 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 100 | COMPONENT Runtime) 101 | endif() 102 | 103 | # Fully re-copy the assets directory on each build to avoid having stale files 104 | # from a previous install. 105 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 106 | install(CODE " 107 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 108 | " COMPONENT Runtime) 109 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 110 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 111 | 112 | # Install the AOT library on non-Debug builds only. 113 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 114 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 115 | COMPONENT Runtime) 116 | endif() 117 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | 11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 12 | # which isn't available in 3.10. 13 | function(list_prepend LIST_NAME PREFIX) 14 | set(NEW_LIST "") 15 | foreach(element ${${LIST_NAME}}) 16 | list(APPEND NEW_LIST "${PREFIX}${element}") 17 | endforeach(element) 18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 19 | endfunction() 20 | 21 | # === Flutter Library === 22 | # System-level dependencies. 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 27 | 28 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 29 | 30 | # Published to parent scope for install step. 31 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 32 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 33 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 34 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 35 | 36 | list(APPEND FLUTTER_LIBRARY_HEADERS 37 | "fl_basic_message_channel.h" 38 | "fl_binary_codec.h" 39 | "fl_binary_messenger.h" 40 | "fl_dart_project.h" 41 | "fl_engine.h" 42 | "fl_json_message_codec.h" 43 | "fl_json_method_codec.h" 44 | "fl_message_codec.h" 45 | "fl_method_call.h" 46 | "fl_method_channel.h" 47 | "fl_method_codec.h" 48 | "fl_method_response.h" 49 | "fl_plugin_registrar.h" 50 | "fl_plugin_registry.h" 51 | "fl_standard_message_codec.h" 52 | "fl_standard_method_codec.h" 53 | "fl_string_codec.h" 54 | "fl_value.h" 55 | "fl_view.h" 56 | "flutter_linux.h" 57 | ) 58 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 59 | add_library(flutter INTERFACE) 60 | target_include_directories(flutter INTERFACE 61 | "${EPHEMERAL_DIR}" 62 | ) 63 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 64 | target_link_libraries(flutter INTERFACE 65 | PkgConfig::GTK 66 | PkgConfig::GLIB 67 | PkgConfig::GIO 68 | ) 69 | add_dependencies(flutter flutter_assemble) 70 | 71 | # === Flutter tool backend === 72 | # _phony_ is a non-existent file to force this command to run every time, 73 | # since currently there's no way to get a full input/output list from the 74 | # flutter tool. 75 | add_custom_command( 76 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 77 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 78 | COMMAND ${CMAKE_COMMAND} -E env 79 | ${FLUTTER_TOOL_ENVIRONMENT} 80 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 81 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 82 | VERBATIM 83 | ) 84 | add_custom_target(flutter_assemble DEPENDS 85 | "${FLUTTER_LIBRARY}" 86 | ${FLUTTER_LIBRARY_HEADERS} 87 | ) 88 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | void fl_register_plugins(FlPluginRegistry* registry) { 16 | g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = 17 | fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); 18 | file_selector_plugin_register_with_registrar(file_selector_linux_registrar); 19 | g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar = 20 | fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin"); 21 | flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar); 22 | g_autoptr(FlPluginRegistrar) screen_retriever_registrar = 23 | fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); 24 | screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); 25 | g_autoptr(FlPluginRegistrar) system_theme_registrar = 26 | fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin"); 27 | system_theme_plugin_register_with_registrar(system_theme_registrar); 28 | g_autoptr(FlPluginRegistrar) window_manager_registrar = 29 | fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); 30 | window_manager_plugin_register_with_registrar(window_manager_registrar); 31 | } 32 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | file_selector_linux 7 | flutter_acrylic 8 | screen_retriever 9 | system_theme 10 | window_manager 11 | ) 12 | 13 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 14 | ) 15 | 16 | set(PLUGIN_BUNDLED_LIBRARIES) 17 | 18 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 19 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 20 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 23 | endforeach(plugin) 24 | 25 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 26 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 28 | endforeach(ffi_plugin) 29 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | #include 3 | #ifdef GDK_WINDOWING_X11 4 | #include 5 | #endif 6 | 7 | #include "flutter/generated_plugin_registrant.h" 8 | 9 | struct _MyApplication { 10 | GtkApplication parent_instance; 11 | char** dart_entrypoint_arguments; 12 | }; 13 | 14 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 15 | 16 | // Implements GApplication::activate. 17 | static void my_application_activate(GApplication* application) { 18 | MyApplication* self = MY_APPLICATION(application); 19 | GtkWindow* window = 20 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 21 | 22 | // Use a header bar when running in GNOME as this is the common style used 23 | // by applications and is the setup most users will be using (e.g. Ubuntu 24 | // desktop). 25 | // If running on X and not using GNOME then just use a traditional title bar 26 | // in case the window manager does more exotic layout, e.g. tiling. 27 | // If running on Wayland assume the header bar will work (may need changing 28 | // if future cases occur). 29 | gboolean use_header_bar = TRUE; 30 | #ifdef GDK_WINDOWING_X11 31 | GdkScreen *screen = gtk_window_get_screen(window); 32 | GdkDisplay *display =gdk_display_get_default(); 33 | GdkMonitor *monitor =gdk_display_get_primary_monitor(display); 34 | GdkRectangle geo; 35 | gdk_monitor_get_geometry(monitor, &geo); //get current display 36 | int x = geo.width; //current display width 37 | int y = geo.height; //current display height 38 | 39 | if (GDK_IS_X11_SCREEN(screen)) { 40 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 41 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 42 | use_header_bar = FALSE; 43 | } 44 | } 45 | #endif 46 | if (use_header_bar) { 47 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 48 | gtk_widget_show(GTK_WIDGET(header_bar)); 49 | gtk_header_bar_set_title(header_bar, ""); 50 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 51 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 52 | } 53 | else { 54 | gtk_window_set_title(window, ""); 55 | } 56 | 57 | gtk_window_set_default_size(window, x/3*2, y/3*2); 58 | gtk_widget_show(GTK_WIDGET(window)); 59 | 60 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 61 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 62 | 63 | FlView* view = fl_view_new(project); 64 | gtk_widget_show(GTK_WIDGET(view)); 65 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 66 | 67 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 68 | 69 | gtk_widget_grab_focus(GTK_WIDGET(view)); 70 | } 71 | 72 | // Implements GApplication::local_command_line. 73 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) { 74 | MyApplication* self = MY_APPLICATION(application); 75 | // Strip out the first argument as it is the binary name. 76 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 77 | 78 | g_autoptr(GError) error = nullptr; 79 | if (!g_application_register(application, nullptr, &error)) { 80 | g_warning("Failed to register: %s", error->message); 81 | *exit_status = 1; 82 | return TRUE; 83 | } 84 | 85 | g_application_activate(application); 86 | *exit_status = 0; 87 | 88 | return TRUE; 89 | } 90 | 91 | // Implements GObject::dispose. 92 | static void my_application_dispose(GObject *object) { 93 | MyApplication* self = MY_APPLICATION(object); 94 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 95 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 96 | } 97 | 98 | static void my_application_class_init(MyApplicationClass* klass) { 99 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 100 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 101 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 102 | } 103 | 104 | static void my_application_init(MyApplication* self) {} 105 | 106 | MyApplication* my_application_new() { 107 | return MY_APPLICATION(g_object_new(my_application_get_type(), 108 | "application-id", APPLICATION_ID, 109 | "flags", G_APPLICATION_NON_UNIQUE, 110 | nullptr)); 111 | } 112 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/xcuserdata/ 7 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import file_selector_macos 9 | import macos_window_utils 10 | import path_provider_foundation 11 | import screen_retriever 12 | import system_theme 13 | import window_manager 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) 17 | MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) 18 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 19 | ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) 20 | SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin")) 21 | WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14.6' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | # target 'RunnerTests' do 35 | # inherit! :search_paths 36 | # end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = MobileTool 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterMobileCommandTools 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2021 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | com.apple.security.files.user-selected.read-write 12 | 13 | com.apple.security.app-sandbox 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | 8 | let screenFrame=NSScreen.screens[0].frame; //获取第一块屏幕的大小 9 | let scrWidth=screenFrame.size.width 10 | let scrHeight=screenFrame.size.height 11 | let windowWidth=scrWidth/3*2 12 | let windowHeight=scrHeight/3*2 13 | let pointX=(scrWidth-windowWidth)/2 14 | let pointY=(scrHeight-windowHeight)/2 15 | 16 | var windowFrame = self.frame 17 | windowFrame.size.height=windowHeight 18 | windowFrame.size.width=windowWidth 19 | windowFrame.origin.x=pointX 20 | windowFrame.origin.y=pointY 21 | self.contentViewController = flutterViewController 22 | self.setFrame(windowFrame, display: true) 23 | 24 | RegisterGeneratedPlugins(registry: flutterViewController) 25 | 26 | super.awakeFromNib() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-write 8 | 9 | com.apple.security.app-sandbox 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_mobile_command_tools 2 | description: Flutter for Mobile Tool 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.12.0 <3.0.0" 22 | 23 | dependencies: 24 | flutter: 25 | sdk: flutter 26 | 27 | 28 | # The following adds the Cupertino Icons font to your application. 29 | # Use with the CupertinoIcons class for iOS style icons. 30 | cupertino_icons: ^1.0.2 31 | provider: ^6.1.2 32 | 33 | path_provider: ^2.0.2 34 | file_picker: ^4.2.4 35 | archive: ^3.1.2 36 | date_format: ^2.0.4 37 | file_selector: ^1.0.3 38 | file_selector_windows: ^0.9.3+4 39 | file_selector_macos: ^0.9.4+2 40 | file_selector_linux: ^0.9.3+2 41 | fast_gbk: ^1.0.0 42 | fluent_ui: ^4.11.2 43 | window_manager: ^0.3.0 44 | flutter_acrylic: ^1.1.4 45 | system_theme: ^2.3.1 46 | 47 | dev_dependencies: 48 | test_process: ^2.0.2 49 | flutter_test: 50 | sdk: flutter 51 | 52 | # For information on the generic Dart part of this file, see the 53 | # following page: https://dart.dev/tools/pub/pubspec 54 | 55 | # The following section is specific to Flutter. 56 | flutter: 57 | 58 | # The following line ensures that the Material Icons font is 59 | # included with your application, so that you can use the icons in 60 | # the material Icons class. 61 | uses-material-design: true 62 | assets: 63 | - assets/apksigner.json 64 | - assets/apk.jks 65 | - assets/apksigner.jar 66 | - assets/windows/tools.zip 67 | - assets/macos/tools.zip 68 | - assets/linux/tools.zip 69 | 70 | 71 | 72 | # To add assets to your application, add an assets section, like this: 73 | # assets: 74 | # - images/a_dot_burr.jpeg 75 | # - images/a_dot_ham.jpeg 76 | 77 | # An image asset can refer to one or more resolution-specific "variants", see 78 | # https://flutter.dev/assets-and-images/#resolution-aware. 79 | 80 | # For details regarding adding assets from package dependencies, see 81 | # https://flutter.dev/assets-and-images/#from-packages 82 | 83 | # To add custom fonts to your application, add a fonts section here, 84 | # in this "flutter" section. Each entry in this list should have a 85 | # "family" key with the font family name, and a "fonts" key with a 86 | # list giving the asset and other descriptors for the font. For 87 | # example: 88 | fonts: 89 | - family: simple 90 | fonts: 91 | - asset: assets/fonts/SourceHanSansCN-Regular-2.otf 92 | # - asset: fonts/Schyler-Italic.ttf 93 | # style: italic 94 | # - family: Trajan Pro 95 | # fonts: 96 | # - asset: fonts/TrajanPro.ttf 97 | # - asset: fonts/TrajanPro_Bold.ttf 98 | # weight: 700 99 | # 100 | # For details regarding fonts from package dependencies, 101 | # see https://flutter.dev/custom-fonts/#from-packages 102 | -------------------------------------------------------------------------------- /screenshots/linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/screenshots/linux.png -------------------------------------------------------------------------------- /screenshots/macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/screenshots/macos.png -------------------------------------------------------------------------------- /screenshots/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/screenshots/settings.png -------------------------------------------------------------------------------- /screenshots/simtool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/screenshots/simtool.png -------------------------------------------------------------------------------- /screenshots/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/screenshots/windows.png -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_mobile_command_tools/main_test.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | flutter_mobile_command_tools 27 | 28 | 29 | 30 | 33 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_mobile_command_tools", 3 | "short_name": "flutter_mobile_command_tools", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Flutter for Mobile Tool", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(flutter_mobile_command_tools LANGUAGES CXX) 3 | 4 | # 修改文件名称 5 | set(BINARY_NAME "MobileTool") 6 | 7 | cmake_policy(SET CMP0063 NEW) 8 | 9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 10 | 11 | # Configure build options. 12 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 13 | if(IS_MULTICONFIG) 14 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 15 | CACHE STRING "" FORCE) 16 | else() 17 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 18 | set(CMAKE_BUILD_TYPE "Debug" CACHE 19 | STRING "Flutter build mode" FORCE) 20 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 21 | "Debug" "Profile" "Release") 22 | endif() 23 | endif() 24 | 25 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 27 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 28 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 29 | 30 | # Use Unicode for all projects. 31 | add_definitions(-DUNICODE -D_UNICODE) 32 | 33 | # Compilation settings that should be applied to most targets. 34 | function(APPLY_STANDARD_SETTINGS TARGET) 35 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 36 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 37 | target_compile_options(${TARGET} PRIVATE /EHsc) 38 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 39 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 40 | endfunction() 41 | 42 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 43 | 44 | # Flutter library and tool build rules. 45 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 46 | 47 | # Application build 48 | add_subdirectory("runner") 49 | 50 | # Generated plugin build rules, which manage building the plugins and adding 51 | # them to the application. 52 | include(flutter/generated_plugins.cmake) 53 | 54 | 55 | # === Installation === 56 | # Support files are copied into place next to the executable, so that it can 57 | # run in place. This is done instead of making a separate bundle (as on Linux) 58 | # so that building and running from within Visual Studio will work. 59 | set(BUILD_BUNDLE_DIR "$") 60 | # Make the "install" step default, as it's required to run. 61 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 62 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 63 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 64 | endif() 65 | 66 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 67 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 68 | 69 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 70 | COMPONENT Runtime) 71 | 72 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 73 | COMPONENT Runtime) 74 | 75 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 76 | COMPONENT Runtime) 77 | 78 | if(PLUGIN_BUNDLED_LIBRARIES) 79 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 80 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | endif() 83 | 84 | # Fully re-copy the assets directory on each build to avoid having stale files 85 | # from a previous install. 86 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 89 | " COMPONENT Runtime) 90 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 91 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 92 | 93 | # Install the AOT library on non-Debug builds only. 94 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 95 | CONFIGURATIONS Profile;Release 96 | COMPONENT Runtime) 97 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # Set fallback configurations for older versions of the flutter tool. 13 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 14 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 15 | endif() 16 | 17 | # === Flutter Library === 18 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 19 | 20 | # Published to parent scope for install step. 21 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 22 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 23 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 24 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 25 | 26 | list(APPEND FLUTTER_LIBRARY_HEADERS 27 | "flutter_export.h" 28 | "flutter_windows.h" 29 | "flutter_messenger.h" 30 | "flutter_plugin_registrar.h" 31 | "flutter_texture_registrar.h" 32 | ) 33 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 34 | add_library(flutter INTERFACE) 35 | target_include_directories(flutter INTERFACE 36 | "${EPHEMERAL_DIR}" 37 | ) 38 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 39 | add_dependencies(flutter flutter_assemble) 40 | 41 | # === Wrapper === 42 | list(APPEND CPP_WRAPPER_SOURCES_CORE 43 | "core_implementations.cc" 44 | "standard_codec.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 48 | "plugin_registrar.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 51 | list(APPEND CPP_WRAPPER_SOURCES_APP 52 | "flutter_engine.cc" 53 | "flutter_view_controller.cc" 54 | ) 55 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 56 | 57 | # Wrapper sources needed for a plugin. 58 | add_library(flutter_wrapper_plugin STATIC 59 | ${CPP_WRAPPER_SOURCES_CORE} 60 | ${CPP_WRAPPER_SOURCES_PLUGIN} 61 | ) 62 | apply_standard_settings(flutter_wrapper_plugin) 63 | set_target_properties(flutter_wrapper_plugin PROPERTIES 64 | POSITION_INDEPENDENT_CODE ON) 65 | set_target_properties(flutter_wrapper_plugin PROPERTIES 66 | CXX_VISIBILITY_PRESET hidden) 67 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 68 | target_include_directories(flutter_wrapper_plugin PUBLIC 69 | "${WRAPPER_ROOT}/include" 70 | ) 71 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 72 | 73 | # Wrapper sources needed for the runner. 74 | add_library(flutter_wrapper_app STATIC 75 | ${CPP_WRAPPER_SOURCES_CORE} 76 | ${CPP_WRAPPER_SOURCES_APP} 77 | ) 78 | apply_standard_settings(flutter_wrapper_app) 79 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 80 | target_include_directories(flutter_wrapper_app PUBLIC 81 | "${WRAPPER_ROOT}/include" 82 | ) 83 | add_dependencies(flutter_wrapper_app flutter_assemble) 84 | 85 | # === Flutter tool backend === 86 | # _phony_ is a non-existent file to force this command to run every time, 87 | # since currently there's no way to get a full input/output list from the 88 | # flutter tool. 89 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 90 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 91 | add_custom_command( 92 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 93 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 94 | ${CPP_WRAPPER_SOURCES_APP} 95 | ${PHONY_OUTPUT} 96 | COMMAND ${CMAKE_COMMAND} -E env 97 | ${FLUTTER_TOOL_ENVIRONMENT} 98 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 99 | ${FLUTTER_TARGET_PLATFORM} $ 100 | VERBATIM 101 | ) 102 | add_custom_target(flutter_assemble DEPENDS 103 | "${FLUTTER_LIBRARY}" 104 | ${FLUTTER_LIBRARY_HEADERS} 105 | ${CPP_WRAPPER_SOURCES_CORE} 106 | ${CPP_WRAPPER_SOURCES_PLUGIN} 107 | ${CPP_WRAPPER_SOURCES_APP} 108 | ) 109 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | void RegisterPlugins(flutter::PluginRegistry* registry) { 16 | FileSelectorWindowsRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("FileSelectorWindows")); 18 | FlutterAcrylicPluginRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("FlutterAcrylicPlugin")); 20 | ScreenRetrieverPluginRegisterWithRegistrar( 21 | registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); 22 | SystemThemePluginRegisterWithRegistrar( 23 | registry->GetRegistrarForPlugin("SystemThemePlugin")); 24 | WindowManagerPluginRegisterWithRegistrar( 25 | registry->GetRegistrarForPlugin("WindowManagerPlugin")); 26 | } 27 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | file_selector_windows 7 | flutter_acrylic 8 | screen_retriever 9 | system_theme 10 | window_manager 11 | ) 12 | 13 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 14 | ) 15 | 16 | set(PLUGIN_BUNDLED_LIBRARIES) 17 | 18 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 19 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 20 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 21 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 23 | endforeach(plugin) 24 | 25 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 26 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 27 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 28 | endforeach(ffi_plugin) 29 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "run_loop.cpp" 8 | "utils.cpp" 9 | "win32_window.cpp" 10 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 11 | "Runner.rc" 12 | "runner.exe.manifest" 13 | ) 14 | apply_standard_settings(${BINARY_NAME}) 15 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 16 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 17 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 18 | add_dependencies(${BINARY_NAME} flutter_assemble) 19 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "Flutter for Mobile Tool." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "flutter_mobile_command_tools" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "flutter_mobile_command_tools.exe" "\0" 98 | VALUE "ProductName", "flutter_mobile_command_tools" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(RunLoop* run_loop, 8 | const flutter::DartProject& project) 9 | : run_loop_(run_loop), project_(project) {} 10 | 11 | FlutterWindow::~FlutterWindow() {} 12 | 13 | bool FlutterWindow::OnCreate() { 14 | if (!Win32Window::OnCreate()) { 15 | return false; 16 | } 17 | 18 | RECT frame = GetClientArea(); 19 | 20 | // The size here must match the window dimensions to avoid unnecessary surface 21 | // creation / destruction in the startup path. 22 | flutter_controller_ = std::make_unique( 23 | frame.right - frame.left, frame.bottom - frame.top, project_); 24 | // Ensure that basic setup of the controller was successful. 25 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 26 | return false; 27 | } 28 | RegisterPlugins(flutter_controller_->engine()); 29 | run_loop_->RegisterFlutterInstance(flutter_controller_->engine()); 30 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 31 | return true; 32 | } 33 | 34 | void FlutterWindow::OnDestroy() { 35 | if (flutter_controller_) { 36 | run_loop_->UnregisterFlutterInstance(flutter_controller_->engine()); 37 | flutter_controller_ = nullptr; 38 | } 39 | 40 | Win32Window::OnDestroy(); 41 | } 42 | 43 | LRESULT 44 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 45 | WPARAM const wparam, 46 | LPARAM const lparam) noexcept { 47 | // Give Flutter, including plugins, an opportunity to handle window messages. 48 | if (flutter_controller_) { 49 | std::optional result = 50 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 51 | lparam); 52 | if (result) { 53 | return *result; 54 | } 55 | } 56 | 57 | switch (message) { 58 | case WM_FONTCHANGE: 59 | flutter_controller_->engine()->ReloadSystemFonts(); 60 | break; 61 | } 62 | 63 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "run_loop.h" 10 | #include "win32_window.h" 11 | 12 | // A window that does nothing but host a Flutter view. 13 | class FlutterWindow : public Win32Window { 14 | public: 15 | // Creates a new FlutterWindow driven by the |run_loop|, hosting a 16 | // Flutter view running |project|. 17 | explicit FlutterWindow(RunLoop* run_loop, 18 | const flutter::DartProject& project); 19 | virtual ~FlutterWindow(); 20 | 21 | protected: 22 | // Win32Window: 23 | bool OnCreate() override; 24 | void OnDestroy() override; 25 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 26 | LPARAM const lparam) noexcept override; 27 | 28 | private: 29 | // The run loop driving events for this window. 30 | RunLoop* run_loop_; 31 | 32 | // The project to run. 33 | flutter::DartProject project_; 34 | 35 | // The Flutter instance hosted by this window. 36 | std::unique_ptr flutter_controller_; 37 | }; 38 | 39 | #endif // RUNNER_FLUTTER_WINDOW_H_ 40 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "run_loop.h" 7 | #include "utils.h" 8 | 9 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 10 | _In_ wchar_t *command_line, _In_ int show_command) { 11 | // Attach to console when present (e.g., 'flutter run') or create a 12 | // new console when running with a debugger. 13 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 14 | CreateAndAttachConsole(); 15 | }else { 16 | STARTUPINFO si = { 0 }; 17 | si.cb = sizeof(si); 18 | si.dwFlags = STARTF_USESHOWWINDOW; 19 | si.wShowWindow = SW_HIDE; 20 | 21 | PROCESS_INFORMATION pi = { 0 }; 22 | WCHAR lpszCmd[MAX_PATH] = L"cmd.exe"; 23 | if (::CreateProcess(NULL, lpszCmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) { 24 | do { 25 | if (::AttachConsole(pi.dwProcessId)) { 26 | ::TerminateProcess(pi.hProcess, 0); 27 | break; 28 | } 29 | } while (ERROR_INVALID_HANDLE == GetLastError()); 30 | ::CloseHandle(pi.hProcess); 31 | ::CloseHandle(pi.hThread); 32 | } 33 | } 34 | 35 | // Initialize COM, so that it is available for use in the library and/or 36 | // plugins. 37 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 38 | 39 | RunLoop run_loop; 40 | 41 | flutter::DartProject project(L"data"); 42 | 43 | std::vector command_line_arguments = 44 | GetCommandLineArguments(); 45 | 46 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 47 | 48 | //set current frame center 49 | int scrWidth, scrHeight, xShaft, yShaft,mWidth,mHeight; 50 | 51 | scrWidth = GetSystemMetrics(SM_CXSCREEN); 52 | scrHeight = GetSystemMetrics(SM_CYSCREEN); 53 | 54 | //set current frame size 2/3 screen 55 | mWidth = scrWidth / 3 * 2; 56 | mHeight = scrHeight / 3 * 2; 57 | 58 | //center x y 59 | xShaft = (scrWidth - mWidth) / 2; 60 | yShaft = (scrHeight - mHeight) / 2; 61 | 62 | FlutterWindow window(&run_loop, project); 63 | Win32Window::Point origin(xShaft, yShaft); 64 | Win32Window::Size size(mWidth, mHeight); 65 | if (!window.CreateAndShow(L"", origin, size)) { 66 | return EXIT_FAILURE; 67 | } 68 | 69 | window.SetQuitOnClose(true); 70 | 71 | run_loop.Run(); 72 | 73 | ::CoUninitialize(); 74 | return EXIT_SUCCESS; 75 | } 76 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LuckyLi706/flutter_mobile_command_tools/8734eb49ba85f04522f4cee7a1a38288404ffdae/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/run_loop.cpp: -------------------------------------------------------------------------------- 1 | #include "run_loop.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | RunLoop::RunLoop() {} 8 | 9 | RunLoop::~RunLoop() {} 10 | 11 | void RunLoop::Run() { 12 | bool keep_running = true; 13 | TimePoint next_flutter_event_time = TimePoint::clock::now(); 14 | while (keep_running) { 15 | std::chrono::nanoseconds wait_duration = 16 | std::max(std::chrono::nanoseconds(0), 17 | next_flutter_event_time - TimePoint::clock::now()); 18 | ::MsgWaitForMultipleObjects( 19 | 0, nullptr, FALSE, static_cast(wait_duration.count() / 1000), 20 | QS_ALLINPUT); 21 | bool processed_events = false; 22 | MSG message; 23 | // All pending Windows messages must be processed; MsgWaitForMultipleObjects 24 | // won't return again for items left in the queue after PeekMessage. 25 | while (::PeekMessage(&message, nullptr, 0, 0, PM_REMOVE)) { 26 | processed_events = true; 27 | if (message.message == WM_QUIT) { 28 | keep_running = false; 29 | break; 30 | } 31 | ::TranslateMessage(&message); 32 | ::DispatchMessage(&message); 33 | // Allow Flutter to process messages each time a Windows message is 34 | // processed, to prevent starvation. 35 | next_flutter_event_time = 36 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 37 | } 38 | // If the PeekMessage loop didn't run, process Flutter messages. 39 | if (!processed_events) { 40 | next_flutter_event_time = 41 | std::min(next_flutter_event_time, ProcessFlutterMessages()); 42 | } 43 | } 44 | } 45 | 46 | void RunLoop::RegisterFlutterInstance( 47 | flutter::FlutterEngine* flutter_instance) { 48 | flutter_instances_.insert(flutter_instance); 49 | } 50 | 51 | void RunLoop::UnregisterFlutterInstance( 52 | flutter::FlutterEngine* flutter_instance) { 53 | flutter_instances_.erase(flutter_instance); 54 | } 55 | 56 | RunLoop::TimePoint RunLoop::ProcessFlutterMessages() { 57 | TimePoint next_event_time = TimePoint::max(); 58 | for (auto instance : flutter_instances_) { 59 | std::chrono::nanoseconds wait_duration = instance->ProcessMessages(); 60 | if (wait_duration != std::chrono::nanoseconds::max()) { 61 | next_event_time = 62 | std::min(next_event_time, TimePoint::clock::now() + wait_duration); 63 | } 64 | } 65 | return next_event_time; 66 | } 67 | -------------------------------------------------------------------------------- /windows/runner/run_loop.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_RUN_LOOP_H_ 2 | #define RUNNER_RUN_LOOP_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | // A runloop that will service events for Flutter instances as well 10 | // as native messages. 11 | class RunLoop { 12 | public: 13 | RunLoop(); 14 | ~RunLoop(); 15 | 16 | // Prevent copying 17 | RunLoop(RunLoop const&) = delete; 18 | RunLoop& operator=(RunLoop const&) = delete; 19 | 20 | // Runs the run loop until the application quits. 21 | void Run(); 22 | 23 | // Registers the given Flutter instance for event servicing. 24 | void RegisterFlutterInstance( 25 | flutter::FlutterEngine* flutter_instance); 26 | 27 | // Unregisters the given Flutter instance from event servicing. 28 | void UnregisterFlutterInstance( 29 | flutter::FlutterEngine* flutter_instance); 30 | 31 | private: 32 | using TimePoint = std::chrono::steady_clock::time_point; 33 | 34 | // Processes all currently pending messages for registered Flutter instances. 35 | TimePoint ProcessFlutterMessages(); 36 | 37 | std::set flutter_instances_; 38 | }; 39 | 40 | #endif // RUNNER_RUN_LOOP_H_ 41 | -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates and shows a win32 window with |title| and position and size using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------