2014年10月17日 星期五

[android] adb shell 送 intent


ex:
    adb shell am broadcast -a android.intent.action.xxx.xxx --ez state true

ON:
settings put global airplane_mode_on 1
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true

OFF:
settings put global airplane_mode_on 0
am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false

am broadcast [--user <USER_ID> | all | current] <INTENT>

am broadcast: send a broadcast Intent.  Options are:
    --user <USER_ID> | all | current: Specify which user to send to; if not
        specified then send to all users.
    --receiver-permission <PERMISSION>: Require receiver to hold permission.


<INTENT> specifications include these flags and arguments:
    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
    [-c <CATEGORY> [-c <CATEGORY>] ...]
    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
    [--esn <EXTRA_KEY> ...]
    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]
    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]
    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]
    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]
    [-n <COMPONENT>] [-f <FLAGS>]
    [--grant-read-uri-permission] [--grant-write-uri-permission]
    [--debug-log-resolution] [--exclude-stopped-packages]
    [--include-stopped-packages]
    [--activity-brought-to-front] [--activity-clear-top]
    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
    [--activity-launched-from-history] [--activity-multiple-task]
    [--activity-no-animation] [--activity-no-history]
    [--activity-no-user-action] [--activity-previous-is-top]
    [--activity-reorder-to-front] [--activity-reset-task-if-needed]
    [--activity-single-top] [--activity-clear-task]
    [--activity-task-on-home]
    [--receiver-registered-only] [--receiver-replace-pending]
    [--selector]
    [<URI> | <PACKAGE> | <COMPONENT>]

2014年10月15日 星期三

[ubuntu] VIM 用法

選取
v 小寫

選取後可用以下方式操作:
d 刪除選取區內容。
y 複製選取區內容。


/etc/vim/vimrc
插入space取代Tab
:set expandtab

Tab = 4 space
:set tabstop=4

程式縮排需要space的個數
:set shiftwidth=4

:w 令存新檔

[ubuntu] Byobu

F2 - Create a new window
F3 - Move to previous window
F4 - Move to next window
F6 - Detach from this session
F7 - Enter copy/scrollback mode
F8 - Re-title a window
F9 - Configuration Menu
F12 - Lock this terminal

alt + page up 往上捲動視窗
alt + page down 往下捲動視窗

Q: Putty 中使用Byobu F2~F4無效 
Ans: "Terminal" -> "Keyboard" -> "The Function keys and keypad" 選用 "Xterm R6" 便可。

2014年10月14日 星期二

[android] build android error

Case 1:
out/xxxxxx/host/linux-x86/bin/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make: *** [out/xxxxxx/target/product/msm8226/obj/APPS/BackupRestoreConfirmation_intermediates/package.apk] Error 127
make: *** Deleting file `out/xxxxxx/target/product/msm8226/obj/APPS/BackupRestoreConfirmation_intermediates/package.apk'
out/xxxxxx/host/linux-x86/bin/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make: *** Waiting for unfinished jobs....
make: *** [out/xxxxxx/target/product/msm8226/obj/APPS/CalendarProvider_intermediates/package.apk] Error 127
make: *** Deleting file `out/xxxxxx/target/product/msm8226/obj/APPS/CalendarProvider_intermedackage.apk] Error 127
make: *** Deleting file `out/xxxxxx/target/product/msm8226/obj/APPS/DefaultContainerService_intermediates/package.apk'
out/xxxxxx/host/linux-x86/bin/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make: *** [out/xxxxxx/target/product/msm8226/obj/APPS/DownloadProvider_intermediates/package.apk] Error 127
make: *** Deleting file `out/xxxxxx/target/product/msm8226/obj/APPS/DownloadProvider_intermediates/package.apk'

******** Android build FAILED ********

error while loading shared libraries: libz.so.1: cannot open shared object file 安裝
$ sudo apt-get install lib32z1
正在讀取套件清單... 完成
正在重建相依關係
正在讀取狀態資料... 完成
下列【新】套件將會被安裝:
  lib32z1
升級 0 個,新安裝 1 個,移除 0 個,有 1 個未被升級。
需要下載 57.5 kB 的套件檔。
此操作完成之後,會多佔用 178 kB 的磁碟空間。
下載:1 http://tw.archive.ubuntu.com/ubuntu/ trusty/main lib32z1 amd64 1:1.2.8.dfsg-1ubuntu1 [57.5 kB]
取得 57.5 kB 用了 0s (176 kB/s)
選取了原先未選的套件 lib32z1。
(讀取資料庫 ... 目前共安裝了 214592 個檔案和目錄。)
Preparing to unpack .../lib32z1_1%3a1.2.8.dfsg-1ubuntu1_amd64.deb ...
Unpacking lib32z1 (1:1.2.8.dfsg-1ubuntu1) ...
設定 lib32z1 (1:1.2.8.dfsg-1ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.3) ...

