UserHandle represent a real user on the device for supporting multi-user (see UserHandle.MU_ENABLED), via which, one can test whether two uids are same user/app/..., and transform among them
Each app on a multi-user device has a unique id (which is its uid), therefore same app under differnt users are different apps
userId: id of a real device user, starts from 0
Actually, UserHandle is a wrapper of userId, where UserHandle#of(userId) == new UserHandle(userId)
uid: the global unique id of an app
appId: the local id of an app within a specific userId
Therefore, on a single-user device (i.e., UserHandle.MU_ENABLED == false)
userId == 0
uid == appId
Example: an uid with userId 0 and appId 1 can be represended as u0_a1, telling the app belongs to user with userId 0, and in the space of user 0 the app has id 1
UserHandle
represent a real user on the device for supporting multi-user (seeUserHandle.MU_ENABLED
), via which, one can test whether two uids are same user/app/..., and transform among themUserHandle
is a wrapper of userId, whereUserHandle#of(userId) == new UserHandle(userId)
UserHandle.MU_ENABLED == false
)userId == 0
uid == appId
0
and appId1
can be represended asu0_a1
, telling the app belongs to user with userId0
, and in the space of user0
the app has id1
That's how uids by
``` generic_x86:/ # ls -l /data/user/0/ total 832 drwx------ 4 system system 4096 2020-09-10 16:47 android drwx------ 4 u0_a1 u0_a1 4096 2020-09-10 16:47 com.android.backupconfirm drwx------ 4 u0_a34 u0_a34 4096 2020-09-22 21:38 com.android.bips drwx------ 4 u0_a35 u0_a35 4096 2020-09-10 16:47 com.android.bookmarkprovider drwx------ 6 u0_a50 u0_a50 4096 2020-09-10 17:08 com.android.calculator2 drwx------ 4 u0_a3 u0_a3 4096 2020-09-10 16:47 com.android.calllogbackup drwx------ 5 u0_a37 u0_a37 4096 2020-09-22 21:38 com.android.camera2 drwx------ 4 u0_a40 u0_a40 4096 2020-09-10 16:47 com.android.captiveportallogin drwx------ 4 u0_a4 u0_a4 4096 2020-09-10 16:47 com.android.carrierconfig drwx------ 4 u0_a9 u0_a9 4096 2020-09-10 16:47 com.android.cellbroadcastreceiver drwx------ 4 u0_a39 u0_a39 4096 2020-09-10 16:47 com.android.certinstaller drwx------ 12 u0_a52 u0_a52 4096 2020-09-22 21:38 com.android.chrome drwx------ 4 u0_a41 u0_a41 4096 2020-09-10 16:47 com.android.companiondevicemanager drwx------ 5 u0_a13 u0_a13 4096 2020-09-10 16:47 com.android.contacts drwx------ 4 u0_a43 u0_a43 4096 2020-09-10 16:47 com.android.cts.ctsshim drwx------ 4 u0_a6 u0_a6 4096 2020-09-22 21:38 com.android.cts.priv.ctsshim ```ls -l /data/user/<userId>/
are shownReferences