Merge "Prevent race condition by foregroundAppPackageName" into tm-qpr-dev