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) {
|
class SpoofDeviceProvider private constructor(var context: Context) {
|
||||||
|
|
||||||
companion object : SingletonHolder<SpoofDeviceProvider, Context>(::SpoofDeviceProvider) {
|
companion object : SingletonHolder<SpoofDeviceProvider, Context>(::SpoofDeviceProvider) {
|
||||||
|
private const val REGEX = "gplayapi_[a-zA-Z0-9_-]+\\.properties"
|
||||||
private const val SUFFIX = ".properties"
|
private const val SUFFIX = ".properties"
|
||||||
|
|
||||||
fun filenameValid(filename: String): Boolean {
|
fun filenameValid(filename: String): Boolean {
|
||||||
@@ -61,7 +62,7 @@ class SpoofDeviceProvider private constructor(var context: Context) {
|
|||||||
val entries = jarFile.entries()
|
val entries = jarFile.entries()
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
val entry = entries.nextElement()
|
val entry = entries.nextElement()
|
||||||
if (!filenameValid(entry.name)) {
|
if (!entry.name.substringAfterLast("/").matches(Regex(REGEX))) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
propertiesList.add(getProperties(jarFile, entry))
|
propertiesList.add(getProperties(jarFile, entry))
|
||||||
|
|||||||
Reference in New Issue
Block a user