Exemple #1
0
        public static bool AmStartActivity(this ICakeContext context, string adbIntentArguments, AmStartOptions options = null, AdbToolSettings settings = null)
        {
            var t = GetAdbTool(context);

            return(t.StartActivity(adbIntentArguments, options, settings));
        }
Exemple #2
0
        public bool StartActivity(string adbIntentArguments, AmStartOptions options = null, AdbToolSettings settings = null)
        {
            if (settings == null)
            {
                settings = new AdbToolSettings();
            }

            if (options == null)
            {
                options = new AmStartOptions();
            }

            // start [options] intent
            var builder = new ProcessArgumentBuilder();

            AddSerial(settings.Serial, builder);

            builder.Append("shell");
            builder.Append("am");

            builder.Append("start");

            if (options.EnableDebugging)
            {
                builder.Append("-D");
            }
            if (options.WaitForLaunch)
            {
                builder.Append("-W");
            }
            if (options.ProfileToFile != null)
            {
                if (options.ProfileUntilIdle)
                {
                    builder.Append("-P");
                }
                else
                {
                    builder.Append("--start");
                }
                builder.AppendQuoted(options.ProfileToFile.MakeAbsolute(environment).FullPath);
            }
            if (options.RepeatLaunch.HasValue && options.RepeatLaunch.Value > 0)
            {
                builder.Append("-R");
                builder.Append(options.RepeatLaunch.Value.ToString());
            }
            if (options.ForceStopTarget)
            {
                builder.Append("-S");
            }
            if (options.EnableOpenGLTrace)
            {
                builder.Append("--opengl-trace");
            }
            if (!string.IsNullOrEmpty(options.RunAsUserId))
            {
                builder.Append("--user");
                builder.Append(options.RunAsUserId);
            }

            builder.Append(adbIntentArguments);

            var output = new List <string>();

            RunAdb(settings, builder, out output);

            return(output.Any(l => l.StartsWith("Starting:", StringComparison.OrdinalIgnoreCase)));
        }