@@ -13,6 +13,7 @@ import android.os.Binder
1313import android.os.Build
1414import android.os.IBinder
1515import android.os.IInterface
16+ import android.provider.Settings
1617import dev.datlag.mimasu.extension.model.AppInfo
1718import dev.datlag.tooling.Platform
1819import dev.datlag.tooling.async.scopeCatching
@@ -224,14 +225,21 @@ abstract class AIDLService<T : IInterface>(context: Context) : ServiceConnection
224225
225226 fun extensionStorageSettings (context : Context ) {
226227 if (extensionInstalled(context)) {
227- val intent = Intent (
228- Intent .ACTION_MANAGE_PACKAGE_STORAGE ,
229- Uri .parse(" package:$EXTENSION_PACKAGE " )
230- ).apply {
228+ val uri = Uri .fromParts(" package" , EXTENSION_PACKAGE , null )
229+ val intent = Intent (Intent .ACTION_MANAGE_PACKAGE_STORAGE , uri).apply {
231230 addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
232231 addFlags(Intent .FLAG_ACTIVITY_CLEAR_TOP )
233232 }
234- context.startActivity(intent)
233+
234+ if (intent.resolveActivity(context.packageManager) != null ) {
235+ context.startActivity(intent)
236+ } else {
237+ val fallbackIntent = Intent (Settings .ACTION_APPLICATION_DETAILS_SETTINGS , uri).apply {
238+ addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
239+ addFlags(Intent .FLAG_ACTIVITY_CLEAR_TOP )
240+ }
241+ context.startActivity(fallbackIntent)
242+ }
235243 }
236244 }
237245 }
0 commit comments