Android UID and PID
We often start another activity in one activity, or interact with the result of another acitivity (Startactivityforresult). But have you ever thought about permission problems that might arise? If you meet permission denial's exception, then you need to read this article.
Within the same application, we can startactivity from activity A to activity B at will, while the official documentation says StartActivity may report Notfoundexception, Indicates that the activity by start does not exist. Therefore, it is easy to overlook another possible exception,permission denial.
When we are in different application, such as activity in application A to start an activity in a application B, you may not get any exception, or you might have direct force Close off. Since the start activity again, the code has to test permission.
The following conditions can be successfully startactivity without getting permission denial
1. Under the same application
2.Android: Exported= "true"
5. The target activity has corresponding intentfilter, there is an action action or other filter and there is no setting exported=false
6, the initiator'sPid
7, the initiator'sUid(Android. System.UidApplication, we call it root access)
If the above adjustment, satisfies one, generally can (with other several does not have the coercion set conflict), otherwise, will obtain permission denial's exception and causes the Force Close.
Now, let me explain.PidIs the process ID,AndroidUid, which user start program, this program'sAndroidEach of the programs has aAndroidEach program is assigned a different normal level.UidThe same, which makes the shared data have a certain security, each software is not free to obtain data. And the same application has only oneAndroid: Exported= "True", and once Intentfilter is set, exported is set to True by default unless it is forced to false. Of course, for those programs that do not have a intentfilter, its exported property is still false by default and cannot be shared.
2, the permission hint exposes, this is why often must set up the usepermission reason, if others set up theUidForce settings to be the same. In this case, a signed document with the company's signature must be used in order to use a system-shareuid, such as contact, without the need for a third-party signature.
This approach protects the interests of third-party software companies from data security.
Of course if an activity is another system process run out, then it can be the bully, arbitrary permissions, but you cannot develop a third-party application with the systemPidNot fixed), but you can fully develop a systemAndroid. System.AndroidThe. Mk declares that Certificate:platform is available, both with a system signature. This systemand theCompiled system, such as the official system to use the official signature file, CM's system will have to use the CM signature file.
Android UID and PID