-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fix issues with Play Store Policies
- Loading branch information
1 parent
790a8fc
commit 3e36002
Showing
13 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" /> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...src/main/java/me/timschneeberger/rootlessjamesdsp/session/dump/data/PackageServiceDump.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.timschneeberger.rootlessjamesdsp.session.dump.data | ||
|
||
import me.timschneeberger.rootlessjamesdsp.model.AppInfo | ||
|
||
data class PackageServiceDump(val apps: List<AppInfo>) : IDump { | ||
override fun toString(): String { | ||
val sb = StringBuilder("\n--> Apps\n") | ||
apps.forEach(sb::append) | ||
return sb.toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ava/me/timschneeberger/rootlessjamesdsp/session/dump/provider/AudioServiceDumpProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...a/me/timschneeberger/rootlessjamesdsp/session/dump/provider/PackageServiceDumpProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package me.timschneeberger.rootlessjamesdsp.session.dump.provider | ||
|
||
import android.content.Context | ||
import me.timschneeberger.rootlessjamesdsp.model.AppInfo | ||
import me.timschneeberger.rootlessjamesdsp.session.dump.data.PackageServiceDump | ||
import me.timschneeberger.rootlessjamesdsp.session.dump.utils.DumpUtils | ||
import me.timschneeberger.rootlessjamesdsp.utils.extensions.PermissionExtensions.hasPackageUsagePermission | ||
import timber.log.Timber | ||
|
||
class PackageServiceDumpProvider : IDumpProvider { | ||
|
||
fun dump(context: Context): PackageServiceDump? { | ||
if(!context.hasPackageUsagePermission()) { | ||
Timber.e("Package usage permission not granted") | ||
return null | ||
} | ||
|
||
val dump = DumpUtils.dumpAll(context, TARGET_SERVICE, arrayOf("packages")) | ||
dump ?: return null | ||
|
||
return process("$dump\nPackages End") | ||
} | ||
|
||
private fun process(dump: String): PackageServiceDump { | ||
val packageHeaderRegex = """Package \[(\S+)]""".toRegex() | ||
var currentPackage: String? = null | ||
var currentUid = -1 | ||
var currentIsSystem = false | ||
|
||
val apps = mutableListOf<AppInfo>() | ||
dump.lines().forEach { | ||
if(it.contains("Package")) { | ||
currentPackage?.let { pkg -> | ||
apps.add(AppInfo(pkg, pkg, null, currentIsSystem, currentUid)) | ||
} | ||
currentPackage = packageHeaderRegex.find(dump)?.groups?.get(1)?.value ?: currentPackage | ||
} | ||
|
||
if(currentPackage == null) | ||
return@forEach | ||
|
||
if(it.contains("userId")) | ||
currentUid = it.split("=").getOrNull(1)?.trim()?.toIntOrNull() ?: -1 | ||
if(it.contains("flags")) | ||
currentIsSystem = it.contains("SYSTEM") | ||
} | ||
return PackageServiceDump(apps) | ||
} | ||
override fun dumpString(context: Context): String { | ||
val dump = DumpUtils.dumpAll(context, TARGET_SERVICE, arrayOf("packages")) | ||
val sb = StringBuilder("=====> $TARGET_SERVICE raw dump\n") | ||
sb.append(dump) | ||
sb.append("\n\n") | ||
sb.append("=====> $TARGET_SERVICE processed dump\n") | ||
sb.append(process(dump ?: "")) | ||
|
||
return sb.toString() | ||
} | ||
|
||
companion object | ||
{ | ||
const val TARGET_SERVICE = "package" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters