Skip to main content
Glama

enableDemoMode

Activate demo mode to display predefined status bar indicators for consistent screenshots, including time, battery level, signal strength, and more, across Android and iOS platforms.

Instructions

Enable demo mode with consistent status bar indicators for screenshots

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
batteryLevelNoBattery level percentage (0-100)
batteryPluggedNoWhether the device appears to be charging
hideNotificationsNoWhether to hide notification icons
mobileDataTypeNoMobile data type to display
mobileSignalLevelNoMobile signal strength (0-4)
platformYesTarget platform
timeNoTime to display in statusbar in HHMM format (e.g., 1000 for 10:00)
wifiLevelNoWiFi signal strength (0-4)

Implementation Reference

  • The handler function that executes the enableDemoMode tool. It instantiates DemoMode and calls its execute method with the provided arguments, handling errors and formatting the response.
    const enableDemoModeHandler = async (device: BootedDevice, args: EnableDemoModeArgs) => { try { const demoMode = new DemoMode(device); const result = await demoMode.execute(args); return createJSONToolResponse({ message: "Demo mode enabled", observation: result.observation, ...result, demoModeEnabled: true }); } catch (error) { logger.error("Failed to enable demo mode:", error); throw new ActionableError(`Failed to enable demo mode: ${error}`); } };
  • Zod schema defining the input parameters and validation for the enableDemoMode tool.
    export const enableDemoModeSchema = z.object({ time: z.string().optional().describe("Time to display in statusbar in HHMM format (e.g., 1000 for 10:00)"), batteryLevel: z.number().min(0).max(100).optional().describe("Battery level percentage (0-100)"), batteryPlugged: z.boolean().optional().describe("Whether the device appears to be charging"), wifiLevel: z.number().min(0).max(4).optional().describe("WiFi signal strength (0-4)"), mobileDataType: z.enum(["4g", "5g", "lte", "3g", "edge", "none"]).optional().describe("Mobile data type to display"), mobileSignalLevel: z.number().min(0).max(4).optional().describe("Mobile signal strength (0-4)"), hideNotifications: z.boolean().optional().describe("Whether to hide notification icons"), platform: z.enum(["android", "ios"]).describe("Target platform") });
  • Registration of the enableDemoMode tool into the ToolRegistry using registerDeviceAware method, associating name, description, schema, and handler.
    ToolRegistry.registerDeviceAware( "enableDemoMode", "Enable demo mode with consistent status bar indicators for screenshots", enableDemoModeSchema, enableDemoModeHandler );
  • The core execute method in DemoMode class that performs the actual ADB commands to enable Android demo mode with specified status bar elements. This is called by the tool handler.
    async execute(options: DemoModeOptions = {}): Promise<DemoModeResult> { const { time = "1000", batteryLevel = 100, batteryPlugged = false, wifiLevel = 4, mobileDataType = "4g", mobileSignalLevel = 4, hideNotifications = true, } = options; try { // Get current package name from active window const activeWindow = await this.window.getActive(true); logger.info("Setting up Android demo mode for current app:", activeWindow.appId); // Allow demo mode await this.adb.executeCommand("shell settings put global sysui_demo_allowed 1"); // Enter demo mode await this.adb.executeCommand("shell am broadcast -a com.android.systemui.demo -e command enter"); // Set battery status await this.adb.executeCommand( `shell am broadcast -a com.android.systemui.demo -e command battery -e plugged ${ batteryPlugged ? "true" : "false" } -e level ${batteryLevel}` ); // Set clock time await this.adb.executeCommand( `shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm ${time}` ); // Handle notifications if (hideNotifications) { await this.adb.executeCommand( "shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false" ); } // Set network status await this.adb.executeCommand( `shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level ${wifiLevel} -e mobile show -e datatype ${mobileDataType} -e level ${mobileSignalLevel}` ); logger.info("Demo mode setup completed successfully"); return { success: true, message: "Demo mode enabled successfully", demoModeEnabled: true, packageName: activeWindow.appId, activityName: activeWindow.activityName }; } catch (err) { const errorMessage = err instanceof Error ? err.message : String(err); logger.error("Failed to set up demo mode:", err); return { success: false, error: `Failed to set up demo mode: ${errorMessage}`, demoModeEnabled: false }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zillow/auto-mobile'

If you have feedback or need assistance with the MCP directory API, please join our Discord server