Loading location/java/android/location/flags/gnss.aconfig→location/java/android/location/flags/location.aconfig +7 −0 Original line number Diff line number Diff line package: "android.location.flags" flag { name: "fix_service_watcher" namespace: "location" description: "Enable null explicit services in ServiceWatcher" bug: "311210517" } flag { name: "gnss_api_navic_l1" namespace: "location" Loading services/core/java/com/android/server/servicewatcher/CurrentUserServiceSupplier.java +27 −1 Original line number Diff line number Diff line Loading @@ -36,10 +36,12 @@ import android.content.IntentFilter; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.location.flags.Flags; import android.os.Bundle; import android.os.Process; import android.os.UserHandle; import android.util.Log; import android.util.TypedValue; import com.android.internal.util.Preconditions; import com.android.server.FgThread; Loading Loading @@ -70,6 +72,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen private static final String EXTRA_SERVICE_VERSION = "serviceVersion"; private static final String EXTRA_SERVICE_IS_MULTIUSER = "serviceIsMultiuser"; // a package value that will never match against any package (we can't use null since this will // match against any package). private static final String NO_MATCH_PACKAGE = ""; private static final Comparator<BoundServiceInfo> sBoundServiceInfoComparator = (o1, o2) -> { if (o1 == o2) { return 0; Loading Loading @@ -196,7 +202,19 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen Resources resources = context.getResources(); boolean enableOverlay = resources.getBoolean(enableOverlayResId); if (!enableOverlay) { if (Flags.fixServiceWatcher()) { // we don't use getText() or similar because it won't return null values TypedValue out = new TypedValue(); resources.getValue(nonOverlayPackageResId, out, true); CharSequence explicitPackage = out.coerceToString(); if (explicitPackage == null) { return NO_MATCH_PACKAGE; } else { return explicitPackage.toString(); } } else { return resources.getString(nonOverlayPackageResId); } } else { return null; } Loading Loading @@ -233,6 +251,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen @Override public boolean hasMatchingService() { if (Flags.fixServiceWatcher() && NO_MATCH_PACKAGE.equals(mIntent.getPackage())) { return false; } int intentQueryFlags = MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; if (mMatchSystemAppsOnly) { intentQueryFlags |= MATCH_SYSTEM_ONLY; Loading Loading @@ -268,6 +290,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen @Override public BoundServiceInfo getServiceInfo() { if (Flags.fixServiceWatcher() && NO_MATCH_PACKAGE.equals(mIntent.getPackage())) { return null; } BoundServiceInfo bestServiceInfo = null; // only allow services in the correct direct boot state to match Loading Loading
location/java/android/location/flags/gnss.aconfig→location/java/android/location/flags/location.aconfig +7 −0 Original line number Diff line number Diff line package: "android.location.flags" flag { name: "fix_service_watcher" namespace: "location" description: "Enable null explicit services in ServiceWatcher" bug: "311210517" } flag { name: "gnss_api_navic_l1" namespace: "location" Loading
services/core/java/com/android/server/servicewatcher/CurrentUserServiceSupplier.java +27 −1 Original line number Diff line number Diff line Loading @@ -36,10 +36,12 @@ import android.content.IntentFilter; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.location.flags.Flags; import android.os.Bundle; import android.os.Process; import android.os.UserHandle; import android.util.Log; import android.util.TypedValue; import com.android.internal.util.Preconditions; import com.android.server.FgThread; Loading Loading @@ -70,6 +72,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen private static final String EXTRA_SERVICE_VERSION = "serviceVersion"; private static final String EXTRA_SERVICE_IS_MULTIUSER = "serviceIsMultiuser"; // a package value that will never match against any package (we can't use null since this will // match against any package). private static final String NO_MATCH_PACKAGE = ""; private static final Comparator<BoundServiceInfo> sBoundServiceInfoComparator = (o1, o2) -> { if (o1 == o2) { return 0; Loading Loading @@ -196,7 +202,19 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen Resources resources = context.getResources(); boolean enableOverlay = resources.getBoolean(enableOverlayResId); if (!enableOverlay) { if (Flags.fixServiceWatcher()) { // we don't use getText() or similar because it won't return null values TypedValue out = new TypedValue(); resources.getValue(nonOverlayPackageResId, out, true); CharSequence explicitPackage = out.coerceToString(); if (explicitPackage == null) { return NO_MATCH_PACKAGE; } else { return explicitPackage.toString(); } } else { return resources.getString(nonOverlayPackageResId); } } else { return null; } Loading Loading @@ -233,6 +251,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen @Override public boolean hasMatchingService() { if (Flags.fixServiceWatcher() && NO_MATCH_PACKAGE.equals(mIntent.getPackage())) { return false; } int intentQueryFlags = MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; if (mMatchSystemAppsOnly) { intentQueryFlags |= MATCH_SYSTEM_ONLY; Loading Loading @@ -268,6 +290,10 @@ public final class CurrentUserServiceSupplier extends BroadcastReceiver implemen @Override public BoundServiceInfo getServiceInfo() { if (Flags.fixServiceWatcher() && NO_MATCH_PACKAGE.equals(mIntent.getPackage())) { return null; } BoundServiceInfo bestServiceInfo = null; // only allow services in the correct direct boot state to match Loading