Friday, April 26, 2013

APK file :study : Dump/Dex2jar/Modify

Reference:
+http://www.androidguys.com/2010/12/23/modify-apk-files/

Dump the apk file: please refer to other post before.

Zip:

+ change the aaa.apk to aaa.zip, and unzip it.
after unzip it, the following is the struct



The in the folder under res\, the res\layout resource file(.xml) is the same as build. Because I just rename the *.apk file *.zip,and can unzip it. so I use winRAR to open *.apk directly, and saw the same struct as below.
classes.dex:

There is a *.dex here, after google it. I found the dex2jar project
the example is so cool! that modify the apk file.

I follow the step to compare it to the original project in the Eclipse.

I also include the bbb.jar file which generate by dex2jar.exe into the Eclipse,
as you can see when you access it, it should shows the bytecode.

Java : byteCode:
+ wiki (has example)

*.java --> *.class (byteCode)


C code:
*.o
*.so





How to dump the apk file?



adt-bundle-windows-x86-20130219\sdk\platform-tools\aapt list -a aaa.apk

res/drawable/icon.png
res/layout/face_detect_surface_view.xml
res/layout/mylistview1.xml
res/layout/sslake_ui_test.xml
res/raw/lbpcascade_frontalface.xml
AndroidManifest.xml
resources.arsc
classes.dex
lib/armeabi-v7a/libdetection_based_tracker.so
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA

Resource table:
Package Groups (1)
Package Group 0 id=127 packageCount=1 name=org.opencv.sslake.digitdetector
  Package 0 id=127 name=org.opencv.sslake.digitdetector typeCount=6
    type 0 configCount=1 entryCount=2
      spec resource 0x7f010000 org.opencv.sslake.digitdetector:attr/show_fps: flags=0x00000000
      spec resource 0x7f010001 org.opencv.sslake.digitdetector:attr/camera_id: flags=0x00000000
      config (default):
        resource 0x7f010000 org.opencv.sslake.digitdetector:attr/show_fps: <bag>
        resource 0x7f010001 org.opencv.sslake.digitdetector:attr/camera_id: <bag>
    type 1 configCount=1 entryCount=1
      spec resource 0x7f020000 org.opencv.sslake.digitdetector:drawable/icon: flags=0x00000000
      config (default):
        resource 0x7f020000 org.opencv.sslake.digitdetector:drawable/icon: t=0x03 d=0x00000004 (s=0x0008 r=0x00)
    type 2 configCount=1 entryCount=3
      spec resource 0x7f030000 org.opencv.sslake.digitdetector:layout/face_detect_surface_view: flags=0x00000000
      spec resource 0x7f030001 org.opencv.sslake.digitdetector:layout/mylistview1: flags=0x00000000
      spec resource 0x7f030002 org.opencv.sslake.digitdetector:layout/sslake_ui_test: flags=0x00000000
      config (default):
        resource 0x7f030000 org.opencv.sslake.digitdetector:layout/face_detect_surface_view: t=0x03 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f030001 org.opencv.sslake.digitdetector:layout/mylistview1: t=0x03 d=0x00000001 (s=0x0008 r=0x00)
        resource 0x7f030002 org.opencv.sslake.digitdetector:layout/sslake_ui_test: t=0x03 d=0x00000002 (s=0x0008 r=0x00)
    type 3 configCount=1 entryCount=1
      spec resource 0x7f040000 org.opencv.sslake.digitdetector:raw/lbpcascade_frontalface: flags=0x00000000
      config (default):
        resource 0x7f040000 org.opencv.sslake.digitdetector:raw/lbpcascade_frontalface: t=0x03 d=0x00000003 (s=0x0008 r=0x00)
    type 4 configCount=1 entryCount=14
      spec resource 0x7f050000 org.opencv.sslake.digitdetector:id/any: flags=0x00000000
      spec resource 0x7f050001 org.opencv.sslake.digitdetector:id/back: flags=0x00000000
      spec resource 0x7f050002 org.opencv.sslake.digitdetector:id/front: flags=0x00000000
      spec resource 0x7f050003 org.opencv.sslake.digitdetector:id/fd_activity_surface_view: flags=0x00000000
      spec resource 0x7f050004 org.opencv.sslake.digitdetector:id/textView1: flags=0x00000000
      spec resource 0x7f050005 org.opencv.sslake.digitdetector:id/linearLayout1: flags=0x00000000
      spec resource 0x7f050006 org.opencv.sslake.digitdetector:id/textView2: flags=0x00000000
      spec resource 0x7f050007 org.opencv.sslake.digitdetector:id/textView3: flags=0x00000000
      spec resource 0x7f050008 org.opencv.sslake.digitdetector:id/editText1: flags=0x00000000
      spec resource 0x7f050009 org.opencv.sslake.digitdetector:id/button1: flags=0x00000000
      spec resource 0x7f05000a org.opencv.sslake.digitdetector:id/button2: flags=0x00000000
      spec resource 0x7f05000b org.opencv.sslake.digitdetector:id/scrollView1: flags=0x00000000
      spec resource 0x7f05000c org.opencv.sslake.digitdetector:id/imageButton1: flags=0x00000000
      spec resource 0x7f05000d org.opencv.sslake.digitdetector:id/button3: flags=0x00000000
      config (default):
        resource 0x7f050000 org.opencv.sslake.digitdetector:id/any: <bag>
        resource 0x7f050001 org.opencv.sslake.digitdetector:id/back: <bag>
        resource 0x7f050002 org.opencv.sslake.digitdetector:id/front: <bag>
        resource 0x7f050003 org.opencv.sslake.digitdetector:id/fd_activity_surface_view: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050004 org.opencv.sslake.digitdetector:id/textView1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050005 org.opencv.sslake.digitdetector:id/linearLayout1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050006 org.opencv.sslake.digitdetector:id/textView2: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050007 org.opencv.sslake.digitdetector:id/textView3: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050008 org.opencv.sslake.digitdetector:id/editText1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f050009 org.opencv.sslake.digitdetector:id/button1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f05000a org.opencv.sslake.digitdetector:id/button2: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f05000b org.opencv.sslake.digitdetector:id/scrollView1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f05000c org.opencv.sslake.digitdetector:id/imageButton1: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
        resource 0x7f05000d org.opencv.sslake.digitdetector:id/button3: t=0x12 d=0x00000000 (s=0x0008 r=0x00)
    type 5 configCount=1 entryCount=1
      spec resource 0x7f060000 org.opencv.sslake.digitdetector:string/app_name: flags=0x00000000
      config (default):
        resource 0x7f060000 org.opencv.sslake.digitdetector:string/app_name: t=0x03 d=0x00000005 (s=0x0008 r=0x00)

