Loading services/core/java/com/android/server/pm/IntentResolverInterceptor.javadeleted 100644 → 0 +0 −104 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.pm; import static com.android.server.wm.ActivityInterceptorCallback.INTENT_RESOLVER_ORDERED_ID; import android.Manifest; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.provider.DeviceConfig; import android.util.Slog; import com.android.internal.R; import com.android.internal.app.ChooserActivity; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.server.LocalServices; import com.android.server.wm.ActivityInterceptorCallback; import com.android.server.wm.ActivityInterceptorCallback.ActivityInterceptorInfo; import com.android.server.wm.ActivityTaskManagerInternal; /** * Redirects Activity starts for the system bundled {@link ChooserActivity} to an external * Sharesheet implementation by modifying the target component when appropriate. * <p> * Note: config_chooserActivity (Used also by ActivityTaskSupervisor) is already updated to point * to the new instance. This value is read and used for the new target component. */ public final class IntentResolverInterceptor { private static final String TAG = "IntentResolverIntercept"; private final Context mContext; private final ComponentName mFrameworkChooserComponent; private final ComponentName mUnbundledChooserComponent; private boolean mUseUnbundledSharesheet; private final ActivityInterceptorCallback mActivityInterceptorCallback = new ActivityInterceptorCallback() { @Nullable @Override public ActivityInterceptResult intercept(ActivityInterceptorInfo info) { if (mUseUnbundledSharesheet && isSystemChooserActivity(info)) { Slog.d(TAG, "Redirecting to UNBUNDLED Sharesheet"); info.intent.setComponent(mUnbundledChooserComponent); return new ActivityInterceptResult(info.intent, info.checkedOptions); } return null; } }; public IntentResolverInterceptor(Context context) { mContext = context; mFrameworkChooserComponent = new ComponentName(mContext, ChooserActivity.class); mUnbundledChooserComponent = ComponentName.unflattenFromString( Resources.getSystem().getString(R.string.config_chooserActivity)); } /** * Start listening for intents and USE_UNBUNDLED_SHARESHEET property changes. */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public void registerListeners() { LocalServices.getService(ActivityTaskManagerInternal.class) .registerActivityStartInterceptor(INTENT_RESOLVER_ORDERED_ID, mActivityInterceptorCallback); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, mContext.getMainExecutor(), properties -> updateUseUnbundledSharesheet()); updateUseUnbundledSharesheet(); } @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) private void updateUseUnbundledSharesheet() { mUseUnbundledSharesheet = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.USE_UNBUNDLED_SHARESHEET, false); if (mUseUnbundledSharesheet) { Slog.d(TAG, "using UNBUNDLED Sharesheet"); } else { Slog.d(TAG, "using FRAMEWORK Sharesheet"); } } private boolean isSystemChooserActivity(ActivityInterceptorInfo info) { return mFrameworkChooserComponent.getPackageName().equals(info.aInfo.packageName) && mFrameworkChooserComponent.getClassName().equals(info.aInfo.name); } } services/core/java/com/android/server/pm/PackageManagerService.java +0 −9 Original line number Diff line number Diff line Loading @@ -939,7 +939,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService private final DexOptHelper mDexOptHelper; private final SuspendPackageHelper mSuspendPackageHelper; private final DistractingPackageHelper mDistractingPackageHelper; private final IntentResolverInterceptor mIntentResolverInterceptor; private final StorageEventHelper mStorageEventHelper; /** Loading Loading @@ -1688,7 +1687,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService mSharedLibraries.setDeletePackageHelper(mDeletePackageHelper); mIntentResolverInterceptor = null; mStorageEventHelper = testParams.storageEventHelper; registerObservers(false); Loading Loading @@ -2248,8 +2246,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService mServiceStartWithDelay = SystemClock.uptimeMillis() + (60 * 1000L); mIntentResolverInterceptor = new IntentResolverInterceptor(mContext); Slog.i(TAG, "Fix for b/169414761 is applied"); } Loading Loading @@ -4139,11 +4135,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService // Prune unused static shared libraries which have been cached a period of time schedulePruneUnusedStaticSharedLibraries(false /* delay */); // TODO(b/222706900): Remove this intent interceptor before T launch if (mIntentResolverInterceptor != null) { mIntentResolverInterceptor.registerListeners(); } } //TODO: b/111402650 Loading services/core/java/com/android/server/wm/ActivityInterceptorCallback.java +0 −6 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ public abstract class ActivityInterceptorCallback { @IntDef(suffix = { "_ORDERED_ID" }, value = { FIRST_ORDERED_ID, PERMISSION_POLICY_ORDERED_ID, INTENT_RESOLVER_ORDERED_ID, VIRTUAL_DEVICE_SERVICE_ORDERED_ID, DREAM_MANAGER_ORDERED_ID, LAST_ORDERED_ID // Update this when adding new ids Loading @@ -77,11 +76,6 @@ public abstract class ActivityInterceptorCallback { */ public static final int PERMISSION_POLICY_ORDERED_ID = 1; /** * The identifier for {@link com.android.server.pm.IntentResolverInterceptor}. */ public static final int INTENT_RESOLVER_ORDERED_ID = 2; /** * The identifier for {@link com.android.server.companion.virtual.VirtualDeviceManagerService} * interceptor. Loading Loading
services/core/java/com/android/server/pm/IntentResolverInterceptor.javadeleted 100644 → 0 +0 −104 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.pm; import static com.android.server.wm.ActivityInterceptorCallback.INTENT_RESOLVER_ORDERED_ID; import android.Manifest; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; import android.provider.DeviceConfig; import android.util.Slog; import com.android.internal.R; import com.android.internal.app.ChooserActivity; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.server.LocalServices; import com.android.server.wm.ActivityInterceptorCallback; import com.android.server.wm.ActivityInterceptorCallback.ActivityInterceptorInfo; import com.android.server.wm.ActivityTaskManagerInternal; /** * Redirects Activity starts for the system bundled {@link ChooserActivity} to an external * Sharesheet implementation by modifying the target component when appropriate. * <p> * Note: config_chooserActivity (Used also by ActivityTaskSupervisor) is already updated to point * to the new instance. This value is read and used for the new target component. */ public final class IntentResolverInterceptor { private static final String TAG = "IntentResolverIntercept"; private final Context mContext; private final ComponentName mFrameworkChooserComponent; private final ComponentName mUnbundledChooserComponent; private boolean mUseUnbundledSharesheet; private final ActivityInterceptorCallback mActivityInterceptorCallback = new ActivityInterceptorCallback() { @Nullable @Override public ActivityInterceptResult intercept(ActivityInterceptorInfo info) { if (mUseUnbundledSharesheet && isSystemChooserActivity(info)) { Slog.d(TAG, "Redirecting to UNBUNDLED Sharesheet"); info.intent.setComponent(mUnbundledChooserComponent); return new ActivityInterceptResult(info.intent, info.checkedOptions); } return null; } }; public IntentResolverInterceptor(Context context) { mContext = context; mFrameworkChooserComponent = new ComponentName(mContext, ChooserActivity.class); mUnbundledChooserComponent = ComponentName.unflattenFromString( Resources.getSystem().getString(R.string.config_chooserActivity)); } /** * Start listening for intents and USE_UNBUNDLED_SHARESHEET property changes. */ @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) public void registerListeners() { LocalServices.getService(ActivityTaskManagerInternal.class) .registerActivityStartInterceptor(INTENT_RESOLVER_ORDERED_ID, mActivityInterceptorCallback); DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI, mContext.getMainExecutor(), properties -> updateUseUnbundledSharesheet()); updateUseUnbundledSharesheet(); } @RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG) private void updateUseUnbundledSharesheet() { mUseUnbundledSharesheet = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.USE_UNBUNDLED_SHARESHEET, false); if (mUseUnbundledSharesheet) { Slog.d(TAG, "using UNBUNDLED Sharesheet"); } else { Slog.d(TAG, "using FRAMEWORK Sharesheet"); } } private boolean isSystemChooserActivity(ActivityInterceptorInfo info) { return mFrameworkChooserComponent.getPackageName().equals(info.aInfo.packageName) && mFrameworkChooserComponent.getClassName().equals(info.aInfo.name); } }
services/core/java/com/android/server/pm/PackageManagerService.java +0 −9 Original line number Diff line number Diff line Loading @@ -939,7 +939,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService private final DexOptHelper mDexOptHelper; private final SuspendPackageHelper mSuspendPackageHelper; private final DistractingPackageHelper mDistractingPackageHelper; private final IntentResolverInterceptor mIntentResolverInterceptor; private final StorageEventHelper mStorageEventHelper; /** Loading Loading @@ -1688,7 +1687,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService mSharedLibraries.setDeletePackageHelper(mDeletePackageHelper); mIntentResolverInterceptor = null; mStorageEventHelper = testParams.storageEventHelper; registerObservers(false); Loading Loading @@ -2248,8 +2246,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService mServiceStartWithDelay = SystemClock.uptimeMillis() + (60 * 1000L); mIntentResolverInterceptor = new IntentResolverInterceptor(mContext); Slog.i(TAG, "Fix for b/169414761 is applied"); } Loading Loading @@ -4139,11 +4135,6 @@ public class PackageManagerService implements PackageSender, TestUtilityService // Prune unused static shared libraries which have been cached a period of time schedulePruneUnusedStaticSharedLibraries(false /* delay */); // TODO(b/222706900): Remove this intent interceptor before T launch if (mIntentResolverInterceptor != null) { mIntentResolverInterceptor.registerListeners(); } } //TODO: b/111402650 Loading
services/core/java/com/android/server/wm/ActivityInterceptorCallback.java +0 −6 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ public abstract class ActivityInterceptorCallback { @IntDef(suffix = { "_ORDERED_ID" }, value = { FIRST_ORDERED_ID, PERMISSION_POLICY_ORDERED_ID, INTENT_RESOLVER_ORDERED_ID, VIRTUAL_DEVICE_SERVICE_ORDERED_ID, DREAM_MANAGER_ORDERED_ID, LAST_ORDERED_ID // Update this when adding new ids Loading @@ -77,11 +76,6 @@ public abstract class ActivityInterceptorCallback { */ public static final int PERMISSION_POLICY_ORDERED_ID = 1; /** * The identifier for {@link com.android.server.pm.IntentResolverInterceptor}. */ public static final int INTENT_RESOLVER_ORDERED_ID = 2; /** * The identifier for {@link com.android.server.companion.virtual.VirtualDeviceManagerService} * interceptor. Loading