-
-
Notifications
You must be signed in to change notification settings - Fork 499
Installer attribution (#444 ask 3/3) #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ae03f33
feat(domain): InstallerAttribution model and TweaksRepository wiring
rainxchzed fa15d68
feat(installer): pass installerPackageName through Shizuku and Dhizuk…
rainxchzed 706a6d9
feat(tweaks): InstallerAttributionCard with preset radios and custom …
rainxchzed a186f58
docs: announce Installer attribution in 1.8.1 what's-new
rainxchzed 398dccb
fix(installer-attribution): enforce lowercase package names, trim cus…
rainxchzed 937f2d9
fix(installer-attribution): catch DataStore write failures and surfac…
rainxchzed f68579f
fix(installer-attribution): wrap preset/system writes in runCatching …
rainxchzed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...src/androidMain/aidl/zed/rainxch/core/data/services/dhizuku/IDhizukuInstallerService.aidl
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| package zed.rainxch.core.data.services.dhizuku; | ||
|
|
||
| interface IDhizukuInstallerService { | ||
| int installPackage(in ParcelFileDescriptor pfd, long fileSize, String expectedPackageName, long expectedVersionCode); | ||
| int installPackage(in ParcelFileDescriptor pfd, long fileSize, String expectedPackageName, long expectedVersionCode, String installerPackageName); | ||
| int uninstallPackage(String packageName); | ||
| void destroy(); | ||
| } |
2 changes: 1 addition & 1 deletion
2
...src/androidMain/aidl/zed/rainxch/core/data/services/shizuku/IShizukuInstallerService.aidl
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| package zed.rainxch.core.data.services.shizuku; | ||
|
|
||
| interface IShizukuInstallerService { | ||
| int installPackage(in ParcelFileDescriptor pfd, long fileSize); | ||
| int installPackage(in ParcelFileDescriptor pfd, long fileSize, String installerPackageName); | ||
| int uninstallPackage(String packageName); | ||
| void destroy(); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
43 changes: 43 additions & 0 deletions
43
core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/model/InstallerAttribution.kt
This file contains hidden or 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,43 @@ | ||
| package zed.rainxch.core.domain.model | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| sealed interface InstallerAttribution { | ||
| @Serializable | ||
| data object SystemDefault : InstallerAttribution | ||
|
|
||
| @Serializable | ||
| data class Preset(val key: PresetKey) : InstallerAttribution | ||
|
|
||
| @Serializable | ||
| data class Custom(val packageName: String) : InstallerAttribution | ||
|
|
||
| fun resolvePackageName(): String? = when (this) { | ||
| SystemDefault -> null | ||
| is Preset -> key.packageName | ||
| is Custom -> packageName.trim().takeIf { it.isNotBlank() } | ||
| } | ||
| } | ||
|
|
||
| @Serializable | ||
| enum class PresetKey(val packageName: String) { | ||
| PLAY_STORE("com.android.vending"), | ||
| FDROID("org.fdroid.fdroid"), | ||
| OBTAINIUM("dev.imranr.obtainium.app"), | ||
| ; | ||
|
|
||
| companion object { | ||
| fun fromName(name: String?): PresetKey? = entries.find { it.name == name } | ||
| } | ||
| } | ||
|
|
||
| object InstallerAttributionDefaults { | ||
| val packageNamePattern = Regex("^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+\$") | ||
|
|
||
| fun isValidPackageName(name: String): Boolean { | ||
| val trimmed = name.trim() | ||
| if (trimmed.isEmpty()) return false | ||
| return packageNamePattern.matches(trimmed) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.