Coder Social home page Coder Social logo

android-library's People

Contributors

abelgardep avatar aitorbp avatar andyscherzinger avatar davigonz avatar davivel avatar deepdiver1975 avatar dependabot[bot] avatar fesave avatar hannesa2 avatar imgurpreetsk avatar jabarros avatar jesmrec avatar juancag05 avatar karakayasemi avatar lukasreschke avatar malkomich avatar manuelplazaspalacio avatar mendhak avatar michaelstingl avatar mmmarcy avatar przybylski avatar shashvat-kedia avatar stoyicker avatar thescrabi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-library's Issues

About OCS requests and handlers

Actual behaviour

  • Using Fiddler with new android 2.1.0, i can see there are new request to /owncloud/index.php/ocs/cloud/user?format=json with index.php acting as a handler of /ocs/cloud/user requests.

But, there are other requests to ocs like /owncloud/ocs/v1.php/cloud/capabilities?format=json and /owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares?path=/&reshares=true&subfiles=true that does not uses index.php as handler, these old ones uses v1.php.

Why not to use the same v1.php to handle /cloud/user requests or create a new handler inside ocs folder and get in one place all the ocs controllers?

Environment data

ownCloud app version: android 2.1.0

ownCloud server version: 9.1.0.15

Replace Jackrabbit-webdav and deprecated/end-of-life HttpClient 3.1 libs with active and trustable WebDAV + HTTP client libraries

Hi,

it seems the android-library is currently using the HttpClient libs in version 3.1 released in 2007. This has reached End-Of-Life in 2011 (https://hc.apache.org/httpclient-legacy/index.html).

Have you considered to move to the still maintananced https://hc.apache.org/ ?


Edited by @davigonz from here on


ACs


TOPICS TO DISCUSS

  • How to update OwnCloudClient:
    • Option 1: Extend OkHttpClient instead of HttpClient.
    • Option 2: Do not extend OkHttpClient and decouple it from OwnCloudClient, so that OkHttpClient can be easily used regardless of implementation details and OwnCloudClient is not too affected when upgrading OkHttpClient to future versions.
  • How to implement the new WebDAV methods
    • Option 1: use a new wrapper for all the methods.

TASKS

  • Look for active and trustable WebDAV + HTTP client libraries.
    Candidates:
    1. OKHttp 3.10.0: https://github.com/square/okhttp
    2. Sardine: https://github.com/lookfirst/sardine Not enough active nor trustable
    3. HttpUrlConnection: https://developer.android.com/reference/java/net/HttpURLConnection.html
  • Include new network library dependency.
  • Use our sample_client app to perform some tests:
    • GET to retrieve server status.
    • PROPFIND to read remote folder.
  • Separate the previous tests in one branch for each candidate library:
  • Implement basic requests by using the sample client app and the new endpoint, without depending on ownCloud Android library => PR: #187
    • Check server (GET): show the server version
    • Refresh (PROPFIND): show the xml contained in propfind response with the list of files
    • Upload (PUT): show successful message if the upload is properly performed.
    • Download (GET): show successful message if the download is properly performed. The downloaded file won't be created locally in this stage.
    • Delete remote (DELETE): show successful message if the deletion is properly performed.
  • Having a look at the code of a different library and testing it
  • Create wrapper with generic WebDAV and non WebDAV methods.
    • WebDAV
      • Propfind
      • Copy
      • Move
      • Put
      • MkCol
    • Non WebDAV
      • Get
      • Post
      • Put
      • Delete
  • Requests to implement, with the headers and properties required
    • Files (WEBDAV - /remote.php/dav/files/davUser/):
      • UploadRemoteFileOperation => PUT
        • Upload working
        • Upload progress in notification bar and uploads view
        • Cancel upload
        • Retry upload
      • ChunkedUploadRemoteFileOperation, use new chunking=> PUT
        • Upload working
        • Upload progress in notification bar and uploads view
        • Cancel chunked upload
          • Delete remote chunks folder when canceling upload
        • Retry chunked upload
      • DownloadRemoteFileOperation
      • RemoveRemoteFileOperation
      • CopyRemoteFileOperation => COPY
      • RenameRemoteFileOperation => LOCALMOVE (MOVE)
      • CreateRemoteFolderOperation => MKCOL
      • ExistenceCheckRemoteOperation => PROPFIND
      • MoveRemoteFileOperation => MOVE
      • ReadRemoteFileOperation => PROPFIND
      • ReadRemoteFolderOperation => PROPFIND
        • Request properties:
          • creationdate
          • quota-used-bytes
          • permissions
          • quota-available-bytes
          • id
          • getcontentlength
          • size
          • privatelink
    • OAuth:
      • OAuth2GetAccessTokenOperation
      • OAuth2RefreshAccessTokenOperation
    • Shares /ocs/v1.php/apps/files_sharing/api/v1/shares:
      • CreateRemoteShareOperation => POST
      • GetRemoteShareesOperation => GET
      • GetRemoteShareOperation => GET
      • GetRemoteSharesForFileOperation => GET
      • GetRemoteSharesOperation => GET
      • RemoveRemoteShareOperation => DELETE
      • UpdateRemoteShareOperation => PUT
    • Status:
      • GetRemoteStatusOperation /status.php => GET
      • GetRemoteCapabilitiesOperation /ocs/v1.php/cloud/capabilities => GET
    • Users:
      • GetRemoteUserAvatarOperation /index.php/avatar/=> GET
      • GetRemoteUserInfoOperation /ocs/v1.php/cloud/user => GET
      • GetRemoteUserQuotaOperation /ocs/v1.php/cloud/users/username => GET
  • Create custom interceptors to put user agent and credentials headers in all the requests.
  • Merge non ownCloud changes to dav4android by creating separate MRs
  • Update sample client app to use the current library operations.

TESTS

[TO DO]


RELATED ISSUES

Android Library can't handle very large quotas

I have no idea If I need to transplant my bug here myself or what. But here is a copy from this bug report against the client. owncloud/android#940

I've just done a logcat with the working and broken versions. Below is a snippet when it finally "fails". An error appears for every folder that is synced with the 1.7.1 version - which does not occur in 1.7.0

failed sync message:
D/SyncManager(21209): failed sync operation [email protected]:443 u0 (owncloud), org.owncloud, USER, latestRunTime 1141928554, EXPEDITED, reason: 10375, SyncResult: tooManyRetries: true delayUntil: 86400 stats []

Possible cause:
E/ReadRemoteFolderOperation(13246): java.lang.NumberFormatException: Invalid long: "3.89279745229E+12"

D/OwnCloudClient #1(13246): REQUEST PROPFIND /owncloud/remote.php/webdav/Documents%20at%20computer/some%20files/
I/ActivityManager(21209): Start proc com.google.android.youtube for service com.google.android.youtube/.app.remote.YouTubeTvRouteProviderService: pid=14090 uid=10073 gids={50073, 3003, 1028, 1015}
W/ActivityManager(21209): Permission Denial: Accessing service ComponentInfo{com.google.android.music/com.google.android.music.dial.DialMediaRouteProviderService} from pid=7398, uid=10023 that is not exported from uid 10061
E/ReadRemoteFolderOperation(13246): Synchronized /Documents at computer/some files/: Unexpected exception
E/ReadRemoteFolderOperation(13246): java.lang.NumberFormatException: Invalid long: "3.89279745229E+12"
E/ReadRemoteFolderOperation(13246): at java.lang.Long.invalidLong(Long.java:124)
E/ReadRemoteFolderOperation(13246): at java.lang.Long.parse(Long.java:361)
E/ReadRemoteFolderOperation(13246): at java.lang.Long.parseLong(Long.java:352)
E/ReadRemoteFolderOperation(13246): at java.lang.Long.parseLong(Long.java:318)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.common.network.WebdavEntry.(WebdavEntry.java:140)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation.readData(ReadRemoteFolderOperation.java:143)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation.run(ReadRemoteFolderOperation.java:89)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:136)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.operations.RefreshFolderOperation.fetchAndSyncRemoteFolder(RefreshFolderOperation.java:284)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.operations.RefreshFolderOperation.run(RefreshFolderOperation.java:202)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:136)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.synchronizeFolder(FileSyncAdapter.java:291)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.fetchChildren(FileSyncAdapter.java:369)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.synchronizeFolder(FileSyncAdapter.java:311)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.fetchChildren(FileSyncAdapter.java:369)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.synchronizeFolder(FileSyncAdapter.java:311)
E/ReadRemoteFolderOperation(13246): at com.owncloud.android.syncadapter.FileSyncAdapter.onPerformSync(FileSyncAdapter.java:190)
E/ReadRemoteFolderOperation(13246): at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
D/RefreshFolderOperation(13246): Synchronizing [email protected]:443/Documents at computer/some files/
D/FileSyncAdapter(13246): Send broadcast com.owncloud.android.syncadapter.FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED
D/FileDisplayActivity(13246): Received broadcast com.owncloud.android.syncadapter.FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED
D/FileSyncAdapter(13246): Send broadcast com.owncloud.android.syncadapter.FileSyncAdapter.EVENT_FULL_SYNC_END
D/SyncManager(21209): failed sync operation [email protected]:443 u0 (owncloud), org.owncloud, USER, latestRunTime 1141928554, EXPEDITED, reason: 10375, SyncResult: tooManyRetries: true delayUntil: 86400 stats []
D/SyncManager(21209): not retrying sync operation because it retried too many times: [email protected]:443 u0 (owncloud), org.owncloud, USER, latestRunTime 1141931912, EXPEDITED, reason: 10375
D/dalvikvm(21209): GC_EXPLICIT freed 1310K, 24% free 51401K/66848K, paused 4ms+8ms, total 143ms
D/FileDisplayActivity(13246): Setting progress visibility to true
D/FileDisplayActivity(13246): Received broadcast com.owncloud.android.syncadapter.FileSyncAdapter.EVENT_FULL_SYNC_END
D/FileDisplayActivity(13246): Setting progress visibility to false

