测试工具--填充通话记录

152 阅读16分钟

 

简单介绍下:

       此工具专为填充通话记录使用,做手机测试的朋友最烦的是填充数据,要一个个填充,很麻烦,通话记录导入Vcard(.vcf)文件也是相当麻烦,使用工具只需连接终端,adb root下即可(本工具是根据当前公司的产品和需求制定,可根据源码修改)
终端安卓系统带的是双系统,普通的不需要此选项,我们自己使用的是公网手机,对讲机一般是专网/PDT,echat是产品的apk可忽略.
使用前终端需要root,可以cmd界面进行adb root,每个产品root指令不同,也可以使用工具辅助root。

package toolUI;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Random;
import java.util.Scanner;

import org.sqlite.JDBC;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;

import java.awt.Panel;
import java.awt.BorderLayout;
import java.awt.Dialog.ModalExclusionType;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import javax.swing.DropMode;
import javax.swing.JScrollPane;

public class DBtlloview {
	//全局变量
	public JFrame frame;
//	JPanel container;
//	private JTextArea textArea;
//	private JTextField textField_RF;
//	private JTextField textField_number;
//	private JTextField textField_name;
//	private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	private static JButton btn_Button_xuanzeDBfile=null;
	private JTextField jTextField;
//	private static JButton btn_Button_xieru;
//	private String mTotalContent;//文件内容
//	private File mDestFile;//目标文件
//	int ROM;//鼠标指定行数
//	String sum;//原来的行内容
	private JTextField textNumberField;
     /**
	 * Launch the application.启动应用程序
	 */
	public static void main(String[] args) throws Exception {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DBtlloview window = new DBtlloview();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
				
	 
	}


	/**
	 * Create the application.初始化
	 */
	public DBtlloview() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {

		frame = new JFrame("享有盛誉之名");
		frame.setTitle("dsy通话记录填充工具V0.0.1");
		frame.setBounds(100, 100, 508, 432);
		frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		

		//选择按钮
		JButton btn_Button_xuanzeDBfile = new JButton("选择文件");
		btn_Button_xuanzeDBfile.setBounds(14, 32, 95, 22);
		frame.getContentPane().add(btn_Button_xuanzeDBfile);
		//文件路径显示框
		jTextField = new JTextField();
		jTextField.setText("D:\\");
		jTextField.setBounds(113, 33, 285, 21);
		frame.getContentPane().add(jTextField);
		jTextField.setColumns(10);
		
		//文件选择路径实现
	 	btn_Button_xuanzeDBfile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				JFileChooser jChooser = new JFileChooser();
				jChooser.setDialogTitle("dengshengyu");
				int returnVal = jChooser.showOpenDialog(null);
				java.io.File file =jChooser.getSelectedFile();
				if (JFileChooser.APPROVE_OPTION == returnVal) {
					//需要传入的参数
					jTextField.setText(file.getAbsolutePath());
					String strPath = file.getAbsolutePath();
					System.out.println(strPath);
				 }
			}
    	});
	 	
	 	
	 	JLabel label = new JLabel("填充数量:");
	 	label.setBounds(34, 80, 75, 18);
	 	frame.getContentPane().add(label);
	 	//填充数量框
	 	textNumberField = new JTextField();
	 	textNumberField.setText("请输入正确数字");
		textNumberField.setColumns(10);
		textNumberField.setBounds(113, 78, 99, 21);
		frame.getContentPane().add(textNumberField);
		//只能输入数字
		textNumberField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				if(textNumberField.getText().equals(null)){
					
				}
			}
			
		});
		//填充按钮
		JButton btn_Button_tianchong = new JButton("填充");
		btn_Button_tianchong.setBounds(218, 78, 99, 22);
		frame.getContentPane().add(btn_Button_tianchong);
		//填充实现
		btn_Button_tianchong.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				int Allanmber = Integer.parseInt(textNumberField.getText());//执行次数
				System.out.println("执行次数:"+Allanmber);
				int anumber = 1;
				int res=JOptionPane.showConfirmDialog(null, "若无calllog.db文件请取消", "盛誉提醒", JOptionPane.YES_NO_OPTION);		
		if(res==JOptionPane.YES_NO_OPTION){		
	         for(int j=0;j<Allanmber;j++){//执行输入的次数
				/**
				 * JDBC数据库连接
				 * */
					//转入路径
					String strPath = jTextField.getText();//db目标路径
				try {
					Class.forName("org.sqlite.JDBC");	
				    Connection conn = DriverManager.getConnection("jdbc:sqlite:"+strPath+"\\calllog.db"); //PC上的
//					Connection conn = DriverManager.getConnection
//							("jdbc:sqlite:/data/data/com.android.providers.contacts/databases/calllog.db");				   
					/*生成随机号码*/
					Random random = new Random();
					String number="";
					for(int i=0;i<6;i++){
						number+=random.nextInt(10);
					}
					System.out.print(number);
					String phonenumber = number; //手机号码是字符类似
					System.out.print("phonenumber"+phonenumber);
					// calls是表名称
					//严格按照这样的格式编写,数据表的分为字符和数字,红色(为null)和绿色的都是数字类型,白色的都是字符类型
							//insert into calls values(11,'333333',1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)
							String YESpublicsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'1','1',0,0,0,0,0,'1','1','1',0,-1,1,0,0,0,'CN',0,0,'1','1',0,0,0,0,'1',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)";
							System.out.print("YESpublicsql:"+YESpublicsql);
					//insert into calls values(11,'333333',1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)
					//String sql = "insert into calls values("
					           + anumber + ",'" + phonenumber+"'"
					           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
					System.out.print("sql"+sql);
					anumber=anumber+1;
				    
					System.out.println("SQL语句:"+sql);
					Statement stmt = conn.createStatement();
					stmt.executeUpdate(sql);
				    conn.close();

				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}
				
				
			 }//for
		  }else{
			  JOptionPane.showMessageDialog(null, "此路径下无db文件无法操作");//消息框
		  }
				
		}
			
		});

		//删除全部
		JButton btn_Button_DeleteAll = new JButton("全部删除");
		btn_Button_DeleteAll.setBounds(329, 78, 99, 22);
		frame.getContentPane().add(btn_Button_DeleteAll);
		

		//删除实现 DELETE FROM calls WHERE _id = 15
		btn_Button_DeleteAll.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
