Skip to content

Commit

Permalink
commit code
Browse files Browse the repository at this point in the history
  • Loading branch information
mengyanshou committed Feb 20, 2023
1 parent 1216808 commit a27f19b
Show file tree
Hide file tree
Showing 31 changed files with 337 additions and 298 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
branches:
- main
# paths-ignore

repository_dispatch:
types:
- api
env:
# APP名称
APP_NAME: ADBKIT
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.3.9
- 修复 adb dex server在安卓12启动失败的问题
- 优化日志显示
- 修复无法加载 Android13 图标的bug
- Flutter框架引擎升级到3.7.1

## 1.3.8-1
- 修复设备激活Shizuku提示权限不足的问题

Expand Down
Binary file modified assets/app_server
Binary file not shown.
5 changes: 3 additions & 2 deletions lib/adb_tool.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library adb_tool;

import 'package:flutter_acrylic/flutter_acrylic.dart';
// import 'package:flutter_acrylic/flutter_acrylic.dart';

// 这个文件提供其他项目集成adb_tool的时候导包
export 'app/modules/history/history_page.dart';
Expand All @@ -18,6 +18,7 @@ export 'themes/theme.dart';


Future<double> getMacTitlebarWidth() async {
return await Window.getTitlebarHeight();
return 0;
// return await Window.getTitlebarHeight();
}

2 changes: 1 addition & 1 deletion lib/adbkit_entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class _ADBToolEntryPointState extends State<ADBToolEntryPoint> with WindowListen
Global.instance.initGlobal();
Global.instance.hasSafeArea = widget.hasSafeArea;
Global.instance.showQRCode = widget.showQRCode;
AppManager.globalInstance;
DevicesController controller = Get.find();
controller.init();
AppManager.globalInstance;
isInit = true;
}

Expand Down
48 changes: 24 additions & 24 deletions lib/app/controller/config_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:adb_tool/config/settings.dart';
import 'package:adb_tool/themes/theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
// import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:get/get.dart' hide ScreenType;
import 'package:global_repository/global_repository.dart';
import 'package:settings/settings.dart';
Expand Down Expand Up @@ -35,29 +35,29 @@ class ConfigController extends GetxController {
};

void syncBackgroundStyle() {
if (backgroundStyle == BackgroundStyle.normal) {
if (GetPlatform.isWindows || GetPlatform.isLinux) {
return;
}
Window.setEffect(
effect: WindowEffect.disabled,
color: theme.colorScheme.background,
dark: false,
);
}
if (backgroundStyle == BackgroundStyle.image) {
Window.setEffect(
effect: WindowEffect.disabled,
color: theme.colorScheme.background.withOpacity(0.2),
dark: false,
);
} else {
Window.setEffect(
effect: WindowEffect.acrylic,
color: theme.colorScheme.background.withOpacity(0.2),
dark: false,
);
}
// if (backgroundStyle == BackgroundStyle.normal) {
// if (GetPlatform.isWindows || GetPlatform.isLinux) {
// return;
// }
// Window.setEffect(
// effect: WindowEffect.disabled,
// color: theme.colorScheme.background,
// dark: false,
// );
// }
// if (backgroundStyle == BackgroundStyle.image) {
// Window.setEffect(
// effect: WindowEffect.disabled,
// color: theme.colorScheme.background.withOpacity(0.2),
// dark: false,
// );
// } else {
// Window.setEffect(
// effect: WindowEffect.acrylic,
// color: theme.colorScheme.background.withOpacity(0.2),
// dark: false,
// );
// }
}

