SpoofDeviceProvider: Filter packed .properties with specific regex

Certain build time files also ends with .properties extension that results in
showing null otherwise. We are only shipping files supplied to us from
gplayapi library, so filter them with a matching regex.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-04-23 14:24:07 +05:30
parent 53854a8a67
commit 2daa434dea

View File

@@ -35,6 +35,7 @@ import java.util.jar.JarFile
class SpoofDeviceProvider private constructor(var context: Context) {
companion object : SingletonHolder<SpoofDeviceProvider, Context>(::SpoofDeviceProvider) {
private const val REGEX = "gplayapi_[a-zA-Z0-9_-]+\\.properties"
private const val SUFFIX = ".properties"
fun filenameValid(filename: String): Boolean {
@@ -61,7 +62,7 @@ class SpoofDeviceProvider private constructor(var context: Context) {
val entries = jarFile.entries()
while (entries.hasMoreElements()) {
val entry = entries.nextElement()
if (!filenameValid(entry.name)) {
if (!entry.name.substringAfterLast("/").matches(Regex(REGEX))) {
continue
}
propertiesList.add(getProperties(jarFile, entry))
@@ -173,4 +174,4 @@ class SpoofDeviceProvider private constructor(var context: Context) {
}
return deviceNames
}
}
}