FFOS 1.3 settings usb tethering 流程
来源:互联网 发布:java怎么调用方法 编辑:程序博客网 时间:2024/06/06 03:01
RNDIS的百度解释
Remote Network Driver Interface Specification,既是RemoteNDIS,既是远程网络驱动接口规范。基于USB实现RNDIS实际上就是TCP/IP over USB,就是在USB设备上跑TCP/IP,让USB设备看上去像一块网卡。[1]
USB的通常配置为,设置为RNDIS后就表示是做为电脑的网络分享;
界面上的显示在Gaia层的代码
Hotspot.html (gaia\apps\settings\elements) 1910 2014/12/1
<input type="checkbox" name="tethering.usb.enabled" class="uninit">
当checkbox状态改变的时候,在Settings.js (gaia\apps\settings\js)中处理
handleEvent: function settings_handleEvent(event)
==》
value = input.checked; // boolean
==》
var cset = {}; cset[key] = value;
settings.createLock().set(cset);
此处的改变会走到gecko层NetworkManager.js (gecko\dom\system\gonk)
case TOPIC_MOZSETTINGS_CHANGED:
let setting = JSON.parse(data);
this.handle(setting.key, setting.value);
break;
this.handle的处理
This. handleUSBTetheringToggle:
gNetworkService对应的定义
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
"@mozilla.org/network/service;1",
"nsINetworkService");
在omni\components\ components.manifest中查找定义
component {c14cabaf-bb8e-470d-a2f1-2cb6de6c5e5c} NetworkService.js
contract @mozilla.org/network/service;1 {c14cabaf-bb8e-470d-a2f1-2cb6de6c5e5c}
对应的enableUsbRndis实现:
// Switch usb function by modifying property of persist.sys.usb.config.
enableUsbRndis: function(enable, callback){
if(DEBUG) debug("enableUsbRndis: " + enable);
let params = {
cmd: "enableUsbRndis",
enable: enable
};
// Ask net work to report the result when this value is set to true.
if (callback) {
params.report= true;
} else {
params.report= false;
}
// The callback function in controlMessage may not be fired immediately.
params.isAsync= true;
//this._usbTetheringAction = TETHERING_STATE_ONGOING;
this.controlMessage(params, function(data){
callback.enableUsbRndisResult(data.result, data.enable);
});
},
调用controlMessage将USB的RNDIS设置打开/关闭,然后在enableUsbRndisResult设置IP
controlMessage: function(params, callback){
if (this.shutdown){
return;
}
if (callback) {
let id = this.idgen++;
params.id = id;
this.controlCallbacks[id]= callback;
}
if (gNetworkWorker) {
gNetworkWorker.postMessage(params);
}
},
enableUsbRndisResult实现,红色代码为设置IP。
enableUsbRndisResult: function(success, enable){
if (success) {
// If enable is false, don't find usb interface cause it is already down,
// just use the internal interface in settings.
if (enable) {
this._tetheringInterface[TETHERING_TYPE_USB].internalInterface= this.getUsbInterface();
}
this.setUSBTethering(enable,
this._tetheringInterface[TETHERING_TYPE_USB],
this.usbTetheringResultReport.bind(this));
} else {
this.usbTetheringResultReport("Failed to set usb function");
throw new Error("failed to set USB Function to adb");
}
},
其中gNetworkWorker的定义如下:
XPCOMUtils.defineLazyServiceGetter(this, "gNetworkWorker",
"@mozilla.org/network/worker;1",
"nsINetworkWorker");
其定义在NetworkWorker.cpp(gecko\dom\system\gonk)
static const mozilla::Module::ContractIDEntry kNetworkWorkerContracts[]= {
{ "@mozilla.org/network/worker;1", &kNS_NETWORKWORKER_CID },
{ nullptr }
};
所以最终会走到NetworkUtils.cpp(gecko\dom\system\gonk)
bool NetworkUtils::enableUsbRndis(NetworkParams&aOptions)
char newConfig[PROPERTY_VALUE_MAX] = "";
property_get(SYS_USB_CONFIG_PROPERTY, currentConfig, nullptr);
join(configFuncs, USB_CONFIG_DELIMIT, PROPERTY_VALUE_MAX, newConfig);
if (strcmp(currentConfig, newConfig)) {
property_set(SYS_USB_CONFIG_PROPERTY, newConfig);
}
设置系统属性。至此,gaia 到gecko 部分的rndis 部分走完。
- FFOS 1.3 settings usb tethering 流程
- 五、 Usb setting 中tethering 设置流程
- WiFi Tethering & Usb Tethering
- Android USB Tethering的实现以及代码流程
- Android USB Tethering的实现以及代码流程
- Reverse USB tethering
- Android USB Tethering
- Android USB Tethering
- OpenWrt支持usb tethering
- android下usb框架系列文章---(5)Usb setting 中tethering 设置流程
- Android USB tethering相关代码
- FFOS 1.3 enable fdn 流程图
- uibuntu 利用手机USB tethering 上网
- enable usb tethering via command line failed
- Tethering
- USB Tethering always displays grey when USB tethering type is Linux(EEM)
- usb alternate settings
- linux usb wifi settings
- 2014年10月22日网易游戏数据库系统工程师初面
- 《解决VirtualBox安裝Windows 2000失败》
- 有时候项目导入Eclipse中引用包没问题,但是大面积报错,很有可能是项目的字符编码应该选择UTF-8
- 使用XmlTextReader 读取XML
- android 应用获取系统权限
- FFOS 1.3 settings usb tethering 流程
- Android使用UncaughtExceptionHandler捕获全局异常
- 自定义layout中嵌套button问题
- 如何在64位windows7上同时使用32位和64位的Eclipse
- 稳定婚姻问题和Gale-Shapley算法
- 明星微信营销开始啦!
- Javascript的入门理解
- SpringMVC + spring3.1.1 + hibernate4.1.0 集成及常见问题总结
- 怎样关闭整个程序