code: private void verifyMainActivityInManifest(ComponentName component) {
      Intent launchIntent =
          new Intent(Intent.ACTION_MAIN)
              .addCategory(Intent.CATEGORY_LAUNCHER)
              .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
              .setPackage(component.getPackageName());
  
      boolean existsMatchingActivity =
          Iterables.any(
              packageManager.queryIntentActivities(
                  launchIntent, MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE),
              resolveInfo -> {
                ActivityInfo activityInfo = resolveInfo.activityInfo;
                return TextUtils.equals(activityInfo.packageName, component.getPackageName())
                    && TextUtils.equals(activityInfo.name, component.getClassName())
                    && activityInfo.exported;
              });
      if (!existsMatchingActivity) {
        throw new SecurityException(
            "Attempt to launch activity without "
                + " category Intent.CATEGORY_LAUNCHER or activity is not exported"
                + component);
      }
    }
docs: Ensures that {@code component} is present in the manifest as an exported and enabled launcher
  activity. This check and the error thrown are the same as the check done by the real {@link
  CrossProfileApps}.