Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
b804411f
Unverified
Commit
b804411f
authored
Jan 22, 2019
by
Don Gagne
Committed by
GitHub
Jan 22, 2019
Browse files
Merge pull request #7183 from DonLakeFlyer/AndroidSerialPermissions
Fix android USB permissions
parents
6580a544
6243dbac
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
android/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
View file @
b804411f
...
...
@@ -41,8 +41,8 @@ public class CdcAcmSerialDriver extends CommonUsbSerialDriver {
private
static
final
int
SET_CONTROL_LINE_STATE
=
0x22
;
private
static
final
int
SEND_BREAK
=
0x23
;
public
CdcAcmSerialDriver
(
UsbDevice
device
,
UsbDeviceConnection
connection
)
{
super
(
device
,
connection
);
public
CdcAcmSerialDriver
(
UsbDevice
device
)
{
super
(
device
);
}
@Override
...
...
android/src/com/hoho/android/usbserial/driver/CommonUsbSerialDriver.java
View file @
b804411f
...
...
@@ -35,11 +35,13 @@ abstract class CommonUsbSerialDriver implements UsbSerialDriver {
public
static
final
int
DEFAULT_READ_BUFFER_SIZE
=
16
*
1024
;
public
static
final
int
DEFAULT_WRITE_BUFFER_SIZE
=
16
*
1024
;
protected
final
UsbDevice
mDevice
;
protected
final
UsbDeviceConnection
mConnection
;
protected
final
UsbDevice
mDevice
;
protected
final
Object
mReadBufferLock
=
new
Object
();
protected
final
Object
mWriteBufferLock
=
new
Object
();
protected
final
Object
mReadBufferLock
=
new
Object
();
protected
final
Object
mWriteBufferLock
=
new
Object
();
protected
UsbDeviceConnection
mConnection
=
null
;
private
int
_permissionStatus
=
permissionStatusRequestRequired
;
/** Internal read buffer. Guarded by {@link #mReadBufferLock}. */
protected
byte
[]
mReadBuffer
;
...
...
@@ -47,14 +49,28 @@ abstract class CommonUsbSerialDriver implements UsbSerialDriver {
/** Internal write buffer. Guarded by {@link #mWriteBufferLock}. */
protected
byte
[]
mWriteBuffer
;
public
CommonUsbSerialDriver
(
UsbDevice
device
,
UsbDeviceConnection
connection
)
{
public
CommonUsbSerialDriver
(
UsbDevice
device
)
{
mDevice
=
device
;
mConnection
=
connection
;
mReadBuffer
=
new
byte
[
DEFAULT_READ_BUFFER_SIZE
];
mWriteBuffer
=
new
byte
[
DEFAULT_WRITE_BUFFER_SIZE
];
}
@Override
public
void
setConnection
(
UsbDeviceConnection
connection
)
{
mConnection
=
connection
;
}
@Override
public
int
permissionStatus
()
{
return
_permissionStatus
;
}
@Override
public
void
setPermissionStatus
(
int
permissionStatus
)
{
_permissionStatus
=
permissionStatus
;
}
/**
* Returns the currently-bound USB device.
*
...
...
android/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java
View file @
b804411f
...
...
@@ -61,8 +61,8 @@ public class Cp2102SerialDriver extends CommonUsbSerialDriver {
private
UsbEndpoint
mReadEndpoint
;
private
UsbEndpoint
mWriteEndpoint
;
public
Cp2102SerialDriver
(
UsbDevice
device
,
UsbDeviceConnection
connection
)
{
super
(
device
,
connection
);
public
Cp2102SerialDriver
(
UsbDevice
device
)
{
super
(
device
);
}
private
int
setConfigSingle
(
int
request
,
int
value
)
{
...
...
android/src/com/hoho/android/usbserial/driver/FtdiSerialDriver.java
View file @
b804411f
...
...
@@ -211,8 +211,8 @@ public class FtdiSerialDriver extends CommonUsbSerialDriver {
* @throws UsbSerialRuntimeException if the given device is incompatible
* with this driver
*/
public
FtdiSerialDriver
(
UsbDevice
usbDevice
,
UsbDeviceConnection
usbConnection
)
{
super
(
usbDevice
,
usbConnection
);
public
FtdiSerialDriver
(
UsbDevice
usbDevice
)
{
super
(
usbDevice
);
mType
=
null
;
}
...
...
android/src/com/hoho/android/usbserial/driver/ProlificSerialDriver.java
View file @
b804411f
...
...
@@ -231,8 +231,8 @@ public class ProlificSerialDriver extends CommonUsbSerialDriver {
return
((
getStatus
()
&
flag
)
==
flag
);
}
public
ProlificSerialDriver
(
UsbDevice
device
,
UsbDeviceConnection
connection
)
{
super
(
device
,
connection
);
public
ProlificSerialDriver
(
UsbDevice
device
)
{
super
(
device
);
}
@Override
...
...
android/src/com/hoho/android/usbserial/driver/UsbSerialDriver.java
View file @
b804411f
...
...
@@ -83,6 +83,16 @@ public interface UsbSerialDriver {
/** 2 stop bits. */
public
static
final
int
STOPBITS_2
=
2
;
public
static
final
int
permissionStatusSuccess
=
0
;
public
static
final
int
permissionStatusDenied
=
1
;
public
static
final
int
permissionStatusRequested
=
2
;
public
static
final
int
permissionStatusRequestRequired
=
3
;
public
static
final
int
permissionStatusOpen
=
4
;
public
int
permissionStatus
();
public
void
setPermissionStatus
(
int
permissionStatus
);
public
void
setConnection
(
UsbDeviceConnection
connection
);
/**
* Returns the currently-bound USB device.
*
...
...
android/src/com/hoho/android/usbserial/driver/UsbSerialProber.java
View file @
b804411f
...
...
@@ -65,11 +65,7 @@ public enum UsbSerialProber {
if
(!
testIfSupported
(
usbDevice
,
FtdiSerialDriver
.
getSupportedDevices
()))
{
return
Collections
.
emptyList
();
}
final
UsbDeviceConnection
connection
=
manager
.
openDevice
(
usbDevice
);
if
(
connection
==
null
)
{
return
Collections
.
emptyList
();
}
final
UsbSerialDriver
driver
=
new
FtdiSerialDriver
(
usbDevice
,
connection
);
final
UsbSerialDriver
driver
=
new
FtdiSerialDriver
(
usbDevice
);
return
Collections
.
singletonList
(
driver
);
}
},
...
...
@@ -80,11 +76,7 @@ public enum UsbSerialProber {
if
(!
testIfSupported
(
usbDevice
,
CdcAcmSerialDriver
.
getSupportedDevices
()))
{
return
Collections
.
emptyList
();
}
final
UsbDeviceConnection
connection
=
manager
.
openDevice
(
usbDevice
);
if
(
connection
==
null
)
{
return
Collections
.
emptyList
();
}
final
UsbSerialDriver
driver
=
new
CdcAcmSerialDriver
(
usbDevice
,
connection
);
final
UsbSerialDriver
driver
=
new
CdcAcmSerialDriver
(
usbDevice
);
return
Collections
.
singletonList
(
driver
);
}
},
...
...
@@ -95,11 +87,7 @@ public enum UsbSerialProber {
if
(!
testIfSupported
(
usbDevice
,
Cp2102SerialDriver
.
getSupportedDevices
()))
{
return
Collections
.
emptyList
();
}
final
UsbDeviceConnection
connection
=
manager
.
openDevice
(
usbDevice
);
if
(
connection
==
null
)
{
return
Collections
.
emptyList
();
}
final
UsbSerialDriver
driver
=
new
Cp2102SerialDriver
(
usbDevice
,
connection
);
final
UsbSerialDriver
driver
=
new
Cp2102SerialDriver
(
usbDevice
);
return
Collections
.
singletonList
(
driver
);
}
},
...
...
@@ -110,11 +98,7 @@ public enum UsbSerialProber {
if
(!
testIfSupported
(
usbDevice
,
ProlificSerialDriver
.
getSupportedDevices
()))
{
return
Collections
.
emptyList
();
}
final
UsbDeviceConnection
connection
=
manager
.
openDevice
(
usbDevice
);
if
(
connection
==
null
)
{
return
Collections
.
emptyList
();
}
final
UsbSerialDriver
driver
=
new
ProlificSerialDriver
(
usbDevice
,
connection
);
final
UsbSerialDriver
driver
=
new
ProlificSerialDriver
(
usbDevice
);
return
Collections
.
singletonList
(
driver
);
}
};
...
...
android/src/org/mavlink/qgroundcontrol/QGCActivity.java
View file @
b804411f
This diff is collapsed.
Click to expand it.
libs/qtandroidserialport/src/qserialport_android.cpp
View file @
b804411f
...
...
@@ -197,7 +197,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
if
(
deviceId
==
BAD_PORT
)
{
qWarning
()
<<
"Error opening
%s
"
<<
systemLocation
.
toLatin1
().
data
();
qWarning
()
<<
"Error opening"
<<
systemLocation
.
toLatin1
().
data
();
q_ptr
->
setError
(
QSerialPort
::
DeviceNotFoundError
);
return
false
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment