AutoGo Android Automation Framework

repository·master·Indexed 42 days ago

https://github.com/dasongzi1366/autogo

A 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.

Tokens
1.2K
Snippets
7
Records
8
Agent score
4%

What's inside AutoGo

  1. Overview of AutoGo

    master
    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.
  2. Start custom Activities, Services, or Broadcasts

    master

    Use these functions to trigger specific Android components using an IntentOptions configuration.

    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",
    })
  3. Inspect current package and activity

    master

    Use CurrentPackage and CurrentActivity to identify the application and specific component currently in focus on the Android device. These functions parse the output of dumpsys window to extract the package name and class name.

    packageName := app.CurrentPackage()
    activityName := app.CurrentActivity()
  4. Manage Android applications (Install, Uninstall, Clear, etc.)

    master

    The app package provides several functions to manage the lifecycle and state of installed applications via shell commands:

    • Launch(packageName string) bool: Starts the application. Returns true if successful.
    • OpenAppSetting(packageName string) bool: Opens the application's system settings page. Returns true if 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")
  5. View or Edit files using system apps

    master

    Open 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")
  6. Configure IntentOptions for custom actions

    master

    The IntentOptions struct is used to define the parameters for custom Android Intents when calling StartActivity, SendBroadcast, or StartService.

    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
    }