@@ -2,7 +2,10 @@
|
||||
package="com.mogo.usbcamera">
|
||||
|
||||
|
||||
<uses-feature android:name="android.hardware.usb.host"/>
|
||||
<!-- 声明使用usb -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.usb.host"
|
||||
android:required="true" />
|
||||
|
||||
<application>
|
||||
|
||||
|
||||
@@ -108,7 +108,9 @@ public final class USBMonitor {
|
||||
mOnDeviceConnectListener = listener;
|
||||
mAsyncHandler = HandlerThreadHandler.createHandler(TAG);
|
||||
destroyed = false;
|
||||
if (DEBUG) Log.v(TAG, "USBMonitor:mUsbManager=" + mUsbManager);
|
||||
if (DEBUG) {
|
||||
Log.v(TAG, "USBMonitor:mUsbManager=" + mUsbManager);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +118,9 @@ public final class USBMonitor {
|
||||
* never reuse again
|
||||
*/
|
||||
public void destroy() {
|
||||
if (DEBUG) Log.i(TAG, "destroy:");
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "destroy:");
|
||||
}
|
||||
unregister();
|
||||
if (!destroyed) {
|
||||
destroyed = true;
|
||||
@@ -149,9 +153,13 @@ public final class USBMonitor {
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
public synchronized void register() throws IllegalStateException {
|
||||
if (destroyed) throw new IllegalStateException("already destroyed");
|
||||
if (destroyed) {
|
||||
throw new IllegalStateException("already destroyed");
|
||||
}
|
||||
if (mPermissionIntent == null) {
|
||||
if (DEBUG) Log.i(TAG, "register:");
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "register:");
|
||||
}
|
||||
final Context context = mWeakContext.get();
|
||||
if (context != null) {
|
||||
mPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), 0);
|
||||
|
||||
@@ -480,6 +480,7 @@ public abstract class AbstractUVCCameraHandler extends Handler {
|
||||
try {
|
||||
mSync.wait();
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user