Android manifest:
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=2)
    A: android:versionCode(0x0101021b)=(type 0x10)0x15
    A: android:versionName(0x0101021c)="2.1" (Raw: "2.1")
    A: package="org.opencv.sslake.digitdetector" (Raw: "org.opencv.sslake.digitdetector")
    E: application (line=7)
      A: android:theme(0x01010000)=@0x1030007
      A: android:label(0x01010001)=@0x7f060000
      A: android:icon(0x01010002)=@0x7f020000
      A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
      E: activity (line=12)
        A: android:name(0x01010003)="org.opencv.sslake.digitdetector.MainActivity" (Raw: "org.opencv.sslake.digitdetector.MainActivity")
        E: intent-filter (line=13)
          E: action (line=14)
            A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
          E: category (line=15)
            A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
      E: activity (line=18)
        A: android:name(0x01010003)="org.opencv.sslake.digitdetector.KUIActivity" (Raw: "org.opencv.sslake.digitdetector.KUIActivity")
      E: activity (line=20)
        A: android:label(0x01010001)=@0x7f060000
        A: android:name(0x01010003)="FdActivity" (Raw: "FdActivity")
        A: android:screenOrientation(0x0101001e)=(type 0x10)0x0
        A: android:configChanges(0x0101001f)=(type 0x11)0xa0
        E: intent-filter (line=24)
    E: supports-screens (line=34)
      A: android:anyDensity(0x0101026c)=(type 0x12)0xffffffff
      A: android:smallScreens(0x01010284)=(type 0x12)0xffffffff
      A: android:normalScreens(0x01010285)=(type 0x12)0xffffffff
      A: android:largeScreens(0x01010286)=(type 0x12)0xffffffff
      A: android:resizeable(0x0101028d)=(type 0x12)0xffffffff
    E: uses-sdk (line=40)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x8
    E: uses-permission (line=42)
      A: android:name(0x01010003)="android.permission.CAMERA" (Raw: "android.permission.CAMERA")
    E: uses-feature (line=44)
      A: android:name(0x01010003)="android.hardware.camera" (Raw: "android.hardware.camera")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=45)
      A: android:name(0x01010003)="android.hardware.camera.autofocus" (Raw: "android.hardware.camera.autofocus")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=46)
      A: android:name(0x01010003)="android.hardware.camera.front" (Raw: "android.hardware.camera.front")
      A: android:required(0x0101028e)=(type 0x12)0x0
    E: uses-feature (line=47)
      A: android:name(0x01010003)="android.hardware.camera.front.autofocus" (Raw: "android.hardware.camera.front.autofocus")
      A: android:required(0x0101028e)=(type 0x12)0x0

