항상 최상위에 나오는 뷰 만들기2 (팝업 비디오 + Q슬라이드)

[출처 : http://blog.daum.net/mailss/35]

이전에 쓴 글 '항상 최상위에 나오는 뷰 만들기'는 뷰는 나오지만 터치 이벤트를 받지 못했다. 터치 이벤트를 받더라도 ACTION_OUTSIDE 이벤트만 받을 수 있었다.


이제는 그냥 최상위 뷰만 나오게 하는 것이 아니라 뷰를 최상위에 나오게 하면서 모든 터치 이벤트를 받아보자. 터치로 뷰를 이동해보고(갤럭시의 팝업 비디오 처럼) 투명도를 조절해보자!!(옵티머스의 Q슬라이드)


이전에 쓴 '항상 최상위에 나오는 뷰 만들기' 와 방식은 같다.

1. 최상위에 나오게 하기 위해서는 Window에 뷰는 넣는다.

2. 다른 화면에서도 나오게 하기위해서는 서비스에서 뷰를 생성하여야 한다.

3. 뷰에 들어오는 터치 이벤트를 OnTouchListener를 통해서 받는다.


1. 서비스 생성

자신의 앱이 종료된 후에도 항상 해당 뷰가 떠 있어야 한다. 그래서 Activity에서 뷰를 추가하는 것이 아니라 Service에서 뷰를 추가 해야 한다.


AlwaysOnTopService.java

public class AlwaysOnTopService extends Service {
    @Override
    public IBinder onBind(Intent arg0) { return null; }
    
    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}


2. 뷰 생성 및 최상위 윈도우에 추가

간단하게 텍스트뷰 하나 추가하는 코드이다.

    private TextView mPopupView;                            //항상 보이게 할 뷰
    private WindowManager.LayoutParams mParams;  //layout params 객체. 뷰의 위치 및 크기
    private WindowManager mWindowManager;          //윈도우 매니저

    @Override
    public void onCreate() {
        super.onCreate();

        mPopupView = new TextView(this);                                         //뷰 생성
        mPopupView.setText("이 뷰는 항상 위에 있다.");                        //텍스트 설정
        mPopupView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); //텍스트 크기 18sp
        mPopupView.setTextColor(Color.BLUE);                                  //글자 색상
        mPopupView.setBackgroundColor(Color.argb(127, 0, 255, 255)); //텍스트뷰 배경 색

        //최상위 윈도우에 넣기 위한 설정
        mParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,//항상 최 상위. 터치 이벤트 받을 수 있음.
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,  //포커스를 가지지 않음
            PixelFormat.TRANSLUCENT);                                        //투명
        mParams.gravity = Gravity.LEFT | Gravity.TOP;                   //왼쪽 상단에 위치하게 함.
        
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);  //윈도우 매니저
        mWindowManager.addView(mPopupView, mParams);      //윈도우에 뷰 넣기. permission 필요.
    }


 이전 글에서는 TYPE을 TYPE_SYSTEM_OVERLAY로 주었다. 이러면 화면 전체를 대상으로 뷰를 넣지만 터치 이벤트를 받지는 못한다.

 하지만 TYPE을 TYPE_PHONE으로 설정하면 터치 이벤트를 받을 수 있다. 하지만 Status bar 밑으로만 활용가능하고 뷰가 Focus를 가지고 있어 원래 의도대로 뷰 이외의 부분에 터치를 하면 다른 앱이 터치를 사용해야 하는데 이것이 불가능 하고 키 이벤트 까지 먹어 버린다.

 이것을 해결하기 위해 FLAG 값으로 FLAG_NOT_FOCUSABLE을 주면 뷰가 포커스를 가지지 않아 뷰 이외의 부분의 터치 이벤트와 키 이벤트를 먹지 않아서 자연스럽게 동작할 수 있게 된다.


3. 매니페스트에 퍼미션 설정

WinodwManager에 addView 메소드를 사용하려면 android.permission.SYSTEM_ALERT_WINDOW 퍼미션이 필요하다.


<manifest  ................ >
    <application ................ >
        <activity
           ................
        </activity>
        <service 
           ................
        </service>
    </application>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-sdk android:minSdkVersion="7" />
</manifest>


이전 글에는 service 태그 안에 퍼미션을 주라고 했지만 service에 주지 않아도 된다. 그냥 uses-permission을 주면 된다.


4. 터치 이벤트 받기

뷰에 터치 리스너를 등록하면 터치 이벤트를 받을 수 있다.


mPopupView.setOnTouchListener(mViewTouchListener);              //팝업뷰에 터치 리스너 등록


private OnTouchListener mViewTouchListener = new OnTouchListener() {
    @Override public boolean onTouch(View v, MotionEvent event) {
        switch(event.getAction()) {
            case MotionEvent.ACTION_DOWN:                //사용자 터치 다운이면
                if(MAX_X == -1)
                    setMaxPosition();
                START_X = event.getRawX();                    //터치 시작 점
                START_Y = event.getRawY();                    //터치 시작 점
                PREV_X = mParams.x;                            //뷰의 시작 점
                PREV_Y = mParams.y;                            //뷰의 시작 점
                break;
            case MotionEvent.ACTION_MOVE:
                int x = (int)(event.getRawX() - START_X);    //이동한 거리
                int y = (int)(event.getRawY() - START_Y);    //이동한 거리
                
                //터치해서 이동한 만큼 이동 시킨다
                mParams.x = PREV_X + x;
                mParams.y = PREV_Y + y;
                
                optimizePosition();        //뷰의 위치 최적화
                mWindowManager.updateViewLayout(mPopupView, mParams);    //뷰 업데이트
                break;
        }
        
        return true;
    }
};


터치로 뷰를 이동하거나 크기 조절을 하려면 WindowManager.LayoutParams 객체의 값을 변경해 주면 된다. x, y는 뷰의 시작점 좌표이다. Q슬라이드 처럼 투명도 조절은alpha값을 변경하면 된다. 0~1사의 값을 넣어 주면 된다.

이렇게 WindowManager.LayoutParams의 값을 변경해준 다음 WindowManager의 updateViewLayout메소드를 사용하여 뷰의 변경사항을 적용한다.



5. 뷰 제거

서비스 종료시 뷰를 제거 해야 한다.

    @Override
    public void onDestroy() {
        if(mWindowManager != null) {        //서비스 종료시 뷰 제거. *중요 : 뷰를 꼭 제거 해야함.
            if(mPopupView != null) mWindowManager.removeView(mPopupView);
            if(mSeekBar != null) mWindowManager.removeView(mSeekBar);
        }
        super.onDestroy();
    }


6. 서비스 실행/중지 할 activity 만들기

AlwaysOnTopActivity.java


public class AlwaysOnTopActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        findViewById(R.id.start).setOnClickListener(this);        //시작버튼
        findViewById(R.id.end).setOnClickListener(this);            //중시버튼
    }
    
    @Override
    public void onClick(View v) {
        int view = v.getId();
        if(view == R.id.start)
            startService(new Intent(this, AlwaysOnTopService.class));    //서비스 시작
        else
            stopService(new Intent(this, AlwaysOnTopService.class));    //서비스 종료
    }
}


실행 결과


 앱 시작뷰 추가 바탕화면 (위치 이동)

 동영상 재생
 Dragon Flight 게임
인터넷 (투명값 변경)




 AlwaysOnTop.zip

전체 샘플 코드 첨부하였습니다.

1.     Multipart Message 종류

Message

정의

Mixed

다른 Content-type 헤더를 갖는 파일을 전송하는데 사용.

메일 클라이언트가 읽기 쉬운 포맷일 경우는 바로 표시고, 그렇지 않으면 첨부파일 형태로 표시.

메일 클라이언트에서 지원해야 할 MIME typetext/plain

Digest

하나 이상의 메시지 포워드시 사용

Message/rfc822

메일 클라이언트에서 지원해야 할 MIME type.

Alternative

동일한 내용을 다른 형식으로 표현 할 때 사용.

Related

상호 연관된 여러 개의 파트로 구성.

HTML 같은 문서에서 이미지 참조 할 때 뒤따르는 파트를 내부에서 참조.

Report

이 메시지 타입은 text/plain message/delivery-status로 나뉨.

Signed

본문과 서명 포함을 뜻함.

Encypted

메시지 타입 암호화

Application/octet-stream와 이를 풀기 위한 제어파트로 구분.

Form-data

파일, 비아스키, 데이터, 이진수 데이터 등을 전송할 때 사용.

 

2.     Content-type : multipart/form-data를 이용한 파일 전송.

장점 : GET POST 보다 더 많은 데이터를 전송할 수 있고, 여러 개의 파일을 한꺼번에 보낼 수 있음.

조건 : multipart/form-data로 전송할 시에는 boundary를 지정해 주어야 함.

      Boundary는 지정된 규칙은 존재하지 않음. 단지 맨 마지막 부분에 [Boundary ]—식으로 하이픈[-]

      두 개 넣어줘야 함.

헤더 구성

è  Content-type: multipart/form-data, boundary=12345 [Boundary ]

바디 구성

è  --12345 [Boundary]

è  Content-Diposition:form-data; name=”abc” [파라미터 이름]

è  0000 [파라미터 값]

è  --12345 [Boundary]

è  Content-Diposition:form-data; name=”attach_file_name” [파라미터 이름]; filename=”c:\test\123.jpg” [파일 경로]

è  Content-type: image/jpeg

è  Content-Transfer-Encoding : binary

è  ….[파일 바이너리]

è  --12345 [Boundary]--

 

Body에서의 각각의 파라미터에서의 Content-Disposition Content-type은 헤더 부분과 바디 부분으로 작게 나눠지게 됨.[헤더부분은 파라미터의 속성을 뜻하고, 바디 부분은 데이터의 유형을 나타냄.]

 

Content-Transfer-EncodingDefault Encoding(7BIT)과 일치하지 않으면 헤더에서 제공되어야 함.

종류 : 7bit, 8bit, binary, quoted-printable, base64, ietf-token, x-token

참조 : [RFC2045 http://www.ietf.org/rfc/rfc2045.txt]

 

Content-disposition : 컨텐트 타입의 옵션이기도 하면서, 실제로 지정된 파일명을 지정함으로써 더 자세한

 파일의 속성을 알려줄 수 있음.

disposition := "Content-Disposition" ":"

                    disposition-type

                    *(";" disposition-parm)

 

     disposition-type := "inline"

                       / "attachment"

                       / extension-token

                       ; values are not case-sensitive

 

     disposition-parm := filename-parm

                       / creation-date-parm

                       / modification-date-parm

                       / read-date-parm

                       / size-parm

                       / parameter

 

     filename-parm := "filename" "=" value

 

     creation-date-parm := "creation-date" "=" quoted-date-time

 

     modification-date-parm := "modification-date" "=" quoted-date-time

 

     read-date-parm := "read-date" "=" quoted-date-time

 

     size-parm := "size" "=" 1*DIGIT

 

     quoted-date-time := quoted-string

                      ; contents MUST be an RFC 822 `date-time'

                      ; numeric timezones (+HHMM or -HHMM) MUST be used

   Inline : 브라우저 인식 파일 확장자를 가진 파일들에 대해서는 웹브라우저 상에서 바로 파일을 자동으로

보여줄 수 있어서 의미상인 멀티파트 메시지를 표현하는데 있음.

그 외의 파일들에 대해서는 파일 다운로드 대화상자가 나타나도록 하는 헤더 속성임.

Attachment : 브라우저 인식 파일 확장자 구분 없이 모든 파일이 파일 다운로드 시 파일 다운로드

대화상자가 나타나도록 하는 헤더 속성 임.

참조 : [RFC2183 http://www.ietf.org/rfc/rfc2183.txt]

 

  


 

3.     Content-type/mixed

헤더 구성

è  Content-type: multipart/form-data, boundary=12345 [Boundary ]

바디 구성

è  --12345 [Boundary]

è  Content-Diposition:form-data; name=”abc” [파라미터 이름]

è  0000 [파라미터 값]

è  --12345 [Boundary]

è  Content-Diposition:form-data; name=”files”

è  Content-type:multipart/mixed; boundary=abcde [Boundary]

è  -- abcde [Boundary]

è  Content-Diposition: attachment; filename=”c:\test\123.jpg” [파일 경로]

è  Content-type: image/jpeg

è  ….[파일 바이너리]

è  -- abcde [Boundary]

è  Content-Diposition: attachment; filename=”c:\test\456.jpg” [파일 경로]

è  Content-type: image/jpeg

è  ….[파일 바이너리]

è  -- abcde [Boundary]--

è  --12345 [Boundary]--

 

[Intro]

제가 이전에 세미나에서 발표 했던 내용과도 관련이 있는 내용이긴 합니다.

Activity를 안전하게 보호하기 위한 방법 중에서,

<activity> 태그에 있는 exported 속성을 false로 만들어서

다른 어플리케이션에서 접근 할 수 없게 만들 수 있었습니다.

 

그런데 exported ="false"속성은 다른 어플리케이션에서 전혀 보이지 않게 숨기는 속성이기 때문에,

재사용을 할 수 없다는, 다소 Activity 철학과는 살짝 거리가 있는 속성이기도 합니다.

뭐... 그래도 재사용 필요없는 Activity에겐 유용한 속성이긴 하지요.

 

 

[exported="false" 를 쓰면 안되는 상황이 있다고?]

예... 그렇습니다. 모든 상황에서 사용 가능한건 아닙니다.

 

원래 오늘 별 내용 없습니다. 간단한 메모 수준의 포스팅이죠.

exported="false" 속성을 사용하면 안되는 상황이 있는데,

바로 MAIN/LAUNCHER Activity에는 사용하면 절대 안됩니다.

 

모든 Activity들을 안전하게 만든다고 모두 exported="false" 속성을 주어서는 안됩니다.

MAIN/LAUNCHER Activity에 exported="false" 속성을 주면

다음과 같은 exception이 발생합니다.

ERROR/Rosie(255): 
Launcher does not have the permission to launch Intent 
{ action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER}

flags=0x10200000 comp={kr.vizpei.blog/kr.vizpei.blog.TestActivity} }. 
Make sure to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity.


ERROR/Rosie(255): 
java.lang.SecurityException: Permission Denial
starting Intent { action=android.intent.action.MAIN categories=
{android.intent.category.LAUNCHER} flags=0x10200000 
comp={kr.vizpei.blog/kr.vizpei.blog.TestActivity} } 
from ProcessRecord{43851f00 255:com.htc.launcher/9999} (pid=255, uid=9999) 
requires null

먼저 SecurityException이 발생 하고,

exported 속성을 true로 설정해 달라는 메세지가 출력됩니다.

 

절대로 MAIN/LAUNCHER Activity에 exported="false" 속성을 주지 맙시다!


출처 : http://blog.naver.com/PostList.nhn?blogId=visualc98&categoryNo=0&from=postList

void onLoadResource(WebView view, String url)

외부 리소스를 불러올 때 처리할 내용을 구현한다.


void onPageFinished(WebView view, String url)

페이지 로딩이 완료 되었을 때 처리할 내용을 구현한다.


void onPageStarted(WebView view, String url, Bitmap favicon)

페이지 로딩이 시작될 때 처리할 내용을 구현한다.


void onReceivedError(WebView view, int errorCode, String description, String failingUrl)

오류가 발생했을 때 처리할 내용을 구현한다.


void onScaleChanged(WebView view, float oldScale, float newScale)

스케일이 변경되었을 때 처리할 내용을 구현한다.


WebResourceResponse shouldInterceptRequest(WebView view, String url)

리소스 요청이 있을 때 처리할 내용을 구현한다.


boolean shouldOverrideKeyEvent(WebView view, KeyEvent event)

키 이벤트 발생시에 처리할 내용을 구현한다.


boolean shouldOverrideUrlLoading(WebView view, String url)

새로운 Url을 불러 오려고 할 때 처리할 내용을 구현한다.

안드로이드 개발자 사이트에 보면 tcpdump 를 이용하는 방법이 있다. 
Linux나 Windows에서 tcpdump를 사용해본 경험이 있는 분들은 간단하게 아래 설명을 보면된다.

arm용으로 빌드된 tcpdump-arm (첨부파일을 받아 확장자 변경) 바이너리를 단말기나 Emulator에 push한다.

$adb remount
$adb push ./tcpdump-arm /data/local
$adb
#cd /data/local
#chmod 777 tcpdump-arm
#./tcpdump-arm -X -n -s 0 port 80 -w /sdcard/capture.pcap //만일 80 포트에서 I/O되는 패킷을 저장할 경우 
...
... 인터넷 작업...
...
#^c
sdcard에서 저장된 capture.pcap파일을 꺼내어 wireshark(http://www.wireshark.org/download.html) 를 이용하여 TCP Stream을 확인하면 된다. tcpdump는 서버로부터 아무 응답이 없는 경우 단말기의 Socket에서 SYN (TCP 연결) 패킷이 보내졌는지, 서버가 응답안하는지, 전송, 응답 패킷을 확인하는 경우 유용하다.

[펌] Debugging with tcpdump and other tools

Installing tcpdump

Pushing the binary to an existing device

Download tcpdump from http://www.tcpdump.org/, then execute:

adb root
adb remount
adb push /wherever/you/put/tcpdump /system/xbin/tcpdump
adb shell chmod 6755 /data/local/tmp/tcpdump
adb shell
#./tcpdump-arm 

If you are running your own build, execute:

mmm external/tcpdump  # install the binary in out/.../system/xbin
make snod # build a new system.img that includes it

Flash the device as usual, for example, fastboot flashball.

If you want to build tcpdump by default, add CUSTOM_TARGETS += tcpdump to your buildspec.mk.

Running tcpdump

You need to have root access on your device.

Batch mode capture

The typical procedure is to capture packets to a file and then examine the file on the desktop, as illustrated below:

adb shell tcpdump -i any -p -s 0 -w /sdcard/capture.pcap
# "-i any": listen on any network interface
# "-p": disable promiscuous mode (doesn't work anyway)
# "-s 0": capture the entire packet
# "-w": write packets to a file (rather than printing to stdout)

... do whatever you want to capture, then ^C to stop it ...

adb pull /sdcard/capture.pcap .
sudo apt-get install wireshark # or ethereal, if you're still on dapper
wireshark capture.pcap # or ethereal

... look at your packets and be wise ...

You can run tcpdump in the background from an interactive shell or from Terminal. By default,tcpdump captures all traffic without filtering. If you prefer, add an expression like port 80 to thetcpdump command line.

Real time packet monitoring

Execute the following if you would like to watch packets go by rather than capturing them to a file (-n skips DNS lookups. -s 0 captures the entire packet rather than just the header):

adb shell tcpdump -n -s 0

Typical tcpdump options apply. For example, if you want to see HTTP traffic:

adb shell tcpdump -X -n -s 0 port 80

You can also monitor packets with wireshark or ethereal, as shown below:

# In one shell, start tcpdump.
adb shell "tcpdump -n -s 0 -w - | nc -l -p 11233"

# In a separate shell, forward data and run ethereal.
adb forward tcp:11233 tcp:11233 && nc 127.0.0.1 11233 | ethereal -k -S -i -

Note that you can't restart capture via ethereal. If anything goes wrong, you will need to rerun both commands.

For more immediate output, add -l to the tcpdump command line, but this can cause adb to choke (it helps to use a nonzero argument for -s to limit the amount of data captured per packet; -s 100is sufficient if you just want to see headers).

Disabling encryption

If your service runs over httpstcpdump is of limited use. In this case, you can rewrite some service URLs to use http, for example:

vendor/google/tools/override-gservices url:calendar_sync_https_proxy \

https://www.google.com/calendar rewrite http://android.clients.google.com/proxy/calendar

Other network debugging commands

On the device:

  • ifconfig interface: note that unlike Linux, you need to give ifconfig an argument
  • netcfg: lists interfaces and IP addresses
  • iftop: like top for network
  • route: examine the routing table
  • netstat: see active network connections
  • ncnetcat connection utility

On the desktop:

  • curl: fetch URLs directly to emulate device requests

Sunday, August 30th, 2009 | Author: Tim

Dumping packets..

So a while back I had written about gathering packets from the android phone - often using simple ARP spoofing and Wireshark to grab all the traffic. Sadly I kept postponing this post and then just forgot to put it up, showing how to grab the packets in a much easier way, which doesn’t even require you to put your android phone on a WIFI network.

I’m not sure why this method never seemed to dawn on me in the beginning - since it’s so simple basically and has come in hand numerous times since :)

On your computers shell/cmd;

adb shell tcpdump -vv -s 0 -w /sdcard/output.cap

A quick run down of the switches we are using are the following;

-vv puts tcpdump into verbose mode - to give us some extra information
-s 0 sets the size of sender to look for to zero, telling the program to grab all packets
-w /sdcard/output.cap will let us set the packets grabbed to be written to the sdcard for analysis later.

Once your done just break the command (control-c) and go open up the .cap file with your favorite analyzer like wireshark.

You can also just run this command from your favorite terminal on the phone — allowing you to grab packets on the go. This should be pretty obvious, though I feel I must say it since people seem to think adb is something unlike a terminal? I’m not sure why this comes up, but people end up pasting the same thing I’ve done often, and then saying “You can just do it in a terminal on the phone, and it’s easiierr!”. Well yes, yes you can… Though copy-pasta-ing someones ideadoesn’t make your much brighter ;)

Directly on the phone, or already adb’ed into it;

tcpdump -vv -s 0 -w /sdcard/output.cap

Update: 8/31/09 I’ve pulled the tcpdump from my rom and uploaded it to my server, you can download it here: tcpdump. It is tcpdump version 3.9.8 libpcap version 0.9.8 - for anyone wondering. Push this file to you /system/bin or /system/xbin and then chmod’ing it to be executable should make this work. Enjoy!


출처 : http://blog.naver.com/PostView.nhn?blogId=vicfaith&logNo=150086174382

프로그래밍에 친숙한 네트워크 전문가는 프로토콜 문서를 보는 것보다 그 프로토콜이 구현된 API를 들여다 보는 것을 통해 보다 빠르고 정확하게 프로토콜에 대해 이해하기도 한다. - Softgear Ko


본 문서는 http://developer.android.com/sdk/android-4.0.html 의 WiFi Direct 를 번역하였습니다.


Wi-Fi Direct

안 드로이드는 이제 사용자간 연결(P2P)을 위한 Wi-Fi Direct 를 지원한다. 이 P2P 연결은, 핫스팟이나 인터넷 연결 없이, 안드로이드 장치 또는 다른 디바이스 간의 직접 연결 및 통신을 말한다. 안드로이드 프레임워크는 Wi-Fi P2P API를 제공하여, 당신이 Wi-Fi Direct를 지원하는 다른 디바이스를 찾고 연결할 수 있도록 하고, Bluetooth 연결보다 더 긴 거리에서 더 빠른 통신을 가능하게 한다.


새로운 패키지 android.net.wifi.p2p 

(http://developer.android.com/reference/android/net/wifi/p2p/package-summary.html

는 Wi-Fi를 통한 P2P 연결을 수행하는데 필요한 모든 API를 포함한다. 당신이 사용하게 될 주 클래스는 WifiP2pManager 이다. 이는 당신이 getSystemService(WIFI_P2P_SERVICE) 를 호출하여 사용할 수 있다. WifiP2pManager 는 다음 기능을 가진 API들을 포함한다.


* initialize() 를 호출하여 P2P 연결을 위한 당신의 어플리케이션을 초기화

* discoverPeers() 를 호출하여 이웃 디바이스를 찾아내기(discover)

* connect()를 호출하여 P2P 연결을 시작

* 기타 기능


몇몇 다른 필수적인 인터페이스 및 클래스는 다음과 같다.

* WifiP2pManager.ActionListener 인터페이스는 당신이 상대방을 찾거나(discover) 연결하는 동작이 성공하거나 실패한 경우 호출되는 콜백(callback)을 받을 수 있게 한다.

* WifiP2pManager.PeerListListener 인터페이스는 당신이 발견된 상대방에 관한 정보를 받을 수 있게 한다. 이 콜백은 WifiP2pDeviceList 를 제공하는데, 여기서 통신 범위내에 있는 각 디바이스 별 WifiP2pDevice 객체를 뽑아내어, 디바이스 이름, 주소, 디바이스 타입, WPS 설정 등과 같은 정보를 얻을 수 있다.

* WifiP2pManager.GroupInfoListener 인터페이스는 당신이 P2P 그룹에 관한 정보를 받을 수 있게 한다. 이 콜백은 WifiP2pGroup 객체를 제공하는데, 이는 소유자(owner), 네트워크 이름, 암호구문(passphrase) 등과 같은 그룹 정보를 제공한다.

* WifiP2pManager.ConnectionInfoListener 인터페이스는 당신이 현재 연결에 관한 정보를 받도록 한다. 이 콜백은 WifiP2pInfo 객체를 제공하는데, 이는 그룹이 구성되었는지 여부, 누가 그룹 소유자인지를 포함한다.


Wi-Fi P2P API들을 사용하기 위해서는, 당신의 어플은 다음 사용자 권한들을 요청해야 한다.

* ACCESS_WIFI_STATE

* CHANGE_WIFI_STATE

* INTERNET (비록 당신의 어플이 기술적으로 인터넷에 연결하지 않을지라도, Wi-Fi Direct 통신을 위한 표준 java socket들은 Internet permission을 요구한다)


안드로이드 시스템은 다음과 같은 Wi-Fi P2P 이벤트에 대해 몇가지 action을 broadcast한다.

* WIFI_P2P_CONNECTION_CHANGED_ACTION: P2P연결 상태가 변경 되었음을 나타낸다.. 이는 WifiP2pInfo 객체를 가진 EXTRA_WIFI_P2P_INFO 와 NetworkInfo 객체를 가진 EXTRA_NETWORK_INFO 를 전달한다.

* WIFI_P2P_STATE_CHANGED_ACTION: P2P 상태가 enabled와 disabled 사이에서 변경 되었음을 나타낸다. 이는 WIFI_P2P_STATE_DISABLED 또는 WIFI_P2P_STATE_ENABLED 를 가진 EXTRA_WIFI_STATE 를 전달한다.

* WIFI_P2P_PEERS_CHANGED_ACTION: 상대방 디바이스 리스트가 변경되었음을 나타낸다.

* WIFI_P2P_THIS_DEVICE_CHANGED_ACTION: 이 디바이스에 대한 세부사항(details)가 변경되었음을 나타낸다.


더 자세한 정보를 위해서는 WifiP2pManager 문서 

http://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager.html ) 

를 참고하라. 그리고 또한, Wi-Fi Direct 데모 샘플 어플리케이션 

http://developer.android.com/resources/samples/WiFiDirectDemo/index.html ) 

을 보라.


- 문서끝.


출 처: 쏘프트 스토리에서 퍼옴.
         http://blog.naver.com/PostView.nhn?blogId=softgear&logNo=100150666274

'안드로이드' 카테고리의 다른 글

WebViewClient  (0) 2012.07.12
Android WireShark TCP dump  (0) 2012.07.12
Android 빌드하기  (0) 2012.03.03
Framework에서 Attrs.xml에 추가하기  (0) 2012.02.03
Device Administration  (0) 2012.01.28

Target Board  이솝 커뮤니티의 S5PC100 보드를 사용하므로이솝 프로젝트 사이트 내용을 참고합니다.

http://www.aesop.or.kr/?mid=issuetracker&vid=AESOPC100

 

1.       Install GCC Tool chain

-          Download : http://www.aesop.or.kr/?mid=issuetracker&act=dispIssuetrackerDownload&vid=AESOPC100

GCC : arm-s5pc1xx-linux-gnueabi-4.3.2.tar.gz

GCC 4.3.2  사용하며, GCC 관련 자료는 http://gcc.gnu.org 확인 하시기 바랍니다.

 

-          압축해제

이솝 보드용 Tool chain 호스트 시스템의 /opt 디렉터리에 설치를 합니다.

/opt 폴더를 복사하고다음의 명령으로 압축을 해제하시면 됩니다.

 

sudo tar xzf arm-s5pc1xx-linux-gnueabi-4.3.2.tar.gz

 

 

1.png

 

-          환경설정

Tool chain  Path  설정해주는 것이며다음과 같이 합니다.

 

sudo gedit /etc/profile

 

아래와 같이 창이 열리면선택된 부분과 같이 아래 Path  추가해 줍니다.

PATH=$PATH:$HOME/bin:/opt/s5pc1xx/cross/armv7a/bin

 

2.png

 

source /etc/profile

 

PATH 설정 확인

echo $PATH

 

3.png

 

arm-s5pc1xx-linux-gnueabi-gcc –v

 

4.png

 

2.       Install & Build U-Boot

-          Download : http://www.aesop.or.kr/?mid=issuetracker&act=dispIssuetrackerDownload&vid=AESOPC100

U-Boot 1.3.4 : u-boot-1.3.4-aesop.100428.tar.gz

 

-          압축해제

본인이 사용할 적절한 위치에 압축을 풀어 주시면 됩니다.

tar 명령어로 하셔도 되고그냥 파일 브라우저에서 압축해제 툴로 바로 실행하셔도 풀어도 됩니다.

 

5.png

 

-          U-Boot Build

다음과 같이 명령어를 수행합니다.

make clobber               <- 기존에 만들어 것들을 제거

make ntc100_config    <- 이솝보드용 config 설정

make                       

 

6.png

 

빌드 완료가 되면 아래 화면에서 처럼 u-boot.bin  사용하면 됩니다.

 

7.png

 

3.       Install & Build Android Linux Kernel

-          Download : http://www.aesop.or.kr/?mid=issuetracker&act=dispIssuetrackerDownload&vid=AESOPC100

Linux Kernel 2.6.29 : android-2.6.29-aesop-RTM10.tar.gz

해당 Kernel Android  X-Windows 모두 지원을 합니다.

 

-          Kernel Build

tar xzf android-2.6.29-aesop-RTM10.tar.gz

cd android-2.6.29-aesop-RTM10

make ntc100_xwindows_defconfig   <- X-Winodws  커널 빌드 

make ntc100_android_defconfig      <- Android  커널 빌드 

make zImage

 

아래와 같이 빌드가 완료되었으며, arch/arm/boot/zImage  생성이 되었습니다.

8.png

                 

4.       Build Android

-          Download  “Android 개발환경 구축” 게시물을 참조하시기 바라며,

추가로 이솝 보드용 소스는 아래와 같습니다.

Android Eclair : http://www.aesop.or.kr/?mid=issuetracker&act=dispIssuetrackerDownload&vid=AESOPC100

 

-          Build

Android source  있는 위치에서 아래와 같이 aesopc100_build.sh  실행하면 됩니다.

 

eastsky@ubuntu:~/dawid/android/android_eclair_aesopc100$ ./aesopc100_build.sh

 

9.png

 

빌드가 완료되면 아래와 같이 system.img 파일이 생성이 됩니다.

 

10.png

 

.. /android_eclair_aesopc100/out/target/product/smdkc100 아래 img 파일이 생성이 됩니다.

 

11.png

 

5.       Make NFS – Android  Root Fils System

-          NFS  디렉토리 생성  FS 파일을 복사 (본인에 맞게 적절한 곳을 지정하여 만들면 됩니다).

일단 /out/target/product/smdkc100  Output 파일들이 있는 곳으로 이동을 합니다.

 

cd /home/eastsky/dawid/android/android_eclair_aesopc100/out/target/product/smdkc100

 

12.png

 

 root 에서 편하게 사용하기 위해 root 계정으로 전환하고 아래와 같은 경로로 생성합니다.

 

mkdir /root/work/rootfs/test

 

그리고 아래와 같이 파일들을 복사합니다.

cp -a root/*  /root/work/rootfs/test

cp -a data   /root/work/rootfs/test/data/

cp -a system  /root/work/rootfs/test/system/

 

NFS 용으로 사용할 디렉토리 /root/work/rootfs/test  이동 합니다.

그리고 권한을 아래와 같이 변경하여 줍니다.

 

chown -R root.root *

chmod -R 777 data system

 

13.png

 

6.       Android New Vender & Product  (출처 이솝의 고도리님 http://www.aesop.or.kr/?document_srl=265476#7)

이솝 보드용 Android 소스를 그대로 사용하면 굳히 따로 아래와 같이 Vendor  따로  만들고 하셔도 됩니다.

 

l  일단 android 다운로드 받은 디렉토리로 움직인 후에 aesop이란 vendor 하나 만듭니다.

기존에 있는 sample 이용해서 하나 만들도록 하겠습니다.

 

cd vendor

cp -a sample aesop

cd aesop

 

Android.mk

products  빼고 전부 삭제

 

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

rm -rf apps/ frameworks/ sdk_addon/ skins/

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

 

l   products 새롭게 정의

 

1>

                  cd products

                  vi AndroidProducts.mk

 

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

                  PRODUCT_MAKEFILES := \

                    $(LOCAL_DIR)/sample_addon.mk

                   

                  ==> 이렇게  것을 새로운 보드 이름으로 대체

 

                  PRODUCT_MAKEFILES := \

                    $(LOCAL_DIR)/ntc100.mk

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

 

                  그리고 기존의 복잡한 sample관련 mk 파일을 지웁니다.

                  rm sample_addon.mk

 

2>

ntc100.mk 다음과 같이 edit

                  vi ntc100.mk

 

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

                  $(call inherit-product, build/target/product/generic.mk)

 

                  PRODUCT_MANUFACTURER := aesop

                  PRODUCT_NAME := ntc100

                  PRODUCT_DEVICE := ntc100

                  PRODUCT_BOARD := ntc100

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

 

l   새롭게 추가된 board 대한 directory 구성

기존의 generic board 것을 이용한다. generic board 디렉토리를 ntc100 디렉토리로 복사

                  cd ..

                  cp -a ../../build/target/board/generic/ ./ntc100     <- Vender  새로 만든 것입니다.

                 

 부분은 적용하지 않아도 된다. board 따라 틀림(kernel 따라)

                   부분은 product kernel 내에서의 keypad driver 따라 keylayout 지정하는 부분인데,

 부분은 건너뛰어도 됩니다.

 

                  그냥 이게 없으면 qwerty.kl  로딩되거든요.

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

                  vi AndroidBoard.mk

                  tuttle2 nt-keypad 수정(여기서 nt-keypad key device driver 이름이다)

 

                  mv tuttle2.kcm nt-keypad.kcm

                  mv tuttle2.kl nt-keypad.kl

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

 

                  vi BoardConfig.mk 해서 USE_CAMERA_STUB:=true  추가한다.

                  이유는

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

                  //주의사항

                  frameworks/base/camera/libcameraservice/Android.mk 보면

 

                  #

                  # Set USE_CAMERA_STUB for non-emulator and non-simulator builds, if you want

                  # the camera service to use the fake camera.  For emulator or simulator builds,

                  # we always use the fake camera.

 

                  ifeq ($(USE_CAMERA_STUB),)

                   USE_CAMERA_STUB:=false

                   ifneq ($(filter sooner generic sim,$(TARGET_DEVICE)),)

                    USE_CAMERA_STUB:=true

                   endif #libcamerastub

                  endif

 

                   경우

                  USE_CAMERA_STUB:=true  BoardConfig.mk  넣어줘야 한다.

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

 

l   build script 만들기

android top으로 가서 vi ntc100.sh 해서

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

#!/bin/sh

 

CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}')

 

START_TIME=`date +%s`

echo make -j$CPU_JOB_NUM PRODUCT-ntc100-eng

echo

make -j$CPU_JOB_NUM PRODUCT-ntc100-eng

if [ $? != 0 ] ; then

                                    exit $?

fi

 

END_TIME=`date +%s`

 

echo "Total compile time is $((($END_TIME-$START_TIME)/60)) minutes $((($END_TIME-$START_TIME)%60)) seconds"

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

 

저장하고 나온 후에

(

                   명령은 samsung C100 code 보면 build script 있는데 그것을 베낀 것입니다.

                  실제로는 host cpu갯수를 읽은 후에

 

                  make PRODUCT-ntc100-eng

 

                  -j 옵션을 이용해서 실행하는 것입니다.

)

                 생성된 script 실행 permission 줍니다.

 

chmod 755 ntc100.sh

'안드로이드' 카테고리의 다른 글

Android WireShark TCP dump  (0) 2012.07.12
[WiFi Direct] WiFi Direct in Android 4.0 API Overview (번역)  (0) 2012.05.07
Framework에서 Attrs.xml에 추가하기  (0) 2012.02.03
Device Administration  (0) 2012.01.28
MIME-Type 의 종류  (0) 2012.01.26
인터넷을 찾아보면서 어떻게 해야되는지 이해하지 못했다.
하지만 여러번의 삽질 끝에 찾았다.
방법은 다음과 같다.

frameworks/base/core/res/res/vlaues/attrs.xml에 원하는 속성을 추가.
여기선 Theme에 추가를 기준으로 했다.

<declare-styleable name="Theme">
...
<!-- Present the text in ALL CAPS. This may use a small-caps form when available. -->
<attr name="textAllCaps" />

<!-- csjung test. -->
<attr name="csjung" format="string" />
</declare-styleable>
위의 조건은 Public 형식.
만약 Private 처리하고싶다면 생성한 attr위에 hide를 선언.
<!-- @hide csjung test. -->
<attr name="csjung" format="string" />
</declare-styleable>

그리고 다음의 파일을 Open.
frameworks/base/core/res/res/vlaues/Public.xml
테마가 선언된 인덱스에서 가장 마지막 연동 인덱스에 추가.
 <public type="attr" name="publicKey" id="0x010103a6" />
 <public type="attr" name="csjung" id="0x010103a7" />

 <public type="style" name="TextAppearance.SuggestionHighlight" id="0x01030118" />
위에서 확인시 publicKey가 Theme 가 선언된 Index에서의 가장 마지막에 선언된 Index.

그리고 확인을 해봐야 하나 Theme는 Default Theme 를 선언해줘야 하는 것 같음.
이는 확인을 해봐야 함.
아직 확인은 하지 못했지만, 저는 frameworks/base/core/res/res/vlaues/Themes.xml에
다음과 같이 Default값을 선언.
<style name="Theme">
    <item name="csjung">@android:string/candidates_style</item>
    <item name="colorForeground">@android:color/bright_foreground_dark</item>

그리고 나서 Build 창에서 'make update-api' 란 명령어를 실행.

결과
framesorks/base/api/current.txt에 추가한 api가 등록된 것을 확인.

Device Administration


Android developer site 의 번역 입니다.

가급적 전문 용어는 원문을 사용하였으며, 의역이 꽤 있습니다.


원문 출저 / 번역자 명시 하에 수정/재배포 가능 합니다.

번역자 : nilakantha38@gmail.com
원문 : http://developer.android.com/guide/topics/admin/device-admin.html



Device Administration


Android 2.2 introduces support for enterprise applications by offering the Android Device Administration API. The Device Administration API provides device administration features at the system level. These APIs allow you to create security-aware applications that are useful in enterprise settings, in which IT professionals require rich control over employee devices. For example, the built-in Android Email application has leveraged the new APIs to improve Exchange support. Through the Email application, Exchange administrators can enforce password policies — including alphanumeric passwords or numeric PINs — across devices. Administrators can also remotely wipe (that is, restore factory defaults on) lost or stolen handsets. Exchange users can sync their email and calendar data.


Android 2.2 는 Android Device Andministration API 를 통해, 보안성 등이 필요시되는 기업 어플리케이션을 위한 지원을 한다. Device Administration API  는 system 레벨에서의 기기 관리 기능을 제공한다. 이 API 들은 당신이 IT 기업에서 고용자의 기기에 설정하고자 하는 다양한 보안 설정을 지원하는 어플리케이션의 개발에 유용하게 사용될 수 있다.
예를 들어, Android 에 포함 되어 있는 Email app 은 Exchange 기능 지원을 개선하기 위해 이 API 를 사용했다. Email app 에서 Exchange 관리자는 기기들에 password 정책을 강제 할 수 있다 - 알파벳+숫자 조합 password 나 숫자로만 이루어진 password 등을 포함해서.
관리자는 또한, 잃어버리거나 도둑 맞은 기기에 원격 데이터 삭제 기능(기기를 출고 직후 상태로 되돌린다)을 사용 할 수 있다. Exchange 사용자는 email 과 calendar 데이터를 sync 할 수 있다.

This document is intended for developers who want to develop enterprise solutions for Android-powered devices. It discusses the various features provided by the Device Administration API to provide stronger security for employee devices that are powered by Android.


이 기기는 Android 기기에 enterprise solution 을 개발하고자 하는 개발자들을 위한다. 직원의 Android 기기에 강력한 보안 기능을 개발하기 위한 기능을 제공하는 Device Administration API 에 대해 이야기 한다.

Device Administration API Overview

Here are examples of the types of applications that might use the Device Administration API:
  • Email clients.
  • Security applications that do remote wipe.
  • Device management services and applications.

Device Administration API 를 사용할 만한 application 의 종류는 다음과 같다 :
  • Email client application
  • 원격 데이터 삭제를 하는 보안 application
  • 기기 관리 서비스와 application

How does it work?

You use the Device Administration API to write device admin applications that users install on their devices. The device admin application enforces the desired policies. Here's how it works:
  • A system administrator writes a device admin application that enforces remote/local device security policies. These policies could be hard-coded into the app, or the application could dynamically fetch policies from a third-party server.
  • The application is installed on users' devices. Android does not currently have an automated provisioning solution. Some of the ways a sysadmin might distribute the application to users are as follows:
    • Android Market.
    • Enabling non-market installation.
    • Distributing the application through other means, such as email or websites.
  • The system prompts the user to enable the device admin application. How and when this happens depends on how the application is implemented.
  • Once users enable the device admin application, they are subject to its policies. Complying with those policies typically confers benefits, such as access to sensitive systems and data.

사용자들이 그들의 기기에 설치할 기기 관리 application 을 개발하기 위해 당신은 Device Administration API 를 사용할 것이다.
Device admin application 은 보안 정책을 강제한다. 이것은 다음과 같이 동작한다 :
  • system administrator 는 원격/또는 지역적으로 동작할 device security 정책을 강제할 device admin application 을 개발한다.
  • 해당 application 이 사용자의 기기에 설치된다. Android 는 현재로썬 자동화된 설치 방법은 없다. system admin 은 다음과 같은 방법으로 application 을 유저에게 배포 할 수 있다 :
    • Android market
    • non-market 설치를 허용하기.
    • email 이나 website 로 배포하기.
  • system 은 사용자가 device admin application 을 활성화 하도록 해야 한다. 이것이 어떻게, 언제 이루어지는지는 application 이 어떻게 구현 되었는가에 달렸다.
  • 한번 사용자들이 device admin application 을 활성화 하면, 사용자들은 device admin application 의 정책을 따르게 된다. 이 정책들을 따르는 것은 민감한 시스템과 데이터로의 접속과 같은 이익을 제공할 수 있을 것이다.


If users do not enable the device admin app, it remains on the device, but in an inactive state. Users will not be subject to its policies, and they will conversely not get any of the application's benefits—for example, they may not be able to sync data.


사용자들이 device admin app 을 활성화 하지 않으면, 그것은 device 에 남아 있겠지만, 비활성화 된 상태로 있을 것이다. 사용자들은 그 정책을 따르지 않게 되고, application 의 기능을 사용하지 못할 것이다 - 예를 들면, data 를 sync 하지 못할 것이다.

If a user fails to comply with the policies (for example, if a user sets a password that violates the guidelines), it is up to the application to decide how to handle this. However, typically this will result in the user not being able to sync data.


사용자가 정책을 따르지 않는다면(예를 들어, 사용자가 가이드라인을 어기는 password 를 설정한다던지), 이를 어떻게 제어할지는 application 의 몫이다. 다만, 일반적으로는 사용자가 data sync 를 못하게 할 것이다.

If a device attempts to connect to a server that requires policies not supported in the Device Administration API, the connection will not be allowed. The Device Administration API does not currently allow partial provisioning. In other words, if a device (for example, a legacy device) does not support all of the stated policies, there is no way to allow the device to connect.


기기가 Device administration API 에서 지원하지 않는 정책을 요구하는 서버에 연결을 시도하면, 연결은 실패할 것이다. Device Administration API 는 현재로썬 partial provisioning 을 지원하지 않는다. 달리 말하자면, 기기가(예를 들어, 구형 버전의 기기) 모든 정책을 지원하지 않는다면, 해당 기기를 연결할 방법이 없다.

If a device contains multiple enabled admin applications, the strictest policy is enforced. There is no way to target a particular admin application.


기기가 여러개의 admin application 을 활성화 했다면, 가장 강한 정책이 설정된다.
개별의 admin application 을 부분적으로 사용하는 방법은 없다.

To uninstall an existing device admin application, users need to first unregister the application as an administrator.


admin application 을 삭제하고자 한다면, 사용자는 일단 application 을 administrator 에서 해제 설정(앞서 행한 활성화를 무효화 해야 한다는 뜻)을 해야 한다.

Policies

In an enterprise setting, it's often the case that employee devices must adhere to a strict set of policies that govern the use of the device. The Device Administration API supports the policies listed in Table 1. Note that the Device Administration API currently only supports passwords for screen lock:


기업 설정에서, 직원의 기기가 기기의 사용을 제어하는 정책을 설정해야 하는 것은 흔한 경우이다. Device Administration API 는 아래의 표에 적힌 정책들을 지원한다.
현재로써는 Device Administration API 는 screen lock 을 위한 password 만을 제공한다 :

Table 1. Policies supported by the Device Administration API.
PolicyDescription
Password enabled Requires that devices ask for PIN or passwords.


기기가 PIN(숫자로만 이루어진 비밀번호) 나 password 를 요구하도록 한다.
Minimum password length Set the required number of characters for the password. For example, you can require PIN or passwords to have at least six characters.


password 의 최소 길이를 설정 한다. 예를 들어, 당신은 최소 6자 이상의 PIN 이나 password 를 요구 할 수 있다.
Alphanumeric password required Requires that passwords have a combination of letters and numbers. They may include symbolic characters.


password 가 숫자와 글자의 조합으로 이루어지도록 한다. 특수 문자도 포함될 수 있다.
Maximum failed password attempts Specifies how many times a user can enter the wrong password before the device wipes its data. The Device Administration API also allows administrators to remotely reset the device to factory defaults. This secures data in case the device is lost or stolen.


device 가 데이터를 지워 버리기 전에 몇회까지 틀린 password 의 입력을 허용할 것인지 설정한다. Device Administration API 는 또한 administrator 가 원격으로 기기를 출하 직후 상태로 reset 할 수 있는 기능을 제공한다. 이는 기기를 잃어버렸거나 도둑 맞은 경우 보안을 제공할 수 있다.
Maximum inactivity time lock Sets the length of time since the user last touched the screen or pressed a button before the device locks the screen. When this happens, users need to enter their PIN or passwords again before they can use their devices and access data. The value can be between 1 and 60 minutes.


사용자가 마지막으로 화면을 터치하거나 button 을 누른 후 얼마나 많은 시간이 지난 후 screen 을 lock 할지를 설정 할 수 있다. 해당 시간이 지나면, 사용자는 그들의 기기를 다시 사용하기 위해 PIN 이나 password 를 입력해야 한다. 값은 1분에서 60분까지 설정 가능하다.

Other features

In addition to supporting the policies listed in the above table, the Device Administration API lets you do the following:
  • Prompt user to set a new password.
  • Lock device immediately.
  • Wipe the device's data (that is, restore the device to its factory defaults).

위의 표에서 설명한 정책들 외에도, Device Administration API 는 다음과 같은 정책을 제공한다 :
  • 사용자가 새로운 password 를 설정하도록 요구.
  • device 를 즉각 Lock 시킨다.
  • device 의 데이터를 삭제(이는, 기기를 출하 직후의 상태로 되돌린다).

Sample Application

The examples used in this document are based on the Device Administration API sample, which is included in the SDK samples. For information on downloading and installing the SDK samples, see Getting the Samples. Here is the complete code for the sample.


이 문서에서 사용하는 예시는 SDK sample 에 포함된 Device Administration API sample 에 기초한다. SDK sample 의 다운로드와 설치를 위해서는 Getting the samples 문서를 참고 바란다. 여기 예제의 전체 코드가 있다.

The sample application offers a demo of device admin features. It presents users with a user interface that lets them enable the device admin application. Once they've enabled the application, they can use the buttons in the user interface to do the following:


예제 application 은 device admin 기능의 demo 를 제공한다. 그것은 사용자들이 admin application 을 활성화 할 수 있는 UI 를 제공한다. 한번 사용자가 이 application 을 활성화 하면, 그들은 다음의 기능을 사용하기 위해 버튼을 사용 할 수 있다 :

  • Set password quality.
  • Specify the minimum length for the user's password.
  • Set the password. If the password does not conform to the specified policies, the system returns an error.
  • Set how many failed password attempts can occur before the device is wiped (that is, restored to factory settings).
  • Set the maximum amount of inactive time that can elapse before the device locks.
  • Make the device lock immediately.
  • Wipe the device's data (that is, restore factory settings).

  • password 제한 설정.
  • 사용자 password 의 최소 길이 설정.
  • password 설정. 만약 해당 password 가 제시된 정책을 따르지 않을 경우, system 은 에러를 냄.
  • 얼마나 많은 password 실패가 반복될 때 기기의 데이터를 삭제할지(즉, 출하 직후 환경으로 복구됨).
  • 기기를 lock 하기 전 얼마나 많은 시간을 유지할 것인가 설정.
  • 즉시 기기를 lock.
  • 기기의 데이터 삭제(출하 직후 환경으로 복구)


Figure 1. Screenshot of the Sample Application

Developing a Device Administration Application

System administrators can use the Device Administration API to write an application that enforces remote/local device security policy enforcement. This section summarizes the steps involved in creating a device administration application.




System administrator 는 remote/local 기기 보안 정책 강제를 할 수 있는 application 의 개발을 위해 Device Administration API 를 사용 할 수 있다. 이 section 은 device administration application 을 개발하기 위한 단계를 요약, 정리해 본다.

Creating the manifest

manifest 만들기


To use the Device Administration API, the application's manifest must include the following:

Device Administration API 를 사용하기 위해서, application 의 manifest 는 다음을 포함해야 한다 :
  • 다음을 포함하는, DeviceAdminReceiver 의 subclass.
    • BIND_DEVICE_ADMIN 권한.
    • manifest 에 intent filter 로 선언, ACTION_DEVICE_ADMIN_ENABLE intent 를 받을 수 있어야함.
  • 사용하는 보안 정책을 metadata 로 선언.

Here is an excerpt from the Device Administration sample manifest:


Device Administration sample 의 manifest 로부터 다음을 참고하라 :

<activity android:name=".app.DeviceAdminSample$Controller"
          android:label="@string/activity_sample_device_admin">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.SAMPLE_CODE" />
    </intent-filter>
</activity>
<receiver android:name=".app.DeviceAdminSample"
          android:label="@string/sample_device_admin"
          android:description="@string/sample_device_admin_description"
          android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
               android:resource="@xml/device_admin_sample" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>
Note that:


다음을 참고하라 :

  • The activity in the sample application is an Activity subclass called Controller. The syntax ".app.DeviceAdminSample$Controller" indicates that Controller is an inner class that is nested inside the DeviceAdminSample class. Note that an Activity does not need to be an inner class; it just is in this example.
  • The following attributes refer to string resources that for the sample application reside in ApiDemos/res/values/strings.xml. For more information about resources, see Application Resources.
    • android:label="@string/activity_sample_device_admin" refers to the user-readable label for the activity.
    • android:label="@string/sample_device_admin" refers to the user-readable label for the permission.
    • android:description="@string/sample_device_admin_description" refers to the user-readable description of the permission. A descripton is typically longer and more informative than a label.
  • android:permission="android.permission.BIND_DEVICE_ADMIN" is a permission that a DeviceAdminReceiver subclass must have, to ensure that only the system can interact with the receiver (no application can be granted this permission). This prevents other applications from abusing your device admin app.
  • android.app.action.DEVICE_ADMIN_ENABLED is the the primary action that a DeviceAdminReceiver subclass must handle to be allowed to manage a device. This is set to the receiver when the user enables the device admin app. Your code typically handles this in onEnabled(). To be supported, the receiver must also require the BIND_DEVICE_ADMIN permission so that other applications cannot abuse it.
  • When a user enables the device admin application, that gives the receiver permission to perform actions in response to the broadcast of particular system events. When suitable event arises, the application can impose a policy. For example, if the user attempts to set a new password that doesn't meet the policy requirements, the application can prompt the user to pick a different password that does meet the requirements.
  • android:resource="@xml/device_admin_sample" declares the security policies used in metadata. The metadata provides additional information specific to the device administrator, as parsed by the DeviceAdminInfo class. Here are the contents of device_admin_sample.xml:

  • 예제 application 에서 사용된 activity 는 Controller 라는 이름의, Activity 의 subclass 이다. ".app.DeviceAdminSample$Controller" 라는 문법은 Controller 가 DeviceAdminSample class 의 nested class 임을 알린다. Activity 가 굳이 inner class 일 필요는 없음을 참고하라; 단지 이 예제에서의 상황일 뿐이다.
  • 다음의 속성들은 ApiDemos/res/values/string.xml 에 포함된, 예제 application 의 문자열 resource 를 가리킨다.
    • android:label="@string/activity_sample_device_admin" 은 사용자가 읽을 수 있는, activity 의 lable 을 가리킨다.
    • android:label="@string/sample_device_admin" 은 사용자가 읽을 수 있는, permission 의 lable 을 가리킨다.
    • android:description="@string/sample_device_admin_description" 은 사용자가 읽을 수 있는, permission 의 설명을 가리킨다. 설명은 일반적으로 label 보다 길고, 알아 보기 쉽다.
  • android:permission="android.permission.BIND_DEVICE_ADMIN" 은 system 만이 이 receiver 와 상호 동작 한다는(어떤 application 도 이 permission 을 얻을 수 없다), DeviceAdminReceiver subclass 가 반드시 가져야 하는 권한이다. 이것은 다른 application 이 당신의 device admin app 을 방해하지 못하게 한다.
  • android.app.action.DEVICE_ADMIN_ENABLED 는 DeviceAdminReceiver subclass 가 기기를 관리 하기 위해 반드시 받아야 하는 action 이다. 이것은 사용자가 device admin app 을 활성화 시킬 때 receiver 에게 전달된다. 당신은 코드 상으로 이를 onEnabled() 에서 처리 하면 된다. receiver 는 또한, 다른 application 이 이를 악용하지 못하도록 BIND_DEVICE_ADMIN 권한을 요청 해야 한다.
  • 사용자가 device admin application 을 활성화 할 때, receiver 는 개별적인 system event broadcast 에 대해 반응을 할 수 있는 권한을 얻는다. 그러한 event 가 발생할 때, application 은 정책을 부과 할 수 있다. 예를 들어, 사용자가 현재 보안 정책을 지키지 않는 새로운 password 를 설정한다면 application 은 사용자가 현재 보안 정책을 지키는 다른 password 를 설정하도록 할 수 있다.
  • android:resource="@xml/device_admin_sample" 은 metadata 로 사용되는 보안 정책을 기술한다. metadata 는 DeviceAdminInfo class 에 의해 분석되는, device administrator 에 의해 사용되는 추가적인 정보를 제공한다.

<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
  <uses-policies>
    <limit-password />
    <watch-login />
    <reset-password />
    <force-lock />
    <wipe-data />
  </uses-policies>
</device-admin>
In designing your device administration application, you don't need to include all of the policies, just the ones that are relevant for your app.


당신의 device administration application 을 설계함에 있어서, 모든 정책을 metadata 에 포함할 필요는 없다. 당신의 app 에서 사용할 정책만을 기술하면 된다.

For more discussion of the manifest file, see the Android Developers Guide.


manifest file 에 대한 보다 많은 정보를 위해선, Adnroid Developers Guide 를 참고하라.


Implementing the code

The Device Administration API includes the following classes:
DeviceAdminReceiver
Base class for implementing a device administration component. This class provides a convenience for interpreting the raw intent actions that are sent by the system. Your Device Administration application must include a DeviceAdminReceiver subclass.
DevicePolicyManager
A class for managing policies enforced on a device. Most clients of this class must have published a DeviceAdminReceiver that the user has currently enabled. The DevicePolicyManager manages policies for one or more DeviceAdminReceiver instances
DeviceAdminInfo
This class is used to specify metadata for a device administrator component.
These classes provide the foundation for a fully functional device administration application. The rest of this section describes how you use the DeviceAdminReceiver and DevicePolicyManager APIs to write a device admin application.

Device Administration API 는 다음의 class 들을 포함한다 :
DeviceAdminReceiver
  • device administration component 를 구현하기 위한 Base class. 이 class 는 system 으로부터 받는 raw intent action 에 쉽게 반응 할 수 있도록 해준다. 당신의 Device Administration application 은 DeviceAdminReceiver 의 subclass 를 포함해야 한다.


DevicePolicyManager
  • 기기에서 강제되는 정책들을 관리하기 위한 class. 이 클래스의 대부분의 client 들은 사용자가 현재 활성화 한 DeviceAdminReceiver 를 배포해야 한다. DevicePolicyManager 는 하나 또는 그 이상의 DeviceAdminReceiver instance 들을 위한 정책을 관리한다.


DeviceAdminInfo
  • device administrator component 의 metadata 를 기술하는데 사용된다.

이 class 들은 전체 device administration application 을 위한 토대를 제공한다.
이 section 의 다음 부분들은 DeviceAdminReceiver 와 DevicePolicyManager 를 device admin application 을 개발하기 위해 어떻게 사용하는지 기술한다.





Subclassing DeviceAdminReceiver

To create a device admin application, you must subclass DeviceAdminReceiver. The DeviceAdminReceiver class consists of a series of callbacks that are triggered when particular events occur.


device admin application 을 개발하기 위해, 당신은 DeviceAdminReceiver 의 subclass 를 만들어야 한다. DeviceAdminReceiver class 는 몇몇 event 가 일어날 때마다 호출되는 callback 함수들을 가지고 있다.

In its DeviceAdminReceiver subclass, the sample application simply displays a Toast notification in response to particular events. For example:


DeviceAdminReceiver 의 subclass 에서, 예제 application 은 간단히 각각의 event 에 응답해서 Toast notification 만 표시한다. 예를 들면 :

public class DeviceAdminSample extends DeviceAdminReceiver {
...
    @Override
    public void onEnabled(Context context, Intent intent) {
        showToast(context, "Sample Device Admin: enabled");
    }

    @Override
    public CharSequence onDisableRequested(Context context, Intent intent) {
        return "This is an optional message to warn the user about disabling.";
    }

    @Override
    public void onDisabled(Context context, Intent intent) {
        showToast(context, "Sample Device Admin: disabled");
    }

    @Override
    public void onPasswordChanged(Context context, Intent intent) {
        showToast(context, "Sample Device Admin: pw changed");
    }

    void showToast(Context context, CharSequence msg) {
        Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    }
...
}

Enabling the application

One of the major events a device admin application has to handle is the user enabling the application. The user must explicitly enable the application for the policies to be enforced. If the user chooses not to enable the application it will still be present on the device, but its policies will not be enforced, and the user will not get any of the application's benefits.


device admin application 이 처리해야 하는 가장 중요한 event 중 하나는 사용자의 application 활성화 event 이다. 사용자는 보안 정책의 강제를 위해 application 을 명시적으로 활성화 해야 한다. 사용자가 application 을 활성화 하지 않기로 결정해도 해당 application 은 여전히 device 에 존재하지만, 정책을 강제 당하진 않으며, 사용자는 해당 application 으로부터 어떤 이득을 얻지 못할 것이다.

The process of enabling the application begins when the user performs an action that triggers the ACTION_ADD_DEVICE_ADMIN intent. In the sample application, this happens when the user clicks the Enable Admin button.


application 의 활성화는 사용자가 ACTION_ADD_DEVICE_ADMIN intent 를 발생시키면서 시작된다. 예제 application 에서, 이는 사용자가 Enable Admin 버튼을 클릭할 때 동작한다.

When the user clicks the Enable Admin button, the display changes to prompt the user to enable the device admin application, as shown in figure 2.


사용자가 Enable Admin 버튼을 클릭하면, figure 2 와 같은, 사용자의 device admin application 활성화를 위한 화면으로 이동한다.


Figure 2. Sample Application: Activating the Application
Below is the code that gets executed when the user clicks the Enable Admin button shown in figure 1.


아래는 사용자가 Enable Admin 버튼을 클릭했을 때 실행되는 code 다.

 private OnClickListener mEnableListener = new OnClickListener() {
    public void onClick(View v) {
        // Launch the activity to have the user enable our admin.
        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
               mDeviceAdminSample);
        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
               "Additional text explaining why this needs to be added.");
        startActivityForResult(intent, RESULT_ENABLE);
    }
};
...
// This code checks whether the device admin app was successfully enabled.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case RESULT_ENABLE:
            if (resultCode == Activity.RESULT_OK) {
                Log.i("DeviceAdminSample", "Administration enabled!");
            } else {
                Log.i("DeviceAdminSample", "Administration enable FAILED!");
            }
            return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
The line intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample) states that mDeviceAdminSample (which is a DeviceAdminReceiver component) is the target policy. This line invokes the user interface shown in figure 2, which guides users through adding the device administrator to the system (or allows them to reject it).


intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample) 은 mDeviceAdminSample(DeviceAdminReceiver component) 이 target policy 임을 가리킨다. 이 내용은 사용자가 사용자가 device administrator 를 system 에 추가하는(또는 이를 거부하는) figure 2 의 화면과 마주하도록 한다.

When the application needs to perform an operation that is contingent on the device admin application being enabled, it confirms that the application is active. To do this it uses the DevicePolicyManager method isAdminActive(). Notice that the DevicePolicyManager methodisAdminActive() takes a DeviceAdminReceiver component as its argument:


application 이 활성화된 device admin application 의 동작을 실행하고자 한다면, application 이 활성화 되어 있음을 확인해야 한다. 이를 위해 DevicePolicyManager 의 isAdminActive() 메소드를 사용 할 수 있다. DevicePolicyManager 의 isAdminActive() 메소드는 DeviceAdminReceiver component 를 그 인자로 사용함을 알아둬라 :

DevicePolicyManager mDPM;
...
boolean active = mDPM.isAdminActive(mDeviceAdminSample);
if (active) {
    // Admin app is active, so do some admin stuff
               ...
} else {
    // do something else
}

Managing policies

DevicePolicyManager is a public class for managing policies enforced on a device. DevicePolicyManager manages policies for one or more DeviceAdminReceiver instances.


DevicePolicyManager 는 기기에 강제된 정책을 관리하는 public class 이다.
DevicePolicyManager 는 하나 또는 이상의 DeviceAdminReceiver instance 를 위한 정책을 관리한다.

You get a handle to the DevicePolicyManager as follows:


당신은 다음과 같이 DevicePolicyManager 를 얻을 수 있다 :

DevicePolicyManager mDPM =
    (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
This section describes how to use DevicePolicyManager to perform administrative tasks:

이 section 은 관리 업무를 위해 어떻게 DevicePolicyManager 를 사용하는지 기술한다 :
  • password 정책 설정
  • 기기 lock 설정
  • data 삭제 실행

Set password policies

DevicePolicyManager includes APIs for setting and enforcing the device password policy. In the Device Administration API, the password only applies to screen lock. This section describes common password-related tasks.


DevicePolicyManager 는 기기의 password 정책을 설정하고 강제할 수 있는 API 를 포함한다. Device Administration API 에서, password 는 screen lock 에만 적용된다. 이 section 에서는 일반적인 password 에 관계된 동작에 대해 기술한다.

Set a password for the device
This code displays a user interface prompting the user to set a password:


아래의 코드는 사용자에게 password 를 설정하도록 하는 화면을 나타나게 한다 :

Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);
Set the password quality
The password quality can be one of the following DevicePolicyManager constants:
PASSWORD_QUALITY_ALPHABETIC
The user must enter a password containing at least alphabetic (or other symbol) characters.
PASSWORD_QUALITY_ALPHANUMERIC
The user must enter a password containing at least both numeric and alphabetic (or other symbol) characters.
PASSWORD_QUALITY_NUMERIC
The user must enter a password containing at least numeric characters.
PASSWORD_QUALITY_SOMETHING
The policy requires some kind of password, but doesn't care what it is.
PASSWORD_QUALITY_UNSPECIFIED
The policy has no requirements for the password.




password quality 는 아래의 DevicePolicyManager class 의 상수 중 하나가 될 수 있다 :
PASSWORD_QUALITY_ALPHABETIC
사용자는 문자(또는 특수문자)를 포함하는 password 를 설정 해야 한다.
PASSWORD_QUALITY_ALPHANUMERIC
사용자는 숫자와 문자(또는 특수문자)가 혼합된 password 를 설정 해야 한다.
PASSWORD_QUALITY_NUMERIC
사용자는 숫자로 이루어진 password 를 설정 해야 한다.
PASSWORD_QUALITY_SOMETHING
password 를 설정 해야 하지만, 그 구성을 제약하진 않는다.
PASSWORD_QUALITY_UNSPECIFIED
password 에 대한 강제 사항이 없다.




For example, this is how you would set the password policy to require an alphanumeric password:


예를 들어, 다음과 같이 문자+숫자 혼합 password 설정 정책을 설정 할 수 있다.

DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
...
mDPM.setPasswordQuality(mDeviceAdminSample, DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
Set the minimum password length
You can specify that a password must be at least the specified minimum length. For example:


다음과 같이 password 의 최소 길이를 설정 할 수 있다 :

DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
int pwLength;
...
mDPM.setPasswordMinimumLength(mDeviceAdminSample, pwLength);
Set maximum failed password attempts
You can set the maximum number of allowed failed password attempts before the device is wiped (that is, reset to factory settings). For example:


다음의 코드로 몇회의 password 입력 실패 시 기기의 data 삭제를 실행 할지 설정 할 수 있다 :

DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
int maxFailedPw;
 ...
mDPM.setMaximumFailedPasswordsForWipe(mDeviceAdminSample, maxFailedPw);

Set device lock

You can set the maximum period of user inactivity that can occur before the device locks. For example:


다음의 코드로 얼마 동안 사용자 입력이 없을 때 기기를 lock 할 지 설정 할 수 있다 :

DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
...
long timeMs = 1000L*Long.parseLong(mTimeout.getText().toString());
mDPM.setMaximumTimeToLock(mDeviceAdminSample, timeMs);
You can also programmatically tell the device to lock immediately:


또한 다음과 같이 당장 기기를 lock 하도록 할 수도 있다 :

DevicePolicyManager mDPM;
mDPM.lockNow();

Perform data wipe

You can use the DevicePolicyManager method wipeData() to reset the device to factory settings. This is useful if the device is lost or stolen. Often the decision to wipe the device is the result of certain conditions being met. For example, you can usesetMaximumFailedPasswordsForWipe() to state that a device should be wiped after a specific number of failed password attempts.


DevicePolicyManager 의 wipeData() 메소드를 이용해 factory setting 으로 기기를 복원 시킬 수 있다. 이것은 기기를 잃었거나 도난 당했을 때 유용할 것이다. 종종 데이터 삭제는 여러 조건이 복합되었을 때 결정된다. 예를 들어, setMaximumFailedPasswordsForWipe() 를 이용해 여러번 password 입력이 실패했을 때에 데이터 삭제를 진행한다.
You wipe data as follows:


데이터 삭제는 다음과 같이 실행할 수 있다 :

DevicePolicyManager mDPM;
mDPM.wipeData(0);
The wipeData() method takes as its parameter a bit mask of additional options. Currently the value must be 0.


wipeData() 메소드는 추가적인 옵션을 bit mask 로 해서 그 인자로 받는다.
현재로썬, 이 값은 반드시 0이어야 한다.
MIME-Type Description File Extension
application/acad AutoCAD drawing files dwg
application/clariscad ClarisCAD files ccad
application/dxf DXF (AutoCAD) dxf
application/msaccess Microsoft Access file mdb
application/msword Microsoft Word file doc
application/octet-stream Uninterpreted binary bin
application/pdf PDF (Adobe Acrobat) pdf
application/postscript Postscript, encapsulated Postscript, ai, ps, eps
Adobe Illustrator
application/rtf Rich Text Format file rtf rtf
application/vnd.ms-excel Microsoft Excel file xls
application/vnd.ms-powerpoint Microsoft PowerPoint file ppt
application/x-cdf Channel Definition Format file cdf
application/x-csh C-shell script csh csh
application/x-dvi TeX dvi dvi dvi
application/x-javascript Javascript source file js
application/x-latex LaTeX source file latex
application/x-mif FrameMaker MIF format mif
application/x-msexcel Microsoft Excel file xls
application/x-mspowerpoint Microsoft PowerPoint file ppt
application/x-tcl TCL script tcl
application/x-tex TeX source file tex
application/x-texinfo Texinfo (emacs) texinfo, texi
application/x-troff troff file t, tr, roff t, tr, roff
application/x-troff-man troff with MAN macros man
application/x-troff-me troff with ME macros me
application/x-troff-ms troff with MS macros ms
application/x-wais-source WAIS source file src
application/zip ZIP archive zip
audio/basic Basic audio (usually m-law) au, snd
audio/x-aiff AIFF audio aif, aiff, aifc
audio/x-wav Windows WAVE audio wav
image/gif GIF image gif
image/ief Image Exchange Format file ief
image/jpeg JPEG image jpeg, jpg jpe
image/tiff TIFF image tiff, tif
image/x-cmu-raster CMU Raster image ras
image/x-portable-anymap PBM Anymap image format pnm
image/x-portable-bitmap PBM Bitmap image format pbm
image/x-portable-graymap PBM Graymap image format pgm
image/x-portable-pixmap PBM Pixmap image format ppm
image/x-rgb RGB image format rgb
image/x-xbitmap X Bitmap image xbm
image/x-xpixmap X Pixmap image xpm
image/x-xwindowdump X Windows Dump (xwd) xwd
multipart/x-gzip GNU ZIP archive gzip
multipart/x-zip PKZIP archive zip
text/css Cascading style sheet css
text/html HTML file html, htm
text/plain Plain text txt
text/richtext MIME Rich Text rtx
text/tab-separated- values Text with tab-separated values tsv
text/xml XML document xml
text/x-setext Struct-Enhanced text etx
text/xsl XSL style sheet xsl
video/mpeg MPEG video mpeg, mpg, mpe
video/quicktime QuickTime video qt, mov
video/x-msvideo Microsoft Windows video avi
video/x-sgi-movie SGI movie player format movie


MIME 확장명

파일 확장명 

 application/x-silverlight-app  .xap
 application/manifest  .manifest 
 application/x-ms-application  .application 
 application/x-ms-xbap  .xbap
 application/octet-stream  .deploy
 application/vnd.ms-xpsdocument  .xps 
 application/xaml+xml  .xaml
 application/vnd.ms-cab-compressed  .cab
 application/vnd.openxmlformats-officedocument.wordprocessingml.document  .docx
 application/vnd.openxmlformats-officedocument.wordprocessingml.document  .docm
 application/vnd.openxmlformats-officedocument.presentationml.presentation  .pptx
 application/vnd.openxmlformats-officedocument.presentationml.presentation  .pptm
 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet  .xlsx
 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet  .xlsm
 application/msaccess  .accdb
 application/x-mspublisher  .pub
 image/svg+xml  .svg
 application/xhtml+xml  .xht
 application/xhtml+xml  .xhtml

+ Recent posts