Skip to content

Commit

Permalink
fix(GmsCore support): Do not show battery optimization error on Andro…
Browse files Browse the repository at this point in the history
…id Automotive devices (Google built-in) (#4218)
  • Loading branch information
LisoUseInAIKyrios authored Dec 27, 2024
1 parent cff1153 commit d6e389c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ public static void checkGmsCore(Activity context) {
}

// 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,
Expand Down Expand Up @@ -147,6 +151,10 @@ private static boolean batteryOptimizationsEnabled(Context context) {
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
Expand Down

0 comments on commit d6e389c

Please sign in to comment.