Fixed crash on devices that don't support android.content.pm.action.CONFIRM_INSTALL

This commit is contained in:
Koen J
2025-12-01 10:58:04 +01:00
parent 92ec085d25
commit 6d6309973e
2 changed files with 14 additions and 1 deletions
@@ -1,5 +1,6 @@
package com.futo.platformplayer.receivers
import android.content.ActivityNotFoundException
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@@ -26,14 +27,24 @@ class InstallReceiver : BroadcastReceiver() {
val activityIntent: Intent? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent::class.java)
} else {
@Suppress("DEPRECATION")
intent.getParcelableExtra(Intent.EXTRA_INTENT)
}
if (activityIntent == null) {
Logger.w(TAG, "Received STATUS_PENDING_USER_ACTION and activity intent is null.")
onReceiveResult.emit(context.getString(R.string.install_failed_device_installer_broken))
return;
}
context.startActivity(activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
try {
context.startActivity(activityIntent)
} catch (e: ActivityNotFoundException) {
Logger.e(TAG, "System installer cannot handle CONFIRM_INSTALL intent. ROM is broken; falling back / reporting error.", e)
onReceiveResult.emit(context.getString(R.string.install_failed_device_installer_broken))
}
}
PackageInstaller.STATUS_SUCCESS -> onReceiveResult.emit(null);
PackageInstaller.STATUS_FAILURE -> onReceiveResult.emit(context.getString(R.string.general_failure));
@@ -45,6 +56,7 @@ class InstallReceiver : BroadcastReceiver() {
PackageInstaller.STATUS_FAILURE_STORAGE -> onReceiveResult.emit(context.getString(R.string.not_enough_storage));
else -> {
val msg = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
Logger.w(TAG, "Received unknown install status $status, message=$msg")
onReceiveResult.emit(msg)
}
}
+1
View File
@@ -25,6 +25,7 @@
<string name="subscriptions">Subscriptions</string>
<string name="loading">Loading</string>
<string name="retry">Retry</string>
<string name="install_failed_device_installer_broken">Failed to start system installer. Your devices ROM is not compatible with automatic updates.</string>
<string name="cancel">Cancel</string>
<string name="failed_to_retrieve_data_are_you_connected">Failed to retrieve data, are you connected?</string>
<string name="settings">Settings</string>