Reputation: 1122
Background :
I want to find out who starts the acore
process after I stop it and call clear data on the process.
Log:
Sep 12 18:50:08 localhost 172.16.4.165 ANDROID: +05:30 2015 000 0 | 09-12 18:49:48.630 I/ActivityManager( 3304): Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=4805 uid=10022 gids={50022, 1028}
There was nothing else in the log which could point me to what started the process. The acore
process has other providers too but the above log narrows it down to the ContactsProvider2
Issue :
The process starts while the cleanup is still ongoing and this results in database getting corrupt.
What I have already tried out :
How to find out a calling activity for content provider in Android? This has solution for API level 19 and above. But my device has API level 18
I tried out Binder.getCallingPid()
in onCreate()
this returns self PID
The getCallingPid()
and getCallingUid()
method which I normally use directly inside a "Service" are not available for "ContentProvider"
Upvotes: 0
Views: 1067
Reputation: 1122
Finally this is what I did for those that are interested. For API level below 19 I could not find any way without modifying framework.
Below is my patch to ActivityManagerService.java which helped me.
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 0081dfc..8ec15c3 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -6676,6 +6676,9 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, "Failed trying to unstop package "
+ cpr.appInfo.packageName + ": " + e);
}
+ Slog.w(v, "startProcessLocked for cpi.processName = "+cpi.processName
+ +"::cpi.applicationInfo.packageName=" + cpi.applicationInfo.packageName
+ + " (Binder.getCallingPid()=" + Binder.getCallingPid());
ProcessRecord proc = startProcessLocked(cpi.processName,
cpr.appInfo, false, 0, "content provider",
@@ -6692,6 +6695,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mLaunchingProviders.add(cpr);
} finally {
Binder.restoreCallingIdentity(origId);
+ Slog.w(TAG, "Binder.getCallingPid() after restoreCallingIdentity(). pid=" + Binder.getCallingPid());
}
}
Upvotes: 0