am 79748b42: Merge change 9000 into donut

Merge commit '79748b42e3e891c0d1541753c133fa83638146ce'

* commit '79748b42e3e891c0d1541753c133fa83638146ce':
  Fix duplicate entries being added when application is in active use
This commit is contained in:
Android (Google) Code Review
2009-07-30 09:56:29 -07:00
committed by Android Git Automerger

View File

@@ -355,7 +355,7 @@ public class ManageApplications extends ListActivity implements
Log.w(TAG, "Couldnt find application info for:"+pkgName); Log.w(TAG, "Couldnt find application info for:"+pkgName);
break; break;
} }
mObserver.invokeGetSizeInfo(info); mObserver.invokeGetSizeInfo(pkgName);
break; break;
case ADD_PKG_DONE: case ADD_PKG_DONE:
if(localLOGV) Log.i(TAG, "Message ADD_PKG_DONE"); if(localLOGV) Log.i(TAG, "Message ADD_PKG_DONE");
@@ -367,7 +367,12 @@ public class ManageApplications extends ListActivity implements
if (status) { if (status) {
size = data.getLong(ATTR_PKG_STATS); size = data.getLong(ATTR_PKG_STATS);
formattedSize = data.getString(ATTR_PKG_SIZE_STR); formattedSize = data.getString(ATTR_PKG_SIZE_STR);
int idx = mAppInfoAdapter.getIndex(pkgName);
if (idx == -1) {
mAppInfoAdapter.addToList(pkgName, size, formattedSize); mAppInfoAdapter.addToList(pkgName, size, formattedSize);
} else {
mAppInfoAdapter.updatePackage(pkgName, size, formattedSize);
}
} }
break; break;
case REFRESH_LABELS: case REFRESH_LABELS:
@@ -1162,19 +1167,6 @@ public class ManageApplications extends ListActivity implements
} }
} }
public boolean updateAppLabel(String pkgName, CharSequence label) {
if ((pkgName == null) || (label == null)) {
return false;
}
AppInfo aInfo = mCache.getEntry(pkgName);
if (aInfo != null) {
aInfo.refreshLabel(label);
notifyDataSetChanged();
return true;
}
return false;
}
private boolean shouldBeInList(int filterOption, ApplicationInfo info) { private boolean shouldBeInList(int filterOption, ApplicationInfo info) {
// Match filter here // Match filter here
if (filterOption == FILTER_APPS_RUNNING) { if (filterOption == FILTER_APPS_RUNNING) {
@@ -1246,6 +1238,24 @@ public class ManageApplications extends ListActivity implements
} }
} }
public void updatePackage(String pkgName,
long size, String formattedSize) {
ApplicationInfo info = null;
try {
info = mPm.getApplicationInfo(pkgName,
PackageManager.GET_UNINSTALLED_PACKAGES);
} catch (NameNotFoundException e) {
return;
}
AppInfo aInfo = mCache.getEntry(pkgName);
if (aInfo != null) {
aInfo.refreshLabel(info.loadLabel(mPm));
aInfo.refreshIcon(info.loadIcon(mPm));
aInfo.setSize(size, formattedSize);
notifyDataSetChanged();
}
}
private void removePkgBase(String pkgName) { private void removePkgBase(String pkgName) {
int imax = mAppList.size(); int imax = mAppList.size();
for (int i = 0; i < imax; i++) { for (int i = 0; i < imax; i++) {
@@ -1311,21 +1321,6 @@ public class ManageApplications extends ListActivity implements
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }
public void updateAppSize(String pkgName, long size, String formattedSize) {
if(pkgName == null) {
return;
}
AppInfo entry = mCache.getEntry(pkgName);
if (entry == null) {
if (localLOGV) Log.w(TAG, "Entry for package:"+pkgName+"doesnt exist in map");
return;
}
// Copy the index into the newly updated entry
if (entry.setSize(size, formattedSize)) {
notifyDataSetChanged();
}
}
} }
/* /*
@@ -1371,7 +1366,7 @@ public class ManageApplications extends ListActivity implements
* and the AppInfo object corresponding to the package name are set on the message * and the AppInfo object corresponding to the package name are set on the message
*/ */
class PkgSizeObserver extends IPackageStatsObserver.Stub { class PkgSizeObserver extends IPackageStatsObserver.Stub {
private ApplicationInfo mAppInfo; String pkgName;
public void onGetStatsCompleted(PackageStats pStats, boolean pSucceeded) { public void onGetStatsCompleted(PackageStats pStats, boolean pSucceeded) {
if(DEBUG_PKG_DELAY) { if(DEBUG_PKG_DELAY) {
try { try {
@@ -1379,12 +1374,11 @@ public class ManageApplications extends ListActivity implements
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }
AppInfo appInfo = null;
Bundle data = new Bundle(); Bundle data = new Bundle();
data.putString(ATTR_PKG_NAME, mAppInfo.packageName); data.putString(ATTR_PKG_NAME, pkgName);
data.putBoolean(ATTR_GET_SIZE_STATUS, pSucceeded); data.putBoolean(ATTR_GET_SIZE_STATUS, pSucceeded);
if(pSucceeded && pStats != null) { if(pSucceeded && pStats != null) {
if (localLOGV) Log.i(TAG, "onGetStatsCompleted::"+pStats.packageName+", ("+ if (localLOGV) Log.i(TAG, "onGetStatsCompleted::"+pkgName+", ("+
pStats.cacheSize+","+ pStats.cacheSize+","+
pStats.codeSize+", "+pStats.dataSize); pStats.codeSize+", "+pStats.dataSize);
long total = getTotalSize(pStats); long total = getTotalSize(pStats);
@@ -1400,14 +1394,14 @@ public class ManageApplications extends ListActivity implements
mHandler.sendMessage(msg); mHandler.sendMessage(msg);
} }
public void invokeGetSizeInfo(ApplicationInfo pAppInfo) { public void invokeGetSizeInfo(String packageName) {
if(pAppInfo == null || pAppInfo.packageName == null) { if (packageName == null) {
return; return;
} }
pkgName = packageName;
if(localLOGV) Log.i(TAG, "Invoking getPackageSizeInfo for package:"+ if(localLOGV) Log.i(TAG, "Invoking getPackageSizeInfo for package:"+
pAppInfo.packageName); packageName);
mAppInfo = pAppInfo; mPm.getPackageSizeInfo(packageName, this);
mPm.getPackageSizeInfo(pAppInfo.packageName, this);
} }
} }