Case 2:
host C++: aidl <= frameworks/base/tools/aidl/generate_java.cpp
host C++: aidl <= frameworks/base/tools/aidl/generate_java_binder.cpp
host C++: aidl <= frameworks/base/tools/aidl/generate_java_rpc.cpp
host C++: aidl <= out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp
out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function 'int yyparse()':
out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1947:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:2091:30: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Export includes file: frameworks/base/tools/aidl/Android.mk -- out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/export_includes
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
Notice file: frameworks/base/tools/aidl/NOTICE -- out/xxxxxx/host/linux-x86/obj/NOTICE_FILES/src//bin/aidl.txt
/bin/bash: flex: command not found
make: *** [out/xxxxxx/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
make: *** Waiting for unfinished jobs....
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

******** Android build FAILED ********

安裝
sudo apt-get install flex

Case 3:

 sudo apt-get install libxml2-utils

[ubuntu] 安裝Java 6

安裝 JDK 6

下載網址
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

$ chmod +x jdk-6u26-linux-x64.bin
$ ./jdk-6u32-linux-x64.bin
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jdk1.6.0_26 /usr/lib/jvm/

安裝
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_26/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_26/bin/java 1

設定使用版本
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java

檢查版本
$ java -version

2014年10月9日 星期四

[ubuntu] 安裝Samba

安裝samba
# sudo apt-get install samba
修改設定
#  vi /etc/samba/smb.conf 

[workspaces]
   comment = workspaces
   path = /home/aa/workspaces/
   browseable = yes
   read only = no
   create mask = 774
   valid users = aa
   admin users = aa

重啟
# sudo /etc/init.d/samba restart 
新增帳號
# sudo smbpasswd -a xxxx

[ubuntu] ssh 安裝

安裝ssh
# apt-get install ssh
# apt-get install openssh-server
修改設定
# vim /etc/ssh/sshd_config
Port 22
PasswordAuthentication yes
重啟
# /etc/init.d/ssh restart

[ubuntu] apt-get

設定proxy 
# /etc/apt/apt.conf 
    Acquire::http::Proxy "http://user:password@xxx.xxx.xxx.xxx:80"; 
source 清單 
# /etc/apt/sources.list 

[ubuntu] grep 用法

grep --help
用法: grep [選項]... 樣板 [檔案]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c

Regexp selection and interpretation:
  -E, --extended-regexp     PATTERN is an extended regular expression (ERE)
  -F, --fixed-strings       PATTERN is a set of newline-separated fixed strings
  -G, --basic-regexp        PATTERN is a basic regular expression (BRE)
  -P, --perl-regexp         PATTERN is a Perl regular expression
  -e, --regexp=PATTERN      use PATTERN for matching
  -f, --file=FILE           obtain PATTERN from FILE
  -i, --ignore-case         ignore case distinctions
  -w, --word-regexp         force PATTERN to match only whole words
  -x, --line-regexp         force PATTERN to match only whole lines
  -z, --null-data           a data line ends in 0 byte, not newline

Miscellaneous:
  -s, --no-messages         suppress error messages
  -v, --invert-match        select non-matching lines
  -V, --version             print version information and exit
      --help                display this help and exit
      --mmap                ignored for backwards compatibility

Output control:
  -m, --max-count=NUM       stop after NUM matches
  -b, --byte-offset         print the byte offset with output lines
  -n, --line-number         print line number with output lines
      --line-buffered       flush output on every line
  -H, --with-filename       print the filename for each match
  -h, --no-filename         suppress the prefixing filename on output
      --label=LABEL         print LABEL as filename for standard input
  -o, --only-matching       show only the part of a line matching PATTERN
  -q, --quiet, --silent     suppress all normal output
      --binary-files=TYPE   assume that binary files are TYPE;
                            TYPE is `binary', `text', or `without-match'
  -a, --text                equivalent to --binary-files=text
  -I                        equivalent to --binary-files=without-match
  -d, --directories=ACTION  how to handle directories;
                            ACTION is `read', `recurse', or `skip'
  -D, --devices=ACTION      how to handle devices, FIFOs and sockets;
                            ACTION is `read' or `skip'
  -R, -r, --recursive       equivalent to --directories=recurse
      --include=FILE_PATTERN  search only files that match FILE_PATTERN
      --exclude=FILE_PATTERN  skip files and directories matching FILE_PATTERN
      --exclude-from=FILE   skip files matching any file pattern from FILE
      --exclude-dir=PATTERN  directories that match PATTERN will be skipped.
  -L, --files-without-match  print only names of FILEs containing no match
  -l, --files-with-matches  print only names of FILEs containing matches
  -c, --count               print only a count of matching lines per FILE
  -T, --initial-tab         make tabs line up (if needed)
  -Z, --null                print 0 byte after FILE name

Context control:
  -B, --before-context=NUM  print NUM lines of leading context
  -A, --after-context=NUM   print NUM lines of trailing context
  -C, --context=NUM         print NUM lines of output context
  -NUM                      same as --context=NUM
      --color[=WHEN],
      --colour[=WHEN]       use markers to highlight the matching strings;
                            WHEN is `always', `never', or `auto'
  -U, --binary              do not strip CR characters at EOL (MSDOS)
  -u, --unix-byte-offsets   report offsets as if CRs were not there (MSDOS)

`egrep' means `grep -E'.  `fgrep' means `grep -F'.
Direct invocation as either `egrep' or `fgrep' is deprecated.
With no FILE, or when FILE is -, read standard input.  If less than two FILEs
are given, assume -h.  Exit status is 0 if any line was selected, 1 otherwise;
if any error occurs and -q was not given, the exit status is 2.

Report bugs to: bug-grep@gnu.org
GNU Grep home page: <http://www.gnu.org/software/grep/>
General help using GNU software: <http://www.gnu.org/gethelp/>

[ubuntu] find 指令

find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]   
    -name 檔名
        ex. find . -name "*.php"
    -i 不區分大小寫
        ex. find . -iname "*.php"
    -not
        ex. find . -not -name "*.php"
    -type
        f 檔案           
            ex. find -type f -iname "*gsm*"
        d 目錄
            ex. find -type d -iname "*gsm*"