diff --git a/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java b/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java index d7bd71590..83a3ca130 100644 --- a/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java +++ b/extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java @@ -106,7 +106,11 @@ public class GmsCoreSupport { } // Check if GmsCore is whitelisted from battery optimizations. - if (batteryOptimizationsEnabled(context)) { + if (isAndroidAutomotive(context)) { + // Ignore Android Automotive devices (Google built-in), + // as there is no way to disable battery optimizations. + Logger.printDebug(() -> "Device is Android Automotive"); + } else if (batteryOptimizationsEnabled(context)) { Logger.printInfo(() -> "GmsCore is not whitelisted from battery optimizations"); showBatteryOptimizationDialog(context, @@ -147,6 +151,10 @@ public class GmsCoreSupport { return !powerManager.isIgnoringBatteryOptimizations(GMS_CORE_PACKAGE_NAME); } + private static boolean isAndroidAutomotive(Context context) { + return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); + } + private static String getGmsCoreDownload() { final var vendorGroupId = getGmsCoreVendorGroupId(); //noinspection SwitchStatementWithTooFewBranches