2012年9月25日 星期二

adb devices no permissions 的解決方法

使用adb devices 出现如下:
List of devices attached
???????????? no permissions

解决方法:
1. 找出usb vid,pid
$ lsusb      #列出usb device內容
Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 192f:0916 Avago Technologies, Pte.
Bus 003 Device 002: ID 0e8f:0022 GreenAsia Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 005: ID 18d1:4e26
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

只要插入usb device查乙次,拔出usb device查詢一次,比較差異就可以知道我們要的usb device是哪一個。
如:
Bus 003 Device 002: ID 0e8f:0022 GreenAsia Inc.
其中的0e8f就是vid,0022就是pid.

2. 編輯權限
sudo vim /etc/udev/rules.d/70-android.rules
加入以下內容
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e8f", ATTRS{idProduct}=="0022",MODE="0666" 

3. 重新啟動 udev service
sudo chmod a+rx /etc/udev/rules.d/70-android.rules 
sudo service udev restart 

4. 重新啟動 adb
sudo ./adb kill-server 
$ ./adb devices

完成

2012年9月18日 星期二

UML中的關聯


class之間的關係有以下幾種
1. Association / 關聯 / knows a
X知道Y的存在
X可能以pointer(指標)或reference(參考)知道Y的存在
在概念模型階段方向性(箭頭)通常不太有意義可以省略

2. Dependency / 相依 / use a
A dependency exists between two elements if changes to the definition of one element (the supplier) may cause changes to the other (the client).
X相依Y
Y若改變 X可能會受到影響 但X的改變不會影響到Y
X可能有某個function可以call Y的function
舉個例子:
有一個 class Circle,提供 drawCircle 的功能,然 drawCircle 內部是使用 java 的 graphic 來實作繪圖。則我們可以說:Circle use a graphic. 也就是 Circle 相依於 graphic.

3. Composition / 組合 / has a
car 組合 wheel
Composition是一種整體完全擁有部分
如車子(car)擁有4個輪子(wheel)
當車子(car)消滅時4個輪子(wheel)同時也會消滅

4. Aggregation / 聚合
car 聚合 passenger
Aggregation是一種"擁有性"比較弱的關係
如:
車子(car)裡面有4個人(passenger)
當車子(car)消滅時4個人(passenger)不會消滅

Composition跟Aggregation在意義的差異在於:
Composition是『同生共死』,當System物件死亡時,Component物件也要跟著死亡。Aggregation是『生死有命』,當System物件死亡時,Component物件並不特別去處理。
在C#、Java這類有garbage collection的語言,composition幾乎不會用到,但在C++,只要用到pointer,就得自己去delete,所以在composition對於C++就很重要。


再舉個例子,(from wiki)
a university owns various departments (e.g., chemistry), and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors. In addition, a Professor could work in more than one department, but a department could not be part of more than one university.

5. Inheritance / 繼承 (UML以繼承表示泛型關係)
X繼承Z,Y繼承Z,此時Z和X,Y之間就存在著泛型關係。
Z是共同化(抽象化),X/Y則是特性化(具體化)
如:
BMW / Benz 繼承Car,則Car和BMW / Benx就存在泛型關係