Categories
Android

吐槽一下新浪微博 Android SDK V2.4.0

吐槽一下新浪微博 Android SDK V2.4.0

周末逛逛github,发现新浪更新了SDK,说是重大版本变更,瞄了一下,大概是文档更规范、代码重构之类的。老版本SDK代码全开放,但 2.3之后,封闭了部分代码。不管如何,我还是直奔观看 AsyncWeiboRunner.request 这个方法究竟改变了没有,结果还是失望了。

我建议微博 Android SDK 的开发人员,好好的阅读AQuery,Volley,android-async-http 这几个异步网络请求库,通过回调方式处理请求结果。新浪也是有回调结果,但要自己加 Handler 更新UI,官方的Demo在回调直接更新UI,其实就是在 http 请求线程里操作的,很容易给新手误导。

很多软件的开发都是如此,开始使用现成的,后面发现使用越来越不爽,不能满足自己的需求,决定重新搞。所以,Weibo for Android 计划使用 Volley作为http 处理库,自己写封装接口。我封装了一个GsonRequest,测试发现老是返回403,抓包才知道参数没有上传。使用 http get 传参数需要注意,重写getParams无效。见:

http://stackoverflow.com/questions/18484647/volley-does-not-call-getparams-for-my-custom-request

getParams() is not called on the GET method, so it seems you’ll have to add it to the URL before you send the request

Categories
Fedora

360 wifi 2 做无线网卡(Linux)

360 wifi刚出来的时候,抢购几次没拿到,后面需求也不是很大,公司、家里都有无线路由器。现在公司人多了,公用的wifi网络变得超级慢,而且mac pro的网线口好像坏了,无法直接插线。琢磨了一会,在我的PC机上装个 360 wifi做 AP。开始以为可以在Linux 虚拟机的xp系统里使用,但当装驱动时,系统崩溃,放弃。Google了 360 wifi linux,发现只有两篇个链接可参考:

360 wifi 2 硬件信息情况:
[deli@violet ~]$ lsusb
Bus 002 Device 009: ID 148f:7601 Ralink Technology, Corp.

$ lspci
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

得装驱动,从MTK网站下载

tar xvf DPO_MT7601U_LinuxSTA_3.0.0.4_20130913.tar.bz2
cd DPO_MT7601U_LinuxSTA_3.0.0.4_20130913/
sudo make install
sudo modprobe mt7601Usta

su -
echo 148F 7601 > /sys/bus/usb/drivers/rt2870/new_id
exit

可以查看多了一个网卡口 ra0:

[deli@violet ~]$ ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:292 errors:0 dropped:0 overruns:0 frame:0
TX packets:292 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:22920 (22.3 KiB) TX bytes:22920 (22.3 KiB)

p2p1 Link encap:Ethernet HWaddr F4:6D:04:73:D4:A6
inet6 addr: fe80::f66d:4ff:fe73:d4a6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:66065 errors:0 dropped:0 overruns:0 frame:0
TX packets:44804 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:38222311 (36.4 MiB) TX bytes:5841642 (5.5 MiB)

ra0 Link encap:Ethernet HWaddr 00:87:36:12:0E:81
inet addr:172.30.3.30 Bcast:172.30.3.255 Mask:255.255.255.0
inet6 addr: fe80::287:36ff:fe12:e81/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144725 errors:0 dropped:0 overruns:0 frame:0
TX packets:1177 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41587475 (39.6 MiB) TX bytes:127539 (124.5 KiB)

$ ethtool -i ra0
driver: RALINK WLAN
version:
firmware-version:
bus-info: CSR 0x0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no

MT7601的Linux驱动中没有实现nl80211的接口,hostapd没法直接用。下面是尝试的过程:
我的Linux是 fedora 16,360 wifi 2, 需要对 github上的脚本做修改:
https://gist.github.com/lytsing/991ab69460587aa91aa5
$ ./ubuntu.sh ra0 p2p1 password

[deli@violet 360-wifi-linux]$ sudo hostapd ~/.360wifi/.hostapd.ra0.conf
Configuration file: /home/deli/.360wifi/.hostapd.ra0.conf
nl80211: 'nl80211' generic netlink not found
nl80211 driver initialization failed.

加载 mac80211 再试试。
[deli@violet 360-wifi-linux]$ sudo modprobe mac80211

[deli@violet 360-wifi-linux]$ sudo hostapd -dd ~/.360wifi/.hostapd.ra0.conf

Configuration file: /home/deli/.360wifi/.hostapd.ra0.conf
nl80211: Failed to set interface ra0 into AP mode
nl80211 driver initialization failed.
ELOOP: remaining socket: sock=4 eloop_data=0x9b77898 user_data=0x9b77da8 handler=0x8075380
ELOOP: remaining socket: sock=6 eloop_data=0x9b795c0 user_data=(nil) handler=0x807ef50

无解。