I'm not really an expert at java - I actually know VERY little. But here is what I think is happening.

The long variable error occurs from the function mentioned in this log line:

E/ReadRemoteFolderOperation(13246): at com.owncloud.android.lib.common.network.WebdavEntry.(WebdavEntry.java:140)

This leads me to:
https://github.com/owncloud/android-library/blob/master/src/com/owncloud/android/lib/common/network/WebdavEntry.java#L140

Which clearly indicates that this is looking at the users quotas available bytes

137 // {DAV:}quota-available-bytes
138 prop = propSet.get(DavPropertyName.create(PROPERTY_QUOTA_AVAILABLE_BYTES));
139 if (prop != null) {
140 mQuotaAvailableBytes = Long.parseLong((String) prop.getValue());
}

My server has a "Default Limit" of Unlimited. And my user account has a Quota of "Default".

All is fine and well here, right?

The value being returned at this line of code is "3.89279745229E+12", which isn't in decimal format.

The limit of a long variable in java is:
Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63 -1)

You need to learn how to handle large numbers for your quota value check.

http://stackoverflow.com/questions/2722122/java-parse-a-number-in-exponential-notation

Also, your demo server doesn't have this large storage limit. Please consider that just because the demo server works when troubleshooting, it doesn't mean the issue is with the users server.

When I set my "Default Storage" value to 100GB, the issue with 1.7.1 went away. This is a OC Android library issue.

TL;DR: They can't handle large storage sizes in their quota checks. Set a quota limit for your "Default Storage" value that just exceeds what you need. I put in 100GB.

File Not Found

i am trying to download file in sample-client from owncloud server m getting File Not Found(404) in result of onRemoteOperationFinished()

Security problem with auth token

Hi,
I wanted to avoid having to enter password every time I start the app (because the final purpose is not just for my personal use).
Yet, if I try this:
ocClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, activity, true);
ocClient.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials(authToken));
authToken = ocClient.getCredentials().getAuthToken();

not only do I realize that the authToken is just the non-encrypted password, which prevents me from storing it anywhere on the user's phone, but additionally, it just does not work with the following error:
Credentials cannot be used for basic authentication: com.owncloud.android.lib.common.network.BearerCredentials

Am I doing something wrong?
Thanks.

Remove redundant use of `HttpClient`

With the changes done by removing the ok http singleton I also introduced a redundend use of the HttpClient wrapper.

