Skip to content

Commit

Permalink
camera: Use the empty app id for all host apps
Browse files Browse the repository at this point in the history
The app id detection is still unreliable and some backends do check if
the window matches the app id. Because that app id for host apps comes
from the app itself through wayland, the checks can fail.

For now we just disable app id detection for host apps for the camera
portal entirely. This should be removed when app id detection has become
more reliable.

Co-authored-by: Jan Grulich <[email protected]>
  • Loading branch information
swick and grulja committed Dec 3, 2024
1 parent b79634c commit 79eb758
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ query_permission_sync (XdpRequest *request)
GAppInfo *info = xdp_app_info_get_gappinfo (app_info);
gboolean allowed;

/* The app id detection is still unreliable and some backends do check if the
* window matches the app id. Because that app id for host apps comes from the
* app itself through wayland, the checks can fail.
* This should be removed when app id detection has become more reliable.
*/
if (xdp_app_info_is_host (app_info))
{
app_id = "";
info = NULL;
}

permission = xdp_get_permission_sync (app_id, PERMISSION_TABLE, PERMISSION_DEVICE_CAMERA);
if (permission == XDP_PERMISSION_ASK || permission == XDP_PERMISSION_UNSET)
{
Expand Down
8 changes: 7 additions & 1 deletion tests/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ extern gchar *appid;
static void
set_camera_permissions (const char *permission)
{
const char *permission_app_id;
const char *permissions[2] = { NULL, NULL };
g_autoptr(GError) error = NULL;

/* x-d-p currently defaults to the empty app id for the camera portal for
* host XdpAppInfos (which the XdpAppInfoTest is). So instead of using the
* `extern gchar *appid` we have to use "" for now. */
permission_app_id = "";

permissions[0] = permission;
xdp_dbus_impl_permission_store_call_set_permission_sync (permission_store,
"devices",
TRUE,
"camera",
appid,
permission_app_id,
permissions,
NULL,
&error);
Expand Down

0 comments on commit 79eb758

Please sign in to comment.