Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android-recover-both-usb-disconnect-fix #5991

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/uvc/uvc-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ namespace librealsense
_messenger = _usb_device->open(_info.mi);
if (_messenger)
{
listen_to_interrupts();
try{
listen_to_interrupts();
} catch(const std::exception& exception) {
// this exception catching avoids crash when disconnecting 2 devices at once - bug seen in android os
LOG_WARNING("rs_uvc_device exception in listen_to_interrupts method: " << exception.what());
}
_power_state = D0;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private synchronized void start() {
Log.d(TAG, "streaming started successfully");
} catch (Exception e) {
Log.d(TAG, "failed to start streaming");
mGLSurfaceView.clear();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,22 @@ private synchronized void invalidateDevices() {
}
}

private void removeDevice(UsbDesc desc) {
Log.d(TAG, "Removing device: " + desc.name);

nRemoveUsbDevice(desc.descriptor);
desc.connection.close();
private void updateListeners(){
for(DeviceListener listener : mAppDeviceListener) {
try {
listener.onDeviceDetach();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
}

private void removeDevice(UsbDesc desc) {
Log.d(TAG, "Removing device: " + desc.name);

nRemoveUsbDevice(desc.descriptor);
desc.connection.close();
updateListeners();
Log.d(TAG, "Device: " + desc.name + " removed successfully");
}

Expand All @@ -108,13 +112,7 @@ private void addDevice(UsbDevice device) {
mDescriptors.put(device.getDeviceName(), desc);
nAddUsbDevice(desc.name, desc.descriptor);

for (DeviceListener listener : mAppDeviceListener){
try {
listener.onDeviceAttach();
} catch (Exception e){
Log.e(TAG, e.getMessage());
}
}
updateListeners();
Log.d(TAG, "Device: " + desc.name + " added successfully");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.intel.realsense.librealsense;

import android.util.Log;

public class StreamProfile extends LrsClass {
private StreamType mType;
Expand Down