Don't have app info pages load so much info

They don't need to resume the ApplicationsState session because they
only need info for one app, instead just make sure ApplicationsState
can load the info as requested.

Bug: 20696893
Change-Id: I146387438348fad1396ac4528819b2f1a93a97bf
This commit is contained in:
Jason Monk
2015-05-26 15:56:05 -04:00
parent 85a72a9088
commit 646befdd16
3 changed files with 22 additions and 26 deletions

View File

@@ -55,7 +55,6 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
protected boolean mAppControlRestricted = false; protected boolean mAppControlRestricted = false;
protected ApplicationsState mState; protected ApplicationsState mState;
private ApplicationsState.Session mSession;
protected ApplicationsState.AppEntry mAppEntry; protected ApplicationsState.AppEntry mAppEntry;
protected PackageInfo mPackageInfo; protected PackageInfo mPackageInfo;
protected int mUserId; protected int mUserId;
@@ -77,7 +76,6 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
mFinishing = false; mFinishing = false;
mState = ApplicationsState.getInstance(getActivity().getApplication()); mState = ApplicationsState.getInstance(getActivity().getApplication());
mSession = mState.newSession(this);
Context context = getActivity(); Context context = getActivity();
mDpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); mDpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE); mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -85,9 +83,6 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
IBinder b = ServiceManager.getService(Context.USB_SERVICE); IBinder b = ServiceManager.getService(Context.USB_SERVICE);
mUsbManager = IUsbManager.Stub.asInterface(b); mUsbManager = IUsbManager.Stub.asInterface(b);
// Need to make sure we have loaded applications at this point.
mSession.resume();
retrieveAppEntry(); retrieveAppEntry();
} }
@@ -95,25 +90,12 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
mAppControlRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL); mAppControlRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL);
mSession.resume();
if (!refreshUi()) { if (!refreshUi()) {
setIntentAndFinish(true, true); setIntentAndFinish(true, true);
} }
} }
@Override
public void onPause() {
super.onPause();
mSession.pause();
}
@Override
public void onDestroyView() {
super.onDestroyView();
mSession.release();
}
protected String retrieveAppEntry() { protected String retrieveAppEntry() {
final Bundle args = getArguments(); final Bundle args = getArguments();
mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null; mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;

View File

@@ -878,20 +878,33 @@ public class ApplicationsState {
synchronized (mEntriesMap) { synchronized (mEntriesMap) {
AppEntry entry = mEntriesMap.get(userId).get(packageName); AppEntry entry = mEntriesMap.get(userId).get(packageName);
if (entry == null) { if (entry == null) {
for (int i=0; i<mApplications.size(); i++) { ApplicationInfo info = getAppInfoLocked(packageName, userId);
ApplicationInfo info = mApplications.get(i); if (info == null) {
if (packageName.equals(info.packageName) try {
&& userId == UserHandle.getUserId(info.uid)) { info = mIpm.getApplicationInfo(packageName, 0, userId);
} catch (RemoteException e) {
Log.w(TAG, "getEntry couldn't reach PackageManager", e);
return null;
}
}
entry = getEntryLocked(info); entry = getEntryLocked(info);
break;
}
}
} }
if (DEBUG_LOCKING) Log.v(TAG, "...getEntry releasing lock"); if (DEBUG_LOCKING) Log.v(TAG, "...getEntry releasing lock");
return entry; return entry;
} }
} }
private ApplicationInfo getAppInfoLocked(String pkg, int userId) {
for (int i = 0; i < mApplications.size(); i++) {
ApplicationInfo info = mApplications.get(i);
if (pkg.equals(info.packageName)
&& userId == UserHandle.getUserId(info.uid)) {
return info;
}
}
return null;
}
void ensureIcon(AppEntry entry) { void ensureIcon(AppEntry entry) {
if (entry.icon != null) { if (entry.icon != null) {
return; return;
@@ -1153,8 +1166,8 @@ public class ApplicationsState {
mMainHandler.sendMessage(msg); mMainHandler.sendMessage(msg);
} }
} }
if (mCurComputingSizePkg == null if (mCurComputingSizePkg != null
|| (mCurComputingSizePkg.equals(stats.packageName) && (mCurComputingSizePkg.equals(stats.packageName)
&& mCurComputingSizeUserId == stats.userHandle)) { && mCurComputingSizeUserId == stats.userHandle)) {
mCurComputingSizePkg = null; mCurComputingSizePkg = null;
sendEmptyMessage(MSG_LOAD_SIZES); sendEmptyMessage(MSG_LOAD_SIZES);

View File

@@ -251,6 +251,7 @@ public class InstalledAppDetails extends AppInfoBase
if (mFinishing) { if (mFinishing) {
return; return;
} }
mState.requestSize(mPackageName, mUserId);
AppItem app = new AppItem(mAppEntry.info.uid); AppItem app = new AppItem(mAppEntry.info.uid);
app.addUid(mAppEntry.info.uid); app.addUid(mAppEntry.info.uid);
if (mStatsSession != null) { if (mStatsSession != null) {