"<" will cause HTML format error --><


HTML: code "<":
==========================
 for(r=0;r&lt;rows;r++)
  {
   for(c=0;c&lt;cols;c++)
==========================
reference:
http://www.w3schools.com/html/html_entities.asp

+It is not possible to use the less than (<) or greater than (>) signs in your text, because the browser will mix them with tags.

+To display a less than sign we must write: &lt; or &#60;



result: it works now !
    // gray debug
       // gray debug
    // 2013/4/12: performance low
 public void RunDebug_1(Mat image)
 {
  Log.i(TAG,"+++RunDebug_1");
  
  int rows = image.rows();
  int cols = image.cols();
  
  //Log.i(TAG,"row:"+rows+"cols:"+cols);
  
  double [] d;
  int r,c;
  double g;
  
  //Log.i(TAG,"+++sslake check 1");
  for(r=0;r<rows;r++)
  {
   for(c=0;c<cols;c++)
   {
    d= image.get(r, c);
    //gray= 0.299*R+ 0.587*G + 0.114*B
    g = 0.299* d[0]+0.587*d[1] + 0.114*d[2];
    
    image.put(r,c,g,g,g,255);
    
   }
   if(r %50 ==0)
    Log.i(TAG,"+++sslake check 1 r:->"+r);
  }

 }
 //

Mayura4Ever.



+http://www.mayura4ever.com/

Online syntax highlighter like TextMate


http://markup.su/highlighter/


/*
 2nd test
*/
class DemoApp {
public static void main(String[] args)
    {
        Demo d = new Demo();
        d.printMessage();
    }
}
  
class Demo {
    String message = " this is sslake test";
      
    public void printMessage() {
        System.out.println(message);
    }
}
/*
this is sslake sample test of SyntaxHighlighter.
*/
style:iPastic-->
/*
 2nd test
*/
class DemoApp {
public static void main(String[] args)
    {
        Demo d = new Demo();
        d.printMessage();
    }
}
  
class Demo {
    String message = " this is sslake test";
      
    public void printMessage() {
        System.out.println(message);
    }
}
/*
this is sslake sample test of SyntaxHighlighter.
*/

SyntaxHighlighter


Reference:
+http://alexgorbatchev.com/SyntaxHighlighter/
+http://pydoing.blogspot.tw/2010/11/syntaxhighlighter-blogger.html


    
class DemoApp {
public static void main(String[] args)
    {
        Demo d = new Demo();
        d.printMessage();
    }
}
 
class Demo {
    String message = " this is sslake test";
     
    public void printMessage() {
        System.out.println(message);
    }
}
/*
this is sslake sample test of SyntaxHighlighter.
*/ 

Wednesday, April 24, 2013

how to install ubuntu on Macbook Air using USB Stick?



reference :
+https://help.ubuntu.com/community/How%20to%20install%20Ubuntu%20on%20MacBook%20using%20USB%20Stick

http://www.maketecheasier.com/install-dual-boot-ubuntu-in-macbook-air/2012/08/27

Step 0:
http://lifehacker.com/5934942/how-to-dual-boot-linux-on-your-mac-and-take-back-your-powerhouse-apple-hardware

Step 1:

 Install rEFit (Extensible Firmware Interface )


Step 2: install unetbootin.
unetbootin-windows-583.exe


















reference#
http://unetbootin.sourceforge.net/#other

Re-installation failed due to different application signatures.

Issue:

Re-installation failed due to different application signatures.
[2013-04-24 15:43:53 - Digit Detector] You must perform a full uninstall of the application. WARNING: This will remove the application data!
[2013-04-24 15:43:53 - Digit Detector] Please execute 'adb uninstall org.opencv.sslake.digitdetector' in a shell.
[2013-04-24 15:43:53 - Digit Detector] Launch canceled!

fixed:
need remove the apps that download from Google play,
after that can launch it from eclipse.

Tuesday, April 23, 2013

Sample code of Digit Detector

Sorry, need more time to review before upload to share to all of you.

Digit Detector in Google Play


This is my first sample program uploaded to Google play to share all of you.
The functionality of this program is try to detect the digit dynamically. kindly try it and provide your precious comments if possible. thanks.

[Background]
1.The program is implemented by using OpenCV.
2.Base on the face detector sample code in OpenCV
3.Since pixel process cost time, need calling into JNI interface to run the algorim in C/C++ code.

[How to run]
Step 1: just download it from Google play.
Step 2: move device until the digit inside middle Rect, then the result will show in right side.

[Try it]
@Google Play

[Sample code]
download