Sunday, October 23, 2011

Android Phone Call Recording - Milestone (Droid) 3

ME863 Milestone 3





Here is the working Skype for Milestone 3 / Droid 3
http://www.mediafire.com/?my50anhr2lp7ueq

Friday, October 14, 2011

Enable Display Mirroring for iPad 1

This is how to use the plutil utility


#back up K48AP.plist
cp -p /System/Library/CoreServices/SpringBoard.app/K48AP.plist /System/Library/CoreServices/SpringBoard.app/K48AP.plist.bak
#patch
plutil -key capabilities -key display-mirroring -yes /System/Library/CoreServices/SpringBoard.app/K48AP.plist
#check
plutil -key capabilities /System/Library/CoreServices/SpringBoard.app/K48AP.plist

Sunday, August 28, 2011

Sunday, August 14, 2011

How to build Android ndk sample using ant

This is a walkthrough of how to build the hello-jni sample from Android ndk after you have installed sdk and ndk. You want to use ant instead of Eclipse for building sample project.

Suppose your install paths of sdk and ndk are
~/android-sdk-mac_x86 and ~/android-ndk-r5c

Setup PATH
export PATH=${PATH}:~/android-sdk-mac_x86/tools:~/android-ndk-r5c

Please take note that for Mac OSX Mavericks, ant is no longer in Mac, just download a binary distribution of Ant from http://ant.apache.org/bindownload.cgi . Just download it, unzip/untar it, and add its bin directory to your PATH. say export PATH=${PATH}:~/apache-ant-1.9.4/bin


ndk-build
cd ~/android-ndk-r5c/samples/hello-jni
ndk-build


list target (assume sdk installed)
android list target

update project with target 1
android update project -t 1 -p .

list avd (suppose AVD4G created during sdk installation)
android list avd

start emulator
emulator -avd AVD4G -scale 0.5 &

#if you have Samsung Galaxy skin (download here)
emulator -avd AVD4G -skin GALAXY_Tab -scale 0.5 &


debug build
ant debug

install to emulator
ant debug install

use ant uninstall to remove

If you want to code-sign the binary, first create the build.properties and self-signing certificate and compile release

create build.properties

# location of the keystore. This is used by ant release
key.store= /my-path-to-mykey/my.keystore
key.alias=mykeystore


create self-signing certificate and compile release
keytool -genkey -v -keystore /my-path-to-mykey/my.keystore -alias mykeystore -keyalg RSA -keysize 2048 -validity 10000
ant release





This is how to compile C++ program with stlport in ndk


cd ~/android-ndk-r5c/samples/test-libstdc++


modify jni/test-libstl.cpp to
jni/test-libstl.cpp    Select all
#include <iostream> using namespace std; int main() {   cout << "hello, world\n";   return 0; }


create jni/Application.mk with
APP_STL := stlport_static


modify jni/Android.mk with
jni/Android.mk    Select all
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := test-libstl LOCAL_SRC_FILES := test-libstl.cpp LOCAL_LDLIBS := -llog include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_EXECUTABLE := test-libstl run:     ~/android-sdk-mac_x86/platform-tools/adb push libs/armeabi/$(LOCAL_MODULE) /data/local/bin/$(LOCAL_MODULE)     ~/android-sdk-mac_x86/platform-tools/adb shell chmod 755 /data/local/bin/$(LOCAL_MODULE)     ~/android-sdk-mac_x86/platform-tools/adb shell /data/local/bin/$(LOCAL_MODULE) # makefile requires the use of tab for the indented spaces above


run with emulator

cd ~/android-ndk-r5c/samples/test-libstdc++
ndk-build clean && ndk-build
ndk-build run


For Windows, add this PATH in environment (path should not have spaces)
C:\Android\android-sdk\tools;C:\Android\apache-ant-1.8.2\bin;C:\Android\android-ndk-r6;

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_29

and you need cygwin to start ndk-build
.
.
.

Friday, July 15, 2011

Binary strstr

strstr is a Standard C function but it cannot handle '\0'. Here is the modified version to handle binary data. The bstrstr confronts to strstr and returns char*

bstrstr Select all

char *(bstrstr)(const char *s1, size_t l1, const char *s2, size_t l2) {
/* find first occurrence of s2[] in s1[] for length l1*/
const char *ss1 = s1;
const char *ss2 = s2;
/* handle special case */
if (l1 == 0)
return (NULL);
if (l2 == 0)
return ((char *)s1);

/* match prefix */
for (; (s1 = bstrchr(s1, *s2, ss1-s1+l1)) != NULL && ss1-s1+l1!=0; ++s1) {

/* match rest of prefix */
const char *sc1, *sc2;
for (sc1 = s1, sc2 = s2; ;)
if (++sc2 >= ss2+l2)
return ((char *)s1);
else if (*++sc1 != *sc2)
break;
}
return (NULL);
}


It needs a bstrchr function as well.
bstrchr Select all

char *(bstrchr) (const char *s, int c, size_t l) {
/* find first occurrence of c in char s[] for length l*/
const char ch = c;
/* handle special case */
if (l == 0)
return (NULL);

for (; *s != ch; ++s, --l)
if (l == 0)
return (NULL);
return ((char*)s);
}


here is the testing program
bstsrstr_test.c Select all

/* bstsrstr test */
#include <stdio.h>
#include <string.h>
#include <ctype.h>

char *(bstrchr) (const char *s, int c, size_t l) {
/* find first occurrence of c in char s[] for length l*/
const char ch = c;
/* handle special case */
if (l == 0)
return (NULL);

for (; *s != ch; ++s, --l)
if (l == 0)
return (NULL);
return ((char*)s);
}

char *(bstrstr)(const char *s1, size_t l1, const char *s2, size_t l2) {
/* find first occurrence of s2[] in s1[] for length l1*/
const char *ss1 = s1;
const char *ss2 = s2;
/* handle special case */
if (l1 == 0)
return (NULL);
if (l2 == 0)
return ((char *)s1);

/* match prefix */
for (; (s1 = bstrchr(s1, *s2, ss1-s1+l1)) != NULL && ss1-s1+l1!=0; ++s1) {

/* match rest of prefix */
const char *sc1, *sc2;
for (sc1 = s1, sc2 = s2; ;)
if (++sc2 >= ss2+l2)
return ((char *)s1);
else if (*++sc1 != *sc2)
break;
}
return (NULL);
}

void printbstr(const char *s, size_t l) {
for (; l!=0 ; --l) {
printf("%c", isprint(*(s))?*(s):'.');
s++;
}
printf("\n");
}

void test(const char *s1, size_t l1, const char *s2, size_t l2) {
printf("\n");
printbstr(s1, l1);
printf("locate ");
printbstr(s2, l2);
const char *r = bstrstr(s1,l1,s2,l2);
if (!r)
printf("not found\n");
else {
printf("result ");
printbstr(r, l1-(size_t)(r-s1));
}
}

int main () {
char *s1 = "I\0am a\0manz";
size_t l1 = 11;

printf("bstrstr test\n------\n");
printbstr(s1, l1);
printf("locate \\%c:%s\n", '0', bstrchr(s1,'\0',l1));
printf("locate %c:%s\n", 'I', bstrchr(s1,'I',l1));
printf("locate %c:%s\n", 'a', bstrchr(s1,'a',l1));
printf("locate %c:%s\n", 'n', bstrchr(s1,'n',l1));
printf("locate %c:%s\n", 'i', bstrchr(s1,'i',l1));
printf("locate %c:%s\n", 'z', bstrchr(s1,'z',l1));

test(s1, l1, "a\0m", 3);
test(s1, l1, "z", 1);
test(s1, l1, "I", 1);
test(s1, l1, "am a", 4);
test(s1, l1, "anz", 3);
test(s1, l1, "ax", 2);
test(s1, l1, "\0x", 2);
test(s1, l1, " x", 2);
test(s1, l1, "\0a", 2);
test(s1, l1, "a\0m", 3);
test(s1, l1, "x", 1);
test(s1, l1, "z", 1);

return 0;
}

