BREW 中提供了Perl 介面庫,開發人員可以通過Perl介面編寫指令碼,來實現批處理命令的自動化執行。其中的API 列表包括:
•串連和控制目標手機
u ConnecttoDevice(char* portName, char* dllName)
u PutDeviceOffline(int)
u ResetDevice()
•複製檔案和目錄
u CopyFileToDevice(char* src, char* dest, bool overwrite)
u CopyFileFromDevice(char* src, char* dest)
u CopyDirDevice(const char* pPCDirName, const char* pDeviceDirName)
•記錄手機的日誌資訊
u SetLogMask(char* logMask)
u SetLogDuration(unsigned long x)
u StartLogger()
•類比手機的按鍵事件
u StartGrinder(char* targetName)
u SetEventInterval(long lEventsInterval)
u SendKeys(int count, char **eventCodes)
下面是Grinder與BTIL結合使用的指令碼樣本。
use GrinderPl;
use enum qw( AVK_ASTERISK=1000 AVK_NUMBER_SIGN AVK_SELECT AVK_UP AVK_DOWN AVK_LEFT AVK_RIGHT AVK_SEND AVK_CLR AVK_END);
use enum qw( NORMAL=0 NO_VOICE_CALL AFTER_VOICE_CALL CONFIG_SCREEN=4 HIDDEN_CONFIG=8 FORCE_UNIQUE=32 SCR_SAVER=64 BACKGROUND=160);
#
# A Grinder perl application to configure Shaker on the phone.
#
# 1) It initializes the perl module.
# 2) Loads the default settings.
# 3) Initializes the phone.
# 4) Starts the BREW applet with flag to start it in background.
# 5) Releases the perl module.
#
#Initialize the perl module. This should be the first function to be called.
GrinderPl::InitPerlModule();
#Load the default settings.
GrinderPl::LoadSettings(0);
if(GrinderPl::InitDeviceEx("COM1", "BTILOEM.dll")) {
$i = 0x12345678; # Id of Applet to be started
GrinderPl::BTILStartApplet($i, BACKGROUND);
}
GrinderPl::ReleasePerlModule();