トラッキング コード

7/18/2012

Starting for Android JUnit Test

If you would like to publish application to Google Market, I recommend that you test.
Android has test framework which helping you to test .

Check develoer's site!!

http://developer.android.com/tools/testing/index.html
The Android framework includes an integrated testing framework that helps you test all aspects of your application and the SDK tools include tools for setting up and running test applications. Whether you are working in Eclipse with ADT or working from the command line, the SDK tools help you set up and run your tests within an emulator or the device you are targeting.
If you aren't yet familiar with the Android testing framework, start by reading Testing Fundamentals. For a step-by-step introduction to Android testing, try the Activity Testing Tutorial.

How to set up Project for eclipse:

http://developer.android.com/tools/testing/testing_android.html

7/01/2012

Phone mode or Tablet mode in Android 4.1 Jelly Bean?




Android 4.1 Jelly Bean has Phone UI Mode and Tablet UI Mode, so same ICS.
How to change Phone / Tablet in Android Frameworks ?

If you have Android SDK Api 16, you can notice source code!!

Definition of UI Mode

Check in PhoneWindowManager#setInitialDisplaySize.

\sources\android-16\com\android\internal\policy\impl\PhoneWindowManager.java

        // SystemUI (status bar) layout policy
        int shortSizeDp = shortSize
                * DisplayMetrics.DENSITY_DEFAULT
                / DisplayMetrics.DENSITY_DEVICE;

        if (shortSizeDp < 600) {
            // 0-599dp: "phone" UI with a separate status & navigation bar
            mHasSystemNavBar = false;
            mNavigationBarCanMove = true;
        } else if (shortSizeDp < 720) {
            // 600-719dp: "phone" UI with modifications for larger screens
            mHasSystemNavBar = false;
            mNavigationBarCanMove = false;
        } else {
            // 720dp: "tablet" UI with a single combined status & navigation bar
            mHasSystemNavBar = true;
            mNavigationBarCanMove = false;
        }

        if (!mHasSystemNavBar) {
            mHasNavigationBar = mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_showNavigationBar);
            // Allow a system property to override this. Used by the emulator.
            // See also hasNavigationBar().
            String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
            if (! "".equals(navBarOverride)) {
                if      (navBarOverride.equals("1")) mHasNavigationBar = false;
                else if (navBarOverride.equals("0")) mHasNavigationBar = true;
            }
        } else {
            mHasNavigationBar = false;
        } 
PhoneWindowManager has been changed from ICS.
Tablet UI mode need 720dp!!

4/01/2012

Getting the Factory Image 4.0.4(IMM76D) of Galaxy Nexus(maguro)




You can get the Factory Image of Galaxy Nexus.

Google Support for Nexus Phones and Flagship Devices.
 http://code.google.com/intl/ja/android/nexus/images.html


Example of 4.0.4 (IMM76D) maguro

wget https://dl.google.com/dl/android/aosp/yakju-imm76d-factory-c6e807a1.tgz
tar xvf ./yakju-imm76d-factory-c6e807a1.tgz
cd yakju-icl53f
./flash-all.sh

3/30/2012

Update to Android 4.0.4 for Nexus S and Galaxy Nexus

Rolling out Android 4.0.4 for Nexus S and Galaxy Nexus!

We can download the ota update zip file from following link.

Galaxy Nexus (maguro / GSM )
http://android.clients.google.com/packages/ota/google_maguro/7f97fbc19417.signed-yakju-IMM76D-from-ICL53F.7f97fbc1.zip

Nexus S (i9020t/i9023)
http://android.clients.google.com/packages/ota/google_crespo/hR7QFEtn.zip

If getting a Status 7 error, you should see this.

3/11/2012

How to use Google Test on Android-4.0.3_r1

AOSP has Google Test project in extarnal/gtest directory.

I try to use Google Test in my Application.

Create Android.mk for Google Test

I was referring to the existing Android.mk in extarnal/gtest/test.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

# Gtest depends on STLPort which does not build on host/simulator.

ifeq ($(BUILD_WITH_ASTL),true)
libgtest_test_includes := \
    bionic/libstdc++/include \
    external/astl/include \
    external/gtest/include \
 $(LOCAL_PATH)/../test \
 $(LOCAL_PATH)/..
libgtest_test_static_lib := libgtest_main libgtest libastl
libgtest_test_shared_lib :=
libgtest_test_host_static_lib := libgtest_main_host libgtest_host libastl_host
libgtest_test_host_shared_lib :=
else
# BUILD_WITH_ASTL could be undefined, force it to false (for the guard
# before the test-target call).
BUILD_WITH_ASTL := false
libgtest_test_includes := \
    bionic \
    external/stlport/stlport \
    external/gtest/include \
 $(LOCAL_PATH)/../test \
 $(LOCAL_PATH)/..
libgtest_test_static_lib := libgtest_main libgtest
libgtest_test_shared_lib := libstlport
libgtest_test_host_static_lib :=
libgtest_test_host_shared_lib :=
endif


LOCAL_MODULE_TAGS := TestAppGtest
LOCAL_C_INCLUDES := $(libgtest_test_includes)

LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libutils \
    libandroid_runtime \
    $(libgtest_test_shared_lib) \
    $(libgtest_test_host_shared_lib)

LOCAL_STATIC_LIBRARIES := \
    $(libgtest_test_static_lib) \
    $(libgtest_test_host_static_lib)

# if LOCAL_SRC_FILES is .cc
#LOCAL_CPP_EXTENSION := .cc

# YOUR Source and Test Source
LOCAL_SRC_FILES := \
    sample1.cpp \
    sample1_unittest.cpp

LOCAL_MODULE := gtest_mytest
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)

include $(BUILD_EXECUTABLE)


Building Google Test

I try to build an apllicaion with google test code.

I uploaded sample project.
https://docs.google.com/open?id=0BwdCdBWuE_7cb2ZzVGt3eHhSOEtEbGVxNnRCSkFJdw

$ cd "YOUR_BUILD_DIRECTORY"
$  . build/envsetup.sh
$ lunch "YOUR_BUILD_LUNCH"
$ make
$ cd packages/apps/
$ cd TestApp
$ mm -B


If building success , executable file is created.
target thumb C++: gtest_mytest <= packages/apps/TestApp/jni/test/sample1.cpp
target thumb C++: gtest_mytest <= packages/apps/TestApp/jni/test/sample1_unittest.cpp
target Executable: gtest_mytest (out/target/product/maguro/obj/EXECUTABLES/gtest_mytest_intermediates/LINKED/gtest_mytest)
target Symbolic: gtest_mytest (out/target/product/maguro/symbols/data/app/gtest_mytest)
target Strip: gtest_mytest (out/target/product/maguro/obj/EXECUTABLES/gtest_mytest_intermediates/gtest_mytest)
Install: out/target/product/maguro/data/app/gtest_mytest

Running Google Test

I try to run Google Test on Galaxy Nexus. My Galaxy Nexus is flashed Android-4.0.3_r1. Copy to executable file.
cd out/target/product/maguro/
$ adb push data/app/gtest_mytest /data/app
2870 KB/s (48728 bytes in 0.016s)
Running test using ADB.
$ adb shell
root@android:/ # cd data/app                                                   
root@android:/data/app # ./gtest_mytest    
Success to run, The test results are displayed.
root@android:/data/app # ./gtest_mytest                                        
Running main() from gtest_main.cc
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero
[ RUN      ] FactorialTest.Positive
[       OK ] FactorialTest.Positive
[----------] 3 tests from IsPrimeTest
[ RUN      ] IsPrimeTest.Negative
[       OK ] IsPrimeTest.Negative
[ RUN      ] IsPrimeTest.Trivial
[       OK ] IsPrimeTest.Trivial
[ RUN      ] IsPrimeTest.Positive
[       OK ] IsPrimeTest.Positive
[----------] Global test environment tear-down
[==========] 6 tests from 2 test cases ran.
[  PASSED  ] 6 tests.

3/10/2012

Create PreferenceActivity with header and Footer.







We can create PreferenceActivity with header and Fotter.

We shoud make following files and call method.
  1. Create Layout with ListView.
  2. Create Preference XML.
  3. Call setContentView() and addPreferencesFromResource() in onCreate().


Create Layout with ListView

Make layout xml file , to set PreferenceActivity#setContentView().
It must have ListView with android:id="@+id/android:list".

you shoud add android:layout_height="0.0dp"and android:layout_weight="1" to ListView, because to show footer in bottom


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <!-- Header  -->

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Header"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

    <!-- Show Preference in ListView  -->

    <ListView
        android:id="@+id/android:list"
        android:layout_width="match_parent"
        android:layout_height="0.0dp"
        android:layout_weight="1" >
    </ListView>

    <!-- Footer -->

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Footer"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

</LinearLayout>


Create Preference XML

Create Preference XML.
Sample.

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

    <CheckBoxPreference
        android:key="checkbox_preference"
        android:summary="summary_checkbox_preference"
        android:title="checkbox_preference" />

    <EditTextPreference
        android:dialogTitle="dialog_title_edittext_preference"
        android:key="edittext_preference"
        android:summary="summary_edittext_preference"
        android:title="title_edittext_preference" />

    <PreferenceScreen
        android:summary="intent_preference"
        android:title="intent_preference" >
        <intent
            android:action="android.intent.action.VIEW"
            android:data="http://www.android.com" />
    </PreferenceScreen>

</PreferenceScreen>


Call setContentView() and addPreferencesFromResource() in onCreate()

You must call setContentView(YOUR_LAYOUT_WIHT_HEADER_FOOTER_ID).

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        addPreferencesFromResource(R.xml.pref);
    }

3/06/2012

Add WPAN project in AOSP master

When I done "repo sync", added WPAN project in AOSP master.

From https://android.googlesource.com/platform/hardware/ti/wpan
* [new branch]      master     -> master

You need to read Android Building.
wpan project for Panda Bluetooth
http://groups.google.com/group/android-building/browse_thread/thread/b07552678a1829f0?pli=1


Wikipedia:http://en.wikipedia.org/wiki/Personal_area_network

WPAN is "Wireless Personal Area Network".This Network is smaller than WLAN.
Include Bluetooth,WiFi,ZigBee.