android 4.0
1、
每个android进程,在AMS中对应有一个ProcessRecord
/**
* Full information about a particular process that
* is currently running.
*/
class ProcessRecord {
final ApplicationInfo info; // all about the first app in the process // 该进程中第一个驻留的app(apk)
final String processName; // name of the process
// List of packages running in the process
final HashSet<String> pkgList = new HashSet<String>(); // 该进程中可以驻留多个app(apk),可以对照下面bugreport中的日志
int pid; // The process of this application;0 if none
// contains HistoryRecord objects
final ArrayList<ActivityRecord> activities = new ArrayList<ActivityRecord>();
// all ServiceRecord running in this process
final HashSet<ServiceRecord> services = new HashSet<ServiceRecord>();
// services that are currently executing code (need to remain foreground).
final HashSet<ServiceRecord> executingServices
= new HashSet<ServiceRecord>();
// All ConnectionRecord this process holds
final HashSet<ConnectionRecord> connections
= new HashSet<ConnectionRecord>();
// all IIntentReceivers that are registered from this process.
final HashSet<ReceiverList> receivers = new HashSet<ReceiverList>();
// class (String) -> ContentProviderRecord
final HashMap<String, ContentProviderRecord> pubProviders
= new HashMap<String, ContentProviderRecord>();
// All ContentProviderRecord process is using
final HashMap<ContentProviderRecord, Integer> conProviders
= new HashMap<ContentProviderRecord, Integer>();
void dump(PrintWriter pw, String prefix) { ......}
}
参考代码:http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/com/android/server/am/ProcessRecord.java#ProcessRecord
2
2.1 比如android 4.0 源码中的某些app,配置在同一个process(com.android.phone)里面
/packages/apps/Phone/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.phone"
coreApp="true"
android:sharedUserId="android.uid.phone"
android:sharedUserLabel="@string/phoneAppLabel" >
<application android:name="PhoneApp"
android:persistent="true"
android:label="@string/phoneAppLabel"
android:icon="@drawable/ic_launcher_phone">
/packages/providers/TelephonyProvider/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.providers.telephony"
coreApp="true"
android:sharedUserId="android.uid.phone">
<application android:process="com.android.phone"
android:allowClearUserData="false"
android:allowBackup="false"
android:label="@string/app_label"
android:icon="@drawable/ic_launcher_phone">
2.2、bugreport日志(使用adb shell bugreport > bugreport.txt抓取的日志,参照ProcessRecord中的dump方法看下面日志)
*PERS* UID 1001 ProcessRecord{43a6db60 3480:com.android.phone/1001}
user #0 uid=1001
class=com.android.phone.PhoneApp =》该进程中驻留的第一个app
dir=/system/priv-app/TeleService.apk publicDir=/system/priv-app/TeleService.apk data=/data/data/com.android.phone =》第一个app对应的信息
packageList={com.android.providers.telephony, com.android.phone.recorder, com.android.stk, com.android.incallui, com.android.phone} =》该进程中驻留的package列表(apk列表)
compat={480dpi}
thread=android.app.ApplicationThreadProxy@439ef138
pid=3480 starting=false
lastActivityTime=-1h18m31s370ms lastPssTime=-2m48s884ms nextPssTime=+12m10s907ms
adjSeq=88299 lruSeq=0 lastPss=36110 lastCachedPss=0
keeping=true cached=false empty=false
oom: max=-12 curRaw=-12 setRaw=-12 cur=-12 set=-12
curSchedGroup=-1 setSchedGroup=-1 systemNoUi=true trimMemoryLevel=5
curProcState=0 repProcState=0 pssProcState=0 setProcState=0 lastStateTime=-10h1m35s579ms
hasShownUi=true pendingUiClean=false hasAboveClient=false
persistent=true removed=false
lastRequestedGc=-10h1m35s579ms lastLowMemory=-10h1m35s579ms reportLowMemory=false
Activities:
- ActivityRecord{43a614c8 u0 com.android.stk/.StkMenuActivity t3}
- ActivityRecord{43dded98 u0 com.android.incallui/.MSimInCallActivity t5}
Services:
- ServiceRecord{43ab8000 u0 com.android.phone.recorder/.RecorderServer}
- ServiceRecord{43ace900 u0 com.android.phone/.BluetoothPhoneService}
- ServiceRecord{43c3e4b0 u0 com.android.phone/.TelephonyDebugService}
- ServiceRecord{43ceda38 u0 com.android.incallui/.CallHandlerService}
- ServiceRecord{43dcaab8 u0 com.android.stk/.StkAppService}
Connections:
- ConnectionRecord{439b55d8 u0 CR com.android.smspush/.WapPushManager:@439b7710}
- ConnectionRecord{43a05ae0 u0 CR com.android.smspush/.WapPushManager:@43a99050}
- ConnectionRecord{43a1d808 u0 com.android.bluetooth/.hfp.HeadsetService:@43cb3600}
- ConnectionRecord{43aa7238 u0 com.android.bluetooth/.hfp.HeadsetService:@43aa7190}
- ConnectionRecord{43af3ef8 u0 com.android.phone/.BluetoothPhoneService:@43beb818}
- ConnectionRecord{43bf6f70 u0 CR com.android.smspush/.WapPushManager:@43af9f90}
- ConnectionRecord{43bfc9d8 u0 CR com.android.phone.recorder/.RecorderServer:@43ab7ce8}
- ConnectionRecord{43c18fc8 u0 CR com.android.smspush/.WapPushManager:@43c87940}
- ConnectionRecord{43c1a138 u0 CR com.android.incallui/.CallHandlerService:@43ced788}
- ConnectionRecord{43c64360 u0 com.android.bluetooth/.hfp.HeadsetService:@43c642b8}
Published Providers:
- com.android.providers.telephony.SmsProvider
-> ContentProviderRecord{43a090e8 u0 com.android.providers.telephony/.SmsProvider}
- com.android.stk.StkContentProvider
-> ContentProviderRecord{439d1a40 u0 com.android.stk/.StkContentProvider}
......
Connected Providers:
- 436b3418/com.android.providers.settings/.SettingsProvider->3480:com.android.phone/1001 s1/1 u0/0 +23h10m54s283ms
Receivers:
- ReceiverList{439981f0 3480 com.android.phone/1001/u0 remote:43caace0}
- ReceiverList{439b6f88 3480 com.android.phone/1001/u0 remote:439d2240}
......
参考:
http://blog.youkuaiyun.com/guoqifa29/article/details/39318585
http://blog.youkuaiyun.com/luoshengyang/article/details/6685853
http://www.blogjava.net/easywu/archive/2011/10/19/361554.html
http://blog.youkuaiyun.com/cigogo/article/details/7483676