diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46629c42..b4491dda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: branches: - main env: - LATEST_VERSION: "1.4.3" + LATEST_VERSION: "1.4.4" jobs: build-and-deploy: diff --git a/apk/SKIP-v1.4.4.apk b/apk/SKIP-v1.4.4.apk new file mode 100644 index 00000000..05de34a2 Binary files /dev/null and b/apk/SKIP-v1.4.4.apk differ diff --git a/app/build.gradle b/app/build.gradle index 9c7b1e86..e65ab358 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { minSdk 24 targetSdk 32 versionCode 1 - versionName "1.4.3" + versionName "1.4.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/app/src/main/java/com/android/skip/MainActivity.kt b/app/src/main/java/com/android/skip/MainActivity.kt index 884e9ae6..07b10308 100644 --- a/app/src/main/java/com/android/skip/MainActivity.kt +++ b/app/src/main/java/com/android/skip/MainActivity.kt @@ -1,8 +1,6 @@ package com.android.skip -import android.content.ComponentName -import android.content.Context -import android.content.Intent +import android.content.* import android.net.Uri import android.os.Build import android.os.Bundle @@ -256,12 +254,26 @@ class MainActivity : ComponentActivity() { apkFile ) + // 创建并注册 BroadcastReceiver + val receiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action == Intent.ACTION_PACKAGE_ADDED) { + // 删除 APK 文件 + apkFile.delete() + } + } + } + registerReceiver(receiver, IntentFilter(Intent.ACTION_PACKAGE_ADDED)) + val intent = Intent(Intent.ACTION_VIEW) intent.setDataAndType(apkUri, "application/vnd.android.package-archive") intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION this.startActivity(intent) + // 取消注册 BroadcastReceiver + unregisterReceiver(receiver) + isUpdateAPKClicked = false } }