4

I have an application say A that have all the permissions enabled at installation. Another app Say B don't have a permission and want to get that permission. Can B communicate with A, So that A can transfer its permission to B.

PLS reply, I'm stuck here. I want to get some permissions dynamically. Is this the best idea or any other idea?

scari
  • 86
  • 2
  • 10

4 Answers4

5

As far as I know, apps can't necessarily give permissions to other apps, BUT AppB could inherit permissions from AppA IF you are the developer of both apps. If both AppA and AppB declare the same sharedUserId value in their manifest (android:sharedUserId="xyz") AND both AppA and AppB are signed with the same signature, then Android will consider them to be the same app as far as permissions go. So, AppB could exist on the device without permission "perm1" for example. Then, AppA could be installed with "perm1". IF AppA and AppB have the same sharedUserId and signature then, when AppA is installed, AppB will be "granted" "perm1".

I haven't tested this just now, but I know it used to work (as of a year ago or so).

user1098205
  • 51
  • 1
  • 2
1

Yes this is possible in a roundabout way using PendingIntents. This is not an exact code snippet but should give you the idea:

You cannot transfer the permissions, but you can transfer capabilities to perform certain actions from A to B. Let's say you want to transfer the capability of executing a certain ACTION.

  1. A needs to create a pending intent:

    Intent intent = new Intent(ACTION);
    PendingIntent pIntent = PendingIntent.getActivity(context, requestCode, intent, flags);

  2. A sends this to B by marshalling the pending intent

    Intent intent = new Intent(context, B.class);
    intent.putExtra("pendingIntent", pIntent);
    startActivity(intent);

  3. At B we deserialize the pending intent and we can use it to perform the restricted ACTION

    PendingIntent pIntent = intent.getExtra("pendingIntent");
    pIntent.send();

Community
  • 1
  • 1
user868459
  • 288
  • 1
  • 3
  • 8
1

That would be quite in-secure, don't your think, if an application could give any permissions to another application...

Some evil-doer would just have to convince you to install his A application ; and, then, no matter what other B application you'd install, that B application wouldn't have to request any specific permission at installation (those would later be granted by A) -- and B would still be able to do anything on your device ?

I sure hope what you're asking is not possible ;-)

Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663
1

Your application A can provide some Content Providers to access information. Application B could use the content provider of A to gain the information. http://developer.android.com/guide/topics/providers/content-providers.html

But somehow this sounds like you want to do something evil. If you like to have more information please provide more about your need to do that!

Mark
  • 7,507
  • 12
  • 52
  • 88
  • 2
    I don't want to do anything evil. I'm interested in creating a system for dynamic permission granting. So that any app in need of permission can send a signal to my app, where I'll ask user authentication and some expiry mechanism to override given permission after some time. If user agrees I'll grant my permission to requested app. – scari Apr 03 '11 at 18:29
  • This is what i want to do... Pls help – scari Apr 03 '11 at 18:29
  • Is there any way i can execute the job proposed by the 'app without permission' under my app where i have all permissions enabled. Like execute handler to a function defined in that app ?? ( Correct me if I'm wrong ). Or can you please suggest any code or docs where i can find how exactly the android deals with the permission request on run time. ( Not the Manifest.xml ) (The real android source) – scari Apr 04 '11 at 09:14