Skip to content

Commit

Permalink
Build: Fix GetLocales lint
Browse files Browse the repository at this point in the history
The linter has false positives when used accross modules, so we have to ignore
the lint for other modules
  • Loading branch information
mar-v-in committed Dec 12, 2023
1 parent a8d32be commit f0b15d2
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion play-services-ads-identifier/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}
}
2 changes: 1 addition & 1 deletion play-services-auth-api-phone/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.microg.gms.common;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
Expand All @@ -39,6 +40,8 @@
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;

import static android.os.Build.VERSION.SDK_INT;

public class DeviceConfiguration {
public List<String> availableFeatures;
public int densityDpi;
Expand Down Expand Up @@ -89,17 +92,28 @@ public DeviceConfiguration(Context context) {
this.nativePlatforms = getNativePlatforms();
widthPixels = displayMetrics.widthPixels;
heightPixels = displayMetrics.heightPixels;
locales = new ArrayList<String>(Arrays.asList(context.getAssets().getLocales()));
for (int i = 0; i < locales.size(); i++) {
locales.set(i, locales.get(i).replace("-", "_"));
}
Collections.sort(locales);
locales = getLocales(context);
Set<String> glExtensions = new HashSet<String>();
addEglExtensions(glExtensions);
this.glExtensions = new ArrayList<String>(glExtensions);
Collections.sort(this.glExtensions);
}

@SuppressLint("GetLocales")
private static List<String> getLocales(Context context) {
List<String> locales = new ArrayList<String>();
if (SDK_INT >= 21) {
locales.addAll(Arrays.asList(context.getAssets().getLocales()));
} else {
locales.add("en-US");
}
for (int i = 0; i < locales.size(); i++) {
locales.set(i, locales.get(i).replace("-", "_"));
}
Collections.sort(locales);
return locales;
}

@SuppressWarnings({"deprecation", "InlinedApi"})
private static List<String> getNativePlatforms() {
List<String> nativePlatforms;
Expand Down
2 changes: 1 addition & 1 deletion play-services-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ android {
}

lintOptions {
disable 'MissingTranslation', 'InvalidPackage', 'BatteryLife', 'ImpliedQuantity', 'MissingQuantity', 'InvalidWakeLockTag', 'UniquePermission'
disable 'MissingTranslation', 'GetLocales', 'InvalidPackage', 'BatteryLife', 'ImpliedQuantity', 'MissingQuantity', 'InvalidWakeLockTag', 'UniquePermission'
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion play-services-droidguard/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion play-services-fido/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion play-services-location/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}

flavorDimensions = ['target']
Expand Down
2 changes: 1 addition & 1 deletion play-services-nearby/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ android {
}

lintOptions {
disable 'MissingTranslation'
disable 'MissingTranslation', 'GetLocales'
}

compileOptions {
Expand Down

0 comments on commit f0b15d2

Please sign in to comment.