Skip to content

Commit d6e389c

Browse files
fix(GmsCore support): Do not show battery optimization error on Android Automotive devices (Google built-in) (ReVanced#4218)
1 parent cff1153 commit d6e389c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

extensions/shared/library/src/main/java/app/revanced/extension/shared/GmsCoreSupport.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ public static void checkGmsCore(Activity context) {
106106
}
107107

108108
// Check if GmsCore is whitelisted from battery optimizations.
109-
if (batteryOptimizationsEnabled(context)) {
109+
if (isAndroidAutomotive(context)) {
110+
// Ignore Android Automotive devices (Google built-in),
111+
// as there is no way to disable battery optimizations.
112+
Logger.printDebug(() -> "Device is Android Automotive");
113+
} else if (batteryOptimizationsEnabled(context)) {
110114
Logger.printInfo(() -> "GmsCore is not whitelisted from battery optimizations");
111115

112116
showBatteryOptimizationDialog(context,
@@ -147,6 +151,10 @@ private static boolean batteryOptimizationsEnabled(Context context) {
147151
return !powerManager.isIgnoringBatteryOptimizations(GMS_CORE_PACKAGE_NAME);
148152
}
149153

154+
private static boolean isAndroidAutomotive(Context context) {
155+
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
156+
}
157+
150158
private static String getGmsCoreDownload() {
151159
final var vendorGroupId = getGmsCoreVendorGroupId();
152160
//noinspection SwitchStatementWithTooFewBranches

0 commit comments

Comments
 (0)