Android is a multi-process system, in which each application (and parts of the system) runs in its own process. Most security between applications and the system is enforced at the process level through standard Linux facilities, such as user and group IDs that are assigned to applications. Additional finer-grained security features are provided through a "permission" mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data.
안드로이드는 각각의 애플리케이션과 시스템 내의 각 영역들이, 자신의 고유한 프로세스 상에서 실행되는 멀티 프로세스 시스템이다. 애플리케이션과 시스템간의 대부분의 보안은 애플리케이션에 할당된 유저User나 그룹 ID와 같은 표준 리눅스 설비를 통해 프로세스 레벨에서 강제된다. 보다 섬세한 추가적인 보안 기능은 퍼미션permission 메커니즘에 의해 제공된다. 퍼미션은 특정 프로세스가 수행할 수 있는 특정 오퍼레이션에 제약을 부가한다. 그리고 데이터의 특정 영역에 대한 임시적 접근을 부여하는 URI 별(per-URI) 퍼미션이 있다.
A central design point of the Android security architecture is that no application, by default, has permission to perform any operations that would adversely impact other applications, the operating system, or the user. This includes reading or writing the user's private data (such as contacts or e-mails), reading or writing another application's files, performing network access, keeping the device awake, etc.
안드로이드 보안 아키텍처의 핵심 디자인 요점은, 디폴트로 어떤 애플리케이션들도 다른 애플리케이션과 운영체제, 또는 사용자에게 나쁜 영향을 미칠 수 있는 임의의 오퍼레이션을 수행할 수 있는 퍼미션을 가지 않는다는 것이다. 이것은 (컨택 또는 이메일과 같은) 사용자의 개인적인 데이터에 대한 읽고 쓰기 및 다른 애플리케이션의 파일에 대한 읽고 쓰기, 네트워크 접근, 디바이스에 대한 활성 상태 유지 등을 포함한다.
An application's process is a secure sandbox. It can't disrupt other applications, except by explicitly declaring the permissions it needs for additional capabilities not provided by the basic sandbox. These permissions it requests can be handled by the operating in various ways, typically by automatically allowing or disallowing based on certificates or by prompting the user. The permissions required by an application are declared statically in that application, so they can be known up-front at install time and will not change after that.
애플리케이션의 프로세스는 보안 안전판sandbox이다. 그것은 기본적인 안전판에 의해 제공되지 않는 추가적인 기능들을 위해 필요한 퍼미션을 명시적으로 선언하는 않고서는, 다른 애플리케이션에 혼란을 줄 수 없다. 그것이 요구하는 이러한 퍼미션들은 다양한 방법들로 운영체제에 의해 제어될 수 있으며, 전형적으로는 인증서를 기반으로 자동으로 허용하거나 또는 불허되며, 사용자에게 확인을 요청하는 것에 의해 제어된다. 하나의 애플리케이션에 의해 요청된 퍼미션은 그 애플리케이션 내에 정적static으로 선언된다. 그러므로 그 퍼미션은 그 애플리케이션의 설치 전에 알 수 있으며, 그 후에는 변경될 수 없다.
All Android applications (.apk files) must be signed with a certificate whose private key is held by their developer. This certificate identifies the author of the application. The certificate does not need to be signed by a certificate authority: it is perfectly allowable, and typical, for Android applications to use self-signed certificates. The certificate is used only to establish trust relationships between applications, not for wholesale control over whether an application can be installed. The most significant ways that signatures impact security is by determining who can access signature-based permissions and who can share user IDs.
모든 안드로이드 애플리케이션들(.apk 파일들)은 그것의 개발자가 보유한 개인키 인증서로 서명되어야 한다. 이 인증서는 애플리케이션의 작성자를 식별한다. 인증서는 공식적인 인증기관에 의해 서명될 필요가 없다: 안드로이드 애플리케이션에서 자체적으로 서명된 인증서를 사용하는 것은, 완벽하게 허용되며 전형적이다. 인증서는 애플리케이션들 간의 신뢰관계를 확립하기 위해서 사용될 뿐이며, 애플리케이션이 설치될 수 있는 가에 대한 판매 통제를 위한 것이 아니다. 서명이 보안에 미치는 가장 중요한 사항들은 서명 기반의 퍼미션에 누가 접근 가능하며 누가 사용자 ID를 공유할 수 있는 지를 결정하는 것이다.
Each Android package (.apk) file installed on the device is given its own unique Linux user ID, creating a sandbox for it and preventing it from touching other applications (or other applications from touching it). This user ID is assigned to it when the application is installed on the device, and remains constant for the duration of its life on that device.
디바이스 상에 설치된 각각의 안드로이드 패키지(.apk) 파일에는 그것 자신의 고유한 리눅스 유저 ID가 부여된다. 이것은 패키지에 대한 안전판을 만들며 그것이 다른 애플리케이션를 터치하는 것을 방지한다(또는 다른 애플리케이션이 그것을 터치하는 것을 방지한다). 이 유저 ID는 애플리케이션이 디바이스에 설치될 때 할당되며, 그 디바이스에 그것이 존속하는 동안 변하지 않고 유지된다.
Because security enforcement happens at the
process level, the code of any two packages can not normally
run in the same process, since they need to run as different Linux users.
You can use the sharedUserId attribute in the
AndroidManifest.xml's
manifest tag of each package to
have them assigned the same user ID. By doing this, for purposes of security
the two packages are then treated as being the same application, with the same
user ID and file permissions. Note that in order to retain security, only two applications
signed with the same signature (and requesting the same sharedUserId) will
be given the same user ID.
보안에 대한 강제enforcement는 프로세스 레벨에서 이루어지기 때문에, 임의의 두 개의 패키지 내의 코드는 일반적으로 동일한 프로세스에서 실행될 수 없다. 따라서 그것은 서로 다른 리눅스 유저로써 실행되어야 한다. 여러분은 그것들에게 동일한 유저 ID를 부여하기 위해, 각각의 패키지 내의 AndroidManifest.xml의 manifest 태그의 sharedUserId 애트리뷰트를 사용할 수 있다. 이렇게 함으로써, 보안적 측면에서 두 개의 패키지는 동일한 애플리케이션으로 간주되며 동일한 유저 ID와 파일 퍼미션을 갖는다. 보안을 유지하기 위해, 동일한 서명을 가진 (그리고 동일한 sharedUserId를 요청하고 있는) 두 개의 애플리케이션에게만 동일한 유저 ID가 부여된다는 것에 주의하라.
Any data stored by an application will be assigned that application's user
ID, and not normally accessible to other packages. When creating a new file
with getSharedPreferences(String, int),
openFileOutput(String, int), or
openOrCreateDatabase(String, int, SQLiteDatabase.CursorFactory),
you can use the
MODE_WORLD_READABLE and/or
MODE_WORLD_WRITEABLE flags to allow any other
package to read/write the file. When setting these flags, the file is still
owned by your application, but its global read and/or write permissions have
been set appropriately so any other application can see it.
애플리케이션에 의해 저장된 모든 데이터는 그 애플리케이션의 유저 ID가 부여될 것이며, 일반적으로는 다른 패키지들에게는 접근 불가하다. 여러분이 어떤 파일을 getSharedPreferences(String, int), openFileOutput(String,int), openOrCreateDatabase(String,int,SQLiteDatabase.CursorFactory)를 사용하여 생성할 경우, 여러분은 파일에 대한 읽기/쓰기를 다른 패키지에 허용하기 위해 MODE_WORLD_READABLE 과 MODE_WORLD_WRITEABLE 플래그를 사용할 수 있다. 이러한 플래그를 설정하면 그 파일은 여전히 여러분의 애플리케이션 소유하에 있지만, 다른 애플리케이션이 그것을 볼 수 있도록 그것에 대한 글로벌global 읽기 쓰기 퍼미션이 적절하게 설정된다.
A basic Android application has no permissions associated with it,
meaning it can not do anything that would adversely impact the user experience
or any data on the device. To make use of protected features of the device,
you must include in your AndroidManifest.xml one or more
tags declaring the permissions that your application needs.<uses-permission>
기본적인 안드로이드 애플리케이션은 그것과 관련된 어떠한 퍼미션도 가지고 있지 않다. 이것이 의미하는 바는, 그것이 사용자의 경험experience과 디바이스 상의 임의의 데이터에 나쁜 영향을 미칠 어떠한 것도 할 수 없다는 것이다. 디바이스의 보호된 기능을 사용하기 위해서는, 여러분의 AndroidManifest.xml 내에 여러분의 애플리케이션이 필요로 하는 퍼미션을 선언하는 하나 또는 그 이상의 <uses-permission> 태그를 포함해야 한다.
For example, an application that needs to monitor incoming SMS messages would specify:
예를 들어 SMS 메시지 수신을 모니터링할 필요가 있는 애플리케이션은 다음과 같이 지정할 수 있다.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.app.myapp" >
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</manifest>
At application install time, permissions requested by the application are granted to it by the package installer, based on checks against the signatures of the applications declaring those permissions and/or interaction with the user. No checks with the user are done while an application is running: it either was granted a particular permission when installed, and can use that feature as desired, or the permission was not granted and any attempt to use the feature will fail without prompting the user.
애플리케이션 설치 시점에, 애플리케이션에 의해 요청된 퍼미션은 해당 퍼미션을 선언하고 있는 애플리케이션의 서명 확인을 기반으로, 그리고(또는) 사용자와의 상호작용에 기반해서 패키지 인스톨러에 의해 그 애플리케이션에게 부여된다. 애플리케이션이 실행되는 동안에는 사용자와의 어떤 확인 절차도 이루어지지 않는다: 애플리케이션이 설치될 때 특정 퍼미션이 부여되어 해당 기능을 원하는 대로 사용할 수 있거나, 또는 그 퍼미션이 부여되지 않아 그 기능을 사용하려는 어떠한 시도도 사용자에게 알리지 않고 실패할 것이다.
Often times a permission failure will result in a SecurityException being thrown back to the application. However,
this is not guaranteed to occur everywhere. For example, the sendBroadcast(Intent) method checks permissions as data is
being delivered to each receiver, after the method call has returned, so you
will not receive an exception if there are permission failures. In almost all
cases, however, a permission failure will be printed to the system log.
종종 퍼미션 실패는 애플리케이션에 보안 예외(SecurityException)가 발생하게 된다. 그러나, 이것은 모든 곳에서 발생하는 것을 보장받지는 못한다. 예를 들어, sendBroadcast(Intent) 메쏘드는 메쏘드 호출이 리턴된 후 데이터가 각각의 리시버에게 전달될 때 퍼미션들을 체크한다. 그러므로 여러분은 그곳에서 퍼미션 실패가 있더라도 그 예외(Exception)를 수신할 수 없을 것이다. 그러나, 거의 대부분의 경우에 퍼미션 실패는 시스템 로그에 기록될 것이다.
The permissions provided by the Android system can be found at Manifest.permission. Any application may also define and enforce its
own permissions, so this is not a comprehensive list of all possible
permissions.
안드로이드 시스템에 의해 제공되는 퍼미션은 Manifest.permission에서 볼 수 있다. 모든 애플리케이션은 자기 자신의 퍼미션을 정의하고 강제할 수 있다. 그러므로 이것은 모든 가능한 퍼미션들을 포함하는 목록은 아니다.
A particular permission may be enforced at a number of places during your program's operation:
여러분이 프로그램이 오퍼레이션되는 동안에 특정 퍼미션이 여러 곳에서 강제될 지도 모른다.
To enforce your own permissions, you must first declare them in your
AndroidManifest.xml using one or more
tags.<permission>
여러분 자신의 퍼미션을 사용하기 위해서, 여러분은 하나 또는 그 이상의 <permission> 태그를 사용해서 AndroidManifest.xml 에 그것들을 먼저 선언해야 한다.
For example, an application that wants to control who can start one of its activities could declare a permission for this operation as follows:
예를 들어 누가 자신의 액티비티들 중의 하나를 시작할 수 있는 가를 제어하길 원하는 애플리케이션은, 아래와 같은 방식으로 이러한 오퍼레이션에 대한 퍼미션을 선언할 수 있다.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.app.myapp" >
<permission android:name="com.me.app.myapp.permission.DEADLY_ACTIVITY"
android:label="@string/permlab_deadlyActivity"
android:description="@string/permdesc_deadlyActivity"
android:permissionGroup="android.permission-group.COST_MONEY"
android:protectionLevel="dangerous" />
</manifest>
The <protectionLevel> attribute is required, telling the system how the
user is to be informed of applications requiring the permission, or who is
allowed to hold that permission, as described in the linked documentation.
9장. “AndroidManifest.xml”의 permission 엘리먼트(protectionLevel을 보라.)에서 설명되듯이, 사용자가 퍼미션을 요구하는 애플리케이션들을 어떻게 알게 되는지, 또는 해당 퍼미션를 보유하는 것이 누구에게 허용되는지를 시스템에 알려주기 위해 <protectionLevel> 애트리뷰트가 요구된다.
The <permissionGroup> attribute is optional, and only used to help the system display
permissions to the user. You will usually want to set this to either a standard
system group (listed in android.Manifest.permission_group) or in more rare cases to one defined by
yourself. It is preferred to use an existing group, as this simplifies the
permission UI shown to the user.
<permissionGroup> 애트리뷰트는 선택 사항이다. 그것은 단지 시스템이 사용자에게 퍼미션을 표시하는 것을 돕기 위하여 사용된다. 여러분은 일반적으로 (android.Manifest.permission_group 에서 리스트 된) 표준 시스템 그룹을 이곳에 설정하길 원할 수 있으며, 또는 다소 드문 경우지만 스스로 직접 정의한 것을 설정할 수도 있다. 사용자에게 보여지는 퍼미션 UI를 단순화하고자 한다면, 이미 존재하는 퍼미션 그룹을 사용하는 것이 좋다.
Note that both a label and description should be supplied for the
permission. These are string resources that can be displayed to the user when
they are viewing a list of permissions
()
or details on a single permission (
android:label).
The label should be short, a few words
describing the key piece of functionality the permission is protecting. The
description should be a couple sentences describing what the permission allows
a holder to do. Our convention for the description is two sentences, the first
describing the permission, the second warning the user of what bad things
can happen if an application is granted the permission.android:description
퍼미션을 위해서는 라벨label과 설명description 두 가지 모두가 제공되어야 하는 것에 주의하라. 이것은 문자열 리소스로써, android:lable은 사용자가 퍼미션 리스트를 볼 때 표시되며, android:description은 한 개의 퍼미션을 상세히 볼 때 표시된다. 라벨은 퍼미션이 보호하고 있는 기능의 핵심 부분을 몇 개의 단어로 기술하도록 간결해야 한다. 설명descrption은 그 퍼미션을 보유하고 있는 것에게 무엇이 허용되는 지를 설명하는 두 개의 문장이어야 한다. 그 설명description을 기술하는 방법은 두 개의 문장인데, 첫 번째 문장은 퍼미션을 설명하는 것이며, 두 번째 문장은 애플리케이션에 해당 퍼미션이 부여되었을 때 발생할 수 있는 나쁜 것이 무엇인지를 사용자에게 경고하는 것이다.
Here is an example of a label and description for the CALL_PHONE permission:
여기에 CALL_PHONE 퍼미션에 대한 라벨label과 설명description의 예제가 있다.
<string name="permlab_callPhone">directly call phone numbers</string>
<string name="permdesc_callPhone">Allows the application to call
phone numbers without your intervention. Malicious applications may
cause unexpected calls on your phone bill. Note that this does not
allow the application to call emergency numbers.</string>
You can look at the permissions currently defined in the system with the
shell command adb shell pm list permissions. In particular,
the '-s' option displays the permissions in a form roughly similar to how the
user will see them:
여러분은 shell 명령어, adb shell pm list permissions를 사용해서, 시스템에 현재 정의되어 있는 퍼미션들을 볼 수 있다. 특히, ‘-s’ 옵션은 사용자가 퍼미션들을 보는 방식과 대략적으로 비슷한 형식으로 퍼미션을 보여준다.
$ adb shell pm list permissions -s All Permissions: Network communication: view Wi-Fi state, create Bluetooth connections, full Internet access, view network state Your location: access extra location provider commands, fine (GPS) location, mock location sources for testing, coarse (network-based) location Services that cost you money: send SMS messages, directly call phone numbers ...
High-level permissions restricting access to entire components of the
system or application can be applied through your
AndroidManifest.xml. All that this requires is including an android:permission attribute on the desired
component, naming the permission that will be used to control access to
it.
시스템이나 애플리케이션의 모든 컴포넌트에 대한 접근을 제약하는 상위계층의 퍼미션들은 여러분의 AndroidManifest.xml을 통해서 적용될 수 있다. 이를 위해 요구되는 것은 필요한 컴포넌트에 android:permission 애트리뷰트를 포함하고, 그 컴포넌트에 대한 접근을 제어하기 위해 사용될 퍼미션 이름을 지정하는 것이 전부이다.
Activity permissions
(applied to the
<activity> tag)
restrict who can start the associated
activity. The permission is checked during
Context.startActivity() and
Activity.startActivityForResult();
if the caller does not have
the required permission then SecurityException is thrown
from the call.
<activity> 태그에 적용된 액티비티 퍼미션은, 누가 해당 액티비티를 시작할 수 있는 지를 제약한다. 그 퍼미션은 Context.startActivity()와 Activity.start ActivityForResult() 함수 내에서 점검된다. 만약 호출자caller가 필요한 퍼미션을 가지고 있지 않으면, 보안예외SecurityException가 호출되는 곳에서 발생된다.
Service permissions
(applied to the
<service> tag)
restrict who can start or bind to the
associated service. The permission is checked during
Context.startService(),
Context.stopService() and
Context.bindService();
if the caller does not have
the required permission then SecurityException is thrown
from the call.
<service> 태그에 적용된 서비스 퍼미션은, 누가 해당 서비스를 시작하거나 바인드할 수 있는가를 제약한다. 퍼미션은 Context.startService(), Contextstop Service() 그리고 Context.bindService() 함수내에서 점검된다. 만약 호출자caller가 필요한 퍼미션을 가지고 있지 않다면, 보안예외SecurityException가 호출되는 곳에서 발생된다.
BroadcastReceiver permissions
(applied to the
<receiver> tag)
restrict who can send broadcasts to the associated receiver.
The permission is checked after
Context.sendBroadcast() returns,
as the system tries
to deliver the submitted broadcast to the given receiver. As a result, a
permission failure will not result in an exception being thrown back to the
caller; it will just not deliver the intent. In the same way, a permission
can be supplied to
Context.registerReceiver()
to control who can broadcast to a programmatically registered receiver.
Going the other way, a permission can be supplied when calling
Context.sendBroadcast()
to restrict which BroadcastReceiver objects are allowed to receive the broadcast (see
below).
<receiver> 태그에 적용된 보로드캐스트 리시버 퍼미션은, 누가 해당 리시버에게 브로드캐스트를 발송할 수 있는가를 제약한다. 퍼미션은 Context.send Broadcast()가 리턴된 후, 시스템이 제출된 브로드캐스트를 주어진 리시버에 전달하기를 시도할 때 점검된다. 결론적으로, 퍼미션 실패는 호출자caller에게 예외exception 결과를 발생시키지 않는다; 다만 퍼미션 실패는 인텐트를 전달하지 못할 뿐이다. 같은 방식으로, 프로그램적으로 등록된 리시버에게 누가 브로드캐스트를 할 수 있는가를 제어하기 위해 Context.registerReceiver()에 퍼미션을 제공할 수 있다. 다른 방법으로 어떤 브로드캐스트 리시버 오브젝트가 브로드캐스트를 수신하는 것이 허용되는 지를 제약하기 위해, Context.sendBroadcast()를 호출할 때 퍼미션이 제공될 수 있다(아래를 보라).
ContentProvider permissions
(applied to the
<provider> tag)
restrict who can access the data in
a ContentProvider. (Content providers have an important
additional security facility available to them called
URI permissions which is described later.)
Unlike the other components,
there are two separate permission attributes you can set:
android:readPermission restricts who
can read from the provider, and
android:writePermission restricts
who can write to it. Note that if a provider is protected with both a read
and write permission, holding only the write permission does not mean
you can read from a provider. The permissions are checked when you first
retrieve a provider (if you don't have either permission, a SecurityException
will be thrown), and as you perform operations on the provider. Using
ContentResolver.query() requires
holding the read permission; using
ContentResolver.insert(),
ContentResolver.update(),
ContentResolver.delete()
requires the write permission.
In all of these cases, not holding the required permission results in a
SecurityException being thrown from the call.
<provider> 태그에 적용된 컨텐트 프로바이더 퍼미션은, 누가 컨텐트 프로로바이더에 있는 데이터에 접근할 수 있는 가를 제약한다(컨텐트 프로바이더는 그들에게 유용한 추가적인 중요한 보안 설비를 가지고 있다. 그것은 URI 퍼미션이라 불리며 나중에 설명된다). 다른 컴포넌트와 달리, 그곳에는 여러분이 설정할 수 있는 두 개의 별도의 퍼미션 애트리뷰트가 있다. android:readPermission은 누가 프로바이더로부터 읽기를 할 수 있는가를 제약하며, android:writePermission은 누가 그것에 쓰기를 할 수 있는가를 제약한다. 만약 프로바이더가 읽기와 쓰기 퍼미션 두 가지로 보호되고 있다면, 쓰기 퍼미션만을 가지고는 여러분이 프로바이더로부터 읽기를 할 수 없다는 것을 의미한다. 퍼미션은 여러분이 처음으로 프로바이더를 얻어올 때 점검되며(만약 여러분이 두 가지 퍼미션 중 어느 하나라도 가지고 있지 않다면, 보안예외(SecurityException)가 발생할 것이다), 그런 다음에 여러분은 프로바이더에 대한 오퍼레이션을 수행한다. ContentResolver.query()를 사용하는 것은 읽기 퍼미션을 가지는 것을 필요로 하며, ContentResolver.insert(), ContentResolver.update(), ContentResolver.delete()를 사용하는 것은 쓰기 퍼미션을 필요로 한다. 이 모든 경우에서, 필요한 퍼미션을 보유하지 않으면 호출하는 곳으로 보안예외SecurityException가 발생하게 된다.
In addition to the permission enforcing who can send Intents to a
registered BroadcastReceiver (as described above), you
can also specify a required permission when sending a broadcast. By calling Context.sendBroadcast() with a
permission string, you require that a receiver's application must hold that
permission in order to receive your broadcast.
(위에서 기술한 것처럼) 누가 등록된 브로드캐스트 리시버에 인텐트를 발송할 수 있는가를 강제하는 퍼미션에 추가해서, 여러분은 브로드캐스트를 보낼 때 필요한 퍼미션을 또한 지정할 수 있다. 퍼미션 문자열을 가지는 Context.sendBroadcast()를 호출하는 것으로, 여러분은 브로드캐스트를 수신하기 위해서는 리시버 애플리케이션이 그 퍼미션을 보유해야 한다는 것을 요구한다.
Note that both a receiver and a broadcaster can require a permission. When this happens, both permission checks must pass for the Intent to be delivered to the associated target.
리시버와 브로드캐스터 둘 다 퍼미션을 요구할 수 있다는 것에 주목하라. 이것이 일어날 때, 관련된 타겟에 인텐트가 전달되도록 하기 위해서는 양쪽 모두의 퍼미션 점검이 통과pass되어야 한다.
Arbitrarily fine-grained permissions can be enforced at any call into a
service. This is accomplished with the Context.checkCallingPermission()
method. Call with a desired
permission string and it will return an integer indicating whether that
permission has been granted to the current calling process. Note that this can
only be used when you are executing a call coming in from another process,
usually through an IDL interface published from a service or in some other way
given to another process.
임의의 정교한 퍼미션들이 하나의 서비스 안으로 호출이 일어날 때 강제될 수 있다. 이것은 Context.checkCallingPermission() 메쏘드를 통해 이뤄진다. 요구되는 퍼미션 문자열을 가지고 호출하라. 그러면 그것은 그 퍼미션이 현재 호출하는 프로세스에게 부여되었는지 여부를 가리키는 정수integer를 리턴할 것이다. 이것은 여러분이 다른 프로세스로부터 들어오는 호출을 실행할 때 사용될 수 있을 뿐이라는 것에 주의하라. 외부로부터 들어오는 호출은 보통 서비스에서 배포된 IDL 인터페이스를 통하거나 또는 다른 프로세스에 제공된 몇가지 다른 방법들에 기반한다.
There are a number of other useful ways to check permissions. If you have
the pid of another process, you can use the Context method Context.checkPermission(String, int, int)
to check a permission against that pid. If you have the package name of another
application, you can use the direct PackageManager method PackageManager.checkPermission(String, String)
to find out whether that particular package has been granted a specific permission.
퍼미션을 점검하기 위한 다른 유용한 방법들이 많이 존재한다. 만약 여러분이 다른 프로세스의 pid(프로세스 ID)를 가지고 있다면, 여러분은 그 pid에 대한 퍼미션을 점검하기 위해 컨텍스트 메쏘드 Context.checkPermission(String, int, int)을 이용할 수 있다. 만약 여러분이 다른 애플리케이션의 패키지 이름을 가지고 있다면, 여러분은 특정한 패키지가 특정 퍼미션을 부여받았는 지를 알아 내기 위해 직접 패키지 매니저의 메쏘드인 PackageManager.check Permission(String, String)을 사용할 수 있다.
The standard permission system described so far is often not sufficient when used with content providers. A content provider may want to protect itself with read and write permissions, while its direct clients also need to hand specific URIs to other applications for them to operate on. A typical example is attachments in a mail application. Access to the mail should be protected by permissions, since this is sensitive user data. However, if a URI to an image attachment is given to an image viewer, that image viewer will not have permission to open the attachment since it has no reason to hold a permission to access all e-mail.
지금까지 기술된 표준 퍼미션 시스템은 컨텐트 프로바이더를 사용할 때는 가끔 충분치 않다. 컨텐트 프로바이더는 읽기와 쓰기 퍼미션을 가지고 그것 자신을 보호하길 원할 수도 있다. 동시에, 프로바이더의 직접적인 클라이언트 또한 그 안에서 다른 애플리케이션들이 오퍼레이션을 할 수 있도록 그것들에 대한 특정 URI들을 건네줄 필요가 있다. 일반적인 예제가 메일 애플리케이션의 첨부파일이다. 메일에 대한 접근은 퍼미션에 의해 보호되어야 한다. 왜냐하면, 이것은 민감한 사용자 데이터이기 때문이다. 하지만 만약 이미지 첨부파일에 대한 URI가 이미지 뷰어에게 주어진다면, 이미지 뷰어는 모든 이메일에 대한 접근 퍼미션을 가질 이유가 없기 때문에 첨부파일을 오픈하기 위한 퍼미션를 가지지 않을 것이다.
The solution to this problem is per-URI permissions: when starting an
activity or returning a result to an activity, the caller can set
Intent.FLAG_GRANT_READ_URI_PERMISSION and/or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION. This grants the receiving activity
permission access the specific data URI in the Intent, regardless of whether
it has any permission to access data in the content provider corresponding
to the Intent.
이 문제의 해결책은 per-URI 퍼미션이다. 액티비티를 시작시킬 때나 혹은 결과를 액티비티에 리턴할 때, 그것을 호출한 곳에서 Intent.FLAG_GRANT_READ_URI_PERMISSION 및(또는) Intent.FLAG_GRANT_WRITE_URI_PERMISSION을 설정할 수 있다. 이것은 인텐트를 수신하는 액티비티가 인텐트에 대응되는 컨텐트 프로바이더 내의 데이터 접근 퍼미션을 보유하고 있는지와 상관없이, 그 액티비티에게 그 인텐트 내의 특정 데이터 URI에 대한 접근 퍼미션을 부여한다.
This mechanism allows a common capability-style model where user interaction (opening an attachment, selecting a contact from a list, etc) drives ad-hoc granting of fine-grained permission. This can be a key facility for reducing the permissions needed by applications to only those directly related to their behavior.
이 메커니즘은 사용자 상호작용(첨부파일을 여는 것, 컨택을 리스트에서 선택하는 것, 기타)이 임시로 정교한 퍼미션을 부여하게 하는 곳에서 일반적인 기능-스타일capability-style 모델을 가능하게 한다. 이것은 애플리케이션들에 의해 필요한 퍼미션을 오직 그것들이 직접적으로 관련된 동작에만 국한하는 핵심 설비가 될 수 있다.
The granting of fine-grained URI permissions does, however, require some
cooperation with the content provider holding those URIs. It is strongly
recommended that content providers implement this facility, and declare that
they support it through the
android:grantUriPermissions attribute or
<grant-uri-permissions> tag.
정교한 URI 퍼미션을 부여하는 것은, 어쨌거나 그러한 URI를 보유한 컨텐트 프로바이더와의 약간의 협력을 요구한다. 컨텐트 프로바이더가 이 설비를 구현하고 android:grantUriPermissions 애트리뷰트 또는 <grant-uri-permissions> 태그를 통해 그것을 지원한다는 것을 선언하는 것이 강력히 권장된다.
More information can be found in the
Context.grantUriPermission(),
Context.revokeUriPermission(), and
Context.checkUriPermission()
methods.
Context.grantUriPermission(), Context.revokeUriPermission(), Context.checkUriPermission() 메쏘드에서 더 많은 정보들을 찾을 수 있다.