Skip to content

Commit

Permalink
Use Activity Manager instead of adb monkey (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaneySprings committed May 11, 2024
1 parent 4133f8a commit c2808ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/DotNet.Meteor.Debug/Agents/DebugLaunchAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class DebugLaunchAgent : BaseLaunchAgent {

DeviceBridge.Install(Configuration.Device.Serial, Configuration.OutputAssembly, logger);
DeviceBridge.Shell(Configuration.Device.Serial, "setprop", "debug.mono.connect", $"port={Configuration.DebugPort}");
DeviceBridge.Shell(Configuration.Device.Serial, "am", "set-debug-app", applicationId);
DeviceBridge.Launch(Configuration.Device.Serial, applicationId, logger);
DeviceBridge.Flush(Configuration.Device.Serial);

Expand Down
3 changes: 3 additions & 0 deletions src/DotNet.Meteor.Debug/LaunchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class LaunchConfiguration {
DebugPort = DebugPort == 0 ? ServerExtensions.FindFreePort() : DebugPort;
ReloadHostPort = ReloadHostPort == 0 ? ServerExtensions.FindFreePort() : ReloadHostPort;
ProfilerPort = ProfilerPort == 0 ? ServerExtensions.FindFreePort() : ProfilerPort;

if (!Directory.Exists(TempDirectoryPath))
Directory.CreateDirectory(TempDirectoryPath);
}

public string GetApplicationName() {
Expand Down
4 changes: 3 additions & 1 deletion src/DotNet.Meteor.Debug/Sdk/DeviceBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public static class DeviceBridge {
new ProcessRunner(adb, argument, logger).WaitForExit();
}
public static void Launch(string serial, string pkg, IProcessLogger logger = null) {
string result = Shell(serial, "monkey", "--pct-syskeys", "0", "-p", pkg, "1");
// This is a legacy method that is no longer used (device auto-rotation issue).
// string result = Shell(serial, "monkey", "--pct-syskeys", "0", "-p", pkg, "1");
string result = Shell(serial, "am", "start", $"{pkg}/$(cmd package resolve-activity -c android.intent.category.LAUNCHER {pkg} | sed -n '/name=/s/^.*name=//p')");
logger?.OnOutputDataReceived(result);
}

Expand Down

0 comments on commit c2808ed

Please sign in to comment.