AutoGo Android Automation Framework
repository·master·Indexed 42 days ago
https://github.com/dasongzi1366/autogoA high-performance Android automation framework written in Go. It runs as a binary executable directly on Android, enabling cross-app automation without requiring helper APKs. It provides capabilities to manage applications (install, uninstall, force stop), inspect current packages and activities, and trigger custom Activities, Services, or Broadcasts via IntentOptions.
What's inside AutoGo
- AutoGo is a high-performance Android automation framework developed in Go. Unlike traditional automation tools, AutoGo provides a binary executable that runs directly on the Android system. This allows for powerful cross-application operation capabilities without the need to install any additional APKs, making it ideal for complex automation scenarios requiring seamless interaction between different applications.
Start custom Activities, Services, or Broadcasts
masterUse these functions to trigger specific Android components using an
IntentOptionsconfiguration.app.StartActivity(app.IntentOptions{ Action: "VIEW", Data: "http://example.com", }) app.SendBroadcast(app.IntentOptions{ Action: "MY_CUSTOM_ACTION", Extras: map[string]string{"key": "value"}, }) app.StartService(app.IntentOptions{ PackageName: "com.example.app", ClassName: ".MyService", })Inspect current package and activity
masterUse
CurrentPackageandCurrentActivityto identify the application and specific component currently in focus on the Android device. These functions parse the output ofdumpsys windowto extract the package name and class name.packageName := app.CurrentPackage() activityName := app.CurrentActivity()Open URLs in the default browser
masterThe
OpenUrlfunction opens a web address using the system's default browser. It automatically prependshttp://if the protocol is missing.app.OpenUrl("google.com") // Opens http://google.comGet the system default browser package
masterUse
GetBrowserPackage()to retrieve the package name of the application currently configured as the system default browser.browserPkg := app.GetBrowserPackage()Manage Android applications (Install, Uninstall, Clear, etc.)
masterThe
apppackage provides several functions to manage the lifecycle and state of installed applications via shell commands:Launch(packageName string) bool: Starts the application. Returnstrueif successful.OpenAppSetting(packageName string) bool: Opens the application's system settings page. Returnstrueif successful.IsInstalled(packageName string) bool: Checks if a package is currently installed.Install(path string): Installs an APK from the specified local path.Uninstall(packageName string): Removes the specified application.Clear(packageName string): Clears all data for the specified application.ForceStop(packageName string): Forcefully stops the specified application.Disable(packageName string): Disables the specified application.Enable(packageName string): Enables a previously disabled application.IgnoreBattOpt(packageName string): Adds the package to the battery optimization whitelist.
app.Launch("com.example.app") app.Clear("com.example.app") app.IsInstalled("com.example.app")View or Edit files using system apps
masterOpen files using the device's default handler for the specific file type.
ViewFile(path string): Opens the file for viewing.EditFile(path string): Opens the file for editing.
app.ViewFile("/sdcard/Download/image.png") app.EditFile("/sdcard/Download/notes.txt")Configure IntentOptions for custom actions
masterThe
IntentOptionsstruct is used to define the parameters for custom Android Intents when callingStartActivity,SendBroadcast, orStartService.type IntentOptions struct { Action string // The intent action (e.g., "VIEW", "EDIT") Type string // The MIME type (e.g., "image/png") Data string // The URI data (e.g., "file:///path/to/file" or "http://url") Category []string // Intent categories PackageName string // The target package name ClassName string // The target class name (used with PackageName) Extras map[string]string // Key-value pairs for intent extras Flags []string // Boolean flags }