Bug 345160

Summary: Solid query fails to match PortableMediaPlayer with specified property
Product: [Frameworks and Libraries] frameworks-solid Reporter: Rajeesh K V <rajeeshknambiar>
Component: generalAssignee: Lukáš Tinkl <lukas>
Status: REPORTED ---    
Severity: normal CC: jgrulich, kdelibs-bugs-null, rajeeshknambiar
Priority: NOR    
Version First Reported In: 5.1.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Debugger screenshot

Description Rajeesh K V 2015-03-14 19:11:22 UTC
Using kf5-solid-5.7.0-3.fc21.x86_64.
$ solid-hardware5 details /org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1
udi = '/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1'
  parent = '/org/kde/solid/udev'  (string)
  vendor = 'Apple Inc.'  (string)
  product = 'iPhone'  (string)
  description = 'Portable Media Player'  (string)
  Block.major = 189  (0xbd)  (int)
  Block.minor = 1  (0x1)  (int)
  Block.device = '/dev/bus/usb/001/002'  (string)
  Camera.supportedProtocols = {'ptp'}  (string list)
  Camera.supportedDrivers = {'gphoto'}  (string list)
  PortableMediaPlayer.supportedProtocols = {'storage', 'ipod'}  (string list)
  PortableMediaPlayer.supportedDrivers = {'usb', 'usbmux'}  (string list)

$solid-hardware5 query "SupportedProtocols & 'ipod'"
(returns nothing)

Reproducible: Always

Steps to Reproduce:
1. Plug in a portable media player (I have an iPhone which is listed as PortableMediaPlayer device by Solid)
2. Run solid-hardware5 query "SupportedProtocols & 'ipod'"
3. Observe that solid-hardware5 query does not list the object

Actual Results:  
Solid query fails to list the device

Expected Results:  
Device udi is returned

I have debugged, and tracked down the issue to:
method Solid::Predicate::matches(const Device &device)
specifically const int index = iface->metaObject()->indexOfProperty(d->property.toLatin1()); fails to return the property index.
iface->metaObject() has two properties {SupportedDrivers,SupportedProtocols}. But indexOfProperty("SupportedProtocols") returns index -1. See attached debugger screenshot.

Please let me know if I can provide any additional information or do further debugging.
Comment 1 Rajeesh K V 2015-03-14 19:12:27 UTC
Created attachment 91560 [details]
Debugger screenshot
Comment 2 Rajeesh K V 2015-03-22 19:22:51 UTC
My mistake. The query had a typo (uppercase 'S' in 'SupportedProtocols'). Correcting this makes QMetaObject::indexofProperty() retun correct index. Yet ultimately the predicate matching fails.

$solid-hardware5 query "PortableMediaPlayer.supportedProtocols & 'ipod'"
returns nothing.

Debugging further showed the following:
In bool Solid::Predicate::matches(const Device &device) const
d->type is "PropertyCheck" and d->compOperator is "Mask", in which case the metaProp value and expected value are converted to int and this fails.
Are string properties not supported for Mask operator?
Comment 3 Jan Grulich 2015-07-30 13:28:02 UTC
It looks it doesn't work that way and the syntax is also different, you can only use something like "solid-hardware5 query 'IS PortableMediaPlayer' and that's all.
Comment 4 Justin Zobel 2021-03-09 05:53:51 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 5 Rajeesh K V 2021-03-28 05:35:40 UTC
$ solid-hardware5 details '/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1'
udi = '/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1'
  parent = '/org/kde/solid/udev' (string)
  vendor = 'Apple Inc.' (string)
  product = 'iPhone' (string)
  description = 'Camera' (string)
  icon = 'camera-photo' (string)
  Block.major = 189  (0xbd)  (int)
  Block.minor = 5  (0x5)  (int)
  Block.device = '/dev/bus/usb/001/006' (string)
  Camera.supportedProtocols = {'ptp'} (string list)
  Camera.supportedDrivers = {'gphoto'} (string list)

It appears 'ipod' is no longer even in the supported protocols list.