Ejemplo n.º 1
0
        private static void usbMuxMode(ref AMDeviceNotificationCallbackInfo callback_info, uint cookie)
        {
            IntPtr devHandle = callback_info.dev;

            if (devHandle == IntPtr.Zero)
            {
                return;
            }

            AMDevice dev = new AMDevice(devHandle);

            if (AMDeviceGetInterfaceType(devHandle) != DEVICE_INTERFACE_USB)
            {
                return;
            }

            if (callback_info.msg == DEVICE_CONNECTED)
            {
                dev.WriteLine("Device Connected");
                Program.OnDeviceAttached(dev);
            }
            if (callback_info.msg == DEVICE_DISCONNECTED)
            {
                dev.WriteLine("Device Disconnected");
            }
        }
Ejemplo n.º 2
0
    public static bool Run(AMDevice device)
    {
        if ( !device.Connect() )
        {
            device.WriteLine("Connect error");
            return false;
        }
        if ( !device.ValidatePairing() )
        {
            device.WriteLine("Pairing error");
            device.Disconnect();
            return false;
        }
        if ( !device.StartSession() )
        {
            device.WriteLine("Session error");
            device.Disconnect();
            return false;
        }

        Hashtable args = Program.inArgs;
        string ca = args["command"] as string;
        string pa = args["param"] as string;
        Task task = new Task(device);
        task.Execute(ca, pa);

        device.StopSession();
        device.Disconnect();

        device.WriteLine("Execute success");
        return true;
    }
Ejemplo n.º 3
0
        void Shutdown(AMDevice device)
        {
            bool success = device.Shutdown();

            if (success)
            {
                device.WriteLine("Shutdown success");
            }
            else
            {
                device.WriteLine("Shutdown fail");
            }
        }
Ejemplo n.º 4
0
        void UpdateTime(AMDevice device)
        {
            bool success = device.UpdateTime();

            if (success)
            {
                device.WriteLine("Sync success");
            }
            else
            {
                device.WriteLine("Sync fail");
            }
        }
Ejemplo n.º 5
0
 public static bool OnDeviceAttached(AMDevice device)
 {
     // 捕捉所有异常
     try
     {
         return Run(device);
     }
     catch ( Exception e )
     {
         device.WriteLine(e.Message);
         return false;
     }
 }
Ejemplo n.º 6
0
        void UninstallApp(AMDevice device, string appId)
        {
            Hashtable apps = device.LookupApps();

            if (!apps.ContainsKey(appId))
            {
                device.WriteLine("UninstallApp skip");
                return;
            }
            bool success = device.UninstallApp(appId);

            if (success)
            {
                device.WriteLine("UninstallApp success");
            }
            else
            {
                device.WriteLine("UninstallApp fail");
            }
        }
Ejemplo n.º 7
0
        void InstallApp(AMDevice device, string appPath)
        {
            FileInfo fd = new FileInfo(appPath);

            if (!fd.Exists)
            {
                device.WriteLine("InstallApp file");
                return;
            }
            bool success = device.InstallApp(appPath);

            if (success)
            {
                device.WriteLine("InstallApp success");
            }
            else
            {
                device.WriteLine("InstallApp fail");
            }
        }
Ejemplo n.º 8
0
        void UninstallProfile(AMDevice device, string profileId)
        {
            Hashtable profiles = device.LookupProfiles();

            if (!profiles.ContainsKey(profileId))
            {
                device.WriteLine("UninstallProfile skip");
                return;
            }
            bool success = device.UninstallProfile(profileId);

            if (success)
            {
                device.WriteLine("UninstallProfile success");
            }
            else
            {
                device.WriteLine("UninstallProfile fail");
            }
        }
Ejemplo n.º 9
0
        void InstallProfile(AMDevice device, string profilePath)
        {
            FileInfo fd = new FileInfo(profilePath);

            if (!fd.Exists)
            {
                device.WriteLine("InstallProfile file");
                return;
            }
            bool success = device.InstallProfile(profilePath);

            if (success)
            {
                device.WriteLine("InstallProfile success");
            }
            else
            {
                device.WriteLine("InstallProfile fail");
            }
        }
Ejemplo n.º 10
0
        void ListProfiles(AMDevice device)
        {
            Hashtable profiles = device.LookupProfiles();

            device.showProfiles(profiles);
        }
