RESTRICT AUTOMERGE

Fix CDM package check

CDM was using a pckage check that returns a value intead of throwing,
resulting in failing to throw on querying other package's associations

Test: ensure attached bug no longer reproduces
Bug: 167244818
Change-Id: I21319b6f5495dcae681541c76b847aad0c00b8ab
This commit is contained in:
Eugene Susla
2020-10-12 16:23:15 -07:00
committed by Sterling Huber
parent d29dc3d991
commit 9ec3bf497e

View File

@@ -25,6 +25,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainRunna
import android.annotation.CheckResult;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.PendingIntent;
import android.companion.AssociationRequest;
import android.companion.CompanionDeviceManager;
@@ -297,7 +298,10 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
checkArgument(getCallingUserId() == userId,
"Must be called by either same user or system");
mAppOpsManager.checkPackage(Binder.getCallingUid(), pkg);
int callingUid = Binder.getCallingUid();
if (mAppOpsManager.checkPackage(callingUid, pkg) != AppOpsManager.MODE_ALLOWED) {
throw new SecurityException(pkg + " doesn't belong to uid " + callingUid);
}
}
@Override