The HttpClient gets introduced to the HttpMethod through the constructor:

abstract class HttpBaseMethod constructor(clientWrapper: HttpClient, url: URL) {
var okHttpClient: OkHttpClient

However the execute() method of the HttpMethod is later called from the OwnCloudClient which extends the HttpClient wrapper:

public int executeHttpMethod(HttpBaseMethod method) throws Exception {
boolean repeatWithFreshCredentials;
int repeatCounter = 0;
int status;
do {
String requestId = RandomUtils.generateRandomUUID();
// Header to allow tracing requests in apache and ownCloud logs
Timber.d("Executing in request with id %s", requestId);
method.setRequestHeader(HttpConstants.OC_X_REQUEST_ID, requestId);
method.setRequestHeader(HttpConstants.USER_AGENT_HEADER, SingleSessionManager.getUserAgent());
method.setRequestHeader(HttpConstants.ACCEPT_ENCODING_HEADER, HttpConstants.ACCEPT_ENCODING_IDENTITY);
if (mCredentials.getHeaderAuth() != null && method.getRequestHeader(AUTHORIZATION_HEADER) == null) {
method.setRequestHeader(AUTHORIZATION_HEADER, mCredentials.getHeaderAuth());
}
status = method.execute();

Getting "in touch" twice with the client is redundant and should be removed. Here are two possible solutions:

1. Try to Inject the client from the constructor:

The HttpClient modifying methods in the `HttpBaseMethod` do not need to be changed: https://github.com/owncloud/android-library/blob/9d80a95a884715f9d71aa16f86bd36d0d50bce14/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt#L110

But the code calling the method.execute() in the OwnCloudClient has to be moved to the HttpMethod:

public int executeHttpMethod(HttpBaseMethod method) throws Exception {

2. Try to inject the client from the execute method:

The HttpClient modifying methods in the `HttpBaseMethod` need to be modified: https://github.com/owncloud/android-library/blob/9d80a95a884715f9d71aa16f86bd36d0d50bce14/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.kt#L110

Instead of modifying the OkHttp client directly we could save the modifications and apply them when calling the execute(client) method.
The only change that need to be applied to OwnCloudClient would be that this is suplied the the execution() method.


Issue: #378
Library: #427
App: owncloud/android#3353

Q: How to build library in JAR format (for legacy eclipse project)?

Hi,

I'm currently working on an eclipse legacy project, that uses the ownCloud library. I want to update the library in the project. To do so i need the library in JAR format. Unfortunately by building with gradle the outcome is in AAR format (at least on Jenkins instance the outcome is AAR).

I found some information on stackoverflow on how to convert an AAR to a JAR, which is basically extracting the classes.jar from the AAR and renaming it.
Unfortunately this doesn't seem to work. When i add the ownCloud-library.jar into my project's lib folder, eclipse is able to find all the classes and importing namespaces seems to work. Building the App works too. But as soon as i try to run the app on an emulator i get the following error(s):

Dx unsupported class file version 52.0
...while parsing com/owncloud/android/lib/BuildConfig.class
Dx 1 error; aborting
Conversion to Dalvik format failed with error 1

After searching a bit on the internet i found a few solutions suggesting to change the JRE version to 1.7 and also the java compliance level to 1.7. But none of these seem to work.

Another solution suggest to create an eclipse project, that references the extracted and renamed classes.jar. I also tried that but then eclipse is not able to resolve the namespaces within the my legacy project.

My thought was, that the above mentioned method to "convert" the AAR to JAR is not correct (or does not create a "dexable" JAR file).

So my first qestion would be: How can i build the ownCloud library with ANT, to get a correctly working JAR file?

I have seen this issue:

https://github.com/owncloud/android/pull/1621

which was about removing the ANT build from the library. The branch seems not to be available anymore, or? I couldn't find it (git clone complains it cannot find the branch).

I understand that ANT is not supported anymore by this library (for good reasons), but maybe someone can help me to get a working JAR?

Thanks in Advance,

Michael

Should tests succeed if connection times out?

I just tried CreateFolderTest. It succeeded. I noticed that several connection times outs occurred before I noticed that my connection was blocked.

I looks like timeouts are "accept" on purpose:

https://github.com/owncloud/android-library/blob/develop/test_client/tests/src/com/owncloud/android/lib/test_project/test/RemoteTest.java#L54

https://github.com/owncloud/android-library/blob/develop/test_client/tests/src/com/owncloud/android/lib/test_project/test/CreateFolderTest.java#L71

I do not understand the reasoning here. IMO, the tests require a working connection to the server, otherwise functionality cannot be tested. So if the connection breaks, the test should fail.

Expired credentials login falls in loop

Hi, I just started contributing to the owncloud android project and I'm seeing a bug that I can't find the reason behind it:

  • After some hours working with app (which I don't think it is relevant to time, since it happened in various situations) it kicks the user out and ask for user's password.
  • after entering correct password it goes in but asks for password over and over again.

Inability to work with cloud using OwnCloudBasicCredentials only (not android.accounts.Account)

When executing operations (e.g. ReadRemoteFolderOperation) - logic always ends up attempting to use mAccount.getSavedAccount() inside client, which is always null for OwnCloudAccount instance if constructor public OwnCloudAccount(Uri baseUri, OwnCloudCredentials credentials) used for creation.

Is it even possible to work with plain username&password pair?

P. S.: is this even actual library to attempt to use for accessing ownCloud? It really looks like you gave up on implementing it in the middle of development and somehow gave it 'stable' status (at least I'm trying to use that branch).
Even your own sample app does not work (and it is, in fact, the only source of documentation for this library - every page related to Android client development redirects users to it).

Sample client sends all requests twice

All webDAV commands sent by sample client are sent twice:
First time without credentials (server returns 401), then with credentials (now sucess 2xx)

This is the server log:

IP - - [16/Jun/2015:22:03:11 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 401 1144 "-" "Jakarta Commons-HttpClient/3.1"
IP - test [16/Jun/2015:22:03:12 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 207 3570 "-" "Jakarta Commons-HttpClient/3.1"

There is probably just a single line missing somewhere. I cannot figure out what it should be and where to put.

PS: I added a simple SslSocketFactory which accepts my self-signed certificate. Could that pose a problem?

Test every PR ?

Do we really need a manual test for every PR, or what prevents a merge of
#224
#228
there is no logic changed at all there.

When I would approve it, I would merge it immediate

Or different asked:
How is the workflow ?

Have problem to connect to OwnCloud server with android api version under 19

When i want to connect to the server with android api version under 19 i get this runtime exception but with api version upper than 19 it works correctly.

com.owncloud.android.lib.sampleclient E/com.owncloud.android.lib.sampleclient.MainActivity﹕ SSL recoverable exception
com.owncloud.android.lib.common.network.CertificateCombinedException
at com.owncloud.android.lib.common.network.AdvancedX509TrustManager.checkServerTrusted(AdvancedX509TrustManager.java:105)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:597)
at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method) at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:398) at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.verifyPeerIdentity(AdvancedSslSocketFactory.java:248) at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.createSocket(AdvancedSslSocketFactory.java:185)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387 atorg.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:222) at com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation.run(ReadRemoteFolderOperation.java:79)
at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:303)

Use Moshi to parse shares

Following our way to use Moshi to parse http responses (Already parsing capabilities, sharees, user info with Moshi), next step is to use moshi to parse shares.

Currently we retrieve the xml response from the shares endpoint, and parse it manually.

With moshi, we need to retrieve the json response, and create a new ShareResponse. Moshi will do the rest.

This PR can be used as reference: #352

Operations in background

I am working on an integration of owncloud upload capabilities into the gpslogger android app (https://github.com/mendhak/gpslogger).
Following the documentation of the android-library (https://doc.owncloud.org/server/8.0/developer_manual/android_library/index.html), what I struggled with is getting upload of a file to run from a background thread. As far as I can see, the current API doesn't directly support that, there's two issues: (1) for the Factory to create a OwnCloudClient, one needs a context; and (2) for the UploadRemoteFileOperation.execute, one needs a Handler (but that can't be created in a background thread if I understand correctly - it fails with "Can't create a handler inside thread that has not called Looper.prepare()").
Circumventing (1) is easy through the readily available constructor. For (2), to avoid having to create a Handler. I ended up calling the run() method directly; for that, the UploadRemoteFileOperation class had to be made public, but then it worked.

I'm quite new to Android development so probably I've just missed a simple thing, if so, I would be very thankful if you pointed me in the right direction!

[New arch] Use Moshi to parse capabilities

GetRemoteCapabilitiesOperation.kt takes care of parsing the capabilities retrieved from the server in JSON format and transform them into RemoteCapability object.

Similarly to what we detailed in owncloud/android#2704, we could use Moshi to make the parsing of capabilities.

Tasks:

  • Move capabilities parsing from library to data layer, that will parse the JSON and transform it into OCCapability object.
  • Get rid of RemoteCapability class since is basically the same as OCCapability.

startRefresh()

I'm trying out this sample_client and upload,download,delete works but refresh doesn't. List view never fills out. "TODO: operation finished in fail" toast every time. Is this a known situation? Doesn't seem like it should be this hard to test out. Just changed the setup.xml strings except user_agent

remove okHttpClient singleton

Remove the okHttpClient signleton from HttpCleint. Use propper injection which we can do from the OwnCloudClientFactory.

Tasks

  • Make okHttpClient nonsingleton
  • move library remoteoperations to nonsingleton
  • move app remoteoperations to nonsingleton
  • implement injection in library
    • research
  • Add/fix Unit tests in library
  • Add/fix Unit tests in app
  • Test if application runs stable

Implementation

App: owncloud/android#3047
Library: #364

SSL recoverable exception

Hello,
i have installed owncloud server version 10, then i imported a wildcard certificate which is from comodo (*.domain.com). When I connect to the cloud via a browser the certicate works perfect.
When i try to connect with the android-library i get the following exception:

E/ReadRemoteFolderOperation: Synchronized /: SSL recoverable exception
                                                                             com.owncloud.android.lib.common.network.CertificateCombinedException
at com.owncloud.android.lib.common.network.AdvancedX509TrustManager.checkServerTrusted(AdvancedX509TrustManager.java:105)
                                                                                 at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:117)
                                                                                 at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:556)
                                                                                 at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
                                                                                 at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
                                                                                 at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.verifyPeerIdentity(AdvancedSslSocketFactory.java:247)
                                                                                 at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.createSocket(AdvancedSslSocketFactory.java:183)
                                                                                 at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
                                                                                 at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)

is there anybody who can help me with this problem?
Thanks!!

`java.lang.SecurityException: caller uid xxxxx is different than the authenticator's uid` when calling OwnCloudClientFactory.createOwnCloudClient

My app displays a list of owncloud accounts retrieved with AccountManager.get(this).getAccountsByType("owncloud")

After the user selects an account I try to create an OwnCloudClient with OwnCloudClientFactory.createOwnCloudClient(selectedAccount, MainActivity.this);.

But the application crashes with a runtime exception:

Caused by: java.lang.SecurityException: caller uid 10341 is different than the authenticator's uid
   at android.os.Parcel.readException(Parcel.java:1546)
   at android.os.Parcel.readException(Parcel.java:1499)
   at android.accounts.IAccountManager$Stub$Proxy.getUserData(IAccountManager.java:692)
   at android.accounts.AccountManager.getUserData(AccountManager.java:344)
   at com.owncloud.android.lib.common.accounts.AccountUtils.getBaseUrlForAccount(AccountUtils.java:141)
   at com.owncloud.android.lib.common.OwnCloudClientFactory.createOwnCloudClient(OwnCloudClientFactory.java:77)
...

Attempt to invoke virtual method 'boolean com.owncloud.android.lib.common.operations.RemoteOperationResult.isSuccess()' on a null object reference

I've integrated ownCloud library in my project as an ".aar" module.
I'm getting the following runtime error whenever I try to execute the following code after initializing ownCloud client:

ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
refreshOperation.execute(client, this, handler);

I know that the ownCloud client is initialized properly and the credentials are correct because I've tested them with the sample app that comes with the SDK and it worked fine.

What could be the problem?

Clean up no longer used libraries

Under the owncloud-android-library/libs directory there's still some .jar that are not needed anymore:

  • commons-httpclient-3.1.jar
  • jackrabbit-webdav-2.12.4.jar

The ownCloud server is not configured!

03-29 14:45:20.484 2583-2728/com.owncloud.android.lib.sampleclient E/ReadRemoteFolderOperation﹕ Synchronized /: The ownCloud server is not configured!
03-29 14:45:20.489 2583-2583/com.owncloud.android.lib.sampleclient E/com.owncloud.android.lib.sampleclient.MainActivity﹕ The ownCloud server is not configured!
03-29 14:45:22.502 2583-2597/com.owncloud.android.lib.sampleclient E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7d3750

Readme and third party

I guess this is not right any more, when I see dependencies

dependencies {
    api 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.51"
    implementation 'com.gitlab.ownclouders:dav4android:oc_support'
}

Third party libraries

ownCloud Android Library uses Apache JackRabbit, version 2.2.5. Copyright (C) 2004-2010 The Apache Software Foundation. Licensed under Apache License, Version 2.0.

Apache JackRabbit depends on Commons HTTPClient version 3.1 and SLF4j version 1.7.5; both included also. Copyright (C) 2004-2010 The Apache Software Foundation. Licensed under Apache License, Version 2.0.

Or does com.gitlab.ownclouders:dav4android:oc_support uses this JackRabbit ?

server return code 405

when i call this method :

private void startRefresh() {

    ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation("/uploads/");  

    refreshOperation.execute(mClient, this, mHandler);  

} 

the server return me code 405 . I don’t know what’s mean , probably httpMethod is incorrect ?
can you help me ?
Thank you.

Proguard

There is no proguard handling at all.
Should be some classes kept ?

warning: Ignoring InnerClasses attribute for an anonymous inner class

I've integrated ownCloud library in my project as an ".aar" module.
In my gradle I add the aar along with the HttpClient library (if I don't add the HttpClient library I get compile errors) I get as follows:

compile 'commons-httpclient:commons-httpclient:3.1'
compile(name: 'android-library-release', ext: 'aar')

I still get two warnings:

warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.httpclient.HttpMethodBase$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.

Could these two warnings affect the other issue that I mentioned in #134?

missing filename/path in remoteFinish

Because otherwise one doesn't know, which of the (already started several file download operations at this point) downloads finished, but to handle them, while others are downloaded, it's necessesary to know the filepath it's gotten saved at.

I did a small workaround, but it's probably not meant that way:
in file: lib-common-operations-RemoteOperationResult:

#115: private String mFilename;
#172: if ("filename".equals(current.getName().toLowerCase())) { mFilename = current.getValue(); }

public String getFilename() { return mFilename == null ? null : mFilename; }

in file: lib-resources-files-DownloadRemoteFileOperation:

// # 85: instead of "result = new RemoteOperationResult...." (custom header)
// old version was line 87
            Header[] headerArray = null;
            if (mGet != null) {
                headerArray = mGet.getResponseHeaders();
                ArrayList<Header> headerList = new ArrayList<Header>();
                Collections.addAll(headerList, headerArray);
                headerList.add(new Header("Filename", tmpFile.toString()));
                headerArray = new Header[headerList.size()];
                headerList.toArray(headerArray);
            } else {
                headerArray = null;
            }
            result = new RemoteOperationResult(isSuccess(status), status, headerArray);

Cheers!

Connecting to owncloud over https (self signed) fails with "SSL recoverable exception"

I am attempting to connect to an owncloud server where the user has issued a self signed certificate.

I try to connect like so, and I am using the SelfSignedConfidentSslSocketFactory, so that any self signed certificate can be accepted. I got this initial code from the test app.

  Protocol pr = Protocol.getProtocol("https");
 if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
     try {
         ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
         Protocol.registerProtocol( "https", new Protocol("https", psf, 443));

     } catch (GeneralSecurityException e) {
         tracer.error("Self-signed confident SSL context could not be loaded", e);
     }
 }

 OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(servername), AppSettings.getInstance(), true);
 client.setDefaultTimeouts('\uea60', '\uea60');
 client.setFollowRedirects(true);
 client.setCredentials(
         OwnCloudCredentialsFactory.newBasicCredentials(username, password)
 );

