Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default android:sharedUserId set if android:sharedUserId was not set

From the documentation:

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID.

Say I have an app that does not specify android:sharedUserId in the AndroidManifest.xml file.

Is the default sharedUserId Android generates (see above documentation) set in the build (same for this app on all devices) or is a different sharedUserId being generated on each device the app is installed?

like image 679
dors Avatar asked Nov 07 '22 22:11

dors


1 Answers

Android generate random unique ID for each application you installed on your device.

You can get this value by:

adb shell dumpsys package com.example.myapp | grep userId=

or in code with :

int uId = getPackageManager().getApplicationInfo("com.example.myapp",PackageManager.GET_META_DATA).uid;

But if you set android:sharedUserId with the same value for two or more apps, they will all share the same ID — provided that their certificate sets are identical.

Apps with the same user ID can access each other's data and, if desired, run in the same process.

like image 79
Ehsan Mashhadi Avatar answered Nov 15 '22 06:11

Ehsan Mashhadi