From dd10bf5818019d58b19f735bfb5c1091d057b8f6 Mon Sep 17 00:00:00 2001 From: Govinda Wasserman Date: Mon, 17 Jul 2023 10:27:43 -0400 Subject: Creates ChooserActivity alias This alias allows us to avoid a bug that caused Share Sheet to crash any app that tried to use it. It also removes the previous solution as it had the potential to not take effect if too many receivers tried to act on the BOOT_COMPLETE broadcast. Test: $ adb root Test: $ adb shell pm disable com.android.intentresolver/.ChooserActivity Test: $ adb shell pm resolve-activity -a android.intent.action.CHOOSER Test: Verify that the activity resolves BUG: 283722356 FIX: 283722356 Change-Id: I820c5f88204c83e635cb877b222bdf6cbe53aaff Merged-In: I820c5f88204c83e635cb877b222bdf6cbe53aaff --- .../intentresolver/ChooserActivityReEnabler.kt | 39 ---------------------- 1 file changed, 39 deletions(-) delete mode 100644 java/src/com/android/intentresolver/ChooserActivityReEnabler.kt (limited to 'java/src') diff --git a/java/src/com/android/intentresolver/ChooserActivityReEnabler.kt b/java/src/com/android/intentresolver/ChooserActivityReEnabler.kt deleted file mode 100644 index 3236c1be..00000000 --- a/java/src/com/android/intentresolver/ChooserActivityReEnabler.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.android.intentresolver - -import android.content.BroadcastReceiver -import android.content.ComponentName -import android.content.Context -import android.content.Intent -import android.content.pm.PackageManager - -/** - * Ensures that the unbundled version of [ChooserActivity] does not get stuck in a disabled state. - */ -class ChooserActivityReEnabler : BroadcastReceiver() { - - override fun onReceive(context: Context, intent: Intent) { - if (intent.action == Intent.ACTION_BOOT_COMPLETED) { - context.packageManager.setComponentEnabledSetting( - CHOOSER_COMPONENT, - PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, - /* flags = */ 0, - ) - - // This only needs to be run once, so we disable ourself to avoid additional startup - // process on future boots - context.packageManager.setComponentEnabledSetting( - SELF_COMPONENT, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - /* flags = */ 0, - ) - } - } - - companion object { - private const val CHOOSER_PACKAGE = "com.android.intentresolver" - private val CHOOSER_COMPONENT = - ComponentName(CHOOSER_PACKAGE, "$CHOOSER_PACKAGE.ChooserActivity") - private val SELF_COMPONENT = - ComponentName(CHOOSER_PACKAGE, "$CHOOSER_PACKAGE.ChooserActivityReEnabler") - } -} -- cgit v1.2.3-59-g8ed1b