/// <summary>
        /// Validate to make sure device matches the API Level chosen.
        /// </summary>
        /// <returns></returns>
        public bool validateDeviceVersion(bool isSim)
        {
            bool retVal = false;
            string baseVersion = "10.2.0.0";
            DebugTokenData dtokenData;

            if (!isSim)
                dtokenData = new DebugTokenData();

            getDeviceSimInfo(isSim);

            if (getDeviceInfo())
            { //** Device Info retrieved - validate API's
                if (getCurrentAPIVersion() != _deviceosversion)
                { //** Currently selected API version is different from attached device OS version.
                    if (IsAPIInstalled(_deviceosversion, "", false) > 0)
                    {
                        retVal = true;
                    }
                    else
                    {
                        if (baseVersion.CompareTo(_deviceosversion) > 0)
                        {
                            UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", _deviceosversion, false, false);

                            if (umd.ShowDialog() == true)
                            {
                                retVal = true;
                            }
                            else
                            {
                                retVal = false;
                            }
                        }
                        else
                        {
                            if (IsRuntimeInstalled(_deviceosversion))
                            {
                                retVal = true;
                            }
                            else
                            {
                                if (IsAPIInstalled(_deviceosversion.Substring(0, _deviceosversion.LastIndexOf('.')), "", true) == 0)
                                {
                                    string apiLevel = GetAPILevel(_deviceosversion.Substring(0, _deviceosversion.LastIndexOf('.')));

                                    if (apiLevel != "")
                                    {
                                        UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", apiLevel, false, false);
                                        if (umd.ShowDialog() == true)
                                        {
                                            umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                                            if (umd.ShowDialog() == true)
                                            {
                                                retVal = true;
                                            }
                                            else
                                            {
                                                retVal = false;
                                            }
                                        }
                                        else
                                        {
                                            retVal = false;
                                        }
                                    }
                                    else
                                        MessageBox.Show("API level not supported at this moment.\n\nAborting...", "API level not supported", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                                else
                                {
                                    UpdateManagerDialog umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                                    if (umd.ShowDialog() == true)
                                    {
                                        retVal = true;
                                    }
                                    else
                                    {
                                        retVal = false;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    retVal = true;
                }
            }
            else
            {
                retVal = false;
            }

            return retVal;
        }
        /// <summary>
        /// Validate to make sure device matches the API Level chosen.
        /// </summary>
        /// <returns></returns>
        public bool validateDeviceVersion(bool isSim)
        {
            bool           retVal      = false;
            string         baseVersion = "10.2.0.0";
            DebugTokenData dtokenData;

            if (!isSim)
            {
                dtokenData = new DebugTokenData();
            }

            getDeviceSimInfo(isSim);

            if (getDeviceInfo())
            {     //** Device Info retrieved - validate API's
                if (getCurrentAPIVersion() != _deviceosversion)
                { //** Currently selected API version is different from attached device OS version.
                    if (IsAPIInstalled(_deviceosversion, "", false) > 0)
                    {
                        retVal = true;
                    }
                    else
                    {
                        if (baseVersion.CompareTo(_deviceosversion) > 0)
                        {
                            UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", _deviceosversion, false, false);

                            if (umd.ShowDialog() == true)
                            {
                                retVal = true;
                            }
                            else
                            {
                                retVal = false;
                            }
                        }
                        else
                        {
                            if (IsRuntimeInstalled(_deviceosversion))
                            {
                                retVal = true;
                            }
                            else
                            {
                                if (IsAPIInstalled(_deviceosversion.Substring(0, _deviceosversion.LastIndexOf('.')), "", true) == 0)
                                {
                                    string apiLevel = GetAPILevel(_deviceosversion.Substring(0, _deviceosversion.LastIndexOf('.')));

                                    if (apiLevel != "")
                                    {
                                        UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", apiLevel, false, false);
                                        if (umd.ShowDialog() == true)
                                        {
                                            umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                                            if (umd.ShowDialog() == true)
                                            {
                                                retVal = true;
                                            }
                                            else
                                            {
                                                retVal = false;
                                            }
                                        }
                                        else
                                        {
                                            retVal = false;
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("API level not supported at this moment.\n\nAborting...", "API level not supported", MessageBoxButton.OK, MessageBoxImage.Error);
                                    }
                                }
                                else
                                {
                                    UpdateManagerDialog umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                                    if (umd.ShowDialog() == true)
                                    {
                                        retVal = true;
                                    }
                                    else
                                    {
                                        retVal = false;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    retVal = true;
                }
            }
            else
            {
                retVal = false;
            }

            return(retVal);
        }
Exemple #3
0
        /// <summary>
        /// Validate to make sure device matches the API Level chosen.
        /// </summary>
        /// <returns></returns>
        public bool validateDeviceVersion(bool isSim)
        {
            bool           retVal            = false;
            string         baseVersion       = "10.2.0.0";
            string         currentAPIVersion = getCurrentAPIVersion();
            DebugTokenData dtokenData;

            if (!isSim)
            {
                dtokenData = new DebugTokenData();
                string LocalFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\";
                string CertPath    = LocalFolder + "author.p12";

                if (!File.Exists(CertPath))
                {
                    return(false);
                }
            }

            getDeviceSimInfo(isSim);

            if (getDeviceInfo())
            {
                string buildVersion = getBuildVersion();
                if ((buildVersion != "") && (_deviceosversion != "") && (compareVersions(_deviceosversion, buildVersion) < 0))
                {
                    if (isSim)
                    {
                        MessageBox.Show("The simulator operating system does not support the API level used to build the app.\n\nSimulator operating system version: " + _deviceosversion + "\nAPI level version used to build the app: " + buildVersion + "\n\nPlease select an API level that is supported by the operating system and rebuild the project before start debugging.", "API level not supported by the simulator's operating system", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("The device operating system does not support the API level used to build the app.\n\nDevice operating system version: " + _deviceosversion + "\nAPI level version used to build the app: " + buildVersion + "\n\nPlease select an API level that is supported by the operating system and rebuild the project before start debugging.", "API level not supported by the device's operating system", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    return(false);
                }

                if (_deviceosversion == currentAPIVersion)
                {
                    SetRuntime("");
                    retVal = true;
                }
                else if ((_deviceosversion.Substring(0, 4) == "10.1") || (_deviceosversion.Substring(0, 4) == "10.0"))
                {
                    SetRuntime("");
                    if (IsAPIInstalled(_deviceosversion, "") > 0)
                    {
                        retVal = true;
                    }
                    else
                    {
                        UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", _deviceosversion, false, false);

                        if (umd.ShowDialog() == true)
                        {
                            retVal = true;
                        }
                        else
                        {
                            retVal = false;
                        }
                    }
                }
                else if (IsRuntimeInstalled(_deviceosversion))
                {
                    SetRuntime(_deviceosversion);
                    retVal = true;
                }
                else
                {
                    UpdateManagerDialog umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                    if (umd.ShowDialog() == true)
                    {
                        // runtime was already set by the Update Manager.
                        retVal = true;
                    }
                    else
                    {
                        SetRuntime("");
                        retVal = false;
                    }
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Validate to make sure device matches the API Level chosen.
        /// </summary>
        /// <returns></returns>
        public bool validateDeviceVersion(bool isSim)
        {
            bool retVal = false;
            string baseVersion = "10.2.0.0";
            string currentAPIVersion = getCurrentAPIVersion();
            DebugTokenData dtokenData;

            if (!isSim)
            {
                dtokenData = new DebugTokenData();
                string LocalFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\";
                string CertPath = LocalFolder + "author.p12";

                if (!File.Exists(CertPath))
                {
                    return false;
                }
            }

            getDeviceSimInfo(isSim);

            if (getDeviceInfo())
            {
                string buildVersion = getBuildVersion();
                if ((buildVersion != "") && (_deviceosversion != "") && (compareVersions(_deviceosversion, buildVersion) < 0))
                {
                    if (isSim)
                    {
                        MessageBox.Show("The simulator operating system does not support the API level used to build the app.\n\nSimulator operating system version: " + _deviceosversion + "\nAPI level version used to build the app: " + buildVersion + "\n\nPlease select an API level that is supported by the operating system and rebuild the project before start debugging.", "API level not supported by the simulator's operating system", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("The device operating system does not support the API level used to build the app.\n\nDevice operating system version: " + _deviceosversion + "\nAPI level version used to build the app: " + buildVersion + "\n\nPlease select an API level that is supported by the operating system and rebuild the project before start debugging.", "API level not supported by the device's operating system", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    return false;
                }

                if (_deviceosversion == currentAPIVersion)
                {
                    SetRuntime("");
                    retVal = true;
                }
                else if ((_deviceosversion.Substring(0, 4) == "10.1") || (_deviceosversion.Substring(0, 4) == "10.0"))
                {
                    SetRuntime("");
                    if (IsAPIInstalled(_deviceosversion, "") > 0)
                    {
                        retVal = true;
                    }
                    else
                    {
                        UpdateManagerDialog umd = new UpdateManagerDialog("The API Level for the operating system version of the attached device is not currently installed.  Would you like to install it now?", _deviceosversion, false, false);

                        if (umd.ShowDialog() == true)
                        {
                            retVal = true;
                        }
                        else
                        {
                            retVal = false;
                        }
                    }
                }
                else if (IsRuntimeInstalled(_deviceosversion))
                {
                    SetRuntime(_deviceosversion);
                    retVal = true;
                }
                else
                {
                    UpdateManagerDialog umd = new UpdateManagerDialog("The Runtime Libraries for the operating system version of the attached device are not currently installed.  Would you like to install them now?", _deviceosversion, true, false);
                    if (umd.ShowDialog() == true)
                    {
                        // runtime was already set by the Update Manager.
                        retVal = true;
                    }
                    else
                    {
                        SetRuntime("");
                        retVal = false;
                    }
                }
            }

            return retVal;
        }