Loading services/companion/java/com/android/server/companion/PackageUtils.java +12 −10 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.companion.CompanionDeviceService; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.FeatureInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.PackageInfoFlags; Loading @@ -39,8 +40,6 @@ import android.content.pm.ServiceInfo; import android.os.Binder; import android.util.Slog; import com.android.internal.util.ArrayUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -65,16 +64,19 @@ final class PackageUtils { static void enforceUsesCompanionDeviceFeature(@NonNull Context context, @UserIdInt int userId, @NonNull String packageName) { final boolean requested = ArrayUtils.contains( getPackageInfo(context, userId, packageName).reqFeatures, FEATURE_COMPANION_DEVICE_SETUP); String requiredFeature = FEATURE_COMPANION_DEVICE_SETUP; FeatureInfo[] requestedFeatures = getPackageInfo(context, userId, packageName).reqFeatures; for (int i = 0; i < requestedFeatures.length; i++) { if (requiredFeature.equals(requestedFeatures[i].name)) { return; } } if (requested) { throw new IllegalStateException("Must declare uses-feature " + FEATURE_COMPANION_DEVICE_SETUP + requiredFeature + " in manifest to use this API"); } } /** * @return list of {@link CompanionDeviceService}-s per package for a given user. Loading Loading
services/companion/java/com/android/server/companion/PackageUtils.java +12 −10 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.companion.CompanionDeviceService; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.FeatureInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.PackageInfoFlags; Loading @@ -39,8 +40,6 @@ import android.content.pm.ServiceInfo; import android.os.Binder; import android.util.Slog; import com.android.internal.util.ArrayUtils; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -65,16 +64,19 @@ final class PackageUtils { static void enforceUsesCompanionDeviceFeature(@NonNull Context context, @UserIdInt int userId, @NonNull String packageName) { final boolean requested = ArrayUtils.contains( getPackageInfo(context, userId, packageName).reqFeatures, FEATURE_COMPANION_DEVICE_SETUP); String requiredFeature = FEATURE_COMPANION_DEVICE_SETUP; FeatureInfo[] requestedFeatures = getPackageInfo(context, userId, packageName).reqFeatures; for (int i = 0; i < requestedFeatures.length; i++) { if (requiredFeature.equals(requestedFeatures[i].name)) { return; } } if (requested) { throw new IllegalStateException("Must declare uses-feature " + FEATURE_COMPANION_DEVICE_SETUP + requiredFeature + " in manifest to use this API"); } } /** * @return list of {@link CompanionDeviceService}-s per package for a given user. Loading