Wednesday, June 29, 2011

How to install GIT repo in ZyXEL NSA-320

ZyXEL NSA-320 is 1.2GHz NAS box with maximum of 2 x 2T harddisk (SATA I/II only)
The current firmware is 4.01 and is OK for the fun_plug

This box provides a very cheap alternative for the git repo plus your other storage need such as video, music download and backup as well.

You can gain telnet access following the instruction here : http://zyxel.nas-central.org/wiki/FFP-stick

and if you want to install GIT repo in this box, follow these steps.

(1) Follow the instruction here to gain telnet access, enable ssh server in the box, move the ffproot to harddisk and reboot your NAS box
http://zyxel.nas-central.org/wiki/FFP-stick

If you failed the installation, I suggest you to download this directly http://www.inreto.de/dns323/fun-plug/0.5/fun_plug.tgz and put the fun_plug.tgz in your USB stick rather than let it download during setup.

(2) install all packages (as you need most of them to build the git binary) from here
assume your server ipaddress is 192.168.0.10 and use ssh to access the NAS box

ssh root@192.168.0.10
mkdir -p /ffp/pkg
cd /ffp/pkg
rsync -av inreto.de::dns323/fun-plug/0.5/packages .
cd packages
funpkg -i *.tgz


(3) remove dns323 utilities which are not useful for NSA-320
funpkg -r dns323-utils-0.7.176-2.tgz

(4) install PERL & python
cd /ffp/pkg
wget http://www.inreto.de/dns323/fun-plug/0.5/extra-packages/perl/perl-5.10-2.tgz
wget http://www.plord.co.uk/funplug/0.5/python-2.6.4-1.tgz
funpkg -i python-2.6.4-1.tgz perl-5.10-2.tgz


(5) install the build environment
mkdir -p /i-data/md0/ffpbuildenv
cd /i-data/md0/ffpbuildenv
svn co svn://inreto.de/svn/dns323/funplug/trunk .


(6) modify the file chroot.sh to this
chroot.sh Select all

#!/ffp/bin/sh
set -x
CWD=$(pwd)
ffp=$(readlink -f /ffp)
root=/ffp-chroot
if [ -d "$root" ]; then
echo "$root exists"
exit 1
fi

mkdir -p $root
cd $root

mkdir -p ffp dev etc proc sys mnt i-data/md0
mount -t proc proc proc
mount -t sysfs sysfs sys
mount --bind /dev dev
mount --bind /etc etc
mount --bind $ffp ffp
mount --bind /i-data/md0 i-data/md0

ln -s ffp/bin bin
ln -s ffp/lib lib
ln -s ffp/sbin sbin
ln -s ffp usr
ln -s i-data/md0/ffproot/home home

chroot . $SHELL

umount i-data/md0
umount ffp
umount etc
umount dev
umount sys
umount proc

rm bin lib sbin usr home
rmdir ffp dev etc proc sys i-data/md0 mnt
rmdir i-data

cd ..
rmdir $root


(7) chroot to the build environment and get the git source and install it in NAS box

cd /i-data/md0/ffpbuildenv
sh chroot.sh
cd i-data/md0/ffpbuildenv/source
wget http://kernel.org/pub/software/scm/git/git-1.7.6.tar.bz2
tar xjvf git-1.7.6.tar.bz2
cd git-1.7.6
./configure --prefix=/ffp
NO_NSEC=YesPlease make install


(8) after installation of git, exit the build environment

exit


(9) create git repo in the box (from your desktop)

ssh root@192.168.0.10 "mkdir -p /home/root/git/yourproject.git; cd /home/root/git/yourproject.git; git --bare init; touch git-daemon-export-ok"


