2011年1月13日 星期四

使用adb批次反安裝APK

private void button_uninstallApk_Click(object sender, EventArgs e)
{
 if (listView_main.Items.Count == 0)
 {
  MessageBox.Show("所有連接裝置不能為空", "資訊", MessageBoxButtons.OK, MessageBoxIcon.Information);
  return;
 }
 Thread uninstallApkThread = new Thread(delegate() { UninstallAllApk(); });
 uninstallApkThread.Start();
}

private void UninstallAllApk()
{
 int testCount = listView_main.Items.Count;
 List<string> content = new List<string>();
 string phoneID = string.Empty;
 string serialNumber = string.Empty;
 string reportName = string.Empty;
 string reportFullName = string.Empty;
 
 for (int i = 0; i < testCount; i++)
 {
  phoneID = GetPhoneID(i);
  serialNumber = GetSerialNum(i);
  Execute("-s " + serialNumber + " uninstall com.asus.vd.alt.testapp");
 }
 SetControlEnable(button_uninstallApk, true);
 MessageBox.Show("所有手機程式已經關閉", "資訊", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

沒有留言: