Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android [USB]如何同時打開UMS和BICR(CD-ROM)

Android [USB]如何同時打開UMS和BICR(CD-ROM)

編輯:關於Android編程

前言
歡迎大家我分享和推薦好用的代碼段~~
聲明
歡迎轉載,但請保留文章原始出處:
CSDN
http://www.csdn.net
雨季o莫憂離:http://blog.csdn.net/luckkof

正文

手機連接電腦時,能同時看到內卡,外卡和虛擬光驅盤符

1. 把LUN改成3個,並且最後一個定義為CDROM

kernel\drivers\usb\gadget\android.c

static int mass_storage_function_init(struct android_usb_function *f,

struct usb_composite_dev *cdev)

{

struct mass_storage_function_config *config;

struct fsg_common *common;

int err;

int i;

config = kzalloc(sizeof(struct mass_storage_function_config),

GFP_KERNEL);

if (!config)

return -ENOMEM;

#ifdef MTK_MULTI_STORAGE_SUPPORT

#ifdef MTK_SHARED_SDCARD

#define NLUN_STORAGE 1

#else

#define NLUN_STORAGE 2

#endif

#else

#define NLUN_STORAGE 1

#endif

#define NLUN_STORAGE 3 //add 1/3

config->fsg.nluns = NLUN_STORAGE;

for(i = 0; i < config->fsg.nluns; i++) {

config->fsg.luns[i].removable = 1;

config->fsg.luns[i].nofua = 1;

}

config->fsg.luns[NLUN_STORAGE-1].cdrom = 1; //add 2/3

common = fsg_common_init(NULL, cdev, &config->fsg);

if (IS_ERR(common)) {

kfree(config);

return PTR_ERR(common);

}

err = sysfs_create_link(&f->dev->kobj,

&common->luns[0].dev.kobj,

"lun");

if (err) {

kfree(config);

return err;

}

/*

* "i" starts from "1", cuz dont want to change the naming of

* the original path of "lun0".

*/

for(i = 1; i < config->fsg.nluns; i++) {

char string_lun[5]={0};

sprintf(string_lun, "lun%d",i);

err = sysfs_create_link(&f->dev->kobj,

&common->luns[i].dev.kobj,

string_lun);

if (err) {

kfree(config);

return err;

}

}

common->android_callback = &mass_storage_callback;

config->common = common;

f->config = config;

return 0;

}

2. 把loop0一開機就寫入lun2/file裡,讓PC可以看到CD-ROM內容。

mediatek\config\mt6589\init.usb.rc

on init

# Workarunod for USB unknow device issue

# USB would switch correct function when set properity sys.usb.config

setprop sys.usb.vid 0BB4

write /sys/class/android_usb/android0/iSerial $ro.serialno

write /sys/class/android_usb/android0/idVendor $sys.usb.vid

on post-fs-data

chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file

chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file

chown system system /sys/class/android_usb/android0/f_rndis/ethaddr

chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr

write /sys/class/android_usb/android0/f_rndis/wceis 1

write /sys/class/android_usb/android0/f_rndis/manufacturer MediaTek

write /sys/class/android_usb/android0/f_rndis/vendorID $sys.usb.vid

write /sys/class/android_usb/android0/f_mass_storage/lun2/file "/dev/block/loop0"

#add 3/3

3. 讓BICR的UI不顯示。

mediatek\config\[PROJECT]\system.prop

ro.sys.usb.bicr=no


  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved