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

Commit 7e95126e authored by Kodlee Yin's avatar Kodlee Yin Committed by Dennis Kiilerich
Browse files

Include ServiceRecord in foreground service exception exception text.

Test: manual verification of logcat using test service that doesn't conform to foreground service rules
Bug: 77647171
Change-Id: Ie35029838359d83c31ea4e3b2faa166ac8aeec47
parent b17c2388
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -2567,6 +2567,8 @@ public final class ActiveServices {
                Message msg = mAm.mHandler.obtainMessage(
                Message msg = mAm.mHandler.obtainMessage(
                        ActivityManagerService.SERVICE_FOREGROUND_CRASH_MSG);
                        ActivityManagerService.SERVICE_FOREGROUND_CRASH_MSG);
                msg.obj = r.app;
                msg.obj = r.app;
                msg.getData().putCharSequence(
                    ActivityManagerService.SERVICE_RECORD_KEY, r.toString());
                mAm.mHandler.sendMessage(msg);
                mAm.mHandler.sendMessage(msg);
            }
            }
        }
        }
@@ -3482,13 +3484,15 @@ public final class ActiveServices {


        if (app != null) {
        if (app != null) {
            mAm.mAppErrors.appNotResponding(app, null, null, false,
            mAm.mAppErrors.appNotResponding(app, null, null, false,
                    "Context.startForegroundService() did not then call Service.startForeground()");
                    "Context.startForegroundService() did not then call Service.startForeground(): "
                        + r);
        }
        }
    }
    }


    void serviceForegroundCrash(ProcessRecord app) {
    void serviceForegroundCrash(ProcessRecord app, CharSequence serviceRecord) {
        mAm.crashApplication(app.uid, app.pid, app.info.packageName, app.userId,
        mAm.crashApplication(app.uid, app.pid, app.info.packageName, app.userId,
                "Context.startForegroundService() did not then call Service.startForeground()");
                "Context.startForegroundService() did not then call Service.startForeground(): "
                    + serviceRecord);
    }
    }


    void scheduleServiceTimeoutLocked(ProcessRecord proc) {
    void scheduleServiceTimeoutLocked(ProcessRecord proc) {
+4 −1
Original line number Original line Diff line number Diff line
@@ -1913,6 +1913,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    static final int FIRST_COMPAT_MODE_MSG = 300;
    static final int FIRST_COMPAT_MODE_MSG = 300;
    static final int FIRST_SUPERVISOR_STACK_MSG = 100;
    static final int FIRST_SUPERVISOR_STACK_MSG = 100;
    static final String SERVICE_RECORD_KEY = "servicerecord";
    static ServiceThread sKillThread = null;
    static ServiceThread sKillThread = null;
    static KillHandler sKillHandler = null;
    static KillHandler sKillHandler = null;
@@ -2161,7 +2163,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                mServices.serviceForegroundTimeout((ServiceRecord)msg.obj);
                mServices.serviceForegroundTimeout((ServiceRecord)msg.obj);
            } break;
            } break;
            case SERVICE_FOREGROUND_CRASH_MSG: {
            case SERVICE_FOREGROUND_CRASH_MSG: {
                mServices.serviceForegroundCrash((ProcessRecord)msg.obj);
                mServices.serviceForegroundCrash(
                    (ProcessRecord) msg.obj, msg.getData().getCharSequence(SERVICE_RECORD_KEY));
            } break;
            } break;
            case DISPATCH_PENDING_INTENT_CANCEL_MSG: {
            case DISPATCH_PENDING_INTENT_CANCEL_MSG: {
                RemoteCallbackList<IResultReceiver> callbacks
                RemoteCallbackList<IResultReceiver> callbacks