예제 #1
0
        public static bool EnsureRootOff(SDBDeviceInfo device, RunMode runMode)
        {
            bool   isRoot;
            string errorMessage;

            bool isSecureProtocol = (new SDBCapability(DeviceManager.SelectedDevice)).GetAvailabilityByKey("secure_protocol");

            if (isSecureProtocol)
            {
                return(true);
            }

            if (!SDBLib.CheckIsRoot(device, out isRoot, out errorMessage))
            {
                Instance.ShowError(StringHelper.CombineMessages("Cannot check if \"root off\" mode set", errorMessage));
                return(false);
            }

            if (isRoot)
            {
                string msg = $"Currently \"root on\" mode is used on the \"{device.Name}\" device.\n";
                switch (runMode)
                {
                case RunMode.Debug:
                    msg +=
                        "Debugging cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while debugging.";
                    break;

                case RunMode.CoreProfiler:
                case RunMode.LiveProfiler:
                case RunMode.MemoryProfiler:
                    msg +=
                        "Profiling cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?\n\n" +
                        "Note: please don't switch to \"root on\" mode manually while profiling.";
                    break;

                default:
                    msg +=
                        "An application cannot be started until switching the device to \"root off\".\n\n" +
                        "Do you want the plugin to switch the device to \"root off\" for you and continue?";
                    break;
                }
                if (System.Windows.MessageBox.Show(msg, "Tizen Plugin", MessageBoxButton.YesNoCancel,
                                                   MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return(false);
                }
                if (!SDBLib.SwitchToRoot(device, false))
                {
                    ProfilerPlugin.Instance.ShowError($"Cannot switch \"{device.Name}\" to \"root off\" mode");
                    return(false);
                }
            }

            return(true);
        }