From 2675616719734ce069db47bd8b563f775351dd38 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 17 May 2016 13:40:44 -0700 Subject: [PATCH] Work on issue #28689719: Runtime restart There are few paths I can see to get a null intent down into the framework at this point. Add in some checks and reports at those places to mitigate and report such problems. Change-Id: If235bf342558321d3fabe9363fcebb2bcea18df1 --- core/java/android/app/LoadedApk.java | 12 +++++++++--- .../android/server/am/ActivityManagerService.java | 9 +++++++++ .../java/com/android/server/am/BroadcastQueue.java | 1 - 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 7d43a1155e61f..3f870005abfe4 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -1046,11 +1046,17 @@ public final class LoadedApk { @Override public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) { - LoadedApk.ReceiverDispatcher rd = mDispatcher.get(); + final LoadedApk.ReceiverDispatcher rd; + if (intent == null) { + Log.wtf(TAG, "Null intent received"); + rd = null; + } else { + rd = mDispatcher.get(); + } if (ActivityThread.DEBUG_BROADCAST) { int seq = intent.getIntExtra("seq", -1); - Slog.i(ActivityThread.TAG, "Receiving broadcast " + intent.getAction() + " seq=" + seq - + " to " + (rd != null ? rd.mReceiver : null)); + Slog.i(ActivityThread.TAG, "Receiving broadcast " + intent.getAction() + + " seq=" + seq + " to " + (rd != null ? rd.mReceiver : null)); } if (rd != null) { rd.performReceive(intent, resultCode, data, extras, diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index a0664627629d3..a7ea62851520f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -7057,6 +7057,15 @@ public final class ActivityManagerService extends ActivityManagerNative return ((PendingIntentRecord)target).sendWithResult(code, intent, resolvedType, finishedReceiver, requiredPermission, options); } else { + if (intent == null) { + // Weird case: someone has given us their own custom IIntentSender, and now + // they have someone else trying to send to it but of course this isn't + // really a PendingIntent, so there is no base Intent, and the caller isn't + // supplying an Intent... but we never want to dispatch a null Intent to + // a receiver, so um... let's make something up. + Slog.wtf(TAG, "Can't use null intent with direct IIntentSender call"); + intent = new Intent(Intent.ACTION_MAIN); + } try { target.send(code, intent, resolvedType, null, requiredPermission, options); } catch (RemoteException e) { diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index 1222f54d15e80..0acc2a07e1533 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -38,7 +38,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Build; import android.os.Bundle; -import android.os.DeadObjectException; import android.os.Handler; import android.os.IBinder; import android.os.Looper;