Program: 191121
Project: 191121
Buggy source:
public void testManifestShortcut_publishOnBroadcast(){
  uninstallPackage(USER_0,CALLING_PACKAGE_1);
  uninstallPackage(USER_0,CALLING_PACKAGE_2);
  uninstallPackage(USER_0,CALLING_PACKAGE_3);
  uninstallPackage(USER_0,CALLING_PACKAGE_4);
  uninstallPackage(USER_10,CALLING_PACKAGE_1);
  uninstallPackage(USER_10,CALLING_PACKAGE_2);
  uninstallPackage(USER_10,CALLING_PACKAGE_3);
  uninstallPackage(USER_10,CALLING_PACKAGE_4);
  mService.handleUnlockUser(USER_0);
  mRunningUsers.put(USER_10,true);
  mService.handleUnlockUser(USER_10);
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_3,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1,ShortcutActivity.class.getName()),R.xml.shortcut_1);
  updatePackageVersion(CALLING_PACKAGE_1,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_1,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_5);
  updatePackageVersion(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  dumpsysOnLogcat("String_Node_Str");
  runWithCaller(LAUNCHER_1,USER_0,() -> {
    mLauncherApps.pinShortcuts(CALLING_PACKAGE_2,list("String_Node_Str","String_Node_Str"),HANDLE_USER_0);
  }
);
  dumpsysOnLogcat("String_Node_Str");
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_2);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertShortcutIds(assertAllImmutable(assertAllPinned(mManager.getPinnedShortcuts())),"String_Node_Str","String_Node_Str");
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllDisabled(list(getCallerShortcut("String_Node_Str")));
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  mRunningUsers.put(USER_10,false);
  mUnlockedUsers.put(USER_10,false);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(getCallerShortcuts());
  }
);
  mRunningUsers.put(USER_10,true);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(getCallerShortcuts());
  }
);
  mUnlockedUsers.put(USER_10,true);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertShortcutIds(assertAllImmutable(assertAllPinned(mManager.getPinnedShortcuts())),"String_Node_Str","String_Node_Str");
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllDisabled(list(getCallerShortcut("String_Node_Str")));
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_5_alt);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName()),R.xml.shortcut_5_reverse);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_0);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName()),R.xml.shortcut_0);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertShortcutIds(assertAllImmutable(assertAllPinned(assertAllDisabled(mManager.getPinnedShortcuts()))),"String_Node_Str","String_Node_Str");
  }
);
}

Fixed version (ground truth):
public void testManifestShortcut_publishOnBroadcast(){
  uninstallPackage(USER_0,CALLING_PACKAGE_1);
  uninstallPackage(USER_0,CALLING_PACKAGE_2);
  uninstallPackage(USER_0,CALLING_PACKAGE_3);
  uninstallPackage(USER_0,CALLING_PACKAGE_4);
  uninstallPackage(USER_10,CALLING_PACKAGE_1);
  uninstallPackage(USER_10,CALLING_PACKAGE_2);
  uninstallPackage(USER_10,CALLING_PACKAGE_3);
  uninstallPackage(USER_10,CALLING_PACKAGE_4);
  mService.handleUnlockUser(USER_0);
  mRunningUsers.put(USER_10,true);
  mService.handleUnlockUser(USER_10);
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_3,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_1,ShortcutActivity.class.getName()),R.xml.shortcut_1);
  updatePackageVersion(CALLING_PACKAGE_1,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_1,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_5);
  updatePackageVersion(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  dumpsysOnLogcat("String_Node_Str");
  runWithCaller(LAUNCHER_1,USER_0,() -> {
    mLauncherApps.pinShortcuts(CALLING_PACKAGE_2,list("String_Node_Str","String_Node_Str"),HANDLE_USER_0);
  }
);
  dumpsysOnLogcat("String_Node_Str");
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_2);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_1,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertShortcutIds(assertAllImmutable(assertAllPinned(mManager.getPinnedShortcuts())),"String_Node_Str","String_Node_Str");
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllDisabled(list(getCallerShortcut("String_Node_Str")));
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  mService.handleCleanupUser(USER_10);
  mRunningUsers.put(USER_10,false);
  mUnlockedUsers.put(USER_10,false);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(getCallerShortcuts());
  }
);
  mRunningUsers.put(USER_10,true);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertEmpty(getCallerShortcuts());
  }
);
  mUnlockedUsers.put(USER_10,true);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_10));
  runWithCaller(CALLING_PACKAGE_2,USER_10,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertEmpty(mManager.getPinnedShortcuts());
  }
);
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str");
    assertShortcutIds(assertAllImmutable(assertAllPinned(mManager.getPinnedShortcuts())),"String_Node_Str","String_Node_Str");
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllEnabled(list(getCallerShortcut("String_Node_Str")));
    assertAllDisabled(list(getCallerShortcut("String_Node_Str")));
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_5_alt);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName()),R.xml.shortcut_5_reverse);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertShortcutIds(assertAllManifest(assertAllImmutable(assertAllEnabled(mManager.getManifestShortcuts()))),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
    assertWith(getCallerShortcuts()).selectManifest().selectByActivity(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName())).haveRanksInOrder("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  }
);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity.class.getName()),R.xml.shortcut_0);
  addManifestShortcutResource(new ComponentName(CALLING_PACKAGE_2,ShortcutActivity2.class.getName()),R.xml.shortcut_0);
  updatePackageLastUpdateTime(CALLING_PACKAGE_2,1);
  mService.mPackageMonitor.onReceive(getTestContext(),genPackageAddIntent(CALLING_PACKAGE_2,USER_0));
  runWithCaller(CALLING_PACKAGE_2,USER_0,() -> {
    assertEmpty(mManager.getManifestShortcuts());
    assertShortcutIds(assertAllImmutable(assertAllPinned(assertAllDisabled(mManager.getPinnedShortcuts()))),"String_Node_Str","String_Node_Str");
  }
);
}