<B:LOOP VALUES='DATA:POSTS' VAR='POST'><B:INCLUDE DATA='POST' NAME='POST'></B:INCLUDE></B:LOOP> ~ <DATA:BLOG.TITLE></DATA:BLOG.TITLE> <DATA:BLOG.PAGETITLE></DATA:BLOG.PAGETITLE>

Thứ Hai, 17 tháng 6, 2013

TẠO HIỆU ỨNG TRONG SUỐT & MỜ CHO STATUS VÀ NAVI BAR

Phần sau đây là bài viết hưởng ứng phong trào "trong suốt hóa" giao diện ROM gốc của SKY. Mặc dù viết và test riêng cho dòng 850 JB, song cũng có thể ứng dụng cho các dòng máy SKY chạy JB khác.

TẠO HIỆU ỨNG TRONG SUỐT & MỜ CHO STATUS VÀ NAVI BAR

A/ NGUYÊN LÝ BIỂU DIỄN ĐỘ TRONG, HIỆU ỨNG MỜ

Mỗi thành phần đồ họa trên Android đều được thể hiện ở 2 dạng, hoặc là file ảnh (.png) hoặc là mã màu hex (hex colour code).

Các file ảnh png, để có chế độ nền trong suốt, cần chỉnh sửa background bằng các công cụ xử lý ảnh số. Có người dùng Photoshop, người khác dùng 1 số công cụ có sẵn (ví dụ 9patch) trong bộ Android SDK.

