smbj icon indicating copy to clipboard operation
smbj copied to clipboard

[Question]: What is a reason for androidSdkVersion = 19 ?

Open isabsent opened this issue 3 years ago • 7 comments
trafficstars

I have found only a few try-catch blocks with multy-catch syntax in your code. Are there other reasons to keep androidSdkVersion = 19 or it can be lowered to 14 for example?

isabsent avatar Feb 09 '22 09:02 isabsent

What would be the reason for downgrading it?

hierynomus avatar Feb 10 '22 22:02 hierynomus

Our file manager supports devices starting from SDK 14.

isabsent avatar Feb 11 '22 08:02 isabsent

If it is possible to use a lower version without code changes I'm fine, if not, then you're out of luck

hierynomus avatar Feb 11 '22 08:02 hierynomus

I'm in a similar situation. When you use menu Analyze -> Inspect code in Android Studio, you can see which functions need SDK 19:

  1. GCMParameterSpec, BCAEADCipherFactory need SDK 19. You can use SMB3 on older SDK versions, but only without encryption.
  2. Some classes use AutoClosable, which is officially supported only on SDK 19, but is part of Android since SDK 14: https://issuetracker.google.com/issues/36999599?pli=1#comment4
  3. Objects.hash in ASN1Tag isn't called unless you put ASN1Tag structures in a hash map or similar
  4. The class ASN1BitString is not called from elsewhere
  5. I have removed the following classes not used on Android: smbj/auth/ExtendedGSSContext.java smbj/auth/GSSAuthenticationContext.java smbj/auth/SpnegoAuthenticator.java smbj/transport/tcp/async/AsyncDirectTcpTransport.java smbj/transport/tcp/async/AsyncDirectTcpTransportFactory.java smbj/transport/tcp/async/AsyncPacketReader.java smbj/transport/tcp/async/PacketBufferReader.java

In conclusion, you can use smbj on SDK 14 and newer without encryption, and on SDK 19 and newer with encryption. To use it without encryption, either disable SMB3, or open Session.java and remove the following line: encryptData |= (sessionContext.getEncryptionKey() != null && connection.getConnectionContext().clientPrefersEncryption()); This enabled encryption even when the user has disabled it, but the server reports that it would prefer encryption.

chrisgch avatar Feb 15 '22 11:02 chrisgch

Thanks a lot!!!

isabsent avatar Feb 15 '22 11:02 isabsent

In conclusion, you can use smbj on SDK 14 and newer without encryption, and on SDK 19 and newer with encryption. To use it without encryption, either disable SMB3, or open Session.java and remove the following line: encryptData |= (sessionContext.getEncryptionKey() != null && connection.getConnectionContext().clientPrefersEncryption()); This enabled encryption even when the user has disabled it, but the server reports that it would prefer encryption.

That is in line with the spec, removing that line basically makes it non-SMB3 compatible. So you're better off disabling SMB3 in the config in that case.

hierynomus avatar Feb 15 '22 12:02 hierynomus

In my app, the user can check/uncheck encrypted transfers. It only forces encrypted transfers when the server requires them. This way the user can choose between more security and higher transfer speeds, not the server.

chrisgch avatar Feb 15 '22 13:02 chrisgch