2013년 8월 26일 월요일

Unzip in Java

    private ProgressDialog mProgressDialog;
    private String unzipLocation = Environment.getExternalStorageDirectory() + "/";
    private String zipFile = Environment.getExternalStorageDirectory() + "/xxx.zip";



                unzip();


        public void unzip() throws IOException {
            mProgressDialog = new ProgressDialog(MainActivity.this);
            mProgressDialog.setMessage("Please Wait...Extracting zip file ... ");
            mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            mProgressDialog.setCancelable(false);
            mProgressDialog.show();
            new UnZipTask().execute(zipFile, unzipLocation);
        }
     
        private class UnZipTask extends AsyncTask<String, Void, Boolean> {
            @SuppressWarnings("rawtypes")
            @Override
            protected Boolean doInBackground(String... params) {
                String filePath = params[0];
                String destinationPath = params[1];
                File archive = new File(filePath);
                try {
                    ZipFile zipfile = new ZipFile(archive);
                    for (Enumeration e = zipfile.entries(); e.hasMoreElements();) {
                        ZipEntry entry = (ZipEntry) e.nextElement();
                        unzipEntry(zipfile, entry, destinationPath);
                    }
                    UnZipUtil d = new UnZipUtil();
                    d.unZip(zipFile, unzipLocation);

                    } catch (Exception e) {

                    return false;
                }
                return true;
            }

            @Override
            protected void onPostExecute(Boolean result) {
                mProgressDialog.dismiss();
            }

            private void unzipEntry(ZipFile zipfile, ZipEntry entry, String outputDir) throws IOException {
                if (entry.isDirectory()) {
                    createDir(new File(outputDir, entry.getName()));
                    return;
                }

                File outputFile = new File(outputDir, entry.getName());
                    if (!outputFile.getParentFile().exists()) {
                    createDir(outputFile.getParentFile());
                }

                // Log.v("", "Extracting: " + entry);
                BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
                BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
                try {

                } finally {

                    outputStream.flush();
                    outputStream.close();
                    inputStream.close();
                }
            }

            private void createDir(File dir) {
                if (dir.exists()) {
                    return;
                }

                if (!dir.mkdirs()) {
                    throw new RuntimeException("Can not create dir " + dir);
                    }
            }
        }

        public class UnZipUtil {
            public boolean unZip(String zipFile, String ToPath) {
                InputStream is;
                ZipInputStream zis;
                try {
                    String filename;
                    is = new FileInputStream(zipFile);
                    zis = new ZipInputStream(new BufferedInputStream(is));        
                    ZipEntry ze;
                    byte[] buffer = new byte[1024];
                    int count;

                    while ((ze = zis.getNextEntry()) != null) {
                        // zapis do souboru
                        filename = ze.getName();

                        // Need to create directories if not exists, or
                        // it will generate an Exception...
                        if (ze.isDirectory()) {
                           File fmd = new File(ToPath + filename);
                           fmd.mkdirs();
                           continue;
                        }

                        FileOutputStream fout = new FileOutputStream(ToPath + filename);

                        // cteni zipu a zapis
                        while ((count = zis.read(buffer)) != -1) {
                            fout.write(buffer, 0, count);          
                        }

                        fout.close();            
                        zis.closeEntry();
                    }

                    zis.close();
                } catch(IOException e) {
                    e.printStackTrace();
                    return false;
                }

                return true;
            }
        }
    }

MD5SUM string in Java

    public static String createChecksum(String filename) throws Exception {
        InputStream fis =  new FileInputStream(filename);

        byte[] buffer = new byte[1024];
        MessageDigest complete = MessageDigest.getInstance("MD5");
        int numRead;

        do {
            numRead = fis.read(buffer);
            if (numRead > 0) {
                complete.update(buffer, 0, numRead);
            }
        } while (numRead != -1);

        fis.close();
        byte[] digest = complete.digest();
        StringBuffer sb = new StringBuffer();
        for (byte b : digest) {
            if ((int)(b & 0xff) <= 0xf)
                sb.append(Integer.toHexString(0));
            sb.append(Integer.toHexString((int) (b & 0xff)));
        }
 
        return sb.toString();
    }

