Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29cd7f19 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #18827122: system server crashed on broadcasting...

...an intent with invalid or null package uri

Also tweak battery stats to record in the history when we shut
down, to understand when restarts are due to clean shutdowns or
crashes.

Change-Id: I6443dafc23e356be9f569906f6081152d4f92d2b
parent 9d4b7963
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -604,6 +604,7 @@ public abstract class BatteryStats implements Parcelable {
        public static final byte CMD_CURRENT_TIME = 5;
        public static final byte CMD_OVERFLOW = 6;
        public static final byte CMD_RESET = 7;
        public static final byte CMD_SHUTDOWN = 8;

        public byte cmd = CMD_NULL;
        
@@ -3529,6 +3530,11 @@ public abstract class BatteryStats implements Parcelable {
                    pw.println(DateFormat.format("yyyy-MM-dd-HH-mm-ss",
                            rec.currentTime).toString());
                }
            } else if (rec.cmd == HistoryItem.CMD_SHUTDOWN) {
                if (checkin) {
                    pw.print(":");
                }
                pw.println("SHUTDOWN");
            } else if (rec.cmd == HistoryItem.CMD_OVERFLOW) {
                if (checkin) {
                    pw.print(":");
@@ -3849,7 +3855,8 @@ public abstract class BatteryStats implements Parcelable {
                if (histStart >= 0 && !printed) {
                    if (rec.cmd == HistoryItem.CMD_CURRENT_TIME
                            || rec.cmd == HistoryItem.CMD_RESET
                            || rec.cmd == HistoryItem.CMD_START) {
                            || rec.cmd == HistoryItem.CMD_START
                            || rec.cmd == HistoryItem.CMD_SHUTDOWN) {
                        printed = true;
                        hprinter.printNextItem(pw, rec, baseTime, checkin,
                                (flags&DUMP_VERBOSE) != 0);
+3 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.util.Slog;
import com.android.internal.os.BackgroundThread;

import java.util.HashSet;
@@ -279,8 +280,8 @@ public abstract class PackageMonitor extends android.content.BroadcastReceiver {
        mChangeUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
                UserHandle.USER_NULL);
        if (mChangeUserId == UserHandle.USER_NULL) {
            throw new IllegalArgumentException(
                    "Intent broadcast does not contain user handle: " + intent);
            Slog.w("PackageMonitor", "Intent broadcast does not contain user handle: " + intent);
            return;
        }
        onBeginPackageChanges();
        
+12 −0
Original line number Diff line number Diff line
@@ -6955,6 +6955,17 @@ public final class BatteryStatsImpl extends BatteryStats {
        }
    }

    private void recordShutdownLocked(final long elapsedRealtimeMs, final long uptimeMs) {
        if (mRecordingHistory) {
            mHistoryCur.currentTime = System.currentTimeMillis();
            mLastRecordedClockTime = mHistoryCur.currentTime;
            mLastRecordedClockRealtime = elapsedRealtimeMs;
            addHistoryBufferLocked(elapsedRealtimeMs, uptimeMs, HistoryItem.CMD_SHUTDOWN,
                    mHistoryCur);
            mHistoryCur.currentTime = 0;
        }
    }

    // This should probably be exposed in the API, though it's not critical
    private static final int BATTERY_PLUGGED_NONE = 0;

@@ -7627,6 +7638,7 @@ public final class BatteryStatsImpl extends BatteryStats {
    }

    public void shutdownLocked() {
        recordShutdownLocked(SystemClock.elapsedRealtime(), SystemClock.uptimeMillis());
        writeSyncLocked();
        mShuttingDown = true;
    }
+3 −0
Original line number Diff line number Diff line
@@ -683,6 +683,9 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action == null) {
                return;
            }

            boolean queryRestart = false;
            boolean queryRemove = false;
+3 −0
Original line number Diff line number Diff line
@@ -320,6 +320,9 @@ public class UserManagerService extends IUserManager.Stub {
        checkManageUsersPermission("get the profile parent");
        synchronized (mPackagesLock) {
            UserInfo profile = getUserInfoLocked(userHandle);
            if (profile == null) {
                return null;
            }
            int parentUserId = profile.profileGroupId;
            if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) {
                return null;