Fix headless package-check issue in soundtrigger

Change package/UID check to match against any user to avoid cases where
the client app is not installed in SYSTEM_USER (headless) to cause
package manager to fail to find the package name and throw a security
exception.

Bug: 290462753
Bug: 288949320
Test: Assistant in headless mode
Change-Id: I8c804314c197890059c9a5d6184a923ce075ce61
This commit is contained in:
Atneya Nair
2023-07-11 12:07:09 -07:00
parent f20259e60f
commit 04a474f3f3

View File

@@ -365,7 +365,7 @@ public class SoundTriggerService extends SystemService {
// Validate package name
try {
int uid = mPackageManager.getPackageUid(mOriginatorIdentity.packageName,
PackageManager.PackageInfoFlags.of(0));
PackageManager.PackageInfoFlags.of(PackageManager.MATCH_ANY_USER));
if (!UserHandle.isSameApp(uid, mOriginatorIdentity.uid)) {
throw new SecurityException("Uid " + mOriginatorIdentity.uid +
" attempted to spoof package name " +