//				int n = JOptionPane.showConfirmDialog(null, "你确定要删除全部通话记录?", "删除全部通话记录",
//						JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 
//				Object[] options ={ "确定", "取消" };  //自定义按钮上的文字
//				int m = JOptionPane.showOptionDialog(null, "再次确认是否要删除全部?", "清空全部通话记录",
//						JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); 
				int res=JOptionPane.showConfirmDialog(null, "暂不实现,删除后会导致终端报错", "删除全部通话记录", JOptionPane.YES_NO_OPTION);
                if(res==JOptionPane.YES_OPTION){
                	//点击“是”后执行这个代码块
//    				try {
//    				 System.out.println("删除全部通讯记录");	
//    				 Runtime.getRuntime().exec
//    					("adb shell su -rm -r /data/data/com.android.providers.contacts/databases/calllog.db");
    				 JOptionPane.showMessageDialog(null, "请恢复出厂设置");//消息框
//    				} catch (Exception e) {
//    					// TODO: handle exception
//    					
//    				}   
                }else{
                	//点击“否”后执行这个代码块
                    System.out.println("您已取消删除操作");    
                    return;
                }
				
			  
			}
			
			
		});
		
	
		/*辅助设计*/
		JLabel label_1 = new JLabel("进度显示:");
		label_1.setBounds(14, 194, 95, 18);
		frame.getContentPane().add(label_1);

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(14, 213, 462, 159);
		frame.getContentPane().add(scrollPane);

		JTextArea textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
		//辅助操作
		JLabel label_2 = new JLabel("辅助操作(对手机):");
		label_2.setBounds(14, 127, 162, 29);
		frame.getContentPane().add(label_2);
		//root
		JButton btn_Button_root = new JButton("root手机");
		btn_Button_root.setBounds(14, 159, 119, 22);
		frame.getContentPane().add(btn_Button_root);
		//root功能
		btn_Button_root.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				try {

//					if(dev == null){
//					 Runtime.getRuntime().exec("adb wait-for-device");
	   				 Runtime.getRuntime().exec("adb root xxx.cn");//xxx是该产品的root密码
	   				 Runtime.getRuntime().exec("adb remount");
	   				 JOptionPane.showMessageDialog(null, "root成功!");//消息框
//					 }
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				JOptionPane.showMessageDialog(null, "请检查端口");//消息框
	   				}   
			}
			
		});
		
		JButton btn_Button_input = new JButton("导入db文件");
		btn_Button_input.setBounds(292, 159, 119, 22);
		frame.getContentPane().add(btn_Button_input);
		//导入功能
		btn_Button_input.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
			int res=JOptionPane.showConfirmDialog(null, "请确认root和db文件路径选对了吗?", "必须root", JOptionPane.YES_NO_OPTION);
			if(res==JOptionPane.YES_NO_OPTION){//选择确定执行此操作
				try {
					//需要传入文件路径
					String strPath = jTextField.getText();				
					System.out.println(strPath);//这个就是路径	
	   				Runtime.getRuntime().exec("adb push "+strPath+"calllog.db"
	   						+" /data/data/com.android.providers.contacts/databases/");
	   				JOptionPane.showMessageDialog(null, "已复制到手机中,重启终端");//消息框
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				
	   				}   
			 }else{
				 JOptionPane.showMessageDialog(null, "不root无法执行此操作", "警告",JOptionPane.ERROR_MESSAGE);

			 }
		
			}
			
		});
		
		JButton btn_Button_out = new JButton("导出db文件");
		btn_Button_out.setBounds(147, 159, 131, 22);
		frame.getContentPane().add(btn_Button_out);
		//导出功能
		btn_Button_out.addActionListener(new ActionListener(){
		 public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
			int res=JOptionPane.showConfirmDialog(null, "请确定已经root和无中文路径", "必须root", JOptionPane.YES_NO_OPTION);
			if(res==JOptionPane.YES_NO_OPTION){//选择确定执行此操作
				
				try {
					//需要传入文件路径
					 String strPath = jTextField.getText();				
					 System.out.println(strPath);//这个就是路径	
	   				 Runtime.getRuntime().exec(
	   						 "adb pull /data/data/com.android.providers.contacts/databases/calllog.db "+strPath);
	   				 JOptionPane.showMessageDialog(null, "已复制至"+strPath+"根目录下");//消息框
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				 
	   				}  
				
			}else{
				//选择否弹出警告
				JOptionPane.showMessageDialog(null, "不root或中文路径无法执行此操作", "盛誉警告",JOptionPane.ERROR_MESSAGE);
			 }

		 }
			
		});
		

	 	
	}
}
package toolUI;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Random;
import java.util.Scanner;

