zoukankan      html  css  js  c++  java
  • 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执行  (例如:查看日志,部署代码)

  • 相关阅读:
    Android中开发习惯
    Activity、Window和View三者间的关系有一定的见解
    Android底层有一定的认识,研究过相关的Android源码
    安卓工程的启动过程
    OAuth2认证有一定的了解
    屏幕适配经验
    NOIP模拟赛14
    NOIP模拟赛13
    NOIP模拟赛12
    NOIP模拟赛11
  • 原文地址:https://www.cnblogs.com/season-xie/p/6337915.html
Copyright © 2011-2022 走看看