Loading core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java +22 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.StringRes; import android.app.AppGlobals; import android.app.admin.DevicePolicyEventLogger; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; Loading @@ -27,6 +28,7 @@ import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; import android.stats.devicepolicy.DevicePolicyEnums; import android.view.View; import android.view.ViewGroup; import android.widget.Button; Loading Loading @@ -251,6 +253,8 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { abstract @Nullable ViewGroup getInactiveAdapterView(); abstract String getMetricsCategory(); /** * Rebuilds the tab that is currently visible to the user. * <p>Returns {@code true} if rebuild has completed. Loading Loading @@ -282,6 +286,10 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { UserHandle listUserHandle = activeListAdapter.getUserHandle(); if (listUserHandle == mWorkProfileUserHandle && mInjector.isQuietModeEnabled(mWorkProfileUserHandle)) { DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_EMPTY_STATE_WORK_APPS_DISABLED) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_work_apps_off, R.string.resolver_turn_on_work_apps, Loading @@ -294,11 +302,19 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { if (!mInjector.hasCrossProfileIntents(activeListAdapter.getIntents(), UserHandle.myUserId(), listUserHandle.getIdentifier())) { if (listUserHandle == mPersonalProfileUserHandle) { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_sharing_disabled, R.string.resolver_cant_share_with_personal_apps, R.string.resolver_cant_share_cross_profile_explanation); } else { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_WORK) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_sharing_disabled, R.string.resolver_cant_share_with_work_apps, Loading @@ -315,6 +331,12 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { UserHandle listUserHandle = listAdapter.getUserHandle(); if (UserHandle.myUserId() == listUserHandle.getIdentifier() || !hasAppsInOtherProfile(listAdapter)) { if (mWorkProfileUserHandle != null) { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_APPS_RESOLVED) .setStrings(getMetricsCategory()) .write(); } showEmptyState(listAdapter, R.drawable.ic_no_apps, R.string.resolver_no_apps_available, Loading core/java/com/android/internal/app/ChooserActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -2698,6 +2698,11 @@ public class ChooserActivity extends ResolverActivity implements @Override protected void resetButtonBar() {} @Override protected String getMetricsCategory() { return METRICS_CATEGORY_CHOOSER; } /** * Adapter for all types of items and targets in ShareSheet. * Note that ranked sections like Direct Share - while appearing grid-like - are handled on the Loading core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +5 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,11 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd return getListViewForIndex(1 - getCurrentPage()); } @Override String getMetricsCategory() { return ResolverActivity.METRICS_CATEGORY_CHOOSER; } class ChooserProfileDescriptor extends ProfileDescriptor { private ChooserActivity.ChooserGridAdapter chooserGridAdapter; private RecyclerView recyclerView; Loading core/java/com/android/internal/app/ResolverActivity.java +37 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.app.ActivityThread; import android.app.VoiceInteractor.PickOptionRequest; import android.app.VoiceInteractor.PickOptionRequest.Option; import android.app.VoiceInteractor.Prompt; import android.app.admin.DevicePolicyEventLogger; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.ComponentName; Loading Loading @@ -60,6 +61,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.provider.MediaStore; import android.provider.Settings; import android.stats.devicepolicy.DevicePolicyEnums; import android.text.TextUtils; import android.util.Log; import android.util.Slog; Loading @@ -84,6 +86,7 @@ import android.widget.Toast; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.AbstractMultiProfilePagerAdapter.Profile; import com.android.internal.app.chooser.ChooserTargetInfo; import com.android.internal.app.chooser.DisplayResolveInfo; import com.android.internal.app.chooser.TargetInfo; import com.android.internal.content.PackageMonitor; Loading @@ -99,6 +102,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; /** * This activity is displayed when the system attempts to start an Intent for * which there is more than one matching activity, allowing the user to decide Loading Loading @@ -152,6 +156,8 @@ public class ResolverActivity extends Activity implements private static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args"; private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key"; private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state"; protected static final String METRICS_CATEGORY_RESOLVER = "intent_resolver"; protected static final String METRICS_CATEGORY_CHOOSER = "intent_chooser"; /** * TODO(arangelov): Remove a couple of weeks after work/personal tabs are finalized. Loading Loading @@ -1201,12 +1207,14 @@ public class ResolverActivity extends Activity implements if (!mSafeForwardingMode) { if (cti.startAsUser(this, null, currentUserHandle)) { onActivityStarted(cti); maybeLogCrossProfileTargetLaunch(cti, currentUserHandle); } return; } try { if (cti.startAsCaller(this, null, currentUserHandle.getIdentifier())) { onActivityStarted(cti); maybeLogCrossProfileTargetLaunch(cti, currentUserHandle); } } catch (RuntimeException e) { String launchedFromPackage; Loading @@ -1222,6 +1230,18 @@ public class ResolverActivity extends Activity implements } } private void maybeLogCrossProfileTargetLaunch(TargetInfo cti, UserHandle currentUserHandle) { if (!hasWorkProfile() || currentUserHandle == getUser()) { return; } DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_CROSS_PROFILE_TARGET_OPENED) .setBoolean(currentUserHandle == getPersonalProfileUserHandle()) .setStrings(getMetricsCategory(), cti instanceof ChooserTargetInfo ? "direct_share" : "other_target") .write(); } public boolean startAsCallerImpl(Intent intent, Bundle options, boolean ignoreTargetSecurity, int userId) { Loading Loading @@ -1425,7 +1445,8 @@ public class ResolverActivity extends Activity implements * - The target app has declared it supports cross-profile communication via manifest metadata */ private boolean maybeAutolaunchIfCrossProfileSupported() { int count = mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredCount(); ResolverListAdapter activeListAdapter = mMultiProfilePagerAdapter.getActiveListAdapter(); int count = activeListAdapter.getUnfilteredCount(); if (count != 1) { return false; } Loading @@ -1434,7 +1455,7 @@ public class ResolverActivity extends Activity implements if (inactiveListAdapter.getUnfilteredCount() != 1) { return false; } TargetInfo activeProfileTarget = mMultiProfilePagerAdapter.getActiveListAdapter() TargetInfo activeProfileTarget = activeListAdapter .targetInfoForPosition(0, false); TargetInfo inactiveProfileTarget = inactiveListAdapter.targetInfoForPosition(0, false); if (!Objects.equals(activeProfileTarget.getResolvedComponentName(), Loading @@ -1449,6 +1470,11 @@ public class ResolverActivity extends Activity implements return false; } DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_AUTOLAUNCH_CROSS_PROFILE_TARGET) .setBoolean(activeListAdapter.getUserHandle() == getPersonalProfileUserHandle()) .setStrings(getMetricsCategory()) .write(); safelyStartActivity(activeProfileTarget); finish(); return true; Loading Loading @@ -1530,6 +1556,11 @@ public class ResolverActivity extends Activity implements viewPager.setCurrentItem(1); } setupViewVisibilities(); DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_SWITCH_TABS) .setInt(viewPager.getCurrentItem()) .setStrings(getMetricsCategory()) .write(); }); viewPager.setVisibility(View.VISIBLE); Loading Loading @@ -1697,6 +1728,10 @@ public class ResolverActivity extends Activity implements && Objects.equals(lhs.activityInfo.packageName, rhs.activityInfo.packageName); } protected String getMetricsCategory() { return METRICS_CATEGORY_RESOLVER; } @Override // ResolverListCommunicator public void onHandlePackagesChanged(ResolverListAdapter listAdapter) { if (listAdapter == mMultiProfilePagerAdapter.getActiveListAdapter()) { Loading core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java +5 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,11 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA return getListViewForIndex(1 - getCurrentPage()); } @Override String getMetricsCategory() { return ResolverActivity.METRICS_CATEGORY_RESOLVER; } class ResolverProfileDescriptor extends ProfileDescriptor { private ResolverListAdapter resolverListAdapter; final ListView listView; Loading Loading
core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java +22 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.StringRes; import android.app.AppGlobals; import android.app.admin.DevicePolicyEventLogger; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; Loading @@ -27,6 +28,7 @@ import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; import android.os.UserHandle; import android.os.UserManager; import android.stats.devicepolicy.DevicePolicyEnums; import android.view.View; import android.view.ViewGroup; import android.widget.Button; Loading Loading @@ -251,6 +253,8 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { abstract @Nullable ViewGroup getInactiveAdapterView(); abstract String getMetricsCategory(); /** * Rebuilds the tab that is currently visible to the user. * <p>Returns {@code true} if rebuild has completed. Loading Loading @@ -282,6 +286,10 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { UserHandle listUserHandle = activeListAdapter.getUserHandle(); if (listUserHandle == mWorkProfileUserHandle && mInjector.isQuietModeEnabled(mWorkProfileUserHandle)) { DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_EMPTY_STATE_WORK_APPS_DISABLED) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_work_apps_off, R.string.resolver_turn_on_work_apps, Loading @@ -294,11 +302,19 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { if (!mInjector.hasCrossProfileIntents(activeListAdapter.getIntents(), UserHandle.myUserId(), listUserHandle.getIdentifier())) { if (listUserHandle == mPersonalProfileUserHandle) { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_PERSONAL) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_sharing_disabled, R.string.resolver_cant_share_with_personal_apps, R.string.resolver_cant_share_cross_profile_explanation); } else { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_SHARING_TO_WORK) .setStrings(getMetricsCategory()) .write(); showEmptyState(activeListAdapter, R.drawable.ic_sharing_disabled, R.string.resolver_cant_share_with_work_apps, Loading @@ -315,6 +331,12 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { UserHandle listUserHandle = listAdapter.getUserHandle(); if (UserHandle.myUserId() == listUserHandle.getIdentifier() || !hasAppsInOtherProfile(listAdapter)) { if (mWorkProfileUserHandle != null) { DevicePolicyEventLogger.createEvent( DevicePolicyEnums.RESOLVER_EMPTY_STATE_NO_APPS_RESOLVED) .setStrings(getMetricsCategory()) .write(); } showEmptyState(listAdapter, R.drawable.ic_no_apps, R.string.resolver_no_apps_available, Loading
core/java/com/android/internal/app/ChooserActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -2698,6 +2698,11 @@ public class ChooserActivity extends ResolverActivity implements @Override protected void resetButtonBar() {} @Override protected String getMetricsCategory() { return METRICS_CATEGORY_CHOOSER; } /** * Adapter for all types of items and targets in ShareSheet. * Note that ranked sections like Direct Share - while appearing grid-like - are handled on the Loading
core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +5 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,11 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd return getListViewForIndex(1 - getCurrentPage()); } @Override String getMetricsCategory() { return ResolverActivity.METRICS_CATEGORY_CHOOSER; } class ChooserProfileDescriptor extends ProfileDescriptor { private ChooserActivity.ChooserGridAdapter chooserGridAdapter; private RecyclerView recyclerView; Loading
core/java/com/android/internal/app/ResolverActivity.java +37 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.app.ActivityThread; import android.app.VoiceInteractor.PickOptionRequest; import android.app.VoiceInteractor.PickOptionRequest.Option; import android.app.VoiceInteractor.Prompt; import android.app.admin.DevicePolicyEventLogger; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.ComponentName; Loading Loading @@ -60,6 +61,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.provider.MediaStore; import android.provider.Settings; import android.stats.devicepolicy.DevicePolicyEnums; import android.text.TextUtils; import android.util.Log; import android.util.Slog; Loading @@ -84,6 +86,7 @@ import android.widget.Toast; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.AbstractMultiProfilePagerAdapter.Profile; import com.android.internal.app.chooser.ChooserTargetInfo; import com.android.internal.app.chooser.DisplayResolveInfo; import com.android.internal.app.chooser.TargetInfo; import com.android.internal.content.PackageMonitor; Loading @@ -99,6 +102,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; /** * This activity is displayed when the system attempts to start an Intent for * which there is more than one matching activity, allowing the user to decide Loading Loading @@ -152,6 +156,8 @@ public class ResolverActivity extends Activity implements private static final String EXTRA_SHOW_FRAGMENT_ARGS = ":settings:show_fragment_args"; private static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key"; private static final String OPEN_LINKS_COMPONENT_KEY = "app_link_state"; protected static final String METRICS_CATEGORY_RESOLVER = "intent_resolver"; protected static final String METRICS_CATEGORY_CHOOSER = "intent_chooser"; /** * TODO(arangelov): Remove a couple of weeks after work/personal tabs are finalized. Loading Loading @@ -1201,12 +1207,14 @@ public class ResolverActivity extends Activity implements if (!mSafeForwardingMode) { if (cti.startAsUser(this, null, currentUserHandle)) { onActivityStarted(cti); maybeLogCrossProfileTargetLaunch(cti, currentUserHandle); } return; } try { if (cti.startAsCaller(this, null, currentUserHandle.getIdentifier())) { onActivityStarted(cti); maybeLogCrossProfileTargetLaunch(cti, currentUserHandle); } } catch (RuntimeException e) { String launchedFromPackage; Loading @@ -1222,6 +1230,18 @@ public class ResolverActivity extends Activity implements } } private void maybeLogCrossProfileTargetLaunch(TargetInfo cti, UserHandle currentUserHandle) { if (!hasWorkProfile() || currentUserHandle == getUser()) { return; } DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_CROSS_PROFILE_TARGET_OPENED) .setBoolean(currentUserHandle == getPersonalProfileUserHandle()) .setStrings(getMetricsCategory(), cti instanceof ChooserTargetInfo ? "direct_share" : "other_target") .write(); } public boolean startAsCallerImpl(Intent intent, Bundle options, boolean ignoreTargetSecurity, int userId) { Loading Loading @@ -1425,7 +1445,8 @@ public class ResolverActivity extends Activity implements * - The target app has declared it supports cross-profile communication via manifest metadata */ private boolean maybeAutolaunchIfCrossProfileSupported() { int count = mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredCount(); ResolverListAdapter activeListAdapter = mMultiProfilePagerAdapter.getActiveListAdapter(); int count = activeListAdapter.getUnfilteredCount(); if (count != 1) { return false; } Loading @@ -1434,7 +1455,7 @@ public class ResolverActivity extends Activity implements if (inactiveListAdapter.getUnfilteredCount() != 1) { return false; } TargetInfo activeProfileTarget = mMultiProfilePagerAdapter.getActiveListAdapter() TargetInfo activeProfileTarget = activeListAdapter .targetInfoForPosition(0, false); TargetInfo inactiveProfileTarget = inactiveListAdapter.targetInfoForPosition(0, false); if (!Objects.equals(activeProfileTarget.getResolvedComponentName(), Loading @@ -1449,6 +1470,11 @@ public class ResolverActivity extends Activity implements return false; } DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_AUTOLAUNCH_CROSS_PROFILE_TARGET) .setBoolean(activeListAdapter.getUserHandle() == getPersonalProfileUserHandle()) .setStrings(getMetricsCategory()) .write(); safelyStartActivity(activeProfileTarget); finish(); return true; Loading Loading @@ -1530,6 +1556,11 @@ public class ResolverActivity extends Activity implements viewPager.setCurrentItem(1); } setupViewVisibilities(); DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_SWITCH_TABS) .setInt(viewPager.getCurrentItem()) .setStrings(getMetricsCategory()) .write(); }); viewPager.setVisibility(View.VISIBLE); Loading Loading @@ -1697,6 +1728,10 @@ public class ResolverActivity extends Activity implements && Objects.equals(lhs.activityInfo.packageName, rhs.activityInfo.packageName); } protected String getMetricsCategory() { return METRICS_CATEGORY_RESOLVER; } @Override // ResolverListCommunicator public void onHandlePackagesChanged(ResolverListAdapter listAdapter) { if (listAdapter == mMultiProfilePagerAdapter.getActiveListAdapter()) { Loading
core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java +5 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,11 @@ public class ResolverMultiProfilePagerAdapter extends AbstractMultiProfilePagerA return getListViewForIndex(1 - getCurrentPage()); } @Override String getMetricsCategory() { return ResolverActivity.METRICS_CATEGORY_RESOLVER; } class ResolverProfileDescriptor extends ProfileDescriptor { private ResolverListAdapter resolverListAdapter; final ListView listView; Loading