import org.sqlite.JDBC;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;

import java.awt.Panel;
import java.awt.BorderLayout;
import java.awt.Dialog.ModalExclusionType;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import javax.swing.DropMode;
import javax.swing.JScrollPane;
import javax.swing.JMenuBar;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import java.sql.JDBCType;
import javax.swing.JRadioButton;

public class DBtlloview {
	//全局变量
	public JFrame frame;
//	JPanel container;
//	private JTextArea textArea;
//	private JTextField textField_RF;
//	private JTextField textField_number;
//	private JTextField textField_name;
//	private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	private static JButton btn_Button_xuanzeDBfile=null;
	private JTextField jTextField;
	private JRadioButton rdbtnDouble_YES;
	private JRadioButton rdbtnRadio_ON;
	private JRadioButton rdbtnType_public;
	private JRadioButton rdbtnType_gota;
	private JRadioButton rdbtnType_echat;
	private JRadioButton rdbtnType_PDT;
//	private static JButton btn_Button_xieru;
//	private String mTotalContent;//文件内容
//	private File mDestFile;//目标文件
//	int ROM;//鼠标指定行数
//	String sum;//原来的行内容
	private JTextField textNumberField;
     /**
	 * Launch the application.启动应用程序
	 */
	public static void main(String[] args) throws Exception {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DBtlloview window = new DBtlloview();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
				 
	}


