Merge "Update service map when application info is updated" into pi-dev

This commit is contained in:
Fyodor Kupolov
2018-05-16 23:12:52 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 1 deletions

View File

@@ -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(): "

View File

@@ -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);
}

View File

@@ -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