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

Commit cc269d93 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Update service map when application info is updated

Bug: 77271275
Test: PoC app from b/77271275#3 on user 0 and 10
Change-Id: I78dec7e4b0649928cca8275b84259cdd72fe3c97
parent 6db14d01
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -3592,6 +3592,21 @@ public final class ActiveServices {
        }
    }

    public void updateServiceApplicationInfoLocked(ApplicationInfo applicationInfo) {
        final int userId = UserHandle.getUserId(applicationInfo.uid);
        ServiceMap serviceMap = mServiceMap.get(userId);
        if (serviceMap != null) {
            ArrayMap<ComponentName, ServiceRecord> servicesByName = serviceMap.mServicesByName;
            for (int j = servicesByName.size() - 1; j >= 0; j--) {
                ServiceRecord serviceRecord = servicesByName.valueAt(j);
                if (applicationInfo.packageName.equals(serviceRecord.appInfo.packageName)) {
                    serviceRecord.appInfo = applicationInfo;
                    serviceRecord.serviceInfo.applicationInfo = applicationInfo;
                }
            }
        }
    }

    void serviceForegroundCrash(ProcessRecord app, CharSequence serviceRecord) {
        mAm.crashApplication(app.uid, app.pid, app.info.packageName, app.userId,
                "Context.startForegroundService() did not then call Service.startForeground(): "
+1 −0
Original line number Diff line number Diff line
@@ -21455,6 +21455,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            return ActivityManager.BROADCAST_SUCCESS;
                        }
                        mStackSupervisor.updateActivityApplicationInfoLocked(aInfo);
                        mServices.updateServiceApplicationInfoLocked(aInfo);
                        sendPackageBroadcastLocked(ApplicationThreadConstants.PACKAGE_REPLACED,
                                new String[] {ssp}, userId);
                    }
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
                            // original intent used to find service.
    final ServiceInfo serviceInfo;
                            // all information about the service.
    final ApplicationInfo appInfo;
    ApplicationInfo appInfo;
                            // information about service's app.
    final int userId;       // user that this service is running as
    final String packageName; // the package implementing intent's component