2011-07-13

android: howto dump logcat to file

adb logcat *:I -d >log.txt

*:I    all tags' log level above 'Info'
-d > log.txt    dump to file log.txt

http://developer.android.com/guide/developing/tools/adb.html#logcat

DDMS is not reliable esp. for showing very frequent log display.
If frequent log analysis is required, I use adb logcat dump instead.

2011-05-24

android: toggle stagefright

'build.prop' has a property for that.


#
# system props for the MM modules
#
media.stagefright.enable-player=true
media.stagefright.enable-meta=false
media.stagefright.enable-scan=false
media.stagefright.enable-http=true

#setprop media.stagefright.enable-player false
can turn off the stagefright and makes media player runs with opencore.

2011-05-04

android: link third party static libraries with PREBUILT_STATIC_LIBRARY

You have to declare each library as LOCAL_MODULE.
And each LOCAL_SRC_FILES should have only one .a file.

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := foo
LOCAL_SRC_FILES := libfoo.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_STATIC_LIBRARY)

And link this LOCAL_MODULE using LOCAL_STATIC_LIBRARIES

Android.mk(continue)


include $(CLEAR_VARS)

LOCAL_MODULE := bar
LOCAL_LDLIBS := -llog -ldl
LOCAL_SRC_FILES := bar.c
LOCAL_STATIC_LIBRARIES := foo

include $(BUILD_SHARED_LIBRARY)


Now libbar.so will be built with third party library libfoo.a.

For the details, see ndk docs(ANDROID-MK.html and PREBUILTS.html).


p.s. You can NOT link static library to built a new static library in ndk.

2011-04-15

PBKDF2 & symmetric crypto(such as AES)

PBKDF2(Password-Based Key Derivation Function)

salt + password -> key

salt: randomly generated #
password: passphrase
PBKDFS hashes password multiple times with salt to derive a key value.


AES-CBC


data + (IV + key) -> encrypted data
encrypted data + (IV + key) -> data




2011-03-20

android: activity's onResume vs onWindowFocusChanged



From activity.java onResume's comment:




Called after onRestoreInstanceState, onRestart, or onPause, for your activity to start interacting with the user. This is a good place to begin animations, open exclusive-access devices (such as the camera), etc.

Keep in mind that onResume is not the best indicator that your activity is visible to the user; a system window such as the keyguard may be in front. Use onWindowFocusChanged to know for certain that your activity is visible to the user (for example, to resume a game).

Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

2011-01-11

android: How to see the routing table and dns in adb shell


For checking DNS server addresses, you can use getprop, such
as:
| # getprop net.dns1
| 192.168.32.18
or, if you'd like to know the values which dhcp server
offers:
| # getprop dhcp.tiwlan0.dns1
| 192.168.32.18
You also can see dhcp supply default gateway value:
| # getprop dhcp.tiwlan0.gateway
| 192.168.32.1
You might see all property values if you exec 'getprop'
without arguments.
If you'd like to see live routing table, the easiest(but
complicated to understand) way is to see /proc/net/route.
| # cat /proc/net/route
| Iface Destination     Gateway         Flags   RefCnt  Use     Metric  Mask            MTU     Window  IRTT
| tiwlan0       0020A8C0        00000000        0001    0       0       0       00FFFFFF        0       0       0
| tiwlan0       00000000        0120A8C0        0003    0       0       0       00000000        0       0       0
The Destination '00000000' means, of course, default route
and Gateway value '0120A8C0' means '1.32.168.192' in
decimal('192.168.32.1' in reverse), so you can know what is
default gateway address is.