Skip to content
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

Adapted to WSA based on Android 12.1. #5

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,17 @@
.externalNativeBuild
.cxx
local.properties
*.apk
*.ap_
*.aab
*.dex
*.class
bin/
gen/
Thumbs.db
.idea
build/
.navigation
captures/
output.json
obj/
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
namespace = "org.lsposed.wsa.helper"
}

dependencies {
implementation("androidx.compose.ui:ui:$composeVersion")
implementation("androidx.compose.material3:material3:1.0.0-alpha02")
implementation("androidx.compose.material3:material3:1.0.0-alpha12")
implementation("androidx.compose.ui:ui-tooling-preview:$composeVersion")
implementation("androidx.activity:activity-compose:1.4.0")
implementation("com.google.accompanist:accompanist-drawablepainter:0.21.4-beta")
implementation("com.google.accompanist:accompanist-drawablepainter:0.23.1")
debugImplementation("androidx.compose.ui:ui-tooling:$composeVersion")
}
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.lsposed.wsa.helper">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/lsposed/wsa/helper/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val installReceiver: BroadcastReceiver? = getWSAInstallReceiver(this)
setContent {
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (isSystemInDarkTheme())
Expand All @@ -28,11 +27,12 @@ class MainActivity : ComponentActivity() {
MaterialTheme(
colorScheme = colorScheme
) {
val installReceiver: BroadcastReceiver? = getWSAInstallReceiver(this)
if (installReceiver == null || (applicationInfo.flags or ApplicationInfo.FLAG_SYSTEM) == 0) {
AlertDialog(
onDismissRequest = { finish() },
title = {
Text("Failed to initialized")
Text("Failed to initialized\ninstallReceiver=$installReceiver")
},
confirmButton = {}
)
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/org/lsposed/wsa/helper/WSAUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.util.Log
import dalvik.system.PathClassLoader

private var installReceiver: BroadcastReceiver? = null
const val TAG: String = "LSPosed WSA Helper"

fun getWSAInstallReceiver(context: Context) = runCatching {
if (installReceiver != null) return@runCatching installReceiver
Expand All @@ -16,10 +17,12 @@ fun getWSAInstallReceiver(context: Context) = runCatching {
val ctor = handlerClass.getConstructor(Context::class.java)
ctor.newInstance(object : ContextWrapper(context) {
fun onRegister(receiver: BroadcastReceiver?, filter: IntentFilter) {
Log.d("LSPosed", "skip receiver")
if (filter.hasAction(Intent.ACTION_PACKAGE_ADDED) && receiver != null) {
Log.d(TAG, "skip receiver, filter: ${filter.actionsIterator().next()}")
if ((filter.hasAction(Intent.ACTION_PACKAGE_ADDED) ||
filter.hasAction("com.microsoft.windows.app.packageinstall.INTENT_PACKAGE_UNINSTALL_COMMIT")) && receiver != null
) {
installReceiver = receiver
Log.i("LSPosed", "got install receiver")
Log.i(TAG, "got install receiver")
}
}

Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
val composeVersion by extra("1.1.0-rc01")
val composeVersion by extra("1.2.0-beta02")
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0")
classpath("com.android.tools.build:gradle:7.2.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Dec 17 21:37:10 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 1 addition & 0 deletions stub/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
namespace = "org.lsposed.wsa.helper"
}

dependencies {
Expand Down
1 change: 0 additions & 1 deletion stub/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.lsposed.wsa.helper"
android:persistent="true"
android:usesNonSdkApi="true">

Expand Down