Merge "Update language to comply with Android's inclusive language guidance"
This commit is contained in:
committed by
Android (Google) Code Review
commit
6daf67a792
@@ -92,27 +92,27 @@ public class RunningState {
|
||||
// entry.
|
||||
final SparseArray<HashMap<String, ProcessItem>> mServiceProcessesByName
|
||||
= new SparseArray<HashMap<String, ProcessItem>>();
|
||||
|
||||
|
||||
// Processes that are hosting a service we are interested in, organized
|
||||
// by their pid. These disappear and re-appear as services are restarted.
|
||||
final SparseArray<ProcessItem> mServiceProcessesByPid
|
||||
= new SparseArray<ProcessItem>();
|
||||
|
||||
|
||||
// Used to sort the interesting processes.
|
||||
final ServiceProcessComparator mServiceProcessComparator
|
||||
= new ServiceProcessComparator();
|
||||
|
||||
|
||||
// Additional interesting processes to be shown to the user, even if
|
||||
// there is no service running in them.
|
||||
final ArrayList<ProcessItem> mInterestingProcesses = new ArrayList<ProcessItem>();
|
||||
|
||||
|
||||
// All currently running processes, for finding dependencies etc.
|
||||
final SparseArray<ProcessItem> mRunningProcesses
|
||||
= new SparseArray<ProcessItem>();
|
||||
|
||||
|
||||
// The processes associated with services, in sorted order.
|
||||
final ArrayList<ProcessItem> mProcessItems = new ArrayList<ProcessItem>();
|
||||
|
||||
|
||||
// All processes, used for retrieving memory information.
|
||||
final ArrayList<ProcessItem> mAllProcessItems = new ArrayList<ProcessItem>();
|
||||
|
||||
@@ -139,69 +139,74 @@ public class RunningState {
|
||||
|
||||
int mSequence = 0;
|
||||
|
||||
final Comparator<RunningState.MergedItem> mBackgroundComparator
|
||||
= new Comparator<RunningState.MergedItem>() {
|
||||
@Override
|
||||
public int compare(MergedItem lhs, MergedItem rhs) {
|
||||
if (DEBUG_COMPARE) {
|
||||
Log.i(TAG, "Comparing " + lhs + " with " + rhs);
|
||||
Log.i(TAG, " Proc " + lhs.mProcess + " with " + rhs.mProcess);
|
||||
Log.i(TAG, " UserId " + lhs.mUserId + " with " + rhs.mUserId);
|
||||
}
|
||||
if (lhs.mUserId != rhs.mUserId) {
|
||||
if (lhs.mUserId == mMyUserId) return -1;
|
||||
if (rhs.mUserId == mMyUserId) return 1;
|
||||
return lhs.mUserId < rhs.mUserId ? -1 : 1;
|
||||
}
|
||||
if (lhs.mProcess == rhs.mProcess) {
|
||||
if (lhs.mLabel == rhs.mLabel) {
|
||||
final Comparator<RunningState.MergedItem> mBackgroundComparator =
|
||||
new Comparator<RunningState.MergedItem>() {
|
||||
@Override
|
||||
public int compare(MergedItem lhs, MergedItem rhs) {
|
||||
if (DEBUG_COMPARE) {
|
||||
Log.i(TAG, "Comparing " + lhs + " with " + rhs);
|
||||
Log.i(TAG, " Proc " + lhs.mProcess + " with " + rhs.mProcess);
|
||||
Log.i(TAG, " UserId " + lhs.mUserId + " with " + rhs.mUserId);
|
||||
}
|
||||
if (lhs.mUserId != rhs.mUserId) {
|
||||
if (lhs.mUserId == mMyUserId) return -1;
|
||||
if (rhs.mUserId == mMyUserId) return 1;
|
||||
return lhs.mUserId < rhs.mUserId ? -1 : 1;
|
||||
}
|
||||
if (lhs.mProcess == rhs.mProcess) {
|
||||
if (lhs.mLabel == rhs.mLabel) {
|
||||
return 0;
|
||||
}
|
||||
return lhs.mLabel != null ? lhs.mLabel.compareTo(rhs.mLabel) : -1;
|
||||
}
|
||||
if (lhs.mProcess == null) return -1;
|
||||
if (rhs.mProcess == null) return 1;
|
||||
if (DEBUG_COMPARE) {
|
||||
Log.i(TAG, " Label " + lhs.mProcess.mLabel
|
||||
+ " with " + rhs.mProcess.mLabel);
|
||||
}
|
||||
final ActivityManager.RunningAppProcessInfo lhsInfo =
|
||||
lhs.mProcess.mRunningProcessInfo;
|
||||
final ActivityManager.RunningAppProcessInfo rhsInfo =
|
||||
rhs.mProcess.mRunningProcessInfo;
|
||||
final boolean lhsBg = lhsInfo.importance
|
||||
>= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
|
||||
final boolean rhsBg = rhsInfo.importance
|
||||
>= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Bg " + lhsBg + " with " + rhsBg);
|
||||
if (lhsBg != rhsBg) {
|
||||
return lhsBg ? 1 : -1;
|
||||
}
|
||||
final boolean lhsA = (lhsInfo.flags
|
||||
& ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
|
||||
final boolean rhsA = (rhsInfo.flags
|
||||
& ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Act " + lhsA + " with " + rhsA);
|
||||
if (lhsA != rhsA) {
|
||||
return lhsA ? -1 : 1;
|
||||
}
|
||||
if (DEBUG_COMPARE) {
|
||||
Log.i(TAG,
|
||||
" Lru " + lhsInfo.lru + " with " + rhsInfo.lru);
|
||||
}
|
||||
if (lhsInfo.lru != rhsInfo.lru) {
|
||||
return lhsInfo.lru < rhsInfo.lru ? -1 : 1;
|
||||
}
|
||||
if (lhs.mProcess.mLabel == rhs.mProcess.mLabel) {
|
||||
return 0;
|
||||
}
|
||||
return lhs.mLabel != null ? lhs.mLabel.compareTo(rhs.mLabel) : -1;
|
||||
if (lhs.mProcess.mLabel == null) return 1;
|
||||
if (rhs.mProcess.mLabel == null) return -1;
|
||||
return lhs.mProcess.mLabel.compareTo(rhs.mProcess.mLabel);
|
||||
}
|
||||
if (lhs.mProcess == null) return -1;
|
||||
if (rhs.mProcess == null) return 1;
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Label " + lhs.mProcess.mLabel
|
||||
+ " with " + rhs.mProcess.mLabel);
|
||||
final ActivityManager.RunningAppProcessInfo lhsInfo
|
||||
= lhs.mProcess.mRunningProcessInfo;
|
||||
final ActivityManager.RunningAppProcessInfo rhsInfo
|
||||
= rhs.mProcess.mRunningProcessInfo;
|
||||
final boolean lhsBg = lhsInfo.importance
|
||||
>= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
|
||||
final boolean rhsBg = rhsInfo.importance
|
||||
>= ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Bg " + lhsBg + " with " + rhsBg);
|
||||
if (lhsBg != rhsBg) {
|
||||
return lhsBg ? 1 : -1;
|
||||
}
|
||||
final boolean lhsA = (lhsInfo.flags
|
||||
& ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
|
||||
final boolean rhsA = (rhsInfo.flags
|
||||
& ActivityManager.RunningAppProcessInfo.FLAG_HAS_ACTIVITIES) != 0;
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Act " + lhsA + " with " + rhsA);
|
||||
if (lhsA != rhsA) {
|
||||
return lhsA ? -1 : 1;
|
||||
}
|
||||
if (DEBUG_COMPARE) Log.i(TAG, " Lru " + lhsInfo.lru + " with " + rhsInfo.lru);
|
||||
if (lhsInfo.lru != rhsInfo.lru) {
|
||||
return lhsInfo.lru < rhsInfo.lru ? -1 : 1;
|
||||
}
|
||||
if (lhs.mProcess.mLabel == rhs.mProcess.mLabel) {
|
||||
return 0;
|
||||
}
|
||||
if (lhs.mProcess.mLabel == null) return 1;
|
||||
if (rhs.mProcess.mLabel == null) return -1;
|
||||
return lhs.mProcess.mLabel.compareTo(rhs.mProcess.mLabel);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// ----- following protected by mLock -----
|
||||
|
||||
|
||||
// Lock for protecting the state that will be shared between the
|
||||
// background update thread and the UI thread.
|
||||
final Object mLock = new Object();
|
||||
|
||||
|
||||
boolean mResumed;
|
||||
boolean mHaveData;
|
||||
boolean mWatchingBackgroundItems;
|
||||
@@ -210,7 +215,7 @@ public class RunningState {
|
||||
ArrayList<MergedItem> mMergedItems = new ArrayList<MergedItem>();
|
||||
ArrayList<MergedItem> mBackgroundItems = new ArrayList<MergedItem>();
|
||||
ArrayList<MergedItem> mUserBackgroundItems = new ArrayList<MergedItem>();
|
||||
|
||||
|
||||
int mNumBackgroundProcesses;
|
||||
long mBackgroundProcessMemory;
|
||||
int mNumForegroundProcesses;
|
||||
@@ -221,6 +226,7 @@ public class RunningState {
|
||||
// ----- BACKGROUND MONITORING THREAD -----
|
||||
|
||||
final HandlerThread mBackgroundThread;
|
||||
|
||||
final class BackgroundHandler extends Handler {
|
||||
public BackgroundHandler(Looper looper) {
|
||||
super(looper);
|
||||
@@ -372,9 +378,9 @@ public class RunningState {
|
||||
ActivityManager.RunningServiceInfo mRunningService;
|
||||
ServiceInfo mServiceInfo;
|
||||
boolean mShownAsStarted;
|
||||
|
||||
|
||||
MergedItem mMergedItem;
|
||||
|
||||
|
||||
public ServiceItem(int userId) {
|
||||
super(false, userId);
|
||||
}
|
||||
@@ -385,17 +391,17 @@ public class RunningState {
|
||||
= new HashMap<ComponentName, ServiceItem>();
|
||||
final SparseArray<ProcessItem> mDependentProcesses
|
||||
= new SparseArray<ProcessItem>();
|
||||
|
||||
|
||||
final int mUid;
|
||||
final String mProcessName;
|
||||
int mPid;
|
||||
|
||||
|
||||
ProcessItem mClient;
|
||||
int mLastNumDependentProcesses;
|
||||
|
||||
|
||||
int mRunningSeq;
|
||||
ActivityManager.RunningAppProcessInfo mRunningProcessInfo;
|
||||
|
||||
|
||||
MergedItem mMergedItem;
|
||||
|
||||
boolean mInteresting;
|
||||
@@ -404,7 +410,7 @@ public class RunningState {
|
||||
boolean mIsSystem;
|
||||
boolean mIsStarted;
|
||||
long mActiveSince;
|
||||
|
||||
|
||||
public ProcessItem(Context context, int uid, String processName) {
|
||||
super(true, UserHandle.getUserId(uid));
|
||||
mDescription = context.getResources().getString(
|
||||
@@ -412,12 +418,12 @@ public class RunningState {
|
||||
mUid = uid;
|
||||
mProcessName = processName;
|
||||
}
|
||||
|
||||
|
||||
void ensureLabel(PackageManager pm) {
|
||||
if (mLabel != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(mProcessName,
|
||||
PackageManager.MATCH_ANY_USER);
|
||||
@@ -429,11 +435,11 @@ public class RunningState {
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
|
||||
|
||||
// If we couldn't get information about the overall
|
||||
// process, try to find something about the uid.
|
||||
String[] pkgs = pm.getPackagesForUid(mUid);
|
||||
|
||||
|
||||
// If there is one package with this uid, that is what we want.
|
||||
if (pkgs.length == 1) {
|
||||
try {
|
||||
@@ -446,7 +452,7 @@ public class RunningState {
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If there are multiple, see if one gives us the official name
|
||||
// for this uid.
|
||||
for (String name : pkgs) {
|
||||
@@ -465,7 +471,7 @@ public class RunningState {
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If still don't have anything to display, just use the
|
||||
// service info.
|
||||
if (mServices.size() > 0) {
|
||||
@@ -476,7 +482,7 @@ public class RunningState {
|
||||
mLabel = mDisplayLabel.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Finally... whatever, just pick the first package's name.
|
||||
try {
|
||||
ApplicationInfo ai = pm.getApplicationInfo(pkgs[0],
|
||||
@@ -544,16 +550,16 @@ public class RunningState {
|
||||
si.mDescription = context.getResources().getString(
|
||||
R.string.service_started_by_app);
|
||||
}
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
boolean updateSize(Context context, long pss, int curSeq) {
|
||||
mSize = pss * 1024;
|
||||
if (mCurSeq == curSeq) {
|
||||
String sizeStr = Formatter.formatShortFileSize(
|
||||
context, mSize);
|
||||
if (!sizeStr.equals(mSizeStr)){
|
||||
if (!sizeStr.equals(mSizeStr)) {
|
||||
mSizeStr = sizeStr;
|
||||
// We update this on the second tick where we update just
|
||||
// the text in the current items, so no need to say we
|
||||
@@ -563,11 +569,11 @@ public class RunningState {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
boolean buildDependencyChain(Context context, PackageManager pm, int curSeq) {
|
||||
final int NP = mDependentProcesses.size();
|
||||
boolean changed = false;
|
||||
for (int i=0; i<NP; i++) {
|
||||
for (int i = 0; i < NP; i++) {
|
||||
ProcessItem proc = mDependentProcesses.valueAt(i);
|
||||
if (proc.mClient != this) {
|
||||
changed = true;
|
||||
@@ -577,19 +583,19 @@ public class RunningState {
|
||||
proc.ensureLabel(pm);
|
||||
changed |= proc.buildDependencyChain(context, pm, curSeq);
|
||||
}
|
||||
|
||||
|
||||
if (mLastNumDependentProcesses != mDependentProcesses.size()) {
|
||||
changed = true;
|
||||
mLastNumDependentProcesses = mDependentProcesses.size();
|
||||
}
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
void addDependentProcesses(ArrayList<BaseItem> dest,
|
||||
ArrayList<ProcessItem> destProc) {
|
||||
final int NP = mDependentProcesses.size();
|
||||
for (int i=0; i<NP; i++) {
|
||||
for (int i = 0; i < NP; i++) {
|
||||
ProcessItem proc = mDependentProcesses.valueAt(i);
|
||||
proc.addDependentProcesses(dest, destProc);
|
||||
dest.add(proc);
|
||||
@@ -606,7 +612,7 @@ public class RunningState {
|
||||
final ArrayList<ProcessItem> mOtherProcesses = new ArrayList<ProcessItem>();
|
||||
final ArrayList<ServiceItem> mServices = new ArrayList<ServiceItem>();
|
||||
final ArrayList<MergedItem> mChildren = new ArrayList<MergedItem>();
|
||||
|
||||
|
||||
private int mLastNumProcesses = -1, mLastNumServices = -1;
|
||||
|
||||
MergedItem(int userId) {
|
||||
@@ -646,7 +652,7 @@ public class RunningState {
|
||||
int numProcesses = 0;
|
||||
int numServices = 0;
|
||||
mActiveSince = -1;
|
||||
for (int i=0; i<mChildren.size(); i++) {
|
||||
for (int i = 0; i < mChildren.size(); i++) {
|
||||
MergedItem child = mChildren.get(i);
|
||||
numProcesses += child.mLastNumProcesses;
|
||||
numServices += child.mLastNumServices;
|
||||
@@ -661,14 +667,14 @@ public class RunningState {
|
||||
mPackageInfo = mProcess.mPackageInfo;
|
||||
mDisplayLabel = mProcess.mDisplayLabel;
|
||||
mLabel = mProcess.mLabel;
|
||||
|
||||
|
||||
if (!mBackground) {
|
||||
setDescription(context, (mProcess.mPid > 0 ? 1 : 0) + mOtherProcesses.size(),
|
||||
mServices.size());
|
||||
}
|
||||
|
||||
|
||||
mActiveSince = -1;
|
||||
for (int i=0; i<mServices.size(); i++) {
|
||||
for (int i = 0; i < mServices.size(); i++) {
|
||||
ServiceItem si = mServices.get(i);
|
||||
if (si.mActiveSince >= 0 && mActiveSince < si.mActiveSince) {
|
||||
mActiveSince = si.mActiveSince;
|
||||
@@ -678,25 +684,25 @@ public class RunningState {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
boolean updateSize(Context context) {
|
||||
if (mUser != null) {
|
||||
mSize = 0;
|
||||
for (int i=0; i<mChildren.size(); i++) {
|
||||
for (int i = 0; i < mChildren.size(); i++) {
|
||||
MergedItem child = mChildren.get(i);
|
||||
child.updateSize(context);
|
||||
mSize += child.mSize;
|
||||
}
|
||||
} else {
|
||||
mSize = mProcess.mSize;
|
||||
for (int i=0; i<mOtherProcesses.size(); i++) {
|
||||
for (int i = 0; i < mOtherProcesses.size(); i++) {
|
||||
mSize += mOtherProcesses.get(i).mSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String sizeStr = Formatter.formatShortFileSize(
|
||||
context, mSize);
|
||||
if (!sizeStr.equals(mSizeStr)){
|
||||
if (!sizeStr.equals(mSizeStr)) {
|
||||
mSizeStr = sizeStr;
|
||||
// We update this on the second tick where we update just
|
||||
// the text in the current items, so no need to say we
|
||||
@@ -746,7 +752,7 @@ public class RunningState {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static CharSequence makeLabel(PackageManager pm,
|
||||
String className, PackageItemInfo item) {
|
||||
if (item != null && (item.labelRes != 0
|
||||
@@ -756,15 +762,15 @@ public class RunningState {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String label = className;
|
||||
int tail = label.lastIndexOf('.');
|
||||
if (tail >= 0) {
|
||||
label = label.substring(tail+1, label.length());
|
||||
label = label.substring(tail + 1, label.length());
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
static RunningState getInstance(Context context) {
|
||||
synchronized (sGlobalLock) {
|
||||
if (sInstance == null) {
|
||||
@@ -776,9 +782,9 @@ public class RunningState {
|
||||
|
||||
private RunningState(Context context) {
|
||||
mApplicationContext = context.getApplicationContext();
|
||||
mAm = (ActivityManager)mApplicationContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
mAm = mApplicationContext.getSystemService(ActivityManager.class);
|
||||
mPm = mApplicationContext.getPackageManager();
|
||||
mUm = (UserManager)mApplicationContext.getSystemService(Context.USER_SERVICE);
|
||||
mUm = mApplicationContext.getSystemService(UserManager.class);
|
||||
mMyUserId = UserHandle.myUserId();
|
||||
UserInfo userInfo = mUm.getUserInfo(mMyUserId);
|
||||
mHideManagedProfiles = userInfo == null || !userInfo.canHaveProfile();
|
||||
@@ -842,14 +848,14 @@ public class RunningState {
|
||||
}
|
||||
|
||||
private boolean isInterestingProcess(ActivityManager.RunningAppProcessInfo pi) {
|
||||
if ((pi.flags&ActivityManager.RunningAppProcessInfo.FLAG_CANT_SAVE_STATE) != 0) {
|
||||
if ((pi.flags & ActivityManager.RunningAppProcessInfo.FLAG_CANT_SAVE_STATE) != 0) {
|
||||
return true;
|
||||
}
|
||||
if ((pi.flags&ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT) == 0
|
||||
if ((pi.flags & ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT) == 0
|
||||
&& pi.importance >= ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
|
||||
&& pi.importance < ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE
|
||||
&& pi.importanceReasonCode
|
||||
== ActivityManager.RunningAppProcessInfo.REASON_UNKNOWN) {
|
||||
== ActivityManager.RunningAppProcessInfo.REASON_UNKNOWN) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -897,15 +903,15 @@ public class RunningState {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
|
||||
mSequence++;
|
||||
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
// Retrieve list of services, filtering out anything that definitely
|
||||
// won't be shown in the UI.
|
||||
List<ActivityManager.RunningServiceInfo> services
|
||||
List<ActivityManager.RunningServiceInfo> services
|
||||
= am.getRunningServices(MAX_SERVICES);
|
||||
int NS = services != null ? services.size() : 0;
|
||||
for (int i=0; i<NS; i++) {
|
||||
for (int i = 0; i < NS; i++) {
|
||||
ActivityManager.RunningServiceInfo si = services.get(i);
|
||||
// We are not interested in services that have not been started
|
||||
// and don't have a known client, because
|
||||
@@ -918,7 +924,7 @@ public class RunningState {
|
||||
}
|
||||
// We likewise don't care about services running in a
|
||||
// persistent process like the system or phone.
|
||||
if ((si.flags&ActivityManager.RunningServiceInfo.FLAG_PERSISTENT_PROCESS)
|
||||
if ((si.flags & ActivityManager.RunningServiceInfo.FLAG_PERSISTENT_PROCESS)
|
||||
!= 0) {
|
||||
services.remove(i);
|
||||
i--;
|
||||
@@ -933,14 +939,14 @@ public class RunningState {
|
||||
= am.getRunningAppProcesses();
|
||||
final int NP = processes != null ? processes.size() : 0;
|
||||
mTmpAppProcesses.clear();
|
||||
for (int i=0; i<NP; i++) {
|
||||
for (int i = 0; i < NP; i++) {
|
||||
ActivityManager.RunningAppProcessInfo pi = processes.get(i);
|
||||
mTmpAppProcesses.put(pi.pid, new AppProcessInfo(pi));
|
||||
}
|
||||
|
||||
// Initial iteration through running services to collect per-process
|
||||
// info about them.
|
||||
for (int i=0; i<NS; i++) {
|
||||
for (int i = 0; i < NS; i++) {
|
||||
ActivityManager.RunningServiceInfo si = services.get(i);
|
||||
if (si.restarting == 0 && si.pid > 0) {
|
||||
AppProcessInfo ainfo = mTmpAppProcesses.get(si.pid);
|
||||
@@ -954,7 +960,7 @@ public class RunningState {
|
||||
}
|
||||
|
||||
// Update state we are maintaining about process that are running services.
|
||||
for (int i=0; i<NS; i++) {
|
||||
for (int i = 0; i < NS; i++) {
|
||||
ActivityManager.RunningServiceInfo si = services.get(i);
|
||||
|
||||
// If this service's process is in use at a higher importance
|
||||
@@ -1001,7 +1007,7 @@ public class RunningState {
|
||||
proc = new ProcessItem(context, si.uid, si.process);
|
||||
procs.put(si.process, proc);
|
||||
}
|
||||
|
||||
|
||||
if (proc.mCurSeq != mSequence) {
|
||||
int pid = si.restarting == 0 ? si.pid : 0;
|
||||
if (pid != proc.mPid) {
|
||||
@@ -1021,10 +1027,10 @@ public class RunningState {
|
||||
}
|
||||
changed |= proc.updateService(context, si);
|
||||
}
|
||||
|
||||
|
||||
// Now update the map of other processes that are running (but
|
||||
// don't have services actively running inside them).
|
||||
for (int i=0; i<NP; i++) {
|
||||
for (int i = 0; i < NP; i++) {
|
||||
ActivityManager.RunningAppProcessInfo pi = processes.get(i);
|
||||
ProcessItem proc = mServiceProcessesByPid.get(pi.pid);
|
||||
if (proc == null) {
|
||||
@@ -1040,7 +1046,7 @@ public class RunningState {
|
||||
}
|
||||
proc.mDependentProcesses.clear();
|
||||
}
|
||||
|
||||
|
||||
if (isInterestingProcess(pi)) {
|
||||
if (!mInterestingProcesses.contains(proc)) {
|
||||
changed = true;
|
||||
@@ -1052,7 +1058,7 @@ public class RunningState {
|
||||
} else {
|
||||
proc.mInteresting = false;
|
||||
}
|
||||
|
||||
|
||||
proc.mRunningSeq = mSequence;
|
||||
proc.mRunningProcessInfo = pi;
|
||||
}
|
||||
@@ -1060,7 +1066,7 @@ public class RunningState {
|
||||
// Build the chains from client processes to the process they are
|
||||
// dependent on; also remove any old running processes.
|
||||
int NRP = mRunningProcesses.size();
|
||||
for (int i = 0; i < NRP;) {
|
||||
for (int i = 0; i < NRP; ) {
|
||||
ProcessItem proc = mRunningProcesses.valueAt(i);
|
||||
if (proc.mRunningSeq == mSequence) {
|
||||
int clientPid = proc.mRunningProcessInfo.importanceReasonPid;
|
||||
@@ -1085,10 +1091,10 @@ public class RunningState {
|
||||
NRP--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Remove any old interesting processes.
|
||||
int NHP = mInterestingProcesses.size();
|
||||
for (int i=0; i<NHP; i++) {
|
||||
for (int i = 0; i < NHP; i++) {
|
||||
ProcessItem proc = mInterestingProcesses.get(i);
|
||||
if (!proc.mInteresting || mRunningProcesses.get(proc.mPid) == null) {
|
||||
changed = true;
|
||||
@@ -1097,21 +1103,21 @@ public class RunningState {
|
||||
NHP--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Follow the tree from all primary service processes to all
|
||||
// processes they are dependent on, marking these processes as
|
||||
// still being active and determining if anything has changed.
|
||||
final int NAP = mServiceProcessesByPid.size();
|
||||
for (int i=0; i<NAP; i++) {
|
||||
for (int i = 0; i < NAP; i++) {
|
||||
ProcessItem proc = mServiceProcessesByPid.valueAt(i);
|
||||
if (proc.mCurSeq == mSequence) {
|
||||
changed |= proc.buildDependencyChain(context, pm, mSequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Look for services and their primary processes that no longer exist...
|
||||
ArrayList<Integer> uidToDelete = null;
|
||||
for (int i=0; i<mServiceProcessesByName.size(); i++) {
|
||||
for (int i = 0; i < mServiceProcessesByName.size(); i++) {
|
||||
HashMap<String, ProcessItem> procs = mServiceProcessesByName.valueAt(i);
|
||||
Iterator<ProcessItem> pit = procs.values().iterator();
|
||||
while (pit.hasNext()) {
|
||||
@@ -1119,8 +1125,7 @@ public class RunningState {
|
||||
if (pi.mCurSeq == mSequence) {
|
||||
pi.ensureLabel(pm);
|
||||
if (pi.mPid == 0) {
|
||||
// Sanity: a non-process can't be dependent on
|
||||
// anything.
|
||||
// Validation: a non-process can't be dependent on anything.
|
||||
pi.mDependentProcesses.clear();
|
||||
}
|
||||
} else {
|
||||
@@ -1147,7 +1152,7 @@ public class RunningState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (uidToDelete != null) {
|
||||
for (int i = 0; i < uidToDelete.size(); i++) {
|
||||
int uid = uidToDelete.get(i);
|
||||
@@ -1158,7 +1163,7 @@ public class RunningState {
|
||||
if (changed) {
|
||||
// First determine an order for the services.
|
||||
ArrayList<ProcessItem> sortedProcesses = new ArrayList<ProcessItem>();
|
||||
for (int i=0; i<mServiceProcessesByName.size(); i++) {
|
||||
for (int i = 0; i < mServiceProcessesByName.size(); i++) {
|
||||
for (ProcessItem pi : mServiceProcessesByName.valueAt(i).values()) {
|
||||
pi.mIsSystem = false;
|
||||
pi.mIsStarted = true;
|
||||
@@ -1166,7 +1171,7 @@ public class RunningState {
|
||||
for (ServiceItem si : pi.mServices.values()) {
|
||||
if (si.mServiceInfo != null
|
||||
&& (si.mServiceInfo.applicationInfo.flags
|
||||
& ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
& ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
pi.mIsSystem = true;
|
||||
}
|
||||
if (si.mRunningService != null
|
||||
@@ -1180,16 +1185,16 @@ public class RunningState {
|
||||
sortedProcesses.add(pi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Collections.sort(sortedProcesses, mServiceProcessComparator);
|
||||
|
||||
|
||||
ArrayList<BaseItem> newItems = new ArrayList<BaseItem>();
|
||||
ArrayList<MergedItem> newMergedItems = new ArrayList<MergedItem>();
|
||||
mProcessItems.clear();
|
||||
for (int i=0; i<sortedProcesses.size(); i++) {
|
||||
for (int i = 0; i < sortedProcesses.size(); i++) {
|
||||
ProcessItem pi = sortedProcesses.get(i);
|
||||
pi.mNeedDivider = false;
|
||||
|
||||
|
||||
int firstProc = mProcessItems.size();
|
||||
// First add processes we are dependent on.
|
||||
pi.addDependentProcesses(newItems, mProcessItems);
|
||||
@@ -1198,7 +1203,7 @@ public class RunningState {
|
||||
if (pi.mPid > 0) {
|
||||
mProcessItems.add(pi);
|
||||
}
|
||||
|
||||
|
||||
// Now add the services running in it.
|
||||
MergedItem mergedItem = null;
|
||||
boolean haveAllMerged = false;
|
||||
@@ -1216,7 +1221,7 @@ public class RunningState {
|
||||
haveAllMerged = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!haveAllMerged || mergedItem == null
|
||||
|| mergedItem.mServices.size() != pi.mServices.size()) {
|
||||
// Whoops, we need to build a new MergedItem!
|
||||
@@ -1227,11 +1232,11 @@ public class RunningState {
|
||||
}
|
||||
mergedItem.mProcess = pi;
|
||||
mergedItem.mOtherProcesses.clear();
|
||||
for (int mpi=firstProc; mpi<(mProcessItems.size()-1); mpi++) {
|
||||
for (int mpi = firstProc; mpi < (mProcessItems.size() - 1); mpi++) {
|
||||
mergedItem.mOtherProcesses.add(mProcessItems.get(mpi));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mergedItem.update(context, false);
|
||||
if (mergedItem.mUserId != mMyUserId) {
|
||||
addOtherUserItem(context, newMergedItems, mOtherUserMergedItems, mergedItem);
|
||||
@@ -1243,7 +1248,7 @@ public class RunningState {
|
||||
// Finally, interesting processes need to be shown and will
|
||||
// go at the top.
|
||||
NHP = mInterestingProcesses.size();
|
||||
for (int i=0; i<NHP; i++) {
|
||||
for (int i = 0; i < NHP; i++) {
|
||||
ProcessItem proc = mInterestingProcesses.get(i);
|
||||
if (proc.mClient == null && proc.mServices.size() <= 0) {
|
||||
if (proc.mMergedItem == null) {
|
||||
@@ -1264,7 +1269,7 @@ public class RunningState {
|
||||
// Finally finally, user aggregated merged items need to be
|
||||
// updated now that they have all of their children.
|
||||
final int NU = mOtherUserMergedItems.size();
|
||||
for (int i=0; i<NU; i++) {
|
||||
for (int i = 0; i < NU; i++) {
|
||||
MergedItem user = mOtherUserMergedItems.valueAt(i);
|
||||
if (user.mCurSeq == mSequence) {
|
||||
user.update(context, false);
|
||||
@@ -1276,7 +1281,7 @@ public class RunningState {
|
||||
mMergedItems = newMergedItems;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Count number of interesting other (non-active) processes, and
|
||||
// build a list of all processes we will retrieve memory for.
|
||||
mAllProcessItems.clear();
|
||||
@@ -1285,7 +1290,7 @@ public class RunningState {
|
||||
int numForegroundProcesses = 0;
|
||||
int numServiceProcesses = 0;
|
||||
NRP = mRunningProcesses.size();
|
||||
for (int i=0; i<NRP; i++) {
|
||||
for (int i = 0; i < NRP; i++) {
|
||||
ProcessItem proc = mRunningProcesses.valueAt(i);
|
||||
if (proc.mCurSeq != mSequence) {
|
||||
// We didn't hit this process as a dependency on one
|
||||
@@ -1306,7 +1311,7 @@ public class RunningState {
|
||||
numServiceProcesses++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long backgroundProcessMemory = 0;
|
||||
long foregroundProcessMemory = 0;
|
||||
long serviceProcessMemory = 0;
|
||||
@@ -1316,13 +1321,13 @@ public class RunningState {
|
||||
try {
|
||||
final int numProc = mAllProcessItems.size();
|
||||
int[] pids = new int[numProc];
|
||||
for (int i=0; i<numProc; i++) {
|
||||
for (int i = 0; i < numProc; i++) {
|
||||
pids[i] = mAllProcessItems.get(i).mPid;
|
||||
}
|
||||
long[] pss = ActivityManager.getService()
|
||||
.getProcessPss(pids);
|
||||
int bgIndex = 0;
|
||||
for (int i=0; i<pids.length; i++) {
|
||||
for (int i = 0; i < pids.length; i++) {
|
||||
ProcessItem proc = mAllProcessItems.get(i);
|
||||
changed |= proc.updateSize(context, pss[i], mSequence);
|
||||
if (proc.mCurSeq == mSequence) {
|
||||
@@ -1340,7 +1345,7 @@ public class RunningState {
|
||||
if (bgIndex >= mBackgroundItems.size()
|
||||
|| mBackgroundItems.get(bgIndex).mProcess != proc) {
|
||||
newBackgroundItems = new ArrayList<MergedItem>(numBackgroundProcesses);
|
||||
for (int bgi=0; bgi<bgIndex; bgi++) {
|
||||
for (int bgi = 0; bgi < bgIndex; bgi++) {
|
||||
mergedItem = mBackgroundItems.get(bgi);
|
||||
diffUsers |= mergedItem.mUserId != mMyUserId;
|
||||
newBackgroundItems.add(mergedItem);
|
||||
@@ -1363,12 +1368,12 @@ public class RunningState {
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
|
||||
|
||||
if (newBackgroundItems == null) {
|
||||
// One or more at the bottom may no longer exist.
|
||||
if (mBackgroundItems.size() > numBackgroundProcesses) {
|
||||
newBackgroundItems = new ArrayList<MergedItem>(numBackgroundProcesses);
|
||||
for (int bgi=0; bgi<numBackgroundProcesses; bgi++) {
|
||||
for (int bgi = 0; bgi < numBackgroundProcesses; bgi++) {
|
||||
MergedItem mergedItem = mBackgroundItems.get(bgi);
|
||||
diffUsers |= mergedItem.mUserId != mMyUserId;
|
||||
newBackgroundItems.add(mergedItem);
|
||||
@@ -1387,7 +1392,7 @@ public class RunningState {
|
||||
// items for users are collapsed together.
|
||||
newUserBackgroundItems = new ArrayList<MergedItem>();
|
||||
final int NB = newBackgroundItems.size();
|
||||
for (int i=0; i<NB; i++) {
|
||||
for (int i = 0; i < NB; i++) {
|
||||
MergedItem mergedItem = newBackgroundItems.get(i);
|
||||
if (mergedItem.mUserId != mMyUserId) {
|
||||
addOtherUserItem(context, newUserBackgroundItems,
|
||||
@@ -1399,7 +1404,7 @@ public class RunningState {
|
||||
// And user aggregated merged items need to be
|
||||
// updated now that they have all of their children.
|
||||
final int NU = mOtherUserBackgroundItems.size();
|
||||
for (int i=0; i<NU; i++) {
|
||||
for (int i = 0; i < NU; i++) {
|
||||
MergedItem user = mOtherUserBackgroundItems.valueAt(i);
|
||||
if (user.mCurSeq == mSequence) {
|
||||
user.update(context, true);
|
||||
@@ -1409,10 +1414,10 @@ public class RunningState {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<mMergedItems.size(); i++) {
|
||||
for (int i = 0; i < mMergedItems.size(); i++) {
|
||||
mMergedItems.get(i).updateSize(context);
|
||||
}
|
||||
|
||||
|
||||
synchronized (mLock) {
|
||||
mNumBackgroundProcesses = numBackgroundProcesses;
|
||||
mNumForegroundProcesses = numForegroundProcesses;
|
||||
@@ -1432,10 +1437,10 @@ public class RunningState {
|
||||
mLock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
void setWatchingBackgroundItems(boolean watching) {
|
||||
synchronized (mLock) {
|
||||
mWatchingBackgroundItems = watching;
|
||||
|
@@ -112,7 +112,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
|
||||
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
||||
final BatteryTip batteryTip = mBatteryTips.get(i);
|
||||
batteryTip.sanityCheck(mContext);
|
||||
batteryTip.validateCheck(mContext);
|
||||
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
|
||||
batteryTip.updatePreference(mCardPreference);
|
||||
mBatteryTipMap.put(mCardPreference.getKey(), batteryTip);
|
||||
|
@@ -138,7 +138,7 @@ public abstract class BatteryTip implements Comparable<BatteryTip>, Parcelable {
|
||||
* Check whether data is still make sense. If not, try recover.
|
||||
* @param context used to do validate check
|
||||
*/
|
||||
public void sanityCheck(Context context) {
|
||||
public void validateCheck(Context context) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
@@ -107,8 +107,8 @@ public class RestrictAppTip extends BatteryTip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanityCheck(Context context) {
|
||||
super.sanityCheck(context);
|
||||
public void validateCheck(Context context) {
|
||||
super.validateCheck(context);
|
||||
|
||||
// Set it invisible if there is no valid app
|
||||
mRestrictAppList.removeIf(AppLabelPredicate.getInstance(context));
|
||||
|
Reference in New Issue
Block a user