Retrieve UID applications

419 views
Skip to first unread message

ben canavar

unread,
Jul 26, 2011, 11:22:33 AM7/26/11
to android-...@googlegroups.com
I search to retrieve UIDs of all applications installed on my Android.
I look Android dev guidelines but i don't find.
Can you help me?
Please

Thanks

Chris Stratton

unread,
Jul 26, 2011, 2:27:09 PM7/26/11
to android-...@googlegroups.com

I don't think there's an official/stable interface to this for 3rd party apps, and I'm not sure what the platform-internal interface would be.

But if you are interested as a matter of curiosity, you can find this in /data/system/packages.xml

Dianne Hackborn

unread,
Jul 26, 2011, 2:43:26 PM7/26/11
to android-...@googlegroups.com
All APIs for finding information about installed applications are on PackageManager:

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Chris Stratton

unread,
Jul 26, 2011, 3:43:58 PM7/26/11
to android-...@googlegroups.com
On Tuesday, July 26, 2011 2:43:26 PM UTC-4, Dianne Hackborn wrote:
All APIs for finding information about installed applications are on PackageManager:


Yes, but there doesn't appear to be anything for going from package name to UID there, I'm only seeing things in the UID to name direction.  One could call that simply counting up in UID's until getting enough sequential failures to assume the end of the list has been reached, but...


 

Christopher Tate

unread,
Jul 26, 2011, 3:57:06 PM7/26/11
to android-...@googlegroups.com
On Tue, Jul 26, 2011 at 12:43 PM, Chris Stratton <cs0...@gmail.com> wrote:
> On Tuesday, July 26, 2011 2:43:26 PM UTC-4, Dianne Hackborn wrote:
>>
>> All APIs for finding information about installed applications are on
>> PackageManager:
>>
>> http://developer.android.com/reference/android/content/pm/PackageManager.html
>
> Yes, but there doesn't appear to be anything for going from package name to
> UID there....

http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String,
int)

and for the original question about getting the full list of installed
applications:

http://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledApplications(int)

Please *do* read the friendly manual. :)

--
christopher tate
android framework engineer

Chris Stratton

unread,
Jul 26, 2011, 4:31:34 PM7/26/11
to android-...@googlegroups.com
On Tuesday, July 26, 2011 3:57:06 PM UTC-4, Christopher Tate wrote:
> Yes, but there doesn't appear to be anything for going from package name to
> UID there....

http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String,
int)

Please *do* read the friendly manual.  :)

I did.  I'm not seeing UID as a field in PackageInfo.  At least not a public field.

As you point out, there's a way to get a list of all installed packages, and that could be used as a "when to stop" check on my idea of querying the package names associated with an incrementing UID variable, but this would be quite ugly.


Chris Stratton

unread,
Jul 26, 2011, 4:35:06 PM7/26/11
to android-...@googlegroups.com
On Tuesday, July 26, 2011 4:31:34 PM UTC-4, Chris Stratton wrote:
On Tuesday, July 26, 2011 3:57:06 PM UTC-4, Christopher Tate wrote:
> Yes, but there doesn't appear to be anything for going from package name to
> UID there....

http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageInfo(java.lang.String,
int)

Please *do* read the friendly manual.  :)

I did.  I'm not seeing UID as a field in PackageInfo.  At least not a public field,
 
Though I suppose it could be deduced from the contents of the gids field

Christopher Tate

unread,
Jul 26, 2011, 4:38:13 PM7/26/11
to android-...@googlegroups.com
I mispasted; it's PackageManager.getApplicationInfo() that gives you
the uid, not getPackageInfo(). Sorry.

--
christopher tate
android framework engineer

> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.

> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-platform/-/hJlUVguJLmUJ.

tera tellence

unread,
Jul 27, 2011, 10:27:10 AM7/27/11
to android-...@googlegroups.com
Is there an etc/passwd equivalent on Android?

I want to be able to get all the uids at the native level.

Pavan Savoy

unread,
Jul 27, 2011, 10:30:15 AM7/27/11
to android-...@googlegroups.com
On Wed, Jul 27, 2011 at 9:27 AM, tera tellence <tell...@googlemail.com> wrote:
> Is there an etc/passwd equivalent on Android?
>
> I want to be able to get all the uids at the native level.

Aren't they all in system/core/include/private/android_filesystem_config.h ?

--
--Pavan Savoy

Chris Stratton

unread,
Jul 27, 2011, 2:05:40 PM7/27/11
to android-...@googlegroups.com
On Wednesday, July 27, 2011 10:30:15 AM UTC-4, Pavan - ಪವನ್ wrote:
On Wed, Jul 27, 2011 at 9:27 AM, tera tellence <tell...@googlemail.com> wrote:
> Is there an etc/passwd equivalent on Android?
>
> I want to be able to get all the uids at the native level.

Aren't they all in system/core/include/private/android_filesystem_config.h ?

The hard coded ones perhaps, but not the dynamically counting application ones.  Though the combination of Pavan's answer and Christopher Tate's might yield them all.

Dianne Hackborn

unread,
Jul 27, 2011, 3:46:48 PM7/27/11
to android-...@googlegroups.com
On Wed, Jul 27, 2011 at 7:27 AM, tera tellence <tell...@googlemail.com> wrote:
Is there an etc/passwd equivalent on Android?
I want to be able to get all the uids at the native level.

The Android equivalent is the PackageManager APIs. ;)

You'll need to use JNI.

tera tellence

unread,
Aug 4, 2011, 5:50:26 AM8/4/11
to android-...@googlegroups.com
Oh, I want to include a native code as part of init.rc. This has to read the UIDs of all processes and match with those running in the /proc. So was wondering if such an /etc/passwd equivalent exists.. Any help? This is why I don't want to go the JNI way.

Dianne Hackborn

unread,
Aug 4, 2011, 4:12:13 PM8/4/11
to android-...@googlegroups.com

No.

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/O46APKnIkuwJ.

Chris Stratton

unread,
Aug 4, 2011, 4:46:34 PM8/4/11
to android-...@googlegroups.com
On Thursday, August 4, 2011 4:12:13 PM UTC-4, Dianne Hackborn wrote:

No.

Well there is - /data/system/packages.xml fills the function of /etc/passwd with regard to the application-specific user id's - but it's not public.

But then this seems to be a platform mod rather than application development.  And I have a suspicion that the overall project idea is likely to be seriously flawed in other ways or break for other reasons before lack of future-proofness of that file becomes a problem.

A statement of the ultimate functional requirement that is desired might be more productive at this point.
Reply all
Reply to author
Forward
0 new messages