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:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user