Skip to content

Commit 3941ea6

Browse files
committed
[bugfix] protect activityManager npe at some oppo phone
1 parent 855084e commit 3941ea6

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareTinkerInternals.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -372,23 +372,25 @@ private static String getProcessNameInternal(final Context context) {
372372
ActivityManager activityManager =
373373
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
374374

375-
List<ActivityManager.RunningAppProcessInfo> appProcessList = activityManager
376-
.getRunningAppProcesses();
375+
if (activityManager != null) {
376+
List<ActivityManager.RunningAppProcessInfo> appProcessList = activityManager
377+
.getRunningAppProcesses();
377378

378-
if (appProcessList != null) {
379-
try {
380-
for (ActivityManager.RunningAppProcessInfo process : appProcessList) {
381-
if (process.pid == myPid) {
382-
myProcess = process;
383-
break;
379+
if (appProcessList != null) {
380+
try {
381+
for (ActivityManager.RunningAppProcessInfo process : appProcessList) {
382+
if (process.pid == myPid) {
383+
myProcess = process;
384+
break;
385+
}
384386
}
387+
} catch (Exception e) {
388+
Log.e(TAG, "getProcessNameInternal exception:" + e.getMessage());
385389
}
386-
} catch (Exception e) {
387-
Log.e(TAG, "getProcessNameInternal exception:" + e.getMessage());
388-
}
389390

390-
if (myProcess != null) {
391-
return myProcess.processName;
391+
if (myProcess != null) {
392+
return myProcess.processName;
393+
}
392394
}
393395
}
394396

0 commit comments

Comments
 (0)