void changeBackgroundStyle(BackgroundStyle style) {
Expand Down
4 changes: 3 additions & 1 deletion lib/app/controller/devices_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class DevicesController extends GetxController {
String out = await execCmd('$adb start-server');
Log.d('adb start-server out:$out');
// ignore: empty_catches
} catch (e) {}
} catch (e) {
Log.e(e);
}
Future.delayed(const Duration(milliseconds: 1000), () {
letADBStarted();
});
Expand Down
5 changes: 4 additions & 1 deletion lib/app/modules/developer_tool/dash_board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class _DashboardState extends State<Dashboard> with WindowListener {
ADBChannel adbChannel;
Terminal terminal = Terminal();

/// 获取卡片宽度,主要是做响应式适配的
double getCardWidth() {
ResponsiveWrapperData data = ResponsiveWrapper.of(context);
if (data.isPhone) {
Expand Down Expand Up @@ -363,7 +364,7 @@ class _DashboardState extends State<Dashboard> with WindowListener {
List<String> paths;
if (GetPlatform.isDesktop) {
paths = [];
final typeGroup = XTypeGroup(
const typeGroup = XTypeGroup(
label: 'apk',
extensions: ['apk'],
);
Expand All @@ -375,6 +376,7 @@ class _DashboardState extends State<Dashboard> with WindowListener {
paths.add(xFile.path);
}
} else {
// ignore: use_build_context_synchronously
paths = await FileSelector.pick(context);
}
if (paths.isEmpty) {
Expand Down Expand Up @@ -411,6 +413,7 @@ class _DashboardState extends State<Dashboard> with WindowListener {
);
}


void installApkWithPaths(List<String> paths) {
showDialog(
context: context,
Expand Down
17 changes: 13 additions & 4 deletions lib/app/modules/developer_tool/dialog/install_apk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ class InstallApkDialog extends StatefulWidget {
this.paths,
@required this.adbChannel,
}) : super(key: key);

/// 路径列表
final List<String> paths;

/// adb channel 实例
final ADBChannel adbChannel;

@override
Expand Down Expand Up @@ -45,18 +49,23 @@ class _InstallApkDialogState extends State<InstallApkDialog> {
setState(() {});
}
});
StringBuffer stringBuffer = StringBuffer();
for (final String path in widget.paths) {
final String name = p.basename(path);
currentFile = name;
setState(() {});
try {
await widget.adbChannel.install(path);
} catch (e) {
showToast('$name 安装失败,输出:$e');
stringBuffer.write('$name: ${e.message}\n');
}
fileIndex++;
// showToast('$name 已上传');
}
if (stringBuffer.isNotEmpty) {
showToast('安装Apk错误输出\n:${stringBuffer.toString().trim()}', duration: const Duration(milliseconds: 5000));
}
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
}

Expand Down Expand Up @@ -86,7 +95,7 @@ class _InstallApkDialogState extends State<InstallApkDialog> {
RichText(
text: TextSpan(
children: [
TextSpan(
TextSpan(
text: '(',
style: TextStyle(
color: AppColors.fontColor,
Expand All @@ -95,14 +104,14 @@ class _InstallApkDialogState extends State<InstallApkDialog> {
),
TextSpan(
text: '$fileIndex',
style: TextStyle(
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: bold,
),
),
TextSpan(
text: '/$fileNum)',
style: TextStyle(
style: TextStyle(
color: AppColors.fontColor,
fontWeight: bold,
),
Expand Down
8 changes: 4 additions & 4 deletions lib/app/modules/developer_tool/implement/binadb_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ class BinADBChannel extends ADBChannel {

@override
Future<void> install(String file) async {
await execCmmand('adb -s $serial install -t $file');
await execCmmand('$adb -s $serial install -t $file');
}

@override
Future<void> push(String localPath, String remotePath) async {
final String fileName = basename(localPath);
await execCmmand('adb -s $serial push $localPath $remotePath$fileName');
await execCmmand('$adb -s $serial push $localPath $remotePath$fileName');
}

@override
Future<void> changeNetDebugStatus(int port) async {
if (port == 5555) {
await execCmmand(
'adb -s $serial tcpip 5555',
'$adb -s $serial tcpip 5555',
);
} else {
await execCmmand(
'adb -s $serial usb',
'$adb -s $serial usb',
);
}
}
Expand Down
6 changes: 2 additions & 4 deletions lib/app/modules/developer_tool/task_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:adb_tool/utils/http/http.dart';
import 'package:adb_tool/utils/task.dart';
import 'package:adbutil/adbutil.dart';
import 'package:app_manager/app_manager.dart';
import 'package:app_manager/core/interface/app_channel.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart' hide Response;
Expand Down Expand Up @@ -36,14 +35,13 @@ class _TaskManagerState extends State<TaskManager> {
initTask() async {
channel = await DexServer.startServer(widget.entity.serial);
screenSize = ScreenSize.fromWM(
await execCmd('adb -s ${widget.entity.serial} shell wm size'),
await execCmd('$adb -s ${widget.entity.serial} shell wm size'),
);
Timer.periodic(const Duration(seconds: 1), (timer) async {
if (!mounted) {
timer.cancel();
}
Response res =
await httpInstance.get('http://127.0.0.1:${channel.port}/');
Response res = await httpInstance.get('http://127.0.0.1:${channel.port}/');
List<dynamic> data = res.data;
Log.i(data);

Expand Down
10 changes: 4 additions & 6 deletions lib/app/modules/exec_cmd_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class _ExecCmdPageState extends State<ExecCmdPage> {
@override
Widget build(BuildContext context) {
AppBar appBar;
if (ResponsiveWrapper.of(context).isPhone ||
controller.screenType == ScreenType.phone) {
if (ResponsiveWrapper.of(context).isPhone || controller.screenType == ScreenType.phone) {
appBar = AppBar(
title: Text(S.of(context).terminal),
automaticallyImplyLeading: false,
Expand Down Expand Up @@ -74,15 +73,15 @@ class _ExecCmdPageState extends State<ExecCmdPage> {
ItemButton(
title: '开启服务',
onTap: () async {
const String cmd = 'adb start-server\r';
String cmd = '$adb start-server\r';
Global().pty.writeString(cmd);
AdbUtil.startPoolingListDevices();
},
),
ItemButton(
title: '停止服务',
onTap: () async {
const String cmd = 'adb kill-server\r';
String cmd = '$adb kill-server\r';
Global().pty.writeString(cmd);
AdbUtil.stopPoolingListDevices();
final DevicesController controller = Get.find();
Expand All @@ -92,8 +91,7 @@ class _ExecCmdPageState extends State<ExecCmdPage> {
ItemButton(
title: '重启服务',
onTap: () async {
const String cmd =
'adb kill-server && adb start-server\r';
String cmd = '$adb kill-server && adb start-server\r';
Global().pty.writeString(cmd);
},
),
Expand Down
6 changes: 3 additions & 3 deletions lib/app/modules/home/views/adaptive_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:adb_tool/utils/plugin_util.dart';
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
// import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'package:get/get.dart' hide ScreenType;
import 'package:global_repository/global_repository.dart';
import 'package:responsive_framework/responsive_framework.dart';
Expand Down Expand Up @@ -46,8 +46,8 @@ class _AdbToolState extends State<AdbTool> with WidgetsBindingObserver {
if (GetPlatform.isMacOS && RuntimeEnvir.packageName == Config.packageName) {
// 如果这个项目是独立运行的,那么RuntimeEnvir.packageName会在main函数中被设置成Config.packageName
Config.flutterPackage = 'packages/adb_tool/';
Window.makeTitlebarTransparent();
Window.enableFullSizeContentView();
// Window.makeTitlebarTransparent();
// Window.enableFullSizeContentView();
}
configController.syncBackgroundStyle();
WidgetsBinding.instance.addObserver(this);
Expand Down
3 changes: 1 addition & 2 deletions lib/app/modules/wrappers/app_launcher_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:adb_tool/utils/dex_server.dart';
import 'package:app_launcher/app_launcher.dart';
import 'package:app_manager/app_manager.dart';
import 'package:app_manager/controller/app_manager_controller.dart';
import 'package:app_manager/core/interface/app_channel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:get/get.dart';
Expand All @@ -18,7 +17,7 @@ class AppLauncherWrapper extends StatefulWidget {
final DevicesEntity devicesEntity;

@override
_AppLauncherWrapperState createState() => _AppLauncherWrapperState();
State createState() => _AppLauncherWrapperState();
}

class _AppLauncherWrapperState extends State<AppLauncherWrapper> {
Expand Down
6 changes: 2 additions & 4 deletions lib/app/modules/wrappers/app_manager_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:adb_tool/themes/app_colors.dart';
import 'package:adb_tool/utils/dex_server.dart';
import 'package:app_manager/app_manager.dart';
import 'package:app_manager/controller/app_manager_controller.dart';
import 'package:app_manager/core/interface/app_channel.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:get/get.dart';
Expand All @@ -17,7 +16,7 @@ class AppManagerWrapper extends StatefulWidget {
final DevicesEntity devicesEntity;

@override
_AppManagerWrapperState createState() => _AppManagerWrapperState();
State createState() => _AppManagerWrapperState();
}

class _AppManagerWrapperState extends State<AppManagerWrapper> {
Expand Down Expand Up @@ -50,8 +49,7 @@ class _AppManagerWrapperState extends State<AppManagerWrapper> {
}
return AppManagerEntryPoint(
// 直接进到设备的shell
process: YanProcess()
..exec('adb -s ${widget.devicesEntity.serial} shell'),
process: YanProcess()..exec('adb -s ${widget.devicesEntity.serial} shell'),
);
}
}
4 changes: 2 additions & 2 deletions lib/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Config {
static String packageName = 'com.nightmare.adbtools';
static Directory localDir = Directory('${RuntimeEnvir.configPath}/AdbTool');
static File historySaveFile = File('${localDir.path}/.history');
static int versionCode = 33;
static String versionName = '1.3.6';
static int versionCode = 37;
static String versionName = '1.3.9';
static String adbLocalPath = '/data/local/tmp';
static String sdcard = '/sdcard';

Expand Down
Loading

0 comments on commit a27f19b

Please sign in to comment.