private static void SendControllerEvent(string name, int identity, string type)
 {
     AndroidBootUp.SendControllerEventInternal(string.Format("controller_{0} {1} {2}", (object)name, (object)identity, (object)type), (UIHelper.Action)null);
 }
 private static void PerformDeferredSetup()
 {
     if (Opt.Instance.sysPrep)
     {
         return;
     }
     Logger.Info("Console PerformDeferredSetup");
     Stats.SendBootStats("frontend", true, false, MultiInstanceStrings.VmName);
     VMWindow.Instance.SendOrientationToGuest();
     if (RegistryManager.Instance.DefaultGuest.ConfigSynced == 0)
     {
         Logger.Info("Config not synced. Syncing now.");
         ThreadPool.QueueUserWorkItem((WaitCallback)(stateInfo =>
         {
             VmCmdHandler.SyncConfig(InputMapper.GetKeyMappingParserVersion(), MultiInstanceStrings.VmName);
             VmCmdHandler.SetKeyboard(LayoutManager.IsDesktop(), MultiInstanceStrings.VmName);
         }));
     }
     else
     {
         string currentKeyboardLayout = Utils.GetCurrentKeyboardLayout();
         VMWindow.Instance.SetKeyboardLayout(currentKeyboardLayout);
         Logger.Info("Config already synced.");
     }
     ThreadPool.QueueUserWorkItem((WaitCallback)(stateInfo =>
     {
         Logger.Info("Started fqdnSender thread for agent");
         VmCmdHandler.FqdnSend(0, "Agent", MultiInstanceStrings.VmName);
         Logger.Info("fqdnSender thread exiting");
     }));
     ThreadPool.QueueUserWorkItem((WaitCallback)(stateInfo =>
     {
         Logger.Info("Started fqdnSender thread for frontend");
         VmCmdHandler.FqdnSend(0, "frontend", MultiInstanceStrings.VmName);
         Logger.Info("fqdnSender thread exiting");
     }));
     UIHelper.RunOnUIThread((Control)VMWindow.Instance, (UIHelper.Action)(() =>
     {
         try
         {
             string text = System.Windows.Clipboard.GetText(System.Windows.TextDataFormat.Text);
             Logger.Debug("sending clipboard data to android.." + text);
             HTTPUtils.SendRequestToGuestAsync("clipboard", new Dictionary <string, string>()
             {
                 {
                     "text",
                     text
                 }
             }, MultiInstanceStrings.VmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
         }
         catch (Exception ex)
         {
             Logger.Error(" error in sending clipboard data to android.." + ex?.ToString());
         }
     }));
     ThreadPool.QueueUserWorkItem((WaitCallback)(stateInfo => VmCmdHandler.SetMachineType(LayoutManager.IsDesktop(), MultiInstanceStrings.VmName)));
     AndroidBootUp.GpsAttach();
     SensorDevice.Instance.Start(MultiInstanceStrings.VmName);
     AndroidBootUp.CameraAttach();
     AndroidBootUp.SendControllerEventInternal("controller_flush", (UIHelper.Action)(() =>
     {
         foreach (int key in VMWindow.Instance.mControllerMap.Keys)
         {
             SensorDevice.Instance.ControllerAttach(SensorDevice.Type.Accelerometer);
             AndroidBootUp.SendControllerEvent("attach", key, VMWindow.Instance.mControllerMap[key]);
         }
         VMWindow.Instance.mControllerMap.Clear();
     }));
     ThreadPool.QueueUserWorkItem((WaitCallback)(stateInfo =>
     {
         Logger.Info("Checking for Black Screen Error");
         AndroidBootUp.CheckBlackScreenAndRestartGMifOccurs();
     }));
 }