編輯:關於Android編程
如何實現usb驅動自動安裝? 具體的需求可能是:連上usb後,默認選項為內置光盤(cdrom)模式,自動運行內置於光盤中的驅動程序,安裝完成後,再切回到usb mass stoage(ums)模式 [KEYWORD] usb默認連接,Built-in cd-rom,BICR,CD-ROM,cdrom,內置光盤,自動安裝驅動,自動運行,內置驅動程序 [SOLUTION] 以下提供一個實現的思路: 1,將您的驅動程序做成一個iso文件,制作工具可在網上找。 2,修改USB連接後的默認功能為bicr。如何將usb默認連接方式設置為bicr,請參考FAQ04464 3,將iso文件添加進BICR,具體請參考FAQ05690 How to add ISO files into BICR 4,需要修改您的驅動程序。發對應的cmd REZERO_UNIT,根據cmnd[1] 參數不同,來決定是切換到UMS還是BICR。
附上手機側相關code: 此功能相關的code在以下文件,可以參考了解手機側具體實現:...... } else if (REZEROCMD.equals(state)) {
/*When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function(UMS)*/
Slog.w(TAG, PC knows me);
mIsPcKnowMe = true;
setCurrentFunctions(UsbManager.USB_FUNCTION_MASS_STORAGE, false); //修改此處的USB_FUNCTION_MASS_STORAGE為USB_FUNCTION_MTP
return; ......
static int do_scsi_command(struct fsg_common *common)2. android.c
{case REZERO_UNIT:}
printk(Get REZERO_UNIT command = %x , common->cmnd[1]);
if (common->cmnd[1] == 0xB)
common->android_callback(1);
else if (common->cmnd[1] == 0xD)
common->android_callback(2); ......
static void android_work(struct work_struct *data)3. usbdevicemanager.java
{...... char *rezero_event[2] = { USB_STATE=REZEROCMD, NULL };void mass_storage_callback(unsigned char cmd_type)
char *showcdrom_event[2] = { USB_STATE=SHOWCDROMCMD, NULL };
...... if (dev->rezero_cmd == 1) {
uevent_envp_cdrom = rezero_event;
dev->rezero_cmd = 0;
} else if (dev->rezero_cmd == 2) {
uevent_envp_cdrom = showcdrom_event;
dev->rezero_cmd = 0;
}
...... if (uevent_envp_cdrom) {
kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, uevent_envp_cdrom);
xlog_printk(ANDROID_LOG_INFO, USB_LOG, %s: sent uevent %s , __func__, uevent_envp_cdrom[0]);
} else {
xlog_printk(ANDROID_LOG_INFO, USB_LOG, %s: did not send zero uevent , __func__);
}
}
{struct android_dev *dev = _android_dev;
if (cmd_type != 0)
dev->rezero_cmd = cmd_type;
schedule_work(&dev->work);
}
public void updateState(String state) {...... int connected, configured; if (DEBUG) SXlog.d(TAG, updateState - + state);
Message msg; ... } else if (REZEROCMD.equals(state)) {
/*When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function(UMS)*/
Slog.w(TAG, PC knows me);
mIsPcKnowMe = true;
setCurrentFunctions(UsbManager.USB_FUNCTION_MASS_STORAGE, false);
return;
} else if (SHOWCDROMCMD.equals(state)) {
/*When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function(UMS)*/
Slog.w(TAG, SHOW CD-ROM CMD);
setCurrentFunctions(UsbManager.USB_FUNCTION_BICR, false);
return; ...... }
-當窗口工具通過Analyse | Inspect Code方式打開以後,你可以通過這種方式訪問此窗口工具。-當點擊關閉按鈕關閉工具窗口以後,只能通過Analyze |
API 21中將原來的camera API棄用轉而推薦使用新增的camera2 API,這是一個大的動作,因為新API換了架構,讓開發者用起來更難了。先來看看camera
1.Activity類控件(1)ListActivity控件1)ListActivity控件概述ListActivity可以用來實現列表功能。在android中,List
眾所周知,XML是一種可擴展標記語言,它被用來傳輸和存儲數據。在Android中也會隨處可見XML文件,包括一個android項目不可缺少的AndroidManifest