Cherry-picking the following 3 getContentProviderImpl() CLs

- http://ag/5163037

Fix a race in AMS.getContentProviderImpl().

If the provider process has just been killed by AM but appDiedLocked()
hasn't been called yet, this method would wait on the wrong
ContentProviderRecord.

- http://ag/5201125

Fix getContentProviderImpl() permission issue

- http://ag/5284403

Add timeout to AMS.getContentProviderImpl()

Bug: 116876013
Bug: 110030490
Test: manual test with the following debug code:
+                final String prop = "debug.am.provider.fake-kill." + cpr.proc.processName;
+                if (SystemProperties.getBoolean(prop, false)) {
+                    cpr.proc.kill("fake-kill", true);
+                    SystemProperties.set(prop, "0");
+                }
                providerRunning = !cpr.proc.killed;

Then:
setprop debug.am.provider.fake-kill.android.process.acore 1
And launch the contacts app when acore is already running, and make sure
the timeout log shows up on logcat.

Test: Also do it with work profile contacts

Change-Id: I765d61a1b2719a92dff7db0162335f2c09c33421
Merged-in: I2c4ba1e87c2d47f2013befff10c49b3dc337a9a7
Merged-in: Ia35a9d36a34257873edbdcaefcf85d2373f3295e
Merged-in: Id5e7fff228d777eb0d1804654600d9ea156e36fd
1 file changed