	/**
	 * Create the application.初始化
	 */
	public DBtlloview() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {

		frame = new JFrame("享有盛誉之名");
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setTitle("dsy通话记录填充工具V0.0.1");
		frame.setBounds(100, 100, 566, 684);
		frame.getContentPane().setLayout(null);
		

		//选择按钮
		JButton btn_Button_xuanzeDBfile = new JButton("选择文件");
		btn_Button_xuanzeDBfile.setBounds(14, 120, 95, 22);
		frame.getContentPane().add(btn_Button_xuanzeDBfile);
		//文件路径显示框
		jTextField = new JTextField();
		jTextField.setText("D:\\");
		jTextField.setBounds(131, 120, 285, 21);
		frame.getContentPane().add(jTextField);
		jTextField.setColumns(10);
		
		//文件选择路径实现
	 	btn_Button_xuanzeDBfile.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				JFileChooser jChooser = new JFileChooser();
				jChooser.setDialogTitle("dengshengyu");
				int returnVal = jChooser.showOpenDialog(null);
				java.io.File file =jChooser.getSelectedFile();
				if (JFileChooser.APPROVE_OPTION == returnVal) {
					//需要传入的参数
					jTextField.setText(file.getAbsolutePath());
					String strPath = file.getAbsolutePath();
					System.out.println(strPath);
				 }
			}
    	});
	 	
	 	//询问
		JLabel label_3 = new JLabel("是否是双系统:");
		label_3.setBounds(14, 24, 119, 18);
		frame.getContentPane().add(label_3);
		
		rdbtnDouble_YES = new JRadioButton("是");
		rdbtnDouble_YES.setSelected(true);
		rdbtnDouble_YES.setBounds(131, 20, 58, 27);
		frame.getContentPane().add(rdbtnDouble_YES);
		
		rdbtnRadio_ON = new JRadioButton("否");
		rdbtnRadio_ON.setBounds(204, 20, 63, 27);
		frame.getContentPane().add(rdbtnRadio_ON);
		//二选一的方法
		final ButtonGroup group1=new ButtonGroup();
		group1.add(rdbtnDouble_YES);
		group1.add(rdbtnRadio_ON);


		
		JLabel label_4 = new JLabel("选择填充类型:");
		label_4.setBounds(14, 58, 119, 29);
		frame.getContentPane().add(label_4);
		
		rdbtnType_public = new JRadioButton("公网");
		rdbtnType_public.setSelected(true);
		rdbtnType_public.setBounds(131, 59, 75, 27);
		frame.getContentPane().add(rdbtnType_public);
		
		rdbtnType_gota = new JRadioButton("专网");
		rdbtnType_gota.setBounds(204, 59, 75, 27);
		frame.getContentPane().add(rdbtnType_gota);
		
		rdbtnType_echat = new JRadioButton("echat");
		rdbtnType_echat.setBounds(285, 59, 75, 27);
		frame.getContentPane().add(rdbtnType_echat);
		
		rdbtnType_PDT = new JRadioButton("PDT");
		rdbtnType_PDT.setBounds(375, 59, 75, 27);
		frame.getContentPane().add(rdbtnType_PDT);
		//4选1的方法
		final ButtonGroup group2=new ButtonGroup();
		group2.add(rdbtnType_public);
		group2.add(rdbtnType_gota);
		group2.add(rdbtnType_echat);
		group2.add(rdbtnType_PDT);
		
	 	
	 	JLabel label = new JLabel("填充数量:");
	 	label.setBounds(14, 171, 75, 18);
	 	frame.getContentPane().add(label);
	 	//填充数量框
	 	textNumberField = new JTextField();
	 	textNumberField.setText("请输入正确数字");
		textNumberField.setColumns(10);
		textNumberField.setBounds(91, 169, 99, 21);
		frame.getContentPane().add(textNumberField);
		//只能输入数字
		textNumberField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				if(textNumberField.getText().equals(null)){
					
				}
			}
			
		});
		//填充按钮
		JButton btn_Button_tianchong = new JButton("填充");
		btn_Button_tianchong.setBounds(204, 169, 99, 22);
		frame.getContentPane().add(btn_Button_tianchong);
