主UI的adb功能固定位对sdk 5.8以上进行控制操作
This commit is contained in:
parent
75fc8065c2
commit
572a74f97a
@ -2,32 +2,22 @@ package com.qy.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.Permission;
|
||||
import java.util.*;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import com.qy.utils.*;
|
||||
@ -42,15 +32,16 @@ public class AppMain extends JFrame {
|
||||
private JButton zipToJar, jarToBase, reload, btnAdbPull;
|
||||
private JTextField log;
|
||||
public static JSONObject json;
|
||||
private Vector<String> vector;
|
||||
private Vector<String> vector, phonePackageList = new Vector<>();
|
||||
private Map<String, String> adbMap;
|
||||
public static boolean isOpenWindows = false;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JTextField txtCom;
|
||||
private JComboBox<String> txtCom;
|
||||
private JButton btnUserBase;
|
||||
private JTextField textPackName;
|
||||
private JComboBox<String> textPackName;
|
||||
private JButton btnRestartapp;
|
||||
private JLabel lblactivity;
|
||||
private JTextField textActivity;
|
||||
@ -74,6 +65,8 @@ public class AppMain extends JFrame {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
json = Tools.loadConfig(new File("config.cfg"));
|
||||
initPhonePackageList();
|
||||
initAdbData();
|
||||
initView();
|
||||
initData();
|
||||
log.setText("已载入配置文件");
|
||||
@ -85,6 +78,34 @@ public class AppMain extends JFrame {
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void initAdbData() {
|
||||
adbMap = new HashMap<>(9);
|
||||
adbMap.put("开屏", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"open\"");
|
||||
adbMap.put("插屏", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"inter\"");
|
||||
adbMap.put("banner", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"banner\"");
|
||||
adbMap.put("视频", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"video\"");
|
||||
adbMap.put("激励视频", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"reward\"");
|
||||
adbMap.put("SDK信息", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"systemTest\"");
|
||||
adbMap.put("重载网络", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"reloadApi\"");
|
||||
adbMap.put("获取广告参数", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"adBean\"");
|
||||
adbMap.put("查看日志", "adb shell am broadcast -a com.sdk.debug --es package \"[packname]\" --es type \"logcat\"");
|
||||
}
|
||||
|
||||
private void initPhonePackageList() {
|
||||
try {
|
||||
phonePackageList.clear();
|
||||
Process process = Runtime.getRuntime().exec("adb shell pm list packages");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String tmp;
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
phonePackageList.add(tmp.substring(8));
|
||||
}
|
||||
Collections.sort(phonePackageList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
JSONArray array = json.getJSONArray("array");
|
||||
vector = new Vector<>();
|
||||
@ -102,7 +123,7 @@ public class AppMain extends JFrame {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
setTitle("\u8F6C\u6362\u5668v2.9");
|
||||
setTitle("\u8F6C\u6362\u5668v2.10");
|
||||
// TODO Auto-generated constructor stub
|
||||
setSize(900, 456);
|
||||
getContentPane().setLayout(null);
|
||||
@ -180,7 +201,7 @@ public class AppMain extends JFrame {
|
||||
public void smaliPath(String path) {
|
||||
// TODO Auto-generated method stub
|
||||
File input = new File(json.getString("out")
|
||||
+ json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) -1) + ".jar");
|
||||
+ json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar");
|
||||
Tools.toAJar(json.getString("dx"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar"));
|
||||
File outFile = new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.getString("out")
|
||||
+ json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + "_encrypt.jar", Integer.parseInt(path)
|
||||
@ -221,12 +242,13 @@ public class AppMain extends JFrame {
|
||||
log.setBounds(51, 340, 766, 31);
|
||||
getContentPane().add(log);
|
||||
|
||||
txtCom = new JTextField();
|
||||
txtCom.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
txtCom.setText("adb push \"" + new File("").getAbsolutePath() + "/[jar]/data/data/[packname]/plugs/");
|
||||
Vector<String> adbList = new Vector<>(adbMap.keySet());
|
||||
txtCom = new JComboBox<String>(adbList);
|
||||
//txtCom.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
//txtCom.setText("adb push \"" + new File("").getAbsolutePath() + "/[jar]/data/data/[packname]/plugs/");
|
||||
txtCom.setBounds(444, 73, 293, 27);
|
||||
getContentPane().add(txtCom);
|
||||
txtCom.setColumns(10);
|
||||
//txtCom.setColumns(10);
|
||||
|
||||
JLabel lblAdb = new JLabel("adb\u6307\u4EE4");
|
||||
lblAdb.setBounds(444, 51, 72, 18);
|
||||
@ -236,9 +258,8 @@ public class AppMain extends JFrame {
|
||||
btnAdbPull.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
String cmd = txtCom.getText();
|
||||
cmd = cmd.replace("[packname]", textPackName.getText());
|
||||
cmd = cmd.replace("[jar]", configList.getSelectedValue().toString() + ".jar");
|
||||
String cmd = adbMap.get((String) txtCom.getSelectedItem());
|
||||
cmd = cmd.replace("[packname]", (String) Objects.requireNonNull(textPackName.getSelectedItem()));
|
||||
try {
|
||||
System.out.println(cmd);
|
||||
Runtime.getRuntime().exec("adb root");
|
||||
@ -283,7 +304,7 @@ public class AppMain extends JFrame {
|
||||
// TODO Auto-generated method stub
|
||||
Tools.toAJar(json.getString("dx"), file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), "dexTmp.jar"));
|
||||
File fileOut = new EncryptJar().encrypt(new File(file.getAbsolutePath().replace(file.getName(), "dexTmp.jar")), file.getAbsolutePath() + "_encrypt.jar", Integer.valueOf(path)
|
||||
, Integer.valueOf(version));
|
||||
, Integer.parseInt(version));
|
||||
System.out.println("data路径为:" + fileOut.getAbsolutePath());
|
||||
if (log != null)
|
||||
log.setText("data路径为:" + fileOut.getAbsolutePath());
|
||||
@ -334,21 +355,20 @@ public class AppMain extends JFrame {
|
||||
label.setBounds(444, 113, 72, 18);
|
||||
getContentPane().add(label);
|
||||
|
||||
textPackName = new JTextField();
|
||||
textPackName.setText("com.luckyboy.mmxing");
|
||||
textPackName = new JComboBox<String>(phonePackageList);
|
||||
textPackName.setBounds(444, 135, 293, 24);
|
||||
getContentPane().add(textPackName);
|
||||
textPackName.setColumns(10);
|
||||
|
||||
btnRestartapp = new JButton("\u91CD\u542FAPP");
|
||||
btnRestartapp.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
try {
|
||||
Runtime.getRuntime().exec("adb shell am force-stop " + textPackName.getText());
|
||||
Runtime.getRuntime().exec("adb shell am force-stop " + (String) textPackName.getSelectedItem());
|
||||
Runtime.getRuntime()
|
||||
.exec("adb shell am start " + textPackName.getText() + File.separator + textActivity.getText());
|
||||
.exec("adb shell am start " + (String) textPackName.getSelectedItem() + File.separator + textActivity.getText());
|
||||
log.setText("重启完毕");
|
||||
System.out.println("adb shell am start " + (String) textPackName.getSelectedItem() + File.separator + textActivity.getText());
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
@ -401,15 +421,12 @@ public class AppMain extends JFrame {
|
||||
getContentPane().add(uFilePath);
|
||||
uFilePath.setColumns(10);
|
||||
|
||||
JButton button = new JButton("\u83B7\u53D6");
|
||||
JButton button = new JButton("刷新包名");
|
||||
button.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
|
||||
chooser.showOpenDialog(null);
|
||||
File file = chooser.getSelectedFile();
|
||||
uFilePath.setText(file.getAbsolutePath());
|
||||
log.setText("获取自定义文件路径完成");
|
||||
initPhonePackageList();
|
||||
log.setText("获取手机包名完毕");
|
||||
|
||||
}
|
||||
});
|
||||
@ -500,7 +517,7 @@ public class AppMain extends JFrame {
|
||||
});
|
||||
menu.add(mntmsdk_1);
|
||||
|
||||
JMenuItem csj=new JMenuItem("穿山甲资源包");
|
||||
JMenuItem csj = new JMenuItem("穿山甲资源包");
|
||||
csj.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -509,26 +526,28 @@ public class AppMain extends JFrame {
|
||||
});
|
||||
menu.add(csj);
|
||||
|
||||
JMenuItem autoSDK=new JMenuItem("自动生成SDK");
|
||||
JMenuItem autoSDK = new JMenuItem("自动生成SDK");
|
||||
autoSDK.addActionListener(new ActionListener() {
|
||||
String version;
|
||||
String packageName;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new EditToDalog("提示", "请输入版本号", "", path -> {
|
||||
if(!Tools.stringIsNull(path)){
|
||||
version=path;
|
||||
if (!Tools.stringIsNull(path)) {
|
||||
version = path;
|
||||
new EditToDalog("提示", "请输入包名", "com.prujwk.jdyphn", path1 -> {
|
||||
if(!Tools.stringIsNull(path1)){
|
||||
packageName= path1;
|
||||
if (!Tools.stringIsNull(path1)) {
|
||||
packageName = path1;
|
||||
autoPackageSdk();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public void autoPackageSdk(){
|
||||
new AutoPackageSDK(path -> new TextToDalog("提示",String.format("打包完成%s",path)),version,packageName);
|
||||
|
||||
public void autoPackageSdk() {
|
||||
new AutoPackageSDK(path -> new TextToDalog("提示", String.format("打包完成%s", path)), version, packageName);
|
||||
}
|
||||
});
|
||||
menu.add(autoSDK);
|
||||
|
Loading…
Reference in New Issue
Block a user