Memory Usage by apps no longer shows empty icon
ProcessStatsPreference will now fallback to a default icon instead of an empty icon. Logging was added to be able to identify what causes list to add entries with no text. Test: Manual, requires installing -> uninstalling an app Bug: 31812426 Change-Id: Ia1b147ba7a552ec4880776ebf8dba6745154117a
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import android.util.Log;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
@@ -127,6 +128,7 @@ public class ProcStatsPackageEntry implements Parcelable {
|
||||
mUiLabel = mUiTargetApp.loadLabel(pm).toString();
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.d(TAG, "could not find package: " + mPackage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,9 +22,11 @@ import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
|
||||
import android.util.Log;
|
||||
import com.android.settings.AppProgressPreference;
|
||||
|
||||
public class ProcessStatsPreference extends AppProgressPreference {
|
||||
static final String TAG = "ProcessStatsPreference";
|
||||
|
||||
private ProcStatsPackageEntry mEntry;
|
||||
|
||||
@@ -35,11 +37,15 @@ public class ProcessStatsPreference extends AppProgressPreference {
|
||||
public void init(ProcStatsPackageEntry entry, PackageManager pm, double maxMemory,
|
||||
double weightToRam, double totalScale, boolean avg) {
|
||||
mEntry = entry;
|
||||
setTitle(TextUtils.isEmpty(entry.mUiLabel) ? entry.mPackage : entry.mUiLabel);
|
||||
String title = TextUtils.isEmpty(entry.mUiLabel) ? entry.mPackage : entry.mUiLabel;
|
||||
setTitle(title);
|
||||
if (TextUtils.isEmpty(title)) {
|
||||
Log.d(TAG, "PackageEntry contained no package name or uiLabel");
|
||||
}
|
||||
if (entry.mUiTargetApp != null) {
|
||||
setIcon(entry.mUiTargetApp.loadIcon(pm));
|
||||
} else {
|
||||
setIcon(new ColorDrawable(0));
|
||||
setIcon(pm.getDefaultActivityIcon());
|
||||
}
|
||||
boolean statsForeground = entry.mRunWeight > entry.mBgWeight;
|
||||
double amount = avg ? (statsForeground ? entry.mRunWeight : entry.mBgWeight) * weightToRam
|
||||
|
Reference in New Issue
Block a user