/*		if(rdbtnDouble_YES.isSelected()==true){
			System.out.println("选择是");
			if(rdbtnType_public.isSelected()){
				System.out.println("选择公网");//公网路径不变
			}
			if(rdbtnType_gota.isSelected()){
				System.out.println("选择专网");
			}
			if(rdbtnType_echat.isSelected()){
				System.out.println("选择echat"); 	
			}
			if(rdbtnType_PDT.isSelected()){
				System.out.println("选择PDT");
			}
		}else{
			System.out.println("选择否");
			if(rdbtnType_public.isSelected()){
				System.out.println("选择公网1");
			}
			if(rdbtnType_gota.isSelected()){
				System.out.println("选择专网1");
			}
			if(rdbtnType_echat.isSelected()){
				System.out.println("选择echat1");
			}
			if(rdbtnType_PDT.isSelected()){
				System.out.println("选择PDT1");
			}
		}*/
		//填充实现
				btn_Button_tianchong.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent arg0) {
						// TODO Auto-generated method stub
						int Allanmber = Integer.parseInt(textNumberField.getText());//执行次数
						System.out.println("执行次数:"+Allanmber);
						int anumber = 1;
						int res=JOptionPane.showConfirmDialog(null, "若无calllog.db文件请取消", "盛誉提醒", JOptionPane.YES_NO_OPTION);		
				if(res==JOptionPane.YES_NO_OPTION){		
			         for(int j=0;j<Allanmber;j++){//执行输入的次数
						/**
						 * JDBC数据库连接
						 * */
							//转入路径
							String strPath = jTextField.getText();//db目标路径
						try {
							Class.forName("org.sqlite.JDBC");	
						    Connection conn = DriverManager.getConnection("jdbc:sqlite:"+strPath+"\\calllog.db"); //PC上的
//							Connection conn = DriverManager.getConnection
//									("jdbc:sqlite:/data/data/com.android.providers.contacts/databases/calllog.db");				   
							/*生成随机号码*/
							Random random = new Random();
							String number="";
							for(int i=0;i<6;i++){
								number+=random.nextInt(10);
							}
							System.out.print(number);
							String phonenumber = number; //手机号码是字符类似
							System.out.print("phonenumber"+phonenumber);
							// calls是表名称
							//严格按照这样的格式编写,数据表的分为字符和数字,红色(为null)和绿色的都是数字类型,白色的都是字符类型
							//insert into calls values(11,'333333',1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)
							//8组
							String YESpublicsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("YESpublicsql:"+YESpublicsql);

							String YESgotasql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("YESgotasql:"+YESgotasql);
										
							String YESechatsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("YESechatsql:"+YESechatsql);	
							
							String YESPDTsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("YESPDTsql:"+YESPDTsql);
							
							String ONpublicsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("ONpublicsql:"+ONpublicsql);
							
							String ONgotasql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("ONgotasql:"+ONgotasql);
							
							String ONechatsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("ONechatsql:"+ONechatsql);
							
							String ONPDTsql = "insert into calls values("
							           + anumber + ",'" + phonenumber+"'"
							           + ",1,'','',1593485812233,0,null,2,0,'com.android.phone/com.android.services.telephony.TelephonyConnectionService','89860317147559839723','',0,-1,1,null,null,null,'CN',null,null,'','',null,null,0,null,'',1,1593486109999,null,null,null,null,null,null,0,null,0,0,0,0,0,0)";
							System.out.print("ONPDTsql:"+ONPDTsql);
							
							if(rdbtnDouble_YES.isSelected()==true){
								System.out.println("选择是");
								if(rdbtnType_public.isSelected()){
									System.out.println("选择公网");//公网路径不变
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+YESpublicsql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(YESpublicsql);
								    conn.close();
								}
								if(rdbtnType_gota.isSelected()){
									System.out.println("选择专网");
									JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有专网?,请联系邓盛誉修改");//消息框
								}
								if(rdbtnType_echat.isSelected()){
									System.out.println("选择echat");
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+YESpublicsql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(YESpublicsql);
								    conn.close();
								}
								if(rdbtnType_PDT.isSelected()){
									System.out.println("选择PDT");
									JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有PDT?,请联系邓盛誉修改");//消息框
								}
							}else{
								System.out.println("选择否");
								if(rdbtnType_public.isSelected()){
									System.out.println("选择公网1");
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+ ONpublicsql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(ONpublicsql);
								    conn.close();
								}
								if(rdbtnType_gota.isSelected()){
									System.out.println("选择专网1");
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+ ONgotasql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(YESpublicsql);
								    conn.close();
								}
								if(rdbtnType_echat.isSelected()){
									System.out.println("选择echat1");
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+ ONechatsql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(YESpublicsql);
								    conn.close();
								}
								if(rdbtnType_PDT.isSelected()){
									System.out.println("选择PDT1");
									
									anumber=anumber+1;    
									System.out.println("SQL语句:"+ ONPDTsql);
									Statement stmt = conn.createStatement();
									stmt.executeUpdate(ONPDTsql);
								    conn.close();
								}
							}							


						} catch (Exception e) {
							// TODO: handle exception
							e.printStackTrace();
						}
						
						
					 }//for
				  }else{
					  JOptionPane.showMessageDialog(null, "此路径下无db文件无法操作");//消息框
				  }
						
				}
					
	});
		

		//删除全部
		JButton btn_Button_DeleteAll = new JButton("全部删除");
		btn_Button_DeleteAll.setBounds(317, 169, 99, 22);
		frame.getContentPane().add(btn_Button_DeleteAll);
		

		//删除实现 DELETE FROM calls WHERE _id = 15
		btn_Button_DeleteAll.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