 String remotePath = directory + FileUtils.PATH_SEPARATOR + localFile.getName();
 String mimeType = "application/octet-stream"; //unused
 UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(localFile.getAbsolutePath(), remotePath, mimeType);
 uploadOperation.execute(client,this);

This attempts to connect and fails with

  01-30 00:23:28.774     948-2093/com.mendhak.gpslogger E/OwnCloudJob﹕ onRemoteOperationFinish:100 - SSL recoverable exception
      com.owncloud.android.lib.common.network.CertificateCombinedException: null
              at com.owncloud.android.lib.common.network.AdvancedX509TrustManager.checkServerTrusted(AdvancedX509TrustManager.java:105) ~[na:0.0]
              at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:116) ~[na:0.0]
              at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:550) ~[na:0.0]
              at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) ~[na:0.0]
              at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:318) ~[na:0.0]
              at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.verifyPeerIdentity(AdvancedSslSocketFactory.java:248) ~[na:0.0]
              at com.owncloud.android.lib.common.network.AdvancedSslSocketFactory.createSocket(AdvancedSslSocketFactory.java:185) ~[na:0.0]
              at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) ~[na:0.0]
              at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361) ~[na:0.0]
              at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) ~[na:0.0]
              at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) ~[na:0.0]
              at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) ~[na:0.0]
              at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) ~[na:0.0]
              at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:223) ~[na:0.0]
              at com.owncloud.android.lib.resources.files.UploadRemoteFileOperation.uploadFile(UploadRemoteFileOperation.java:120) ~[na:0.0]
              at com.owncloud.android.lib.resources.files.UploadRemoteFileOperation.run(UploadRemoteFileOperation.java:88) ~[na:0.0]
              at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:331) ~[na:0.0]
              at java.lang.Thread.run(Thread.java:818) ~[na:0.0]

