Partial Screen Sharing - Use new app chooser base class
The old one in the framework is deprecated, and not developed anymore. Partial Screen Sharing is the only thing still using it, and preventing it from being removed. There also bug fixes and improvements in the new one, that the Partial Screen Sharing feature would benefit from. Bug: 265905535 Test: MediaProjectionAppSelectorScreenshotTest Test: Manually build and run to trigger the app selector Change-Id: Icbc5b3bcf641288e12fc99973d8dae3467256a2c
This commit is contained in:
@@ -87,5 +87,6 @@
|
||||
<permission name="android.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS" />
|
||||
<permission name="android.permission.READ_SEARCH_INDEXABLES" />
|
||||
<permission name="android.permission.ACCESS_AMBIENT_CONTEXT_EVENT"/>
|
||||
<permission name="android.permission.QUERY_CLONED_APPS"/>
|
||||
</privapp-permissions>
|
||||
</permissions>
|
||||
|
||||
@@ -199,6 +199,7 @@ android_library {
|
||||
"lottie",
|
||||
"LowLightDreamLib",
|
||||
"motion_tool_lib",
|
||||
"IntentResolver-core",
|
||||
],
|
||||
manifest: "AndroidManifest.xml",
|
||||
|
||||
@@ -379,6 +380,7 @@ android_library {
|
||||
"motion_tool_lib",
|
||||
"androidx.core_core-animation-testing-nodeps",
|
||||
"androidx.compose.ui_ui",
|
||||
"IntentResolver-core",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.android.internal.widget.ResolverDrawerLayout
|
||||
<com.android.intentresolver.widget.ResolverDrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:layout_width="match_parent"
|
||||
@@ -84,7 +84,7 @@
|
||||
android:id="@*android:id/tabcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.android.internal.app.ResolverViewPager
|
||||
<com.android.intentresolver.ResolverViewPager
|
||||
android:id="@*android:id/profile_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
@@ -92,4 +92,4 @@
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
|
||||
</com.android.internal.widget.ResolverDrawerLayout>
|
||||
</com.android.intentresolver.widget.ResolverDrawerLayout>
|
||||
|
||||
@@ -30,16 +30,11 @@ import android.os.IBinder
|
||||
import android.os.ResultReceiver
|
||||
import android.os.UserHandle
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LifecycleRegistry
|
||||
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider
|
||||
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.MyUserIdProvider
|
||||
import com.android.intentresolver.ChooserActivity
|
||||
import com.android.intentresolver.chooser.TargetInfo
|
||||
import com.android.internal.annotations.VisibleForTesting
|
||||
import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyStateProvider
|
||||
import com.android.internal.app.AbstractMultiProfilePagerAdapter.MyUserIdProvider
|
||||
import com.android.internal.app.ChooserActivity
|
||||
import com.android.internal.app.ResolverListController
|
||||
import com.android.internal.app.chooser.NotSelectableTargetInfo
|
||||
import com.android.internal.app.chooser.TargetInfo
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorComponent
|
||||
import com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorController
|
||||
@@ -56,12 +51,8 @@ class MediaProjectionAppSelectorActivity(
|
||||
private val activityLauncher: AsyncActivityLauncher,
|
||||
/** This is used to override the dependency in a screenshot test */
|
||||
@VisibleForTesting
|
||||
private val listControllerFactory: ((userHandle: UserHandle) -> ResolverListController)?
|
||||
) :
|
||||
ChooserActivity(),
|
||||
MediaProjectionAppSelectorView,
|
||||
MediaProjectionAppSelectorResultHandler,
|
||||
LifecycleOwner {
|
||||
private val listControllerFactory: ((userHandle: UserHandle) -> ChooserListController)?
|
||||
) : ChooserActivity(), MediaProjectionAppSelectorView, MediaProjectionAppSelectorResultHandler {
|
||||
|
||||
@Inject
|
||||
constructor(
|
||||
@@ -69,8 +60,6 @@ class MediaProjectionAppSelectorActivity(
|
||||
activityLauncher: AsyncActivityLauncher
|
||||
) : this(componentFactory, activityLauncher, listControllerFactory = null)
|
||||
|
||||
private val lifecycleRegistry = LifecycleRegistry(this)
|
||||
override val lifecycle = lifecycleRegistry
|
||||
private lateinit var configurationController: ConfigurationController
|
||||
private lateinit var controller: MediaProjectionAppSelectorController
|
||||
private lateinit var recentsViewController: MediaProjectionRecentsViewController
|
||||
@@ -84,7 +73,6 @@ class MediaProjectionAppSelectorActivity(
|
||||
override fun getLayoutResource() = R.layout.media_projection_app_selector
|
||||
|
||||
public override fun onCreate(bundle: Bundle?) {
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
||||
component = componentFactory.create(view = this, resultHandler = this)
|
||||
component.lifecycleObservers.forEach { lifecycle.addObserver(it) }
|
||||
|
||||
@@ -107,26 +95,6 @@ class MediaProjectionAppSelectorActivity(
|
||||
controller.init()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
configurationController.onConfigurationChanged(newConfig)
|
||||
@@ -137,13 +105,13 @@ class MediaProjectionAppSelectorActivity(
|
||||
override fun createBlockerEmptyStateProvider(): EmptyStateProvider =
|
||||
component.emptyStateProvider
|
||||
|
||||
override fun createListController(userHandle: UserHandle): ResolverListController =
|
||||
override fun createListController(userHandle: UserHandle): ChooserListController =
|
||||
listControllerFactory?.invoke(userHandle) ?: super.createListController(userHandle)
|
||||
|
||||
override fun startSelected(which: Int, always: Boolean, filtered: Boolean) {
|
||||
val currentListAdapter = mChooserMultiProfilePagerAdapter.activeListAdapter
|
||||
val targetInfo = currentListAdapter.targetInfoForPosition(which, filtered) ?: return
|
||||
if (targetInfo is NotSelectableTargetInfo) return
|
||||
if (targetInfo.isNotSelectableTargetInfo) return
|
||||
|
||||
val intent = createIntent(targetInfo)
|
||||
|
||||
@@ -183,7 +151,6 @@ class MediaProjectionAppSelectorActivity(
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
component.lifecycleObservers.forEach { lifecycle.removeObserver(it) }
|
||||
// onDestroy is also called when an app is selected, in that case we only want to send
|
||||
// RECORD_CONTENT_TASK but not RECORD_CANCEL
|
||||
|
||||
@@ -17,10 +17,10 @@ package com.android.systemui.mediaprojection.appselector
|
||||
|
||||
import android.content.Context
|
||||
import android.os.UserHandle
|
||||
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyState
|
||||
import com.android.intentresolver.AbstractMultiProfilePagerAdapter.EmptyStateProvider
|
||||
import com.android.intentresolver.ResolverListAdapter
|
||||
import com.android.internal.R as AndroidR
|
||||
import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyState
|
||||
import com.android.internal.app.AbstractMultiProfilePagerAdapter.EmptyStateProvider
|
||||
import com.android.internal.app.ResolverListAdapter
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.mediaprojection.devicepolicy.PersonalProfile
|
||||
import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver
|
||||
|
||||
Reference in New Issue
Block a user