2013년 8월 12일 월요일

cheapcast on ODROID

chromecast 없이 android 디바이스로 chromecast emulator 해주는 재밌는 어플이 나왔네요.
ODROID에 올려서 사용하면 딱 일 것 같아 시도 해 봤는데 연결이 원할하지 못 하네요.

https://plus.google.com/u/0/107130354111162483072/posts/bc1TZChjhRE

아래 이미지는 Galaxy Nexus에서 ODROID-XU로 Chomecast를 시도한 모습니다.





ODROID-XU의 화면



https://play.google.com/store/apps/developer?id=Sebastian+Mauer

2013년 8월 5일 월요일

ODROID-XU와 big.LITTLE

오드로이드 포럼에 Exynos5410의 big.LITTLE의 문제에 대해서 글이 하나 있습니다.
http://forum.odroid.com/viewtopic.php?f=65&t=1884

Exynos5410의 CCI-400 버그로 big.LITTLE의 클러스트 마이그레이션밖에 동작하지 않습니다. 그래서 이번에 수정되어 나온 Exynos5420과 비교하며 많은 개발자들이 아쉬워하고 있습니다.

IKS(In-Kernel Switcher)가 동작하는 CPU 마이그레이션과 클러스터 마이그레이션은 차이는 DVFS에 의해 특정 clock으로 올라가면 전체가 A15로 동작하지만 Core별로 A7과 A15를 선택적으로 동작 시킬 수 있다는 것입니다. 따라서 클러스커 마이그레이션과 달리 4개의 core가 다 A15로 동작할 필요가 없기 때문에 전력 효율이 높다는 장점이 있습니다. 하지만 big.LITTLE 설명한 것 처럼 저전력과 관련된 설계이고 오드로이드와 같이 A/C 전원이 항상들어가는 시스템에서는 아무런 의미가 없습니다.
Exynos5250은 A15 dual-core이고 Exynos5410은 A15 quad-core라 생각하시면 간단 할 것 같습니다.

물론 Exynos5420이 더 높은 clock과 GPU 성능이 높습니다. 하지막 아직 상용 제품에 출시 되지 않았습니다. 개발 보드로 나오기 위해서는 더 많은 시간이 필요할 것입니다.




big.LITTLE의 최후 목표인 MP모드는 커널의 scheduler의 재설계의 문제 이기 때문에 CCI의 버그와는 무관한 것으로 이해하고 있습니다. 아직 MP모드로의 실제 동작은 먼 얘기로 알고 있습니다.

Apple에서도 다음 CPU에 big.LITTLE을 사용하다고 합니다. Apple이야 자체 커널이 있으니 잘 해결하겠죠??? Apple의 big.LITTLE의 행보가 기대 됩니다.

참고한 사이트 입니다.
http://gamma0burst.tistory.com/m/613

bluez on ODROID-XU(Android-4.2.2)





ODROID-XU에  USB Bluetooth 가 동작합니다.

아래 소스를 기반으로 merge 하였습니다.

http://gitorious.org/android-bluez

git에서 안 받아 지시면 아래 patch를 적용해 보세요.

https://drive.google.com/file/d/0B5aZmgmqP9rORG1ZbWFIMG9wYU0/edit?usp=sharing

2013년 8월 2일 금요일

Android Multi User on ODROID-XU

ODROID-XU

The world’s first big.LITTLE architecture based bare-board computer. 
• Exynos5 Octa Cortex™-A15 1.6Ghz quad core and Cortex™-A7 quad core CPUs
• PowerVR SGX544MP3 GPU (OpenGL ES 2.0, OpenGL ES 1.1 and OpenCL 1.1 EP)
• 2Gbyte LPDDR3 RAM PoP
• USB 3.0 Host x 1, USB 3.0 OTG x 1, USB 2.0 Host x 4
• HDMI 1.4a output Type-D connector
• eMMC 4.5 Flash Storage

Android 4.2.2

device/hardkernel/odroidxu/overlay/frameworks/base/core/res/res/values/config.xml
    <!--  Maximum number of supported users -->
    <integer name="config_multiuserMaximumUsers">3</integer>











2013년 7월 31일 수요일

JNI int,String array parameter, return value

int array를 parameter로 넘겨기 예제(java->jni)

---------------------------------------------------------------------------------------
java file

public class Test {
    static {
        System.loadLibrary("test");
    }

    public static void func1(int arr[]) {
        native_func1(core);
    }

 private native static void native_func1(int arr[]);


---------------------------------------------------------------------------------------
cpp file

static void native_func1(JNIEnv* env, jobject obj, jintArray arr) {
    int size = env->GetArrayLength(arr);

    jint *value = env->GetIntArrayElements(arr, NULL);

    for (int i = 0; i < size; i++) {
        value[i] = i;
    }
 
    env->ReleaseIntArrayElements(arr, value, 0);
    return;
}

static const JNINativeMethod g_methods[] = { 
    { "native_func1", "([I)V", (void*)native_func1 }, 
}; 
  
---------------------------------------------------------------------------------------
//배열 생성 
int[] arr = new int[4];
//배열 전달
Test.func1(arr);


String array를 return value로 받기(jni->java)

---------------------------------------------------------------------------------------
java file
static jobjectArray native_func2(JNIEnv* env, jobject obj) {
    char *temp[4] = { "apple, "banana", tomato", "melon"};

    jobjectArray ret = (jobjectArray)env->NewObjectArray(4, env->FindClass("java/lang/String"),
            env->NewStringUTF(""));

    for (int i = 0; i < 4; i++) {
        env->SetObjectArrayElement(ret, i, env->NewStringUTF(temp[i]));
    }
    return ret;
}

static const JNINativeMethod g_methods[] = {
    { "native_func2", "()[Ljava/lang/String;", (jobjectArray*)native_func2 },
};


---------------------------------------------------------------------------------------
java file

public class Test {
    static {
        System.loadLibrary("test");
    }

    public static String[] func2() {
        return native_func2();
    }

    private native static String[] native_func2();



---------------------------------------------------------------------------------------
String[] str = new String[4];
str = Test.func2();

2013년 7월 29일 월요일

Ubuntu unity에서 한/영 전환키가 unity 실행키가 안되도록 하기

http://ubuntu.or.kr/viewtopic.php?p=101411

xmodmap -e 'remove mod1 = Hangul'

minicom setting for ODROID USB-UART Module Kit



install minicom

$sudo minicom -s

            +-----[configuration]------+
            | Filenames and paths      |
            | File transfer protocols  |
            | Serial port setup        |
            | Modem and dialing        |
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

Serail port setup

=================================================================

    +-----------------------------------------------------------------------+
    | A -    Serial Device      : /dev/ttyUSB0                              |
    | B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
    | D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : No                                       |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

=================================================================
                                                                             
            +-----[configuration]------+                                     
            | Filenames and paths      |                                     
            | File transfer protocols  |                                     
            | Serial port setup        |                                     
            | Modem and dialing        |                                     
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

Save setup as dfl


dev$ ls -l ttyUSB*
crw-rw---- 1 root dialout 188, 0  7월 29 12:30 ttyUSB0

minicom: Cannot open /dev/ttyUSB0: Permission denied

Just add your user to the dialout group so you have appropriate permissions on the device.

$sudo usermod -a -G dialout $USER

2013년 7월 24일 수요일

How to hide Naviation Bar.

Hide Navigation Bar.

edit build.prop
qemu.hw.mainkeys=1


or

setprop qemu.hw.mainkyes 1
killall system_server


If sdk version is API Level 11(Android 4.2.2), add setSystemUiVisibility function in your Activity.

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);


2013년 7월 18일 목요일

"couldn't install on usb storage or sd card"




Modify or delete the contents of yours SD card.


couldn't install on usb storage or sd card


Device mapper debugging message

[  193.421463] device-mapper: table: 254:0: crypt: Error allocating crypto tfm
[  193.421471] device-mapper: ioctl: error adding target to table

set Twofish cipher algorithm feature.
make menuconfig
< >   TEA, XTEA and XETA cipher algorithms
<*>   Twofish cipher algorithm
*** Compression ***



  ┌───────────────────────────────────────────────────────────────────────────────────────── Twofish cipher algorithm ──────────────────────────────────────────────────────────────────────────────────────────┐
  │ CONFIG_CRYPTO_TWOFISH:                                                                                                                                                                                      │
  │                                                                                                                                                                                                             │
  │ Twofish cipher algorithm.                                                                                                                                                                                   │
  │                                                                                                                                                                                                             │
  │ Twofish was submitted as an AES (Advanced Encryption Standard)                                                                                                                                              │
  │ candidate cipher by researchers at CounterPane Systems.  It is a                                                                                                                                            │
  │ 16 round block cipher supporting key sizes of 128, 192, and 256                                                                                                                                             │
  │ bits.                                                                                                                                                                                                       │
  │                                                                                                                                                                                                             │
  │ See also:                                                                                                                                                                                                   │
  │ <http://www.schneier.com/twofish.html>                                                                                                                                                                      │
  │                                                                                                                                                                                                             │
  │ Symbol: CRYPTO_TWOFISH [=y]                                                                                                                                                                                 │
  │ Type  : tristate                                                                                                                                                                                            │
  │ Prompt: Twofish cipher algorithm                                                                                                                                                                            │
  │   Defined at crypto/Kconfig:841                                                                                                                                                                             │
  │   Depends on: CRYPTO [=y]                                                                                                                                                                                   │
  │   Location:                                                                                                                                                                                                 │
  │     -> Cryptographic API (CRYPTO [=y])                                                                                                                                                                      │
  │   Selects: CRYPTO_ALGAPI [=y] && CRYPTO_TWOFISH_COMMON [=y]


2013년 7월 12일 금요일

Portrait HDMI for ODROID(Exynos4412)

for Exynos4412(mali)

edit build.prop and add this.

ro.sf.hwrotation=90


http://codewalkerster.blogspot.kr/2013/06/hdmi-screen-rotation-issue-for-odroid.html

edit device/samsung/exynos4/libhdmi/libhdmiservice/SecTVOutService.cpp


#include <cutils/properties.h>

void SecTVOutService::setHdmiRotate(uint32_t rotVal, uint32_t hwcLayer)
{
    //codewalker
    return;


---------------------------------------------------------------------------------------------------------




    void SecTVOutService::setHdmiStatus(uint32_t status)
    {   

        LOGD("%s HDMI cable status = %d", __func__, status);
        {   
            Mutex::Autolock _l(mLock);

            bool hdmiCableInserted = (bool)status;

            if (mHdmiCableInserted == hdmiCableInserted)
                return;

            if (hdmiCableInserted == true) {
                if (mSecHdmi.connect() == false) {
                    LOGE("%s::mSecHdmi.connect() fail", __func__);
                    hdmiCableInserted = false;
                }   
        #if 1  //yqf, 2012-6-18, keep it, first plug in cable with device landscape mode    
            else{ 
                   //added yqf, STAR00030984 & update roate value to hdmi after connect->disconnect->connect
                //codewalker
                int angle = 0;
                char value[PROPERTY_VALUE_MAX]; 
                property_get("ro.sf.hwrotation", value, NULL); 
                if (value != NULL)
                    angle = atoi(value);

                     mSecHdmi.setUIRotation(globalRotate, angle);
            if(mSecHdmi.mRotateInfoChange)
                mSecHdmi.mRotateInfoChange=false;
                    } 








2013년 7월 10일 수요일

ramdisk rootfs를 system.img에 포함 시키기

http://codewalkerster.blogspot.kr/2013/05/boot-from-system-partition-instead.html

위에 설명에 수동으로 ramdisk의 rootfs를 system에 복사하는 방법이 였습니다.

이번에는 ramdisk의 rootfs를 포함 하여 system.img를 만들어 보겠습니다.

system/core/init/Android.mk를 보면 TARGET_ROOT_OUT 변수가 out/target/product/xxx/root를 의미합니다. 그리고 out/target/product/xxx/root/init에 복사 됩니다.

그래서 전체 Android.mk에서 TARGET_ROOT_OUT를 찾아 TARGET_OUT으로 변경하면 out/target/product/xxx/system으로 복사됩니다. 하지만 코드를 여러 군데 수정 해야 합니다.
그래서 build후 copy하는 방식으로 처리 하였습니다.

build_android.sh를 수정합니다.

SYSTEMIMAGE_PARTITION_SIZE=$(grep "BOARD_SYSTEMIMAGE_PARTITION_SIZE " device/hardkernel/$SEC_PRODUCT/BoardConfig.mk | awk '{field=$NF};END{print field}')

function copy_root_2_system()
{
#root의 내용을 permission 그대로 system 폴더에 복사한다.
    cp -arp $OUT_DIR/root/* $OUT_DIR/system/

#init과 sbin/adbd를 755로 넣어도 644로 바뀌기 때문에 symbolic link 해결
#init과 adbd를 bin으로 복사합니다.
    mv $OUT_DIR/system/init $OUT_DIR/system/bin/
    mv $OUT_DIR/system/sbin/adbd $OUT_DIR/system/bin/
    cd $OUT_DIR/system
    ln -s bin/init init
    cd $OUT_DIR/system/sbin
    ln -s ../bin/adbd adbd

#make_ext4fs로 system 폴더를 system.img로 만든다.
#SYSTEMIMAGE_PARTITION_SIZE 는 BoardConfig.mk의 BOARD_SYSTEMIMAGE_PARTITION_SIZE의 값을 읽어서 설정한다.
    $OUT_HOSTBIN_DIR/make_ext4fs -s -l $SYSTEMIMAGE_PARTITION_SIZE -a system $OUT_DIR/system.img $OUT_DIR/system

    sync
}

    odroidx2)
        build_android
        copy_root_2_system
        make_uboot_img

kernel의 defconfing를 수정합니다. (ODROID-U2)

CONFIG_CMDLINE="root=/dev/mmcblk0p2 rw rootfstype=ext4 init=/init console=ttySAC1,115200n8 androidboot.console=ttySAC1 mem=2047M"

2013년 7월 9일 화요일

iperf로 android 장비 속도 측정하기

1. Ubuntu PC와 android 장비를 direct cable 연결한다.

2. Ubuntu PC의 network 설정을 확인한다.
PC의 설정을 그대로 사용할 것이다.

3. android 장비에 연결된 터미날로 ip 설정을 한다.
ifconfig eth0 192.168.10.191 up
route add default gw 192.168.10.126 dev eth0
PC의 ip에서 마지막 한자리만 1을 더한다.
여기서 gateway는 PC의 그것과 동일하게 한다.

4. pc에 iperf server를 구동한다.
[~]$ iperf -s -f M
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 0.08 MByte (default)
------------------------------------------------------------

5. android에 iPerf for Android를 설치한다.

6. iperf app의 입력란에 아래 값을 넣고 off를 toggle 한다.
-c 192.168.10.190 -P 4 -f M -w 256k -t 60

7. 결과가 아래와 같이 PC에서 출력된다.
[  8]  0.0-60.0 sec   412 MBytes  6.86 MBytes/sec
[  6]  0.0-60.0 sec   368 MBytes  6.13 MBytes/sec
[  5]  0.0-60.1 sec   420 MBytes  7.00 MBytes/sec
[  4]  0.0-60.1 sec   388 MBytes  6.45 MBytes/sec
[SUM]  0.0-60.1 sec  1588 MBytes  26.4 MBytes/sec


아래 사이트 참조 하였습니다.

http://forum.falinux.com/zbxe/index.php?document_srl=533076&mid=lecture_tip

2013년 7월 4일 목요일

Use USB GPS for ODROID

android에 외장형 USB GPS를 연결하여 보자.

아래 보이는 USB 타입 GPS는 ACM 드라이버로 붙습니다.

http://www.ascenglobal.com/info.asp?id=139

kernel에서 ACM을 추가한다.
*** USB Device Class drivers ***                                                                                                
<*>   USB Modem (CDC ACM) support
< >   USB Printer support


아래 링크에서 gps 소스를 다운 받는다.
https://www.dropbox.com/s/tp8zp5grnpis51r/libodroid-gps.tar.gz


device/hardkernel/proprietary/libodroid-gps에 압축을 푼다.


device.mk에 gps가 포함이 되도록 수정한다.
# gps
PRODUCT_PACKAGES += \
    gps.$(TARGET_PRODUCT)

BoardConfig.mk
# GPS                                                                
BOARD_HAVE_ODROID_GPS := true
BOARD_SUPPORT_EXTERNAL_GPS := true 

uevent.odroid[X].rc
 62 #for gps
 63 /dev/ttyACM0    0666    gps     gps
 64 /dev/ttyUSB0    0666    gps     gps


hardware/libhardware/hardware.c
 91     /* Check that the id matches */
 92     if (strcmp(id, hmi->id) != 0) {
 93         ALOGE("load: id=%s != hmi->id=%s", id, hmi->id);
 94         status = -EINVAL;
 95         goto done;
 96     }
 97
 98     //codewalker
 99     if(hmi->dso)
100         hmi->dso = handle;
101
102     /* success */
103     status = 0;





How to support NTFS fs with External Storage.

안드로이드의 external storage(USB Mass Storage)에 NTFS 파일 시스템을 지원하기

android_4.2.2 (BUILD_ID=JDQ39E)

storage_list.xml에 item을 추가한다.
device/hardkernel/odroid/overlay/frameworks/base/core/res/res/xml/storage_list.xml

<storage android:mountPoint="/storage/usb1"

             android:storageDescription="@string/storage_usb"
             android:primary="false"
             android:removable="true" />

USB Mass Storage를 연결 하면 발생하는 노드를 vold.fstab에 추가 한다.
device/hardkernel/odroid/conf/vold.fstab

dev_mount usb /storage/usb1 auto /devices/platform/xxx

init.odroid.rc에 node를 만든다.
device/hardkernel/odroid/conf/init.odroid.rc

mkdir /storage/usb1 0000 system system

system/vold를 수정 한다.

$ svn diff
Index: Volume.cpp
===================================================================
--- Volume.cpp (revision 21)
+++ Volume.cpp (working copy)
@@ -44,6 +44,7 @@
 #include "VolumeManager.h"
 #include "ResponseCode.h"
 #include "Fat.h"
+#include "Ntfs.h"
 #include "Process.h"
 #include "cryptfs.h"

@@ -401,7 +402,13 @@
         if (Fat::check(devicePath)) {
             if (errno == ENODATA) {
                 SLOGW("%s does not contain a FAT filesystem\n", devicePath);
-                continue;
+ if (Ntfs::doMount(devicePath, getMountpoint(), false, false, false,
+ 1000, 1015, 0702, false)) {
+ SLOGE("%s failed to mount via NTFS (%s)\n", devicePath, strerror(errno));
+ } else {
+ SLOGE("NTFS mounted");
+                 continue;
+ }
             }
             errno = EIO;
             /* Badness - abort the mount */
Index: Android.mk
===================================================================
--- Android.mk (revision 21)
+++ Android.mk (working copy)
@@ -12,6 +12,7 @@
  Process.cpp \
  Ext4.cpp \
  Fat.cpp \
+ Ntfs.cpp \
  Loop.cpp \
  Devmapper.cpp \
  ResponseCode.cpp \



Ntfs.h


  1 /*
  2  * Copyright (C) 2008 The Android Open Source Project
  3  *
  4  * Licensed under the Apache License, Version 2.0 (the "License");
  5  * you may not use this file except in compliance with the License.
  6  * You may obtain a copy of the License at
  7  *
  8  *      http://www.apache.org/licenses/LICENSE-2.0
  9  *
 10  * Unless required by applicable law or agreed to in writing, software
 11  * distributed under the License is distributed on an "AS IS" BASIS,
 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  * See the License for the specific language governing permissions and
 14  * limitations under the License.
 15  */
 16
 17 #ifndef _NTFS_H
 18 #define _NTFS_H
 19
 20 #include <unistd.h>
 21
 22 class Ntfs {
 23 public:
 24     static int doMount(const char *fsPath, const char *mountPoint,
 25                        bool ro, bool remount, bool executable,
 26                        int ownerUid, int ownerGid, int permMask,
 27                        bool createLost);
 28 };
 29
 30 #endif


Ntfs.cpp


  1 /*
  2  * Copyright (C) 2008 The Android Open Source Project
  3  *
  4  * Licensed under the Apache License, Version 2.0 (the "License");
  5  * you may not use this file except in compliance with the License.
  6  * You may obtain a copy of the License at
  7  *
  8  *      http://www.apache.org/licenses/LICENSE-2.0
  9  *
 10  * Unless required by applicable law or agreed to in writing, software
 11  * distributed under the License is distributed on an "AS IS" BASIS,
 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  * See the License for the specific language governing permissions and
 14  * limitations under the License.
 15  */
 16
 17 #include <stdio.h>
 18 #include <fcntl.h>
 19 #include <unistd.h>
 20 #include <errno.h>
 21 #include <string.h>
 22 #include <dirent.h>
 23 #include <errno.h>
 24 #include <fcntl.h>
 25
 26 #include <sys/types.h>
 27 #include <sys/stat.h>
 28 #include <sys/types.h>
 29 #include <sys/mman.h>
 30 #include <sys/mount.h>
 31
 32 #include <linux/kdev_t.h>
 33
 34 #define LOG_TAG "Vold"
 35
 36 #include <cutils/log.h>
 37 #include <cutils/properties.h>
 38
 39 #include "Ntfs.h"
 40
 41 static char FSCK_MSDOS_PATH[] = "/system/bin/fsck_msdos";
 42 static char MKDOSFS_PATH[] = "/system/bin/newfs_msdos";
 43 extern "C" int logwrap(int argc, const char **argv, int background);
 44 extern "C" int mount(const char *, const char *, const char *, unsigned long, const void *);
 45
 46 int Ntfs::doMount(const char *fsPath, const char *mountPoint,
 47                  bool ro, bool remount, bool executable,
 48                  int ownerUid, int ownerGid, int permMask, bool createLost) {
 49     int rc;
 50     unsigned long flags;
 51     char mountData[255];
 52
 53     flags = MS_NODEV | MS_NOSUID | MS_DIRSYNC;
54 
 55     flags |= (executable ? 0 : MS_NOEXEC);
 56     flags |= (ro ? MS_RDONLY : 0);
 57     flags |= (remount ? MS_REMOUNT : 0);
 58 
 59     /*
 60      * Note: This is a temporary hack. If the sampling profiler is enabled,
 61      * we make the SD card world-writable so any process can write snapshots.
 62      *
 63      * TODO: Remove this code once we have a drop box in system_server.
 64      */
 65     char value[PROPERTY_VALUE_MAX];
 66     property_get("persist.sampling_profiler", value, "");
 67     if (value[0] == '1') {
 68         SLOGW("The SD card is world-writable because the"
 69             " 'persist.sampling_profiler' system property is set to '1'.");
 70         permMask = 0;
 71     }
 72 
 73     sprintf(mountData,
 74             "utf8,uid=%d,gid=%d,fmask=%o,dmask=%o",
 75             ownerUid, ownerGid, permMask, permMask);
 76 
 77     rc = mount(fsPath, mountPoint, "ntfs", flags, mountData);
 78 
 79     if (rc && errno == EROFS) {
 80         SLOGE("%s appears to be a read only filesystem - retrying mount RO", fsPath);
 81         flags |= MS_RDONLY;
 82         rc = mount(fsPath, mountPoint, "ntfs", flags, mountData);
 83     }
 84 
 85     if (rc == 0 && createLost) {
 86         char *lost_path;
 87         asprintf(&lost_path, "%s/LOST.DIR", mountPoint);
 88         if (access(lost_path, F_OK)) {
 89             /*
 90              * Create a LOST.DIR in the root so we have somewhere to put
 91              * lost cluster chains (fsck_msdos doesn't currently do this)
 92              */
 93             if (mkdir(lost_path, 0755)) {
 94                 SLOGE("Unable to create LOST.DIR (%s)", strerror(errno));
 95             }
 96         }
 97         free(lost_path);
 98     }
 99 
100     return rc;
101 }


Ntfs는 read-only만 지원 됩니다.

shell@android:/ $ mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mmcblk0p2 /system ext4 ro,relatime,data=ordered 0 0
/dev/block/mmcblk0p4 /cache ext4 rw,nosuid,nodev,noatime,nomblk_io_submit,errors=panic,data=ordered 0 0
/dev/block/mmcblk0p3 /data ext4 rw,nosuid,nodev,noatime,nomblk_io_submit,discard,noauto_da_alloc,errors=panic,data=ordered 0 0
/sys/kernel/debug /sys/kernel/debug debugfs rw,relatime 0 0
/dev/block/vold/179:1 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 00
/dev/block/vold/179:1 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0
/dev/block/vold/179:9 /mnt/ext_sd vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 00
/dev/block/vold/8:1 /storage/usb1 ntfs ro,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,umask=0702,nls=utf8,errors=continue,mft_zone_multiplier=1 0 0
shell@android:/ $ 






2013년 6월 28일 금요일

ODROID + XBox Controller Vs. OUYA



요즘 Hot한 OUYA 입니다.

안드로이드 console 게임기죠.

아래 동영상은 ODROID-X에 XBox Controller를 연결하여 게임 하는 모습니다.



OUYA는 GMS(Google Mobile Service)를 포함하시 않고 자체 Launcher가 있습니다.

혹시나 해서 ODROID에 올려 봤는데 안되더군요.
Launcher에서 서버와 통신하여 뭔가를 확인하도록 되어 있는 것 같습니다.


Google Play store를 공식 지원하지 않는 OUYA에서 현재 게임을 Launcher에서 다운 받는지 어떻게 추가하는지 궁금하네요.

OUYA만의 독점 배포 게임이 아니라면 모든 안드로이드에도 게임들이 동작 할 것이고 ODROID가 현재는 더 나은 퍼포먼스를 보여 주고 있죠.

기회가 되면 OUYA Controller를 ODROID에 연결해서 게임을 해보고 싶네요.

어제 Google에서 Android Console을 만든다는 루머가 있었죠.


Nexus-Q가 다음은 Console로 나올까요?

2013년 6월 26일 수요일

Soft keyboard bug.

android(4.1.2)에서 USB Keyboard를 연결하고 Soft keyboard를 사용하기 위해 Physical Keyboard turn off 하면 한번 software keyboard가 동작하고 물리적 키보드를 off하여도 안되고 재부팅 해도 안되네요.안드로이드 버그 인듯 한데 재부팅해도 안되는 건 좀 심각한 문제 인 듯 합니다.

http://comments.gmane.org/gmane.comp.handhelds.android.devel/219858

1. connect usb keyboard.
2. physical keyboard turn off.
3. run soft keyboard and It works only one time.
4. set physical keyboard.
5. physical keyboard turn off.
6. does not work soft keyboard never when usb keyboard is connected.

해결책은 언어를 바꾸고 바로 Default를 선택하면 나오는 화면에서 바꿀 수 있네요.


I found a solution.Change Language and just select Default item of "KEYBOARD & INPUT METHODS" menu. and you can change state of Hardware(Physical keyboard) on/off.


1. click "Language & input"

2. click "Default"
3. Change state of Hardware(Physical keyboard) on/off.



fix this file
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java


 37 import android.view.inputmethod.InputMethodSubtype;
 38 import android.widget.CompoundButton;
 39 import android.widget.CompoundButton.OnCheckedChangeListener;
 40 import android.widget.ImageView;


141     @Override
142     public void onFinishInflate() {
143         mInputMethodMenuList = (LinearLayout) findViewById(R.id.input_method_menu_list);
144         mHardKeyboardSection = (LinearLayout) findViewById(R.id.hard_keyboard_section);
145         mHardKeyboardSwitch = (Switch) findViewById(R.id.hard_keyboard_switch);
146         mHardKeyboardSwitch.setOnCheckedChangeListener(
147             new OnCheckedChangeListener() {
148             @Override
149             public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
150                 updateHardKeyboardEnabled();
151             }
152         });
153         mConfigureImeShortcut = findViewById(R.id.ime_settings_shortcut);
154         mConfigureImeShortcut.setOnClickListener(this);
155         // TODO: If configurations for IME are not changed, do not update
156         // by checking onConfigurationChanged.
157         updateUiElements();
158     }