Is there something else I should be doing to trust self signed certs?

Exception when exhausting http responses

It seems we are trying to exhaust http responses when are already closed, which triggers the error below:

E/OwnCloudClient: Unexpected exception while exhausting not interesting HTTP response; will be IGNORED
    java.io.IOException: closed
        at okio.RealBufferedSource$1.read(RealBufferedSource.java:435)
        at java.io.InputStream.read(InputStream.java:101)
        at com.owncloud.android.lib.common.OwnCloudClient.exhaustResponse(OwnCloudClient.java:234)
        at com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation.createFolder(CreateRemoteFolderOperation.java:112)
        at com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation.run(CreateRemoteFolderOperation.java:84)
        at com.owncloud.android.lib.common.operations.RemoteOperation.runOperation(RemoteOperation.java:251)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:213)
        at com.owncloud.android.operations.CreateFolderOperation.run(CreateFolderOperation.java:62)
        at com.owncloud.android.lib.common.operations.RemoteOperation.runOperation(RemoteOperation.java:251)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:190)
        at com.owncloud.android.operations.common.SyncOperation.execute(SyncOperation.java:68)
        at com.owncloud.android.providers.DocumentsStorageProvider.createFolder(DocumentsStorageProvider.kt:236)
        at com.owncloud.android.providers.DocumentsStorageProvider.createDocument(DocumentsStorageProvider.kt:197)
        at android.provider.DocumentsProvider.callUnchecked(DocumentsProvider.java:1005)
        at android.provider.DocumentsProvider.call(DocumentsProvider.java:951)
        at android.content.ContentProvider$Transport.call(ContentProvider.java:401)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:272)
        at android.os.Binder.execTransact(Binder.java:731)

Use TLS v1, v2

After replacing the network library with OkHttp, we put TLS algorithm by default but we could use higher versions, v1, v1.1 or even v1.2. as we did previous the network library switch.

screenshot 2019-02-13 at 16 50 38

git tag name suggestion

currently there are such tag names

image

In my point of view they should only include numbers, like 1.0 so other apps can include it like

        implementation 'com.github.owncloud:android-library:1.0'

and not like current

        implementation 'com.github.owncloud:android-library:oc-android-library-0.9.24'

please see https://jitpack.io/#owncloud/android-library

remove sample app from library

The Sample app in the library is not used anymore, yet we still have to fix it from time to time in order to be able to compile the whole library without compiler issues. We should remove it as we have not user for it anymore.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.