How to push a Device Assignment(ActivationLockRequest) to MacOS device - macos

When the server creates Activation Lock Bypass Code based on Apple document, how can server push the device assignment(escrow key) to a device?
I want to first push this Device Assignment to a single device as a test. Here is the Device assignment document from Apple. Does anyone has any expereience with this?
I don't have a clue on how to push to a device.

Related

Mac OS X video capture device hot plug driver support

I'm developing driver for USB video capture device. First of all, I've started with CoreMediaIO sample:
https://developer.apple.com/library/content/samplecode/CoreMediaIO/Introduction/Intro.html
The kernel extension is based on IOVideoSample. It gets data from the USB device and sends to the assistant. Kext has IOKitPersonalities based on the USB device. So the device is real and should support HotPlug. Kext main class loads when the device is plugged in and unloads when the device is plugged out.
SampleAssistant was changed only to detect my kext class. PlugIn has NoCMIOHardwarePluginLazyLoadingInfo property.
When all video capture apps are closed - hotplug works well. Terminate function is being called from kext and kext object is being unloaded without any problem.
Even if you start video capture app with the stream from the device, then close it and plug out device - hotplug also works.
It works well with QuickTime player. It can find a stream and show an image, but there is one problem.
When QuickTime (or any other video capture app) works and show stream from the device - hotplug doesn't work. If you try to plug out the device it will remain in the system and USB port won't work until you reboot Mac. According to logs - terminate function wasn't called at all. Seems that something retains a link to the device.
I've started digging into the problem.
First of all, I figured out that SampleAssistant doesn't support hotplug by default. It has notification only for device arriving (DeviceArrived). I've added "interest" notification and handle only "kIOMessageSeviceIsTerminated" message - executing DeviceRemoved function and force deleting device object, but it didn't help.
There is also a file CMIO_DPA_Sample_Server_Stream.cpp. If you go to Stream::Start function and delete "mIOSAStream.Open;" and "mIOSAStream.Start();" lines - hotplug works.
Can you please advise what can be done to solve this problem?

Pairing issue when using SingleEntry (Android)

Socket Mobile SDK documentation states that the socket mobile scanner must be in "SPP" mode in order to work with the SingleEntry example. However, it seems that none of the Android phones i've tested recognize the device when in this mode for initial pairing. It does display in the paired devices list, connects to it fine, but does not fire any of the events (OnDeviceArrival, OnDecodedData, etc..) when a scan happens.
I can only get the SingleEntry example app to work with my Socket Mobile S800 by following the below steps (exactly):
Make sure scanner is in HID mode (default)
On my Android device, scan for pair-able devices. (the S800 displays with a keyboard icon)
Select the S800 device. (S800 does beep confirmation on connection)
Once the device is paired, un-pair it.
Change the S800 mode to "SPP" by scanning the appropriate code (recommended mode to work with Xamarin SingleEntry example)
Re-pair with the S800 device on my Android phone. (the S800 icon is now a desktop instead of a keyboard)
Open the "Socket EZ Pair" app, select pair using Bluetooth, select my S800 device from the list.
Now the OnDecodedData callback fires in the SingleEntry project.
What is the "Socket EZ Pair" app doing that i should be doing in my code to properly pair the device when in "SPP" mode?
Are there any better solutions for cross platform Bluetooth scanning? I'm particularly interested in just the OnScan (OnDecodedData) events...
UPDATE
The explanation is actually very simple. The SingleEntry Xamarin.Android app doesn't handle configuring the scanner for ScanAPI.
As you noted, after pairing the scanner you need to use EZ Pair before the scanner will be recognized by your app. This is because when you pair the scanner using Bluetooth settings, it creates an outgoing connection to the scanner, but ScanAPI listens for incoming connections. EZ Pair presents you with a list of paired Bluetooth devices, it connects to the one you select and configures that scanner to connect back before closing the connection.
The SingleEntry Android sample application includes the EZ Pair logic, but the Xamarin sample does not.
However, once you've used EZ Pair to configure your scanner to connect back, you should receive device arrival and decoded data notifications in the unmodified SingleEntry Xamarin.Android sample application.
Original answer
Not the solution, but good to check
Runtime permissions were introduced in Android 6.0 and SingleEntry has not been updated to check for the required permissions. Unfortunately, the file that sets the target framework is not checked in to git so fresh clones of the sample app now target newer versions than SingleEntry was designed for.
If you open Settings > Apps > Single Entry > Permissions and enable the storage permission, then it should start working.
The real fix is to check for WRITE_EXTERNAL_STORAGE and BLUETOOTH permissions before calling ScanApiHelper.Open() in your application.

