コード例 #1
0
 internal void UninstallApp(string packageName)
 {
     DownloadInstallApk.SerialWorkQueueInstaller(this.ParentWindow.mVmName).Enqueue((SerialWorkQueue.Work)(() =>
     {
         Logger.Info("Uninstall started : " + packageName);
         Dictionary <string, string> data = new Dictionary <string, string>()
         {
             ["package"] = packageName
         };
         try
         {
             JArray jarray = JArray.Parse(HTTPUtils.SendRequestToAgent("uninstall", data, this.ParentWindow.mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp", true));
             try
             {
                 if (!JObject.Parse(jarray[0].ToString())["success"].ToObject <bool>())
                 {
                     ClientStats.SendClientStatsAsync("uninstall", "fail", "app_install", packageName, "", "");
                 }
                 else
                 {
                     this.UpdateCdnAppEntry(false, packageName, "");
                 }
             }
             catch
             {
             }
         }
         catch (Exception ex)
         {
             Logger.Error("Failed to uninstall app. Err: " + ex.Message);
         }
         Logger.Info("Uninstall completed for " + packageName);
     }));
 }
コード例 #2
0
        internal int InstallFLEApk(string packageName, string apkPath)
        {
            Logger.Info("Installing apk: {0}", (object)apkPath);
            int num = BluestacksProcessHelper.RunApkInstaller(apkPath, true, this.ParentWindow.mVmName);

            Logger.Info("Apk installer exit code: {0}", (object)num);
            if (num == 0)
            {
                if (DownloadInstallApk.sDownloadedApkList.Contains(packageName))
                {
                    ClientStats.SendClientStatsAsync("install_from_download", "success", "app_install", packageName, "", "");
                    DownloadInstallApk.sDownloadedApkList.Remove(packageName);
                    this.UpdateCdnAppEntry(true, packageName, "");
                }
                else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName))
                {
                    ClientStats.SendClientStatsAsync("install", "success", "app_install", packageName, "", "");
                    DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName);
                }
                this.ParentWindow.Utils.RunAppOrCreateTabButton(packageName);
                Logger.Info("Installation successful.");
                File.Delete(apkPath);
            }
            else
            {
                if (DownloadInstallApk.sDownloadedApkList.Contains(packageName))
                {
                    ClientStats.SendClientStatsAsync("install_from_download", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), "");
                    DownloadInstallApk.sDownloadedApkList.Remove(packageName);
                }
                else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName))
                {
                    ClientStats.SendClientStatsAsync("install", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), "");
                    DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName);
                }
                ClientStats.SendGeneralStats("apk_inst_error", new Dictionary <string, string>()
                {
                    {
                        "errcode",
                        Convert.ToString(num, (IFormatProvider)CultureInfo.InvariantCulture)
                    },
                    {
                        "precode",
                        "0"
                    },
                    {
                        "app_pkg",
                        packageName
                    }
                });
            }
            Logger.Info("Install Completed : " + packageName);
            return(num);
        }
コード例 #3
0
        public void DownloadApk(
            string apkUrl,
            string packageName,
            bool isLaunchAfterInstall,
            bool isDeleteApk,
            string timestamp = "")
        {
            string str = Path.Combine(RegistryStrings.DataDir, "DownloadedApk");

            if (!Directory.Exists(str))
            {
                Directory.CreateDirectory(str);
            }
            string path2       = Regex.Replace(packageName + ".apk", "[\\x22\\\\\\/:*?|<>]", " ");
            string apkFilePath = Path.Combine(str, path2);

            Logger.Info("Downloading Apk file to: " + apkFilePath);
            this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadStarted(packageName);
            ClientStats.SendClientStatsAsync("download", "unknown", "app_install", packageName, "", "");
            this.mDownloadThread = new Thread((ThreadStart)(() =>
            {
                string apkUrl1 = apkUrl;
                if (DownloadInstallApk.IsContainsGoogleAdId(apkUrl1))
                {
                    apkUrl = this.AddGoogleAdidWithApk(apkUrl1);
                }
                apkUrl = BlueStacksUIUtils.GetFinalRedirectedUrl(apkUrl);
                if (string.IsNullOrEmpty(apkUrl))
                {
                    return;
                }
                this.mIsDownloading = true;
                this.mDownloader = new LegacyDownloader(3, apkUrl, apkFilePath);
                this.mDownloader.Download((LegacyDownloader.UpdateProgressCallback)(percent => this.ParentWindow.mWelcomeTab.mHomeAppManager.UpdateAppDownloadProgress(packageName, percent)), (LegacyDownloader.DownloadCompletedCallback)(filePath =>
                {
                    ClientStats.SendClientStatsAsync("download", "success", "app_install", packageName, "", "");
                    this.mIsDownloading = false;
                    this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadCompleted(packageName, filePath);
                    this.InstallApk(packageName, filePath, isLaunchAfterInstall, isDeleteApk, timestamp);
                    DownloadInstallApk.sDownloadedApkList.Add(packageName);
                }), (LegacyDownloader.ExceptionCallback)(ex =>
                {
                    ClientStats.SendClientStatsAsync("download", "fail", "app_install", packageName, "", "");
                    this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadFailed(packageName);
                    Logger.Error("Failed to download file: {0}. err: {1}", (object)apkFilePath, (object)ex.Message);
                }), (LegacyDownloader.ContentTypeCallback)null, (LegacyDownloader.SizeDownloadedCallback)null, (LegacyDownloader.PayloadInfoCallback)null);
            }))
            {
                IsBackground = true
            };
            this.mDownloadThread.Start();
        }
コード例 #4
0
 internal void AbortApkDownload(string packageName)
 {
     ClientStats.SendClientStatsAsync("download", "cancel", "app_install", packageName, "", "");
     if (this.mDownloader != null)
     {
         this.mDownloader.AbortDownload();
     }
     if (this.mDownloadThread == null)
     {
         return;
     }
     this.mDownloadThread.Abort();
 }
コード例 #5
0
 private static void SendStats(string packageName)
 {
     if (packageName == "com.android.vending")
     {
         ClientStats.SendGPlayClickStats(new Dictionary <string, string>()
         {
             {
                 "source",
                 "bs3_myapps"
             }
         });
     }
     ClientStats.SendClientStatsAsync("init", "success", "app_activity", packageName, "", "");
 }
コード例 #6
0
 internal void InstallApk(
     string packageName,
     string apkPath,
     bool isLaunchAfterInstall,
     bool isDeleteApk,
     string timestamp = "")
 {
     this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallStart(packageName, apkPath);
     DownloadInstallApk.SerialWorkQueueInstaller(this.ParentWindow.mVmName).Enqueue((SerialWorkQueue.Work)(() =>
     {
         Logger.Info("Installing apk: {0}", (object)apkPath);
         int num = BluestacksProcessHelper.RunApkInstaller(apkPath, true, this.ParentWindow.mVmName);
         Logger.Info("Apk installer exit code: {0}", (object)num);
         if (num == 0)
         {
             if (DownloadInstallApk.sDownloadedApkList.Contains(packageName))
             {
                 ClientStats.SendClientStatsAsync("install_from_download", "success", "app_install", packageName, "", "");
                 DownloadInstallApk.sDownloadedApkList.Remove(packageName);
                 this.UpdateCdnAppEntry(true, packageName, timestamp);
             }
             else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName))
             {
                 ClientStats.SendClientStatsAsync("install", "success", "app_install", packageName, "", "");
                 DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName);
             }
             this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallCompleted(packageName);
             if (isLaunchAfterInstall)
             {
                 this.ParentWindow.Utils.RunAppOrCreateTabButton(packageName);
             }
             Logger.Info("Installation successful.");
             if (isDeleteApk)
             {
                 File.Delete(apkPath);
             }
             Logger.Info("Install Completed : " + packageName);
         }
         else
         {
             if (DownloadInstallApk.sDownloadedApkList.Contains(packageName))
             {
                 ClientStats.SendClientStatsAsync("install_from_download", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), "");
                 DownloadInstallApk.sDownloadedApkList.Remove(packageName);
             }
             else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName))
             {
                 ClientStats.SendClientStatsAsync("install", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), "");
                 DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName);
             }
             ClientStats.SendGeneralStats("apk_inst_error", new Dictionary <string, string>()
             {
                 {
                     "errcode",
                     Convert.ToString(num, (IFormatProvider)CultureInfo.InvariantCulture)
                 },
                 {
                     "precode",
                     "0"
                 },
                 {
                     "app_pkg",
                     packageName
                 }
             });
             this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallFailed(packageName);
         }
     }));
 }