//				int n = JOptionPane.showConfirmDialog(null, "你确定要删除全部通话记录?", "删除全部通话记录",
//						JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); 
//				Object[] options ={ "确定", "取消" };  //自定义按钮上的文字
//				int m = JOptionPane.showOptionDialog(null, "再次确认是否要删除全部?", "清空全部通话记录",
//						JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); 
				int res=JOptionPane.showConfirmDialog(null, "暂不实现,删除后会导致终端报错", "删除全部通话记录", JOptionPane.YES_NO_OPTION);
                if(res==JOptionPane.YES_OPTION){
                	//点击“是”后执行这个代码块
//    				try {
//    				 System.out.println("删除全部通讯记录");	
//    				 Runtime.getRuntime().exec
//    					("adb shell su -rm -r /data/data/com.android.providers.contacts/databases/calllog.db");
    				 JOptionPane.showMessageDialog(null, "请恢复出厂设置");//消息框
//    				} catch (Exception e) {
//    					// TODO: handle exception
//    					
//    				}   
                }else{
                	//点击“否”后执行这个代码块
                    System.out.println("您已取消删除操作");    
                    return;
                }
				
			  
			}
			
			
		});
		
	
		/*辅助设计*/
		JLabel label_1 = new JLabel("进度显示:");
		label_1.setBounds(14, 382, 95, 18);
		frame.getContentPane().add(label_1);

		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(14, 413, 462, 159);
		frame.getContentPane().add(scrollPane);

		JTextArea textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
		//辅助操作
		JLabel label_2 = new JLabel("辅助操作(对手机):");
		label_2.setBounds(14, 269, 162, 29);
		frame.getContentPane().add(label_2);
		//root
		JButton btn_Button_root = new JButton("root手机");
		btn_Button_root.setBounds(14, 327, 119, 22);
		frame.getContentPane().add(btn_Button_root);
		//root功能
		btn_Button_root.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				try {

//					if(dev == null){
//					 Runtime.getRuntime().exec("adb wait-for-device");
	   				 Runtime.getRuntime().exec("adb root xxx.cn");//xxx是该产品的root密码
	   				 Runtime.getRuntime().exec("adb remount");
	   				 JOptionPane.showMessageDialog(null, "root成功!");//消息框
//					 }
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				JOptionPane.showMessageDialog(null, "请检查端口");//消息框
	   				}   
			}
			
		});
		
		JButton btn_Button_input = new JButton("导入db文件");
		btn_Button_input.setBounds(292, 327, 119, 22);
		frame.getContentPane().add(btn_Button_input);
		//导入功能
		btn_Button_input.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
			int res=JOptionPane.showConfirmDialog(null, "请确认db文件路径选对了吗?", "必须root", JOptionPane.YES_NO_OPTION);
			if(res==JOptionPane.YES_NO_OPTION){//选择确定执行此操作
				try {
					//先root
					Runtime.getRuntime().exec("adb root xxx.cn");//xxx是该产品的root密码
	   				Runtime.getRuntime().exec("adb remount");
	   			    //需要传入文件路径
					String strPath = jTextField.getText();				
					System.out.println(strPath);//这个就是路径	
					if(rdbtnDouble_YES.isSelected()==true){
						System.out.println("选择是");
						if(rdbtnType_public.isSelected()){
							System.out.println("选择公网");//公网路径不变
							Runtime.getRuntime().exec("adb push "+strPath+"calllog.db"
			   						+" /data/data/com.android.providers.contacts/databases/");
			   				JOptionPane.showMessageDialog(null, "导入成功,重启终端查看结果,如果重启后失败,请先检查路径,然后查看操作文档或联系邓盛誉,");//消息框
			   				Runtime.getRuntime().exec("adb reboot");
						}
						if(rdbtnType_gota.isSelected()){
							System.out.println("选择专网");
							JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有专网?,请联系邓盛誉修改");//消息框
						}
						if(rdbtnType_echat.isSelected()){
							System.out.println("选择echat"); 
							Runtime.getRuntime().exec("adb push "+strPath+"zxts.gotasms.db"
			   						+" /data/user/10/com.mcptt/databases/");
			   				JOptionPane.showMessageDialog(null, "导入成功,重启终端查看结果,如果重启后失败,请先检查路径,然后查看操作文档或联系邓盛誉,");//消息框
			   				Runtime.getRuntime().exec("adb reboot");
						
						}
						if(rdbtnType_PDT.isSelected()){
							System.out.println("选择PDT");
							JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有PDT?,请联系邓盛誉修改");//消息框
						}
					}else{
						System.out.println("选择否");
						if(rdbtnType_public.isSelected()){
							System.out.println("选择公网1");
							Runtime.getRuntime().exec("adb push "+strPath+"calllog.db"
			   						+" /data/data/com.android.providers.contacts/databases/");
			   				JOptionPane.showMessageDialog(null, "导入成功,重启终端查看结果,如果重启后失败,请先检查路径,然后查看操作文档或联系邓盛誉,");//消息框
			   				Runtime.getRuntime().exec("adb reboot");
						}
						if(rdbtnType_gota.isSelected()){
							System.out.println("选择专网1");
							Runtime.getRuntime().exec("adb push "+strPath+"zxts.gotasms.db"
			   						+" /data/data/com.android.providers.contacts/databases/");
			   				JOptionPane.showMessageDialog(null, "导入成功,重启终端查看结果,如果重启后失败,请先检查路径,然后查看操作文档或联系邓盛誉,");//消息框
			   				Runtime.getRuntime().exec("adb reboot");
						}
						if(rdbtnType_echat.isSelected()){
							System.out.println("选择echat1");
							Runtime.getRuntime().exec("adb push "+strPath+"zxts.gotasms.db"
			   						+" /data/user/10/com.mcptt/databases/");
			   				JOptionPane.showMessageDialog(null, "导入成功,重启终端查看结果,如果重启后失败,请先检查路径,然后查看操作文档或联系邓盛誉,");//消息框
			   				Runtime.getRuntime().exec("adb reboot");
						}
						if(rdbtnType_PDT.isSelected()){
							System.out.println("选择PDT1");
							Runtime.getRuntime().exec(
			   						 "adb pull /data/data/com.xxx/databases/zxts.gotasms.db "+strPath);//xxx是该产品的包名
							JOptionPane.showMessageDialog(null, "是否已复制到"+strPath+"根目录下,如果没有,请确认手机有无此zxts.gotasms.db文件");//消息框
							
						}
					}
	   				
					
	   				
	   				
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				
	   				}   
			 }else{
				 JOptionPane.showMessageDialog(null, "不root无法执行此操作", "警告",JOptionPane.ERROR_MESSAGE);

			 }
		
			}
			
		});
		
		JButton btn_Button_out = new JButton("导出db文件");
		btn_Button_out.setBounds(145, 327, 131, 22);
		frame.getContentPane().add(btn_Button_out);
		
		//导出功能
		btn_Button_out.addActionListener(new ActionListener(){
		 public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
			int res=JOptionPane.showConfirmDialog(null, "请确定无中文路径", "必须root", JOptionPane.YES_NO_OPTION);
			if(res==JOptionPane.YES_NO_OPTION){//选择确定执行此操作
				
				try {
					//先root
					Runtime.getRuntime().exec("adb root xxx.cn");//xxx是该产品的root密码
	   				Runtime.getRuntime().exec("adb remount");
					//需要传入文件路径
					 String strPath = jTextField.getText();				
					 System.out.println(strPath);//这个就是路径	
					 if(rdbtnDouble_YES.isSelected()==true){
							System.out.println("选择是");
							if(rdbtnType_public.isSelected()){
								System.out.println("选择公网");//公网路径不变
								Runtime.getRuntime().exec(
				   						 "adb pull /data/data/com.android.providers.contacts/databases/calllog.db "+strPath);
								JOptionPane.showMessageDialog(null, "请确认是否已导入到"+strPath+"根目录下,如果没有,请确认手机有无calllog.db文件");//消息框
							}
							if(rdbtnType_gota.isSelected()){
								System.out.println("选择专网");
								JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有专网?,请联系邓盛誉修改");//消息框
							}
							if(rdbtnType_echat.isSelected()){
								System.out.println("选择echat"); 
								Runtime.getRuntime().exec(
				   						 "adb pull /data/user/10/com.mcptt/databases/zxts.gotasms.db "+strPath);
							JOptionPane.showMessageDialog(null, "请确认是否已导入到"+strPath+"根目录下,如果没有,请确认手机有无zxts.gotasms.db文件");//消息框
							}
							if(rdbtnType_PDT.isSelected()){
								System.out.println("选择PDT");
								JOptionPane.showMessageDialog(null, "请确认安卓P双系统是否有PDT?,请联系邓盛誉修改");//消息框
							}
						}else{
							System.out.println("选择否");
							if(rdbtnType_public.isSelected()){
								System.out.println("选择公网1");
								Runtime.getRuntime().exec(
				   						 "adb pull /data/data/com.android.providers.contacts/databases/calllog.db "+strPath);
								JOptionPane.showMessageDialog(null, "请确认是否已导入到"+strPath+"根目录下,如果没有,请确认手机有无calllog.db文件");//消息框
							}
							if(rdbtnType_gota.isSelected()){
								System.out.println("选择专网1");
								Runtime.getRuntime().exec(
				   						 "adb pull /data/data/com.xxx/databases/GoTaDb.db "+strPath);//xxx是该产品的包名
								JOptionPane.showMessageDialog(null, "是否已复制到"+strPath+"根目录下,如果没有,请确认手机有无此GoTaDb.db文件");//消息框
							}
							if(rdbtnType_echat.isSelected()){
								System.out.println("选择echat1");
								Runtime.getRuntime().exec(
				   						 "adb pull /data/data/com.mcptt/databases/zxts.gotasms.db "+strPath);
							JOptionPane.showMessageDialog(null, "请确认是否已导入到"+strPath+"根目录下,如果没有,请确认手机有无zxts.gotasms.db文件");//消息框
							}
							if(rdbtnType_PDT.isSelected()){
								System.out.println("选择PDT1");
								Runtime.getRuntime().exec(
				   						 "adb pull /data/data/com.xxx/databases/GoTaDb.db "+strPath);//xxx是该产品的包名
								JOptionPane.showMessageDialog(null, "是否已复制到"+strPath+"根目录下,如果没有,请确认手机有无此GoTaDb.db文件");//消息框
								
							}
						}
	   				 
	   				 
	   				} catch (Exception e) {
	   					// TODO: handle exception
	   				 
	   				}  
				
			}else{
				//选择否弹出警告
				JOptionPane.showMessageDialog(null, "不root或中文路径无法执行此操作", "盛誉警告",JOptionPane.ERROR_MESSAGE);
			 }

		 }
			
		});
		

	 	
	}
}