Merge "Fix bug #12957032 Stability-Sys: Java crash in com.android.settings: java.lang.NullPointerException: ...Attempt to invoke virtual method 'boolean android.os.Handler.sendEmptyMessage(int)' on a null object reference"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a16bd76d45
@@ -43,7 +43,7 @@ public class BatteryEntry {
|
|||||||
static final HashMap<String,UidToDetail> sUidCache = new HashMap<String,UidToDetail>();
|
static final HashMap<String,UidToDetail> sUidCache = new HashMap<String,UidToDetail>();
|
||||||
|
|
||||||
static final ArrayList<BatteryEntry> mRequestQueue = new ArrayList<BatteryEntry>();
|
static final ArrayList<BatteryEntry> mRequestQueue = new ArrayList<BatteryEntry>();
|
||||||
static Handler mHandler;
|
static Handler sHandler;
|
||||||
|
|
||||||
static private class NameAndIconLoader extends Thread {
|
static private class NameAndIconLoader extends Thread {
|
||||||
private boolean mAbort = false;
|
private boolean mAbort = false;
|
||||||
@@ -62,7 +62,9 @@ public class BatteryEntry {
|
|||||||
BatteryEntry be;
|
BatteryEntry be;
|
||||||
synchronized (mRequestQueue) {
|
synchronized (mRequestQueue) {
|
||||||
if (mRequestQueue.isEmpty() || mAbort) {
|
if (mRequestQueue.isEmpty() || mAbort) {
|
||||||
mHandler.sendEmptyMessage(MSG_REPORT_FULLY_DRAWN);
|
if (sHandler != null) {
|
||||||
|
sHandler.sendEmptyMessage(MSG_REPORT_FULLY_DRAWN);
|
||||||
|
}
|
||||||
mRequestQueue.clear();
|
mRequestQueue.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -76,7 +78,7 @@ public class BatteryEntry {
|
|||||||
private static NameAndIconLoader mRequestThread;
|
private static NameAndIconLoader mRequestThread;
|
||||||
|
|
||||||
public static void startRequestQueue() {
|
public static void startRequestQueue() {
|
||||||
if (mHandler != null) {
|
if (sHandler != null) {
|
||||||
synchronized (mRequestQueue) {
|
synchronized (mRequestQueue) {
|
||||||
if (!mRequestQueue.isEmpty()) {
|
if (!mRequestQueue.isEmpty()) {
|
||||||
if (mRequestThread != null) {
|
if (mRequestThread != null) {
|
||||||
@@ -96,7 +98,7 @@ public class BatteryEntry {
|
|||||||
if (mRequestThread != null) {
|
if (mRequestThread != null) {
|
||||||
mRequestThread.abort();
|
mRequestThread.abort();
|
||||||
mRequestThread = null;
|
mRequestThread = null;
|
||||||
mHandler = null;
|
sHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +122,7 @@ public class BatteryEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BatteryEntry(Context context, Handler handler, UserManager um, BatterySipper sipper) {
|
public BatteryEntry(Context context, Handler handler, UserManager um, BatterySipper sipper) {
|
||||||
mHandler = handler;
|
sHandler = handler;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.sipper = sipper;
|
this.sipper = sipper;
|
||||||
switch (sipper.drainType) {
|
switch (sipper.drainType) {
|
||||||
@@ -221,7 +223,7 @@ public class BatteryEntry {
|
|||||||
} else {
|
} else {
|
||||||
//name = packages[0];
|
//name = packages[0];
|
||||||
}
|
}
|
||||||
if (mHandler != null) {
|
if (sHandler != null) {
|
||||||
synchronized (mRequestQueue) {
|
synchronized (mRequestQueue) {
|
||||||
mRequestQueue.add(this);
|
mRequestQueue.add(this);
|
||||||
}
|
}
|
||||||
@@ -248,11 +250,8 @@ public class BatteryEntry {
|
|||||||
String[] packageLabels = new String[sipper.mPackages.length];
|
String[] packageLabels = new String[sipper.mPackages.length];
|
||||||
System.arraycopy(sipper.mPackages, 0, packageLabels, 0, sipper.mPackages.length);
|
System.arraycopy(sipper.mPackages, 0, packageLabels, 0, sipper.mPackages.length);
|
||||||
|
|
||||||
int preferredIndex = -1;
|
|
||||||
// Convert package names to user-facing labels where possible
|
// Convert package names to user-facing labels where possible
|
||||||
for (int i = 0; i < packageLabels.length; i++) {
|
for (int i = 0; i < packageLabels.length; i++) {
|
||||||
// Check if package matches preferred package
|
|
||||||
if (packageLabels[i].equals(name)) preferredIndex = i;
|
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageLabels[i], 0);
|
ApplicationInfo ai = pm.getApplicationInfo(packageLabels[i], 0);
|
||||||
CharSequence label = ai.loadLabel(pm);
|
CharSequence label = ai.loadLabel(pm);
|
||||||
@@ -298,8 +297,8 @@ public class BatteryEntry {
|
|||||||
utd.icon = icon;
|
utd.icon = icon;
|
||||||
utd.packageName = defaultPackageName;
|
utd.packageName = defaultPackageName;
|
||||||
sUidCache.put(uidString, utd);
|
sUidCache.put(uidString, utd);
|
||||||
if (mHandler != null) {
|
if (sHandler != null) {
|
||||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_NAME_ICON, this));
|
sHandler.sendMessage(sHandler.obtainMessage(MSG_UPDATE_NAME_ICON, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user