(10) push your project to the git repo in the NAS box (from your desktop)

cd ~/yourprojectdir
git init
git add . # include everything below ./ in the first commit;
# if you want to remove use git rm -r --cache xxx
git commit
git remote add origin ssh://root@192.168.0.10/home/root/git/yourproject.git
git push origin master


(11) If you don't want to build it. Just download this package and install it using funpkg -i git-1.7.6.tgz However, you still need to have some package dependencies like PERL & python in order to run.

.
.
.

Sunday, April 24, 2011

Install Chinese Support in Debain Squeeze

Install Unicode Fonts

su
apt-get install xfonts-intl-chinese xfonts-base unifont
apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp
apt-get install ttf-arphic-gbsn00lp ttf-arphic-gkai00mp


Reconfigure locales
Install dpkg configure
Method 1

su
apt-get install gkdebconf

Applications -> System Tools -> GKDebConf
select locales in packages


Method 2

su
/usr/sbin/dpkg-reconfigure locales


Add the followings in the locale generation

* zh_TW BIG5 - 繁體中文(台灣),使用 Big5 碼。
* zh_TW.UTF-8 UTF-8 - 繁體中文(台灣),使用 UTF-8 碼。
* zh_HK.UTF-8 UTF-8 - 繁體中文(香港),使用 UTF-8 碼。
* zh_CN GB2312 - 簡體中文,使用 GB2312-80
* zh_CN.GBK GBK - 簡體中文,使用 GBK
* zh_CN.UTF-8 UTF-8 - 簡體中文,使用 GB18030

Then choose your default locale

Done
.
.
.

Monday, March 28, 2011

Flash Player plugin old versions

I got problems for the new flash player plugin for Mac mini upgrade to 10.6.6 or 10.6.7 and here is the old version that you can get.

I have to install Flash Player 9.0.289.0

http://kb2.adobe.com/cps/142/tn_14266.html

Monday, February 7, 2011

iPhone Utilities for Mac

iPhone Explorer
http://www.macroplant.com/iphoneexplorer/

Backup Extractor
http://supercrazyawesome.com/

SQLite Database Browser
http://sourceforge.net/projects/sqlitebrowser/



Rescue Data after Recovery for Jailbreak

usbmuxd - iPhone SSH via USB
http://marcansoft.com/uploads/usbmuxd/usbmuxd-1.0.6.tar.bz2

cd usbmuxd-1.0.6/python-client
python tcprelay.py -t 22:2222 &


ssh command to recover user data partition using usbmuxd: (wait for about an hour and requires 29G for 32G iPhone)

ssh -p 2222 root@localhost dd if=/dev/rdisk0s2s1 bs=1M | dd of=iphone-user.img


ssh command to recover the system partition using usbmuxd:

ssh -p 2222 root@localhost dd if=/dev/rdisk0s1 bs=1M | dd of=iphone-root.img




To convert the raw disk image to HFS/+ dmg format (mountable by Mac), change the byte HX to H+ as below




scanning with scalpel 1.60
http://www.digitalforensicssolutions.com/Scalpel/

tar -zxvf scalpel-1.60.tar.gz
cd scalpel-1.60
make bsd
sudo mkdir -p /usr/local/bin /usr/local/etc
sudo cp -p scalpel /usr/local/bin
sudo cp -p scalpel.conf /usr/local/etc
scalpel -c scalpel.conf iphone-root.img

.
.
.

Monday, January 10, 2011

iOS 4.2 beta 3

https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__ipad__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__iphone_4__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__iphone_3gs__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__iphone_3g__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__ipod_touch_4th_generation__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__ipod_touch_3rd_generation__8c5115c.dmg
https://developer.apple.com/ios/download.action?path=/ios/ios_sdk_4.2_beta_3/ios_4.2_beta_3__ipod_touch_2nd_generation__8c5115c.dmg