Ejemplo n.º 11
0
        void ListApps(AMDevice device)
        {
            Hashtable apps = device.LookupApps();

            device.showApps(apps);
        }
Ejemplo n.º 12
0
 void ListApps(AMDevice device)
 {
     Hashtable apps = device.LookupApps();
     device.showApps(apps);
 }
Ejemplo n.º 13
0
 void ListProfiles(AMDevice device)
 {
     Hashtable profiles = device.LookupProfiles();
     device.showProfiles(profiles);
 }
Ejemplo n.º 14
0
 public Task(AMDevice device)
 {
     this.device = device;
 }
Ejemplo n.º 15
0
 public static bool OnDeviceAttached(AMDevice device)
 {
     WaitCallback waitCallback = new WaitCallback(WorkItem);
     ThreadPool.QueueUserWorkItem(waitCallback, device);
     return true;
 }
Ejemplo n.º 16
0
 void Shutdown(AMDevice device)
 {
     bool success = device.Shutdown();
     if ( success )
     {
         device.WriteLine("Shutdown success");
     }
     else
     {
         device.WriteLine("Shutdown fail");
     }
 }
Ejemplo n.º 17
0
 void InstallProfile(AMDevice device, string profilePath)
 {
     FileInfo fd = new FileInfo(profilePath);
     if ( !fd.Exists )
     {
         device.WriteLine("InstallProfile file");
         return;
     }
     bool success = device.InstallProfile(profilePath);
     if ( success )
     {
         device.WriteLine("InstallProfile success");
     }
     else
     {
         device.WriteLine("InstallProfile fail");
     }
 }
Ejemplo n.º 18
0
 void UninstallApp(AMDevice device, string appId)
 {
     Hashtable apps = device.LookupApps();
     if ( !apps.ContainsKey(appId) )
     {
         device.WriteLine("UninstallApp skip");
         return;
     }
     bool success = device.UninstallApp(appId);
     if ( success )
     {
         device.WriteLine("UninstallApp success");
     }
     else
     {
         device.WriteLine("UninstallApp fail");
     }
 }
Ejemplo n.º 19
0
 void UpdateTime(AMDevice device)
 {
     bool success = device.UpdateTime();
     if ( success )
     {
         device.WriteLine("Sync success");
     }
     else
     {
         device.WriteLine("Sync fail");
     }
 }
Ejemplo n.º 20
0
 void UninstallProfile(AMDevice device, string profileId)
 {
     Hashtable profiles = device.LookupProfiles();
     if ( !profiles.ContainsKey(profileId) )
     {
         device.WriteLine("UninstallProfile skip");
         return;
     }
     bool success = device.UninstallProfile(profileId);
     if ( success )
     {
         device.WriteLine("UninstallProfile success");
     }
     else
     {
         device.WriteLine("UninstallProfile fail");
     }
 }
Ejemplo n.º 21
0
 public Task(AMDevice device)
 {
     this.device = device;
 }
Ejemplo n.º 22
0
        private static void usbMuxMode(ref AMDeviceNotificationCallbackInfo callback_info, uint cookie)
        {
            IntPtr devHandle = callback_info.dev;

            if ( devHandle == IntPtr.Zero )
            {
                return;
            }

            AMDevice dev = new AMDevice(devHandle);

            if ( AMDeviceGetInterfaceType(devHandle) != DEVICE_INTERFACE_USB )
            {
                return;
            }

            if ( callback_info.msg == DEVICE_CONNECTED )
            {
                dev.WriteLine("Device Connected");
                Program.OnDeviceAttached(dev);
            }
            if ( callback_info.msg == DEVICE_DISCONNECTED )
            {
                dev.WriteLine("Device Disconnected");
            }
        }
Ejemplo n.º 23
0
 void InstallApp(AMDevice device, string appPath)
 {
     FileInfo fd = new FileInfo(appPath);
     if ( !fd.Exists )
     {
         device.WriteLine("InstallApp file");
         return;
     }
     bool success = device.InstallApp(appPath);
     if ( success )
     {
         device.WriteLine("InstallApp success");
     }
     else
     {
         device.WriteLine("InstallApp fail");
     }
 }