How to get connection status on a BLE device in Windows

I have a Bluetooth low-energy device paired to my Windows 10 machine, when an application try to use it, Windows automatically connects the paired device. I want to be able to read if the device is connected or just paired to Windows. Searching around Window's Device Manager (accessible from Control Panel), I saw that the device had the property "Is connected" under the details tab, it's value (true/false) was changing accordingly to the actual device status.
I tried to read to access this property using the SetupDiGetDeviceProperty function with the DEVPKEY_DeviceContainer_IsConnected predefined key but for some reason I get ERROR_NOT_FOUND.
Any ideas?

Way to get notification about audio device enable/disable in Windows XP/7/8

Is there way in Windows API to be notified when audio device gets enabled or disabled?
I have source code with RegisterDeviceNotification() and WM_DEVICECHANGE; it tracks USB device insertion/removing good. But it does not track laptop's internal audio device enabling or disabling.
Of course I can make timer and use waveInGetNumDevs/waveOutGetNumDevs.
But it is more interest to find way to force OS to send notifications :)
Thank you :)
waveIn/waveOut is legacy API you don't have notifications with. Yes you can poll with timer, of course, as you mentioned. In Vista+ the newer API does have notifications via IMMNotificationClient interface, see also this related answer: Get automatically notified on audio device connection/disconnection?

Programmatically "unplug and replug" a USB device to load new driver in OS X?

I'm working on an installer in OS X that installs an IOKit driver for a USB device, and I'm trying to get it to not require a restart at the end. The installer installs the driver correctly and rebuilds the kext cache, and after it runs, if I unplug and replug the USB device, it correctly loads the new driver and everything works fine.
However, I don't want to require the user to physically unplug the device in order for the new driver to load. There's got to be a way to get OS X to load the new driver programmatically - in effect simulate the device being unplugged and plugged back in again, or something similar. How would I go about doing this? So far, hours of Googling has turned up nothing, so any help will be greatly appreciated!
IOUSBDeviceInterface187::USBDeviceReEnumerate() will do what you want. The only hitch is that to find all of the devices of interest and call this on them manually with IOServiceGetMatchingServices().
/*!
#function USBDeviceReEnumerate
#abstract Tells the IOUSBFamily to reenumerate the device.
#discussion This function will send a terminate message to all clients of the IOUSBDevice (such as
IOUSBInterfaces and their drivers, as well as the current User Client), emulating an unplug
of the device. The IOUSBFamily will then enumerate the device as if it had just
been plugged in. This call should be used by clients wishing to take advantage
of the Device Firmware Update Class specification. The device must be open to use this function.
#availability This function is only available with IOUSBDeviceInterface187 and above.
#param self Pointer to the IOUSBDeviceInterface.
#param options A UInt32 reserved for future use. Ignored in current implementation. Set to zero.
#result Returns kIOReturnSuccess if successful, kIOReturnNoDevice if there is no connection to an IOService,
or kIOReturnNotOpen if the device is not open for exclusive access.
*/
IOReturn (*USBDeviceReEnumerate)(void *self, UInt32 options);
Look in IOKit/usb/IOUSBLib.h
Take a look at diskutil, and especially the mount and unmount options. Those will softwarematically eject and mount devices. You can use diskutil list to get a list of all the currently mounted devices. If you need more info on diskutil, just look at the man page.

Resources