Loading core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -3558,6 +3558,12 @@ --> --> <string name="config_defaultSystemCaptionsService" translatable="false"></string> <string name="config_defaultSystemCaptionsService" translatable="false"></string> <!-- The component name for the system-wide captions manager service. This service must be trusted, as the system binds to it and keeps it running. Example: "com.android.captions/.SystemCaptionsManagerService" --> <string name="config_defaultSystemCaptionsManagerService" translatable="false"></string> <!-- The package name for the incident report approver app. <!-- The package name for the incident report approver app. This app is usually PermissionController or an app that replaces it. When This app is usually PermissionController or an app that replaces it. When a bugreport or incident report with EXPLICT-level sharing flags is going to be a bugreport or incident report with EXPLICT-level sharing flags is going to be Loading core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3409,6 +3409,7 @@ <java-symbol type="string" name="config_defaultContentSuggestionsService" /> <java-symbol type="string" name="config_defaultContentSuggestionsService" /> <java-symbol type="string" name="config_defaultAttentionService" /> <java-symbol type="string" name="config_defaultAttentionService" /> <java-symbol type="string" name="config_defaultSystemCaptionsService" /> <java-symbol type="string" name="config_defaultSystemCaptionsService" /> <java-symbol type="string" name="config_defaultSystemCaptionsManagerService" /> <java-symbol type="string" name="notification_channel_foreground_service" /> <java-symbol type="string" name="notification_channel_foreground_service" /> <java-symbol type="string" name="foreground_service_app_in_background" /> <java-symbol type="string" name="foreground_service_app_in_background" /> Loading services/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ java_library { "services.print", "services.print", "services.restrictions", "services.restrictions", "services.startop", "services.startop", "services.systemcaptions", "services.usage", "services.usage", "services.usb", "services.usb", "services.voiceinteraction", "services.voiceinteraction", Loading services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -129,7 +129,8 @@ public final class ContentCaptureManagerService extends public ContentCaptureManagerService(@NonNull Context context) { public ContentCaptureManagerService(@NonNull Context context) { super(context, new FrameworkResourcesServiceNameResolver(context, super(context, new FrameworkResourcesServiceNameResolver(context, com.android.internal.R.string.config_defaultContentCaptureService), com.android.internal.R.string.config_defaultContentCaptureService), UserManager.DISALLOW_CONTENT_CAPTURE, /* refreshServiceOnPackageUpdate= */ false); UserManager.DISALLOW_CONTENT_CAPTURE, /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_NO_REFRESH); DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE, DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE, ActivityThread.currentApplication().getMainExecutor(), ActivityThread.currentApplication().getMainExecutor(), (namespace, key, value) -> onDeviceConfigChange(key, value)); (namespace, key, value) -> onDeviceConfigChange(key, value)); Loading services/core/java/com/android/server/infra/AbstractMasterSystemService.java +53 −12 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ */ package com.android.server.infra; package com.android.server.infra; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; Loading Loading @@ -45,6 +46,8 @@ import com.android.server.LocalServices; import com.android.server.SystemService; import com.android.server.SystemService; import java.io.PrintWriter; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; import java.util.List; /** /** Loading Loading @@ -75,6 +78,30 @@ import java.util.List; public abstract class AbstractMasterSystemService<M extends AbstractMasterSystemService<M, S>, public abstract class AbstractMasterSystemService<M extends AbstractMasterSystemService<M, S>, S extends AbstractPerUserSystemService<S, M>> extends SystemService { S extends AbstractPerUserSystemService<S, M>> extends SystemService { /** On a package update, does not refresh the per-user service in the cache. */ public static final int PACKAGE_UPDATE_POLICY_NO_REFRESH = 0; /** * On a package update, removes any existing per-user services in the cache. * * <p>This does not immediately recreate these services. It is assumed they will be recreated * for the next user request. */ public static final int PACKAGE_UPDATE_POLICY_REFRESH_LAZY = 1; /** * On a package update, removes and recreates any existing per-user services in the cache. */ public static final int PACKAGE_UPDATE_POLICY_REFRESH_EAGER = 2; @IntDef(flag = true, prefix = { "PACKAGE_UPDATE_POLICY_" }, value = { PACKAGE_UPDATE_POLICY_NO_REFRESH, PACKAGE_UPDATE_POLICY_REFRESH_LAZY, PACKAGE_UPDATE_POLICY_REFRESH_EAGER }) @Retention(RetentionPolicy.SOURCE) public @interface PackageUpdatePolicy {} /** /** * Log tag * Log tag */ */ Loading Loading @@ -127,8 +154,11 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem /** /** * Whether the per-user service should be removed from the cache when its apk is updated. * Whether the per-user service should be removed from the cache when its apk is updated. * * <p>One of {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH}, * {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY} or {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}. */ */ private final boolean mRefreshServiceOnPackageUpdate; private final @PackageUpdatePolicy int mPackageUpdatePolicy; /** /** * Name of the service packages whose APK are being updated, keyed by user id. * Name of the service packages whose APK are being updated, keyed by user id. Loading @@ -154,7 +184,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem @Nullable ServiceNameResolver serviceNameResolver, @Nullable ServiceNameResolver serviceNameResolver, @Nullable String disallowProperty) { @Nullable String disallowProperty) { this(context, serviceNameResolver, disallowProperty, this(context, serviceNameResolver, disallowProperty, /* refreshServiceOnPackageUpdate=*/ true); /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_LAZY); } } /** /** Loading @@ -167,17 +197,19 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem * @param disallowProperty when not {@code null}, defines a {@link UserManager} restriction that * @param disallowProperty when not {@code null}, defines a {@link UserManager} restriction that * disables the service. <b>NOTE: </b> you'll also need to add it to * disables the service. <b>NOTE: </b> you'll also need to add it to * {@code UserRestrictionsUtils.USER_RESTRICTIONS}. * {@code UserRestrictionsUtils.USER_RESTRICTIONS}. * @param refreshServiceOnPackageUpdate when {@code true}, the * @param packageUpdatePolicy when {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY}, the * {@link AbstractPerUserSystemService} is removed from the cache (and re-added) when the * {@link AbstractPerUserSystemService} is removed from the cache when the service * service package is updated; when {@code false}, the service is untouched during the * package is updated; when {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}, the * update. * {@link AbstractPerUserSystemService} is removed from the cache and immediately * re-added when the service package is updated; when * {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH}, the service is untouched during the update. */ */ protected AbstractMasterSystemService(@NonNull Context context, protected AbstractMasterSystemService(@NonNull Context context, @Nullable ServiceNameResolver serviceNameResolver, @Nullable ServiceNameResolver serviceNameResolver, @Nullable String disallowProperty, boolean refreshServiceOnPackageUpdate) { @Nullable String disallowProperty, @PackageUpdatePolicy int packageUpdatePolicy) { super(context); super(context); mRefreshServiceOnPackageUpdate = refreshServiceOnPackageUpdate; mPackageUpdatePolicy = packageUpdatePolicy; mServiceNameResolver = serviceNameResolver; mServiceNameResolver = serviceNameResolver; if (mServiceNameResolver != null) { if (mServiceNameResolver != null) { Loading Loading @@ -645,7 +677,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem final int size = mServicesCache.size(); final int size = mServicesCache.size(); pw.print(prefix); pw.print("Debug: "); pw.print(realDebug); pw.print(prefix); pw.print("Debug: "); pw.print(realDebug); pw.print(" Verbose: "); pw.println(realVerbose); pw.print(" Verbose: "); pw.println(realVerbose); pw.print("Refresh on package update: "); pw.println(mRefreshServiceOnPackageUpdate); pw.print("Refresh on package update: "); pw.println(mPackageUpdatePolicy); if (mUpdatingPackageNames != null) { if (mUpdatingPackageNames != null) { pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames); pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames); } } Loading Loading @@ -701,12 +733,21 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem } } mUpdatingPackageNames.put(userId, packageName); mUpdatingPackageNames.put(userId, packageName); onServicePackageUpdatingLocked(userId); onServicePackageUpdatingLocked(userId); if (mRefreshServiceOnPackageUpdate) { if (mPackageUpdatePolicy != PACKAGE_UPDATE_POLICY_NO_REFRESH) { if (debug) { if (debug) { Slog.d(mTag, "Removing service for user " + userId + " because package " Slog.d(mTag, "Removing service for user " + userId + activePackageName + " is being updated"); + " because package " + activePackageName + " is being updated"); } } removeCachedServiceLocked(userId); removeCachedServiceLocked(userId); if (mPackageUpdatePolicy == PACKAGE_UPDATE_POLICY_REFRESH_EAGER) { if (debug) { Slog.d(mTag, "Eagerly recreating service for user " + userId); } getServiceForUserLocked(userId); } } else { } else { if (debug) { if (debug) { Slog.d(mTag, "Holding service for user " + userId + " while package " Slog.d(mTag, "Holding service for user " + userId + " while package " Loading Loading
core/res/res/values/config.xml +6 −0 Original line number Original line Diff line number Diff line Loading @@ -3558,6 +3558,12 @@ --> --> <string name="config_defaultSystemCaptionsService" translatable="false"></string> <string name="config_defaultSystemCaptionsService" translatable="false"></string> <!-- The component name for the system-wide captions manager service. This service must be trusted, as the system binds to it and keeps it running. Example: "com.android.captions/.SystemCaptionsManagerService" --> <string name="config_defaultSystemCaptionsManagerService" translatable="false"></string> <!-- The package name for the incident report approver app. <!-- The package name for the incident report approver app. This app is usually PermissionController or an app that replaces it. When This app is usually PermissionController or an app that replaces it. When a bugreport or incident report with EXPLICT-level sharing flags is going to be a bugreport or incident report with EXPLICT-level sharing flags is going to be Loading
core/res/res/values/symbols.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3409,6 +3409,7 @@ <java-symbol type="string" name="config_defaultContentSuggestionsService" /> <java-symbol type="string" name="config_defaultContentSuggestionsService" /> <java-symbol type="string" name="config_defaultAttentionService" /> <java-symbol type="string" name="config_defaultAttentionService" /> <java-symbol type="string" name="config_defaultSystemCaptionsService" /> <java-symbol type="string" name="config_defaultSystemCaptionsService" /> <java-symbol type="string" name="config_defaultSystemCaptionsManagerService" /> <java-symbol type="string" name="notification_channel_foreground_service" /> <java-symbol type="string" name="notification_channel_foreground_service" /> <java-symbol type="string" name="foreground_service_app_in_background" /> <java-symbol type="string" name="foreground_service_app_in_background" /> Loading
services/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ java_library { "services.print", "services.print", "services.restrictions", "services.restrictions", "services.startop", "services.startop", "services.systemcaptions", "services.usage", "services.usage", "services.usb", "services.usb", "services.voiceinteraction", "services.voiceinteraction", Loading
services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -129,7 +129,8 @@ public final class ContentCaptureManagerService extends public ContentCaptureManagerService(@NonNull Context context) { public ContentCaptureManagerService(@NonNull Context context) { super(context, new FrameworkResourcesServiceNameResolver(context, super(context, new FrameworkResourcesServiceNameResolver(context, com.android.internal.R.string.config_defaultContentCaptureService), com.android.internal.R.string.config_defaultContentCaptureService), UserManager.DISALLOW_CONTENT_CAPTURE, /* refreshServiceOnPackageUpdate= */ false); UserManager.DISALLOW_CONTENT_CAPTURE, /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_NO_REFRESH); DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE, DeviceConfig.addOnPropertyChangedListener(DeviceConfig.NAMESPACE_CONTENT_CAPTURE, ActivityThread.currentApplication().getMainExecutor(), ActivityThread.currentApplication().getMainExecutor(), (namespace, key, value) -> onDeviceConfigChange(key, value)); (namespace, key, value) -> onDeviceConfigChange(key, value)); Loading
services/core/java/com/android/server/infra/AbstractMasterSystemService.java +53 −12 Original line number Original line Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ */ package com.android.server.infra; package com.android.server.infra; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; Loading Loading @@ -45,6 +46,8 @@ import com.android.server.LocalServices; import com.android.server.SystemService; import com.android.server.SystemService; import java.io.PrintWriter; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; import java.util.List; /** /** Loading Loading @@ -75,6 +78,30 @@ import java.util.List; public abstract class AbstractMasterSystemService<M extends AbstractMasterSystemService<M, S>, public abstract class AbstractMasterSystemService<M extends AbstractMasterSystemService<M, S>, S extends AbstractPerUserSystemService<S, M>> extends SystemService { S extends AbstractPerUserSystemService<S, M>> extends SystemService { /** On a package update, does not refresh the per-user service in the cache. */ public static final int PACKAGE_UPDATE_POLICY_NO_REFRESH = 0; /** * On a package update, removes any existing per-user services in the cache. * * <p>This does not immediately recreate these services. It is assumed they will be recreated * for the next user request. */ public static final int PACKAGE_UPDATE_POLICY_REFRESH_LAZY = 1; /** * On a package update, removes and recreates any existing per-user services in the cache. */ public static final int PACKAGE_UPDATE_POLICY_REFRESH_EAGER = 2; @IntDef(flag = true, prefix = { "PACKAGE_UPDATE_POLICY_" }, value = { PACKAGE_UPDATE_POLICY_NO_REFRESH, PACKAGE_UPDATE_POLICY_REFRESH_LAZY, PACKAGE_UPDATE_POLICY_REFRESH_EAGER }) @Retention(RetentionPolicy.SOURCE) public @interface PackageUpdatePolicy {} /** /** * Log tag * Log tag */ */ Loading Loading @@ -127,8 +154,11 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem /** /** * Whether the per-user service should be removed from the cache when its apk is updated. * Whether the per-user service should be removed from the cache when its apk is updated. * * <p>One of {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH}, * {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY} or {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}. */ */ private final boolean mRefreshServiceOnPackageUpdate; private final @PackageUpdatePolicy int mPackageUpdatePolicy; /** /** * Name of the service packages whose APK are being updated, keyed by user id. * Name of the service packages whose APK are being updated, keyed by user id. Loading @@ -154,7 +184,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem @Nullable ServiceNameResolver serviceNameResolver, @Nullable ServiceNameResolver serviceNameResolver, @Nullable String disallowProperty) { @Nullable String disallowProperty) { this(context, serviceNameResolver, disallowProperty, this(context, serviceNameResolver, disallowProperty, /* refreshServiceOnPackageUpdate=*/ true); /*packageUpdatePolicy=*/ PACKAGE_UPDATE_POLICY_REFRESH_LAZY); } } /** /** Loading @@ -167,17 +197,19 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem * @param disallowProperty when not {@code null}, defines a {@link UserManager} restriction that * @param disallowProperty when not {@code null}, defines a {@link UserManager} restriction that * disables the service. <b>NOTE: </b> you'll also need to add it to * disables the service. <b>NOTE: </b> you'll also need to add it to * {@code UserRestrictionsUtils.USER_RESTRICTIONS}. * {@code UserRestrictionsUtils.USER_RESTRICTIONS}. * @param refreshServiceOnPackageUpdate when {@code true}, the * @param packageUpdatePolicy when {@link #PACKAGE_UPDATE_POLICY_REFRESH_LAZY}, the * {@link AbstractPerUserSystemService} is removed from the cache (and re-added) when the * {@link AbstractPerUserSystemService} is removed from the cache when the service * service package is updated; when {@code false}, the service is untouched during the * package is updated; when {@link #PACKAGE_UPDATE_POLICY_REFRESH_EAGER}, the * update. * {@link AbstractPerUserSystemService} is removed from the cache and immediately * re-added when the service package is updated; when * {@link #PACKAGE_UPDATE_POLICY_NO_REFRESH}, the service is untouched during the update. */ */ protected AbstractMasterSystemService(@NonNull Context context, protected AbstractMasterSystemService(@NonNull Context context, @Nullable ServiceNameResolver serviceNameResolver, @Nullable ServiceNameResolver serviceNameResolver, @Nullable String disallowProperty, boolean refreshServiceOnPackageUpdate) { @Nullable String disallowProperty, @PackageUpdatePolicy int packageUpdatePolicy) { super(context); super(context); mRefreshServiceOnPackageUpdate = refreshServiceOnPackageUpdate; mPackageUpdatePolicy = packageUpdatePolicy; mServiceNameResolver = serviceNameResolver; mServiceNameResolver = serviceNameResolver; if (mServiceNameResolver != null) { if (mServiceNameResolver != null) { Loading Loading @@ -645,7 +677,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem final int size = mServicesCache.size(); final int size = mServicesCache.size(); pw.print(prefix); pw.print("Debug: "); pw.print(realDebug); pw.print(prefix); pw.print("Debug: "); pw.print(realDebug); pw.print(" Verbose: "); pw.println(realVerbose); pw.print(" Verbose: "); pw.println(realVerbose); pw.print("Refresh on package update: "); pw.println(mRefreshServiceOnPackageUpdate); pw.print("Refresh on package update: "); pw.println(mPackageUpdatePolicy); if (mUpdatingPackageNames != null) { if (mUpdatingPackageNames != null) { pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames); pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames); } } Loading Loading @@ -701,12 +733,21 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem } } mUpdatingPackageNames.put(userId, packageName); mUpdatingPackageNames.put(userId, packageName); onServicePackageUpdatingLocked(userId); onServicePackageUpdatingLocked(userId); if (mRefreshServiceOnPackageUpdate) { if (mPackageUpdatePolicy != PACKAGE_UPDATE_POLICY_NO_REFRESH) { if (debug) { if (debug) { Slog.d(mTag, "Removing service for user " + userId + " because package " Slog.d(mTag, "Removing service for user " + userId + activePackageName + " is being updated"); + " because package " + activePackageName + " is being updated"); } } removeCachedServiceLocked(userId); removeCachedServiceLocked(userId); if (mPackageUpdatePolicy == PACKAGE_UPDATE_POLICY_REFRESH_EAGER) { if (debug) { Slog.d(mTag, "Eagerly recreating service for user " + userId); } getServiceForUserLocked(userId); } } else { } else { if (debug) { if (debug) { Slog.d(mTag, "Holding service for user " + userId + " while package " Slog.d(mTag, "Holding service for user " + userId + " while package " Loading