Create a token for the AttributionSource ACameraManager passes to connectDevice
If an AttributionSource does not have a token, data delivery permission checks
fail with "Attempt to invoke interface method
'void android.os.IBinder.linkToDeath(android.os.IBinder$DeathRecipient, int)'
on a null object reference" due to the null binder. Create a token before
passing it to connectDevice.
Bug: 190657833
Flag: com.android.internal.camera.flags.data_delivery_permission_checks
Test: Ran new CameraPermissionTest for ndk clients.
Change-Id: Id7f173ae155b26c723c39cccc8fcbbdc482479a3
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index 5dddd29..f9c1a8a 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -920,6 +920,7 @@
clientAttribution.deviceId = mDeviceContext.deviceId;
clientAttribution.packageName = "";
clientAttribution.attributionTag = std::nullopt;
+ clientAttribution.token = sp<BBinder>::make();
// No way to get package name from native.
// Send a zero length package name and let camera service figure it out from UID