Commander adb小工具开发

目标:能处理一切adb能处理的问题

开源地址:https://github.com/seasonxie/CommandADB

1.UI开发:上中下Panel

mAdminPanel 上部三层按钮
JScrollPane 中间日志输出
bottomPanel 底部两个按钮

buttonForTop(apkOpertion, "当前耗流", Constants.FLOWTEST);
        buttonForTop(apkOpertion, "熄屏检查", Constants.SCREENTEST);

        buttonForTop(customOpertion, "自定义添加", Constants.ADDBUTTON);
        buttonForTop(customOpertion, "自定义删除", Constants.DELETEBUTTON);

        // 底层按钮
        buttonForBottom(bottomPanel, "清屏", Constants.CLEARTEXT);
        buttonForBottom(bottomPanel, "kill/restart adb", Constants.KILLADB);
        addCustomButtons(this);
        JScrollPane sp = new JScrollPane(txtIng);
        this.setLayout(new BorderLayout());
        this.add(mAdminPanel, BorderLayout.NORTH);
        this.add(bottomPanel, BorderLayout.SOUTH);
        this.add(sp, BorderLayout.CENTER);
        setSize(600, 800);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        this.resize(601, 801);

 2.部分操作处理(如清除数据,启动应用 等等)

    if (evt.getActionCommand().equals(Constants.CLEAR)) {  //清数据启动操作
                ShellHandle.exec("adb shell pm clear " + Main.app + "");
                Main.fill("adb shell am start -W " + Main.app + "/" + Main.activity + "");
                ShellHandle.exec("adb shell am start -W " + Main.app + "/" + Main.activity + "");
                Main.fill("重启浏览器完成");
                Main.newline();

            } else if (evt.getActionCommand().equals(Constants.INSTALL)) {  //安装apk操作
                JOptionPane.showMessageDialog(null, "直接把应用拖进来就可以了亲,给好评哦");

            } else if (evt.getActionCommand().equals(Constants.UNINSTALL)) {//删除应用操作
                // showP();
                String commands = "pm uninstall -k " + Main.app + "";
                ShellUtils.execCommand(commands, false);
                Main.fill("当前版本:  " + ShellHandle.getAppVersion());
                // dialog.setVisible(false);
                Main.newline();

            }

同时可自定义添加3个平台的命令

android:adb执行  

window: runtime.exec 执行 (例如:查看host,打开特定文件夹)

linux:连接ssh执行  (例如:查看日志,部署代码)

 

posted @ 2017-01-21 21:42  q55091  阅读(510)  评论(0编辑  收藏  举报