Advertisement
tankcr

getandroid

Jul 29th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using RegawMOD.Android;
  7. using PortableDeviceApiLib;
  8. using System.Management;
  9. using System.Text.RegularExpressions;
  10. using System.Diagnostics;
  11.  
  12.  
  13. namespace MusicLibUtility
  14. {
  15.     public class Devices
  16.     {
  17.        
  18.         AndroidController android;
  19.         Device device;
  20.  
  21.         public event EventHandler TableDataChanged;
  22.  
  23.         private List<Device> tableData;
  24.         public List<Device> TableData
  25.         {
  26.             get { return tableData; }
  27.             set
  28.             {
  29.                 tableData = value;
  30.                 if (TableDataChanged != null)
  31.                 {
  32.                     TableDataChanged(this, EventArgs.Empty);
  33.                 }
  34.             }
  35.         }
  36.         public Devices()
  37.         {
  38.                    
  39.         }
  40.     }
  41.     public class GetDevices
  42.     {
  43.         public static AndroidController GetDeviceData()
  44.         {
  45.             Dictionary<string, string> deviceinfo = new Dictionary<string, string>();
  46.             deviceinfo["props_prod"] = "shell getprop";
  47.            
  48.             AndroidController android;
  49.             RegawMOD.Android.Device device;
  50.             android = AndroidController.Instance;
  51.             if (android.HasConnectedDevices)
  52.             {
  53.                int num = android.ConnectedDevices.Count;
  54.                 for(int i = 0; i < android.ConnectedDevices.Count; i++)
  55.                 {
  56.                     string exp = @"\s+";
  57.                     string serial = android.ConnectedDevices[i];
  58.                     device = android.GetConnectedDevice(serial);
  59.                     string devserial = device.SerialNumber;
  60.                     DeviceState state = device.State;
  61.                     Devices table = new Devices();
  62.                     table.TableData = new List<Device>();
  63.                     Device item = new Device();
  64.                     model(device, item);
  65.                     brand(device, item);
  66.                     language(device, item);
  67.                     version(device, item);
  68.                     country(device, item);
  69.                     Card1(device, exp, item);
  70.                     Card2(device, exp);
  71.                     item.SerialNumber = serial;
  72.  
  73.                 }
  74.             }
  75.             return android;
  76.         }
  77.  
  78.         private static void Card2(RegawMOD.Android.Device device, string exp)
  79.         {
  80.             AdbCommand adbCmdcard = Adb.FormAdbCommand(device, "shell df /storage/*card*");
  81.             string card = Adb.ExecuteAdbCommand(adbCmdcard);
  82.             string[] Card2 = Regex.Split(card, exp);
  83.         }
  84.  
  85.         private static void Card1(RegawMOD.Android.Device device, string exp, Device item)
  86.         {
  87.             AdbCommand adbCmdCard = Adb.FormAdbCommand(device, "shell df /storage/*Card*");
  88.             string Card = Adb.ExecuteAdbCommand(adbCmdCard);
  89.             string[] Card1 = Regex.Split(Card, exp);
  90.             item.free = Card1[8];
  91.         }
  92.  
  93.         private static void country(RegawMOD.Android.Device device, Device item)
  94.         {
  95.             string getcountry = "shell getprop ro.product.locale.region";
  96.             AdbCommand adbCmdgetcountry = Adb.FormAdbCommand(device, getcountry);
  97.             string mycountry = Adb.ExecuteAdbCommand(adbCmdgetcountry);
  98.             item.country = mycountry;
  99.         }
  100.  
  101.         private static void version(RegawMOD.Android.Device device, Device item)
  102.         {
  103.             string getver = "shell getprop ro.product.version";
  104.             AdbCommand adbCmdgetver = Adb.FormAdbCommand(device, getver);
  105.             string myver = Adb.ExecuteAdbCommand(adbCmdgetver);
  106.             item.version = myver;
  107.         }
  108.  
  109.         private static void language(RegawMOD.Android.Device device, Device item)
  110.         {
  111.             string getlang = "shell getprop ro.product.locale.language";
  112.             AdbCommand adbCmdgetlang = Adb.FormAdbCommand(device, getlang);
  113.             string mylanguage = Adb.ExecuteAdbCommand(adbCmdgetlang);
  114.             item.language = mylanguage;
  115.         }
  116.  
  117.         private static void brand(RegawMOD.Android.Device device, Device item)
  118.         {
  119.             string getbrand = "shell getprop ro.product.brand";
  120.             AdbCommand adbCmdgetBrand = Adb.FormAdbCommand(device, getbrand);
  121.             string mybrand = Adb.ExecuteAdbCommand(adbCmdgetBrand);
  122.             item.Brand = mybrand;
  123.         }
  124.  
  125.         private static void model(RegawMOD.Android.Device device, Device item)
  126.         {
  127.             string getmodel = "shell getprop ro.product.model";
  128.             AdbCommand adbCmdgetModel = Adb.FormAdbCommand(device, getmodel);
  129.             string mymodel = Adb.ExecuteAdbCommand(adbCmdgetModel);
  130.             item.model = mymodel;
  131.         }
  132.     }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement