2

Hi I am learning android security so there I went through a topic where someone mentioned a custom permission on activity as like below :-

<permission android:name=”com.testpaccourierkage.mypermission” 
    android:label=”my_permission” 
    android:protectionLevel=”dangerous” 
    android:description=”@string/detonate_description” />

<application> 
    <activity 
        android:permission=”com.testpackage.mypermission”            
        android:name=”.PermissionTestClientActivity”            
        android:label=”@string/app_name”/>  
</application>

I could not understand the use of this. How and where we can use this concept.

Thanks in advance.

guipivoto
  • 18,327
  • 9
  • 60
  • 75
N Sharma
  • 33,489
  • 95
  • 256
  • 444
  • Take a look at [this](http://stackoverflow.com/questions/17078369/few-questions-about-custom-permissions-in-android?lq=1 ) thread to know more about custom permissions – Shashank Udupa May 01 '16 at 14:28

1 Answers1

3

If you are writing a suite of apps, and you want to have an activity in one app that other apps in the suite can start, but arbitrary other third-party apps cannot start, you could use a custom permission as shown in your question.

This is rather unusual. Custom permissions in general are rather unusual, in part because they were designed for pre-installed apps and do not work well for normal Android SDK apps.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • how pre-installed apps are using this concept ? any example – N Sharma May 01 '16 at 14:30
  • @Williams: They use it the same way. The advantage is that they are pre-installed, and so their custom permission definitions are the ones that are enforced. – CommonsWare May 01 '16 at 14:33
  • I still could not understand use of it. what is the need of it. – N Sharma May 01 '16 at 16:33
  • @Williams: "I still could not understand use of it" -- then do not use it. Few developers have a need for custom permissions. – CommonsWare May 01 '16 at 16:36
  • yes but i want to know why few developers need custom permissions. – N Sharma May 01 '16 at 16:37
  • 1
    @Williams: Few developers write more than one app. – CommonsWare May 01 '16 at 16:40
  • so if i set the protection level to dangerous then when i install that app with custom permission then android will ask that permission while installing right ? – N Sharma May 01 '16 at 16:48
  • @Williams: Let us assume two apps: App A and App B. If App A has `` for some custom `dangerous` permission, and App B has `` for the same name, and App A is installed before App B, then when App B is installed, the user should be prompted for that permission, at least prior to Android 6.0. – CommonsWare May 01 '16 at 16:52
  • Thanks great.. i understood :) – N Sharma May 01 '16 at 16:54