Các thành phần đồ họa có màu sắc thể hiện bằng mã màu thì cần đổi sang mã màu trong suốt. Với tông màu đen (#ff000000), Độ trong suốt/Hiệu ứng mờ thể hiện ở dạng mã màu hex như sau:

#00000000 - Độ trong suốt 100%
#3f000000 - màu đen với độ trong suốt 75% (~ 25% hiệu ứng mờ)
#7f000000 - màu đen với độ trong suốt 50% (~ 50% hiệu ứng mờ)
#bf000000 - màu đen với độ trong suốt 25% (~ 75% hiệu ứng mờ)

Ngoài các mã trên, có thể gg để tìm thêm nhiều mã hiệu ứng mờ khác nữa.

B/ CÔNG CỤ

- Bung và đóng gói apk: Apktool v1.5.2 (hoặc bất kỳ công cụ nào có khả năng bung và đóng gói file apk Jelly Bean)
- Chỉnh sửa file xml: Notedpad ++
- Thao tác file nén và sign: 7zip
- Dexodex ROM : AutoDEOTool v1.0.4 hoặc Android Ultimate Toolbox Pro.
- Adb

C/ CHUẨN BỊ

1/ Điện thoại :
- Chạy ROM gốc mọi phiên bản. Tốt nhất nên dùng ROM chưa chỉnh sửa
- Đã root, cài sẵn adbdInsecure.apk, busybox và dexopt-wrapper để phục vụ công đoạn re-odexing

2/ Máy tính

- Cài sẵn Java Runtime Environment (JRE) trong bộ Oracle Java Development Kit.
-Deodex ROM gốc rồi lấy ra các file (deodexed): framework-res.apk; SystemUI.apk và android.policy.jar
- Chép vào cùng thư mục chứa apktool để tiện thao tác.

D/ THỰC HIỆN

ANDROID.POLICY

Tải resource vào bộ nhớ:

c:\apktool>apktool if framework-res.apk

Bung file android.policy.jar bằng lệnh sau:

c:\apktool>apktool d android.policy.jar

Tìm và mở thủ tục sau:

\com\android\internal\policy\impl\PhoneWindowManager.smali

Tìm method này:

.method public getSystemDecorRectLw(Landroid/graphics/RectI )

(….)

.end method

Xóa toàn bộ nội dung của method này (bắt đầu bằng từ khóa .method và kết thúc bằng .end method) và thay bằng đoạn sau:

.method public getSystemDecorRectLw(Landroid/graphics/RectI )
.locals 1

.parameter "systemRect"

.prologue

.line 3047

iget v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSystemLeft:I

iput v0, p1, Landroid/graphics/Rect;->left:I

.line 3048

iget v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSystemTop:I

iput v0, p1, Landroid/graphics/Rect;->top:I

.line 3049

iget v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSystemRight:I

iput v0, p1, Landroid/graphics/Rect;->right:I

.line 3050

iget v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSystemBottom:I

iput v0, p1, Landroid/graphics/Rect;->bottom:I

.line 3051

const/4 v0, 0x0

return v0

.end method

Đóng gói lại

c:\apktool>apktool b android.policy.jar.out

Cách sign file kết quả sau khi đóng gói:

Dùng 7zip mở đồng thời file android.policy.jar gốc và file vừa đóng gói (trong thư mục /android.policy.jar.out/dist/..), kéo toàn bộ thư mục META-INF từ file gốc sang file vừa đóng gói.

Re-odex file android.policy.jar

Nối điện thoại với máy tính bằng cáp microUSB.
Tạo thư mục tmp (nếu chưa có) trên bộ nhớ trong của điện thoại rồi chép file /android.policy.jar.out/dist/android.policy.jar vào thư mục đó (/sdcard/tmp). Đổi tên file trong thư mục /tmp/ thành patched_android.policy.jar.

Từ dòng lệnh, gõ (hoặc copy-paste) lần lượt từng dòng lệnh sau. Cuối mỗi dòng lệnh, nhấn Enter để thực thi.

adb devices

adb remount

adb shell

su

cp system/framework/android.policy.jar sdcard/tmp

cp -f sdcard/tmp/patched_android.policy.jar system/framework/android.policy.jar

dexopt-wrapper system/framework/android.policy.jar system/framework/patched_android.policy.odex $BOOTCLASSPATH

cp -f sdcard/tmp/android.policy.jar system/framework

chmod 777 /system/framework/android.policy.odex

chmod 777 /system/framework/android.policy.jar

chmod 777 /system/framework/patched_android.policy.odex

chmod 644 /system/framework/android.policy.jar

chown root.root /system/framework/android.policy.jar

busybox dd if=/system/framework/android.policy.odex of=/system/framework/patched_android.policy.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

cp /system/framework/patched_android.policy.odex /system/framework/android.policy.odex

(Chú ý: Đến đây điện thoại có thể khởi động lại. Hãy chờ khi máy khởi động xong vào Android mới thực thi các lệnh tiếp theo dưới đây)

adb shell

su

chmod 644 /system/framework/android.policy.odex

chown root.root /system/framework/android.policy.odex

rm /system/framework/patched_android.policy.odex

rm /data/dalvik-cache/*.dex

reboot



* SYSTEMUI

Dùng apktool bung file SystemUI.apk để sửa:

c:\apktool>apktool d SystemUI.apk

Mở file và sửa mã xml. (Chủ yếu là sửa mã màu của android:background)

Lưu ý ở các đoạn mã sửa dưới đây dùng hiệu ứng mờ 50%, tức là “#7f000000”, hoặc 75% (“#3f000000”) để minh họa. Các cụ có thể lựa chọn hiệu ứng trong suốt khác (100%; 80%; 75% v.v) tùy theo sở thích.


\SystemUI\res\layout\navigation_bar.xml

GỐC

< com.android.systemui.statusbar.phone.NavigationBarView android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="fill_parent"

SỬA

< com.android.systemui.statusbar.phone.NavigationBarView android:background="#7f000000" android:layout_width="fill_parent" android:layout_height="fill_parent"

\SystemUI\res\layout-sw600dp\navigation_bar.xml

GỐC

< com.android.systemui.statusbar.phone.NavigationBarView android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="fill_parent"

SỬA

< com.android.systemui.statusbar.phone.NavigationBarView android:background="#7f000000" android:layout_width="fill_parent" android:layout_height="fill_parent"

\SystemUI\res\values\drawables.xml

GỐC:
< item type="drawable" name="status_bar_background">#ff000000


< item type="drawable" name="status_bar_notification_row_background_color">#ff1a1a1a

< item type="drawable" name="system_bar_background">#ff000000

< item type="drawable" name="notification_icon_area_smoke">#aa000000

SỬA:
< item type="drawable" name="status_bar_background">#7f000000

< item type="drawable" name="status_bar_notification_row_background_color">#3f000000

< item type="drawable" name="system_bar_background">#7f000000

< item type="drawable" name="notification_icon_area_smoke">#3f000000


Bung file SystemUI, mở file
\SystemUI\smali\com\android\systemui\statusbar\phone\PhoneStatusBar.smali

tìm đến đoạn mã sau và sửa như dưới đây.

<<<<
Ký hiệu (+) là thêm dòng lệnh sau dấu đó, (-) là xóa bỏ dòng lệnh sau dấu đó. Các dòng lệnh khác giữ nguyên. Đoạn mã sau khi sửa xong không bao gồm ký hiệu (+)/(-). >>>>>>>>>>>


.method private getNavigationBarLayoutParams()Landroid/view/WindowManager$LayoutParams;

.locals 6

.prologue

const/4 v1, -0x1

.line 1328

new-instance v0, Landroid/view/WindowManager$LayoutParams;

const/16 v3, 0x7e7

const v4, 0x800068

(+) const/4 v5, -0x3

move v2, v1

(-) move v5, v1

invoke-direct/range {v0 .. v5}, Landroid/view/WindowManager$LayoutParams;->(IIIII)V


.line 1338


Lưu thay đổi


Mở tiếp

\SystemUI\smali\com\android\systemui\statusbar\tablet\TabletStatusBar.smali

Tìm và sửa:


.method private addStatusBarWindow()V

.locals 7

.prologue

const/4 v1, -0x1

.line 235

invoke-virtual {p0}, Lcom/android/systemui/statusbar/tablet/TabletStatusBar;->makeStatusBarView()Landroid/view/View;

move-result-object v6

.line 237

.local v6, sb:Landroid/view/View;

new-instance v0, Landroid/view/WindowManager$LayoutParams;

const/16 v3, 0x7e7

const v4, 0x800048

(+) const/4 v5, -0x3

(-) const/4 v5, 0x4

(-) move v2, v1

invoke-direct/range {v0 .. v5}, Landroid/view/WindowManager$LayoutParams;->(IIIII)V


Mở thư mục

\SystemUI\res\drawable-xhdpi

Dùng Photoshop mở 2 file ảnh này ra. Dùng tính năng Background Erase Tool để xóa nền của ảnh đi, biến nó thành 100% trong suốt.

ic_systembar_bg.png

ic_systembar_bg_land.png

(Nếu ko có Photoshop, có thể dùng phần mềm sửa ảnh số khác có chức năng tương tự)

Thường thì chỉ cần sửa 2 file trên là đủ. Tuy nhiên, nếu muốn trong suốt thanh navi3 cho mọi style, có thể sửa tương tự như trên với các file ảnh khác như sau:

ic_systembar_bg_02/03/04.png

ic_systembar_bg_land_02/03/04.png


Xong lưu thay đổi lại. Dùng công cụ apktool để đóng gói

C:\Apktool>apktool b SystemUI

Cách sign SystemUI.apk

Dùng 7zip mở đồng thời file SystemUI.apk gốc và file mới sửa trong thư mục SystemUI/dist/…

Kéo META-INF và AndroidManifest.xml từ file gốc thả sang file sửa. Chọn OK khi có hộp thoại yêu cầu xác nhận.

Chép file SystemUI/dist/SystemUI.apk vừa sign xong vào điện thoại, tạm thời cho vào thư mục /system/, set permission rw-r-r (644), owner: root.root, xong rồi tiếp tục di chuyển đè lên file cũ trong /system/app/. Xóa file SystemUI.odex đi.

Wipe dalvik cache lần nữa rồi reboot lại máy.

(Không giống như các file framework, các ứng dụng hệ thống như SystemUI.apk sau khi deodex thì không nhất thiết phải re-odex lại).

E/ CHÚ THÍCH:

- Khi test, hiệu ứng trong suốt và mờ của stt3 và navi3 phát huy đầy đủ với launcher gốc và Sony Xperia Z Launcher ở homescreen và app drawer. Với các ported launcher TouchWiz của Galaxy S4 và LG UI 3, 1 phần hiệu ứng bị mất tác dụng, hoặc với Status Bar (LG) hoặc với Navigation Bar (SS). Các launcher khác chưa thử.

- Khi chạy các ứng dụng thì thanh navi sẽ khôi phục trạng thái gốc, còn status bar không còn trong suốt mà sẽ biến màu tùy theo ứng dụng. Riêng một số ứng dụng hỗ trợ full screen như Youtube hoặc MX video player thì ok.

Vài hình minh họa

Screenshot_2013-06-02-16-45-03


Screenshot_2013-06-02-16-47-56


Screenshot_2013-06-04-23-08-25

Thứ Hai, 3 tháng 6, 2013

HƯỚNG DẪN FIX SMS 160 KÝ TỰ CHO IM-A850S/L/K

HƯỚNG DẪN FIX SMS 160 KÝ TỰ CHO IM-A850S/L/K

I/ GIỚI THIỆU
- Là cách thức patch tương đối ngắn gọn và đơn giản vào framework của Jelly Bean 4.1.2 hiện tại trên IM-A850S/L/K để nâng số ký tự SMS từ 80 lên 160. Gửi SMS được cho 1 số tổng đài SMSC và hỗ trợ mã USSD ít nhiều đã được ROM JellyBean trên IM-A850 hỗ trợ sẵn.
- Đây chưa phải là giải pháp fix hoàn chỉnh để biến SMS trên máy Hàn tương đương bản quốc tế.
- Khi áp dụng lên các dòng máy SKY khác chạy JB thì có thể thành công ngay, có thể phải chỉnh sửa thêm 1 số đoạn mã khác vì framework của các dòng máy SKY không hoàn toàn giống nhau.

II/ CÔNG CỤ
Apktool v1.5.2 : http://www.mediafire.com/?d69tpkw0lc2c081
AutoDEOTool v1.0.4 : http://www.mediafire.com/?agdozspzbb7kk6i
Notepad++ : http://notepad-plus-plus.org/download/
7zip : http://www.7-zip.org/download.html
Adb & dexopt-wrapper : http://www.mediafire.com/?i01jw1yun1eiw58
adbdInsecure : http://www.mediafire.com/?8w3d9wgezazkrq5

III/ DỰ PHÒNG
Đề phòng máy bị bootloop, trước khi chỉnh sửa framework, cần chuẩn bị dự phòng 1 trong các phương án khôi phục như sau:
- Chép file framework.jar và framework.odex gốc vào chỗ lưu trữ nào đó để khi cần copy ngược lại thư mục /system/framework/ trên điện thoại. Khi chép ngược lại thư mục system/framework, nhớ phân quyền 2 file này là rw-r-r (=644).
- Đóng gói 2 file framework.jar và framework.odex gốc thành bản patch.zip để cài qua CWM/TWRP
- Làm bản backup ROM qua CWM/TWRP recovery.

IV/ CHUẨN BỊ
A/ Máy tính
1) Cài sẵn Java Runtime Environment (JRE) trong bộ Java Development Kit.
2) Deodex framework của ROM, bằng tool AutoDEOTool v1.0.4 ở trên.
Ở đây tớ deodex sẵn framework.jar + framework.odex của IM-850K, phiên bản JB 2.12, làm nguồn minh họa. Link tải :http://www.mediafire.com/?4ghs38c20zcachc
3) Tạo thư mục làm việc (ví dụ C:-/Test), chép 3 file trong bộ apktool vào thư mục này.
4) Chép file framework.jar đã deodex vào thư mục làm việc.

B/ Điện thoại
Ở đây minh họa cho máy Vega R3 IM-A850K. Các dòng Sky khác tương tự.
a) Root máy, cài Busybox (thường cài sẵn kèm theo công cụ root). Ko có thì cài từ Play Store.
b) Chép file dexopt-wrapper vào thư mục /system/bin phân quyền permission là rw-r-r (=644). Một số bản ROM đã có sẵn busybox và dexopt-wrapper thì bỏ qua bước này.
c) Bật Settings>System>Developer’s option > USB debugging và Settings>System>Security>Unknown source.
d) Cài adbdInsecure.apk lên điện thoại. Đặt tham số cho nó như thế này.


View attachment 1141228
V/ CHỈNH SỬA
1) Bung file framework.jar.
(Windows 7). Tại thư mục làm việc, mở Command Prompt bằng tổ hợp phím Shift+ Chuột Phải, chọn Open Window Command here.
Từ Command Prompt, gõ lệnh : apktool d framework.jar

View attachment 1141229

2) Chỉnh sửa mã smali
Vào thư mục: framework.jar.out\smali\com\android\internal\telephony\gsm
Mở file smsMessage.smali bằng Notepad++, tìm đến method sau (phím tắt Ctrl+F)


.method public static calculateLength(Ljava/lang/CharSequence;Z)Lcom/android/internal/telephony/SmsMessageBase$TextEncodingDetails;

[Mã Gốc]
.line 1468
const/16 v2, 0x8c

.line 1469
add-int/lit16 v2, v0, 0x85

div-int/lit16 v2, v2, 0x86

.line 1471
iget v2, v1, Lcom/android/internal/telephony/SmsMessageBase$TextEncodingDetails;->msgCount:I

mul-int/lit16 v2, v2, 0x86

.line 1475
rsub-int v2, v0, 0x8c

[Mã sửa]
.line 1468
const/16 v2, 0xa0

.line 1469
add-int/lit16 v2, v0, 0x98

div-int/lit16 v2, v2, 0x99

.line 1471
iget v2, v1, Lcom/android/internal/telephony/SmsMessageBase$TextEncodingDetails;->msgCount:I

mul-int/lit16 v2, v2, 0x99

.line 1475
rsub-int v2, v0, 0xa0


.method public static getEncodableGsm7bitForSubmitBody(Ljava/lang/String; )Z

View attachment 1141230

Bắt đầu :

[Mã Gốc]
.line 604
invoke-static {}, Lcom/android/internal/telephony/SkyMsgConfig;->isKTVendor()Z

[Mã Sửa]
.line 604
invoke-static {}, Lcom/android/internal/telephony/SkyMsgConfig;->getVendor()I

[Gốc]
.line 605
const/16 v0, 0x80

[Sửa]
.line 605
const/16 v0, 0x86


[Gốc]
.line 607
.end local v0 #BODY_MAX_7_BIT:I
.end local v1 #IsEncodableGsm7bit:Z
.end local v3 #textPart:[B

:cond_0
const/16 v0, 0x50

[Sửa]
.line 607
.end local v0 #BODY_MAX_7_BIT:I
.end local v1 #IsEncodableGsm7bit:Z
.end local v3 #textPart:[B

:cond_0
const/16 v0, 0xa0

[Gốc]
.line 615
:try_start_0
const-string v7, "euc-kr"

[Sửa]
.line 615
:try_start_0
const-string v7, "utf-8"

[Gốc]
.line 626
invoke-static {v3, v4}, Lcom/android/internal/telephony/GsmAlphabet;->getMatchableCharForGsm([BI)Z

move-result v7

if-nez v7, :cond_1

.line 627
const/4 v1, 0x0

[Sửa]
.line 626
invoke-static {v3, v4}, Lcom/android/internal/telephony/GsmAlphabet;->getMatchableCharForGsm([BI)Z

move-result v7

if-nez v7, :cond_1

.line 627
const/4 v1, 0x1

[BỔ SUNG]

Trên Notepad++, Chọn menu Search>Find (hoặc Ctr+F)

Tìm các đoạn mã: 0x80

Sửa thành : 0x86 (hoặc 0x8c)

Sau khi chỉnh xong thì chọn Save để lưu thay đổi lại

[CHÚ THÍCH]

Mã Hex --> Decimal :
0x80 = 128
0x86 = 134
0x8c = 140
0x98 = 152
0x99 = 153
0xa0 = 160

VI/ ĐÓNG GÓI
Từ cửa sổ Command Prompt, gõ lệnh :
apktool b framework.jar.out

View attachment 1141234

VII/ SIGN
Dùng 7zip mở đồng thời file framework.jar gốc chưa chỉnh và file framework.jar đã chỉnh sửa trong thư mục \framework.jar.out\dist\ … thành 2 cửa sổ khác nhau. Kéo META-INF và preloaded-classes từ cửa sổ chứa file gốc thả sang cửa sổ chứa file chỉnh sửa, như thế này.

View attachment 1141232

Xong đóng lại.

VIII/ REODEXING
Công đoạn này yêu cầu bắt buộc phải có điện thoại. Nếu chạy từ máy tính phải nối điện thoại với máy tính qua cáp microUSB.

- Tạo thư mục có tên là tmp trên bộ nhớ trong của điện thoại (/sdcard/tmp). Thư mục này để lưu bản backup framework để khi cần có thể khôi phục lại.
- Giải nén adb.rar tải về ở mục CÔNG CỤ, được thư mục ADB. Chép file framework.jar từ thư mục \framework.jar.out\dist\... vào thư mục Adb\ .. Đổi tên file thành patched_framework.jar
- Từ thư mục Adb, mở cửa sổ Command prompt, gõ/copy-paste lần lượt từng dòng lệnh sau. Cuối mỗi dòng lệnh phải nhấn phím Enter để thực thi lệnh đó.

View attachment 1141233

adb devices

adb remount

adb push patched_framework.jar /sdcard/tmp/

adb shell

su

cp system/framework/framework.jar sdcard/tmp

cp system/framework/framework.odex sdcard/tmp

cp -f sdcard/tmp/patched_framework.jar system/framework/framework.jar

dexopt-wrapper system/framework/framework.jar system/framework/patched_framework.odex $BOOTCLASSPATH

cp -f sdcard/tmp/framework.jar system/framework

chmod 777 /system/framework/framework.odex

chmod 777 /system/framework/framework.jar

chmod 777 /system/framework/patched_framework.odex

chmod 644 /system/framework/framework.jar

chown root.root /system/framework/framework.jar

busybox dd if=/system/framework/framework.odex of=/system/framework/patched_framework.odex bs=1 count=20 skip=52 seek=52 conv=notrunc

chmod 644 /system/framework/patched_framework.odex

chown root.root /system/framework/patched_framework.odex

cp /system/framework/patched_framework.odex /system/framework/framework.odex

chmod 644 /system/framework/framework.odex

chown root.root /system/framework/framework.odex

rm /system/framework/patched_framework.odex

rm /data/dalvik-cache/*.dex

reboot


CHÚ Ý
- Nếu chạy đến đoạn mã lệnh nào mà máy tự reboot thì chờ đến khi máy khởi động xong vào Android mới chạy tiếp các lệnh còn lại.
- Có thể tạo file .bat/.sh script (chạy từ PC hoặc trên điện thoại) với các mã lệnh như trên để tự động hóa công đoạn reodex dài dòng văn tự này.

IX/ CHẠY THỬ
Dùng 1 phần mềm quản lý SMS (khác MMS.apk nguyên gốc) để test.
Nếu chạy ok à đóng gói thành bản patch cài qua CWM/TWRP hoặc chèn thẳng vào ROM.
Nếu bị lỗi FC, hoặc bootloop, thực hiện theo phương án ở phần DỰ PHÒNG.

X/ PHÁT TRIỂN
Đây là một số file khác liên quan đến SMS cần chỉnh sửa thêm để có bản fix hoàn thiện hơn.

\smali\com\android\internal\telephony\gsm\GsmSMSDispatcher.smali
\smali\com\android\internal\telephony\RIL.smali
\smali\android\telephony\SmsManager.smali
\smali\android\telephony\SmsMessage.smali

Chủ Nhật, 2 tháng 6, 2013

Hướng dẫn sử dụng adb, logcat ddms

[WIN][GUIDE]HOW TO USE ADB,DDMS AND TAKE A LOGCAT {pictorial explanation}

HOW TO USE ADB , DDMS & TAKING AN LOGCAT ..etc


WHAT IS ADB???
Quote:
EXPLANATION
Quote:
Whenever you create an android app or when you develop an Rom , it is important that you must deliver GOOD QUALITY APP or ROM , that are rid of Bugs ..Eventually you might come across a situation when your APP or ROM isn't working or it is bricking the device or some things are not working .These situation can be tackled only with a proper debugging tools ..So ADB ( android debug bridge) is a powerful Debugging tool and a tool which allows us to step through each line of code and examine the value of each variable.It offers us some of the powerful tools ..Debugging is not a big deal for the people who come from a JAVA programming background .Dalvik VM in android supports java debug wire protocol to attach to the device over ADB
Quote:
ADB

ADB or ANDROID DEBUG BRIDGE is a command-line utility that is often used to communicate over the debug channel with a connected phone or virtual device (emulator). ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more...
SETTING UP ADB :-


Quote:
Quote:
1) Install Java JDK :-
Before installing the Android SDK, you’ll have to install Oracle’s Java development kit. You can download it from here...(click me !!)

Even if you already have the Java runtime (JRE) installed, you’ll need to install the JDK as well.


After installing Java JDK , you can now download the Android SDK from Google .
NOTE:- If you see a any type of Java-related error during installation, then download and install the x86 version of the JDK, not the x64 one ..
Quote:
2) Installing android SDK:-

Download Android SDK from here...(click me !!!)

After clicking on "DOWNLOAD FOR OTHER PLATFORMS" , you will get an extended menu ..




After downloading the .exe file , then Double click on the .exe file and install it in C:\ Drive or on whichever drive you wanna install .


Quote:
Quote:
3) Android SDK Setup
Quote:
Once the Android SDK is downloaded and installed, launch the SDK Manager application from your Start menu.



Enable the Android SDK tools and SDK Platform-tools checkbox and click the Install button. This downloads and installs the platform-tools package, which contains ADB and other utilities.



After installing these packages , Go to the place where you installed ANDROID SDK . IN MY CASE , IT IS :-
Code:
C:\Program files(x86)l\Android\android-sdk\platform-tools
If you used a different install location, you’ll find ADB in the platform-tools directory,inside your ANDROID-SDK directory .



Browse to platform tools and hold Shift and right-click inside it, and select Open command window here...


Quote:
Quote:
NOW YOU WILL SEE THIS :-



Note :- To use ADB with your Android device
Quote:
Quote:
1) you must enable USB debugging on it. You’ll find this option under Developer Options on your device’s Settings screen



Quote:
2)You must install your device drivers :- Individual OEM USB drivers for windows are available for each manufacturer and are listed in the official document ..
After you have downloaded you device drivers, then we have to install on our pc. for that :-

a) connect the device to the computer
b) right click on MY COMPUTER and click manage
c) go to devices > other devices and right click on device and select update driver software.
d) you should see an option to " BROWSE MY COMPUTER FOR DRIVER SOFTWARE" , which you nedd to click on and point to the location of your device driver installation file..


To test whether ADB is working properly, connect your Android device to your computer using a USB cable and run the following command:
Code:
adb devices
Now it will show the devices connected



Now you have sucessfully installed ADB and now we are good to go further..

WHAT IS A LOGCAT :-


Logcat is the command to view the internal logs of the Android system. Viewing logs is often the best way to diagnose a problem, and is required for many issues. This way you'll find out what apps are doing in the background without you noticing.


TAKING AN LOGCAT :-

Now type this in the terminal
Code:
adb logcat -v long > logcat.txt
or

Code:
Code:
adb logcat > logcat.txt
you shall have a log file called name of logcat.txt inside your ADB folder.

Quote:
SOME OF THE USEFULL ADB COMMANDS :-

Quote:
Code:
adb install C:\package.apk
– Installs the package located at C:\package.apk on your computer on your device.
EG -adb install G:\xda.apk
Quote:
Code:
adb uninstall package.name
– Uninstalls the package with package.name from your device.
EG :- you’d use the name com.quoordy.xdadevelopers to uninstall the Xda developers app.
Quote:
Code:
adb push C:\file /sdcard/file
– Pushes a file from your computer to your device. the command here pushes the file located at C:\file on your computer to /sdcard/file on your device .
EG :-adb push G:\system\framework\framework-res.apk /system/framework
Quote:
Code:
adb pull /sdcard/file C:\file
– Pulls a file from your device to your computer – works like adb push, but in reverse. EG :-adb pull /system/app G:\rom\system\app\
Quote:
Code:
adb logcat
– View your Android device’s log. Can be useful for debugging apps.
Quote:
Code:
adb shell
– Gives you an interactive Linux command-line shell on your device.
Quote:
Code:
adb shell command
– Runs the specified shell command on your device.

The Following 23 Users Say Thank You to -MR.WORLDWIDE- For This Useful Post: [ Click to Expand ]
 
advertisement
xda-developers
Saudi Insurance Report
Download a Free Extract Here! The Latest Auto's Industry Data. BusinessMonitor.com/SaudiInsurance


 
-MR.WORLDWIDE-
Unread
(Last edited by -MR.WORLDWIDE-; 31st May 2013 at 03:27 PM.)
#2  
-MR.WORLDWIDE-'s Avatar
Member - OP
Thanks Meter 395
Posts: 84
Join Date: Mar 2013
Default DDMS

The Dalvik Debug Monitor Service (DDMS) as it is known is one of the application debugging tools that must be a part of every ANDROID app developers's toolkit..This is very very useful to the app developers.Its is a very powerful debugging tool environment and offers various unparalleled debugging features like heap information , logcat monitoring , file manager.It is available by default in ECLIPSE IDE environment or even in the ANDROID SDK.It works on top of ADB for device communication..
DDMS can be stated as a standalone application as part of ANDROID DEVICE MONITOR.The Android Device Monitor is a standalone which can be used in case you do not use the eclipse development environment , though the integration with Eclipse is something that other IDE'S could be envious of.
HOW TO USE DDMS ??
1)AS EXPLAINED IN THE ABOVE POST , INSTALL ANDROID SDK....AFTER YOU HAVE INSTALLED PLATFORM-TOOLS & SDK TOOLS..NOW GO TO ANDROID FOLDER AND OPEN TOOLS



2)NOW RUN MONITOR.bat AS ADMINISTRATOR





3)NOW ANDROID DEBUG MONITOR WILL APPEAR ..

Now let's learn about its components and it's use's

DDMS VIEW COMPONENT'S :-

DDMS offers a set of view components , each of which show relevant information related to the connected Emulator.

DEVICES :-
The device panel shows the details of each process that are running in the connected device.There are various operations that can be performed from this panel.



Each of the icons present in this panel performs the functions as follow's :
  • Debug Process Icon :- It show's the state of connection of the debugger.
  • Update Heap :-Clicking on this enables Heap information for the process so that we do not have to do memory deallocation manually.
  • Dump HPROF :- Generates a Heap Dump , useful for tracing memory leaks in your app.
  • Cause GC :-Invokes the Garbage collector to collect heap data.
  • Update thread :-Show's the information about the running thread in the thread tad for selected process
  • Start Method Profiling :- Tracks the metric's related a method. It collects information like the amount of time taken to execute a method,number of calls.
  • Stop Process :-Stops the currently selected process.
  • Screen Capture :- Takes a screenshot of whatever is displayed on the screen.
  • Reset ADB :- Ast he name suggets,it resets ADB.


THREAD'S :-
The thread tab on the right of devices view shows informatiom related to the thread for each process selected in the devices view.The information shown can described as follows.
  • ID :- A unique ID assigned to each thread dby Dalvik V,, which are only odd numbers that start from 3 .
  • Tid :-The linux thread associated with each thread , ehich matches the process ID for each main thread in a process.
  • Status :- Status of the thread in VM , out of daemons are marked with an asterix.other values can be among running?sleeping/init/starting.
HEAP
:-
the heap view show a information and statistics about memory heap .To view heap usage,follow these below steps
  1. From the devices view,select the process for heap usage which has to be examined.
  2. click on update heap
  3. From heap Tab , select Cause GC to enable collecting heap data
Everytime you need to update your heap statistics.This will show you the amount of memory allocated to each

ALLOCATION TRACKER

The allocation Tracker show a real time information about allocation happening in the application over a certain period of time.To enable allocation Tracking.

  1. select the process to be tracked from device panel
  2. click on start tracking from allocation tracker tab.
  3. perform any actions on the devices or emulator that you want to be tracked.
  4. click on Get Allocations objects, since tracking was enabled .


NETWORK STATISTICS
;-
The network tab allows you to track and optimize the amount of network data your app is using.It even allows you to tag network sockets so that you can differentiate between types of data .It will indicate the speed and amount of data received /transmitted ..

EMULATOR CONTROL :-
One problem with testing Android devices using an emulator or developer device is the fact that it is unable to examine the performance of the app in the reak world conditions . like call or SMS is received/sent or when a particular location is reached.To be specific the emulator Tab allows you to to emulate the following real world conditions :
Telephony Status :- the following options are available to set the status of phones network.
  • Voice :- unregistered,home,roaming,searching,denied.
  • Data :- unregistered,home,roaming,searching,denied.
  • Speed :- Full,GSM,HSCSD,GPRS,EDGE,UMTS,HSDPA.
  • Latency :- GPRS,UMTS
  • Telephony Actions :- Telephony actions allow you to spoof the network.
  • Location Settings ;- Emulator control allows you to sppof the location

FILE EXPLORER :-

As the name says it lets you view the directory and file structure if the device and lso easily copy files to and from the emulator so as to enable easy data transfer in a manner similiar to ADB or ADB pull command.
SYSTEM INFORMATION :-

As the name says , it give's us the particular information about the GPU load , CPU load....
DDMS HAS ALSO AN INBUILT LOGCAT VIEWER :-

Biểu mẫu liên hệ

Tên

Email *

Thông báo *