Apps-android-commons: Number of Contributions reduces to zero on re-login

Created on 31 Jan 2019  路  15Comments  路  Source: commons-app/apps-android-commons

Summary:

Contibution fragment shows 0 contibutions(both failed and successful on re-login

Steps to reproduce:

  • First have some contributions either failed or successful
  • Logout of your account from you app
  • Log-in to the same account
  • Your contributions are all vanished

Expected

  • Previous succcessful as well as faile images must have been retained in the application
  • Also this empty fragment displays no such message like "You haven't made any contributions yet"

Device and Android version:
Vivo 1713 Android version 7.0

Screen-shots:
whatsapp image 2019-01-31 at 9 48 23 am

Would you like to work on the issue?
Yes

assigned bug high priority

Most helpful comment

This happened to me again. I found it very annoying and obvious, will prioritize it

All 15 comments

I can verify this happens after re-login. A very weird issue. @madhurgupta10 did you made any progress with this? Did you managed to find the root cause?

Even the notifications gets reset after relogin

This happened to me again. I found it very annoying and obvious, will prioritize it

@neslihanturan I will prioritize it and deep dive to find the root cause to it.

Thanks for your interest @madhurgupta10 but I think it is assigned to @vanshikaarora . @vanshikaarora can you please verify you are still working on this issue?

Edit: Oh I just realized it has been long time since it is assigned. If in 24 hours there is no answer from @vanshikaarora , you can start working on this @madhurgupta10

I am sorry, for no response since long. I'll start working on this soon.

@neslihanturan I was going through the issue what I noticed was that in the application contributions were added to the ContentProvider using

public void save(Contribution contribution) {
        ContentProviderClient db = clientProvider.get();
        try {
            if (contribution.getContentUri() == null) {
                contribution.setContentUri(db.insert(BASE_URI, toContentValues(contribution)));
            } else {
                db.update(contribution.getContentUri(), toContentValues(contribution), null, null);
            }
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        } finally {
            db.release();
        }
    }

And while logging out all files except the libraries are removed (including the ContentProviders) using the clearApplicationData() function of CommonsApplication.java

 File cacheDirectory = context.getCacheDir();
        File applicationDirectory = new File(cacheDirectory.getParent());
        if (applicationDirectory.exists()) {
            String[] fileNames = applicationDirectory.list();
            for (String fileName : fileNames) {
                if (!fileName.equals("lib")) {
                    FileUtils.deleteFile(new File(applicationDirectory, fileName));
                }
            }
        }

Is the above conclusion correct? Please correct me if I am wrong :)

Is the above conclusion correct? Please correct me if I am wrong :)

@neslihanturan Can you give please give your suggestion here? :)

@neslihanturan I have gone through the Issue closely.

Reason's for failure

  • Contribution and other data(like personal preferences in settings) are not fetched through API. They are stored locally in cache, files, databases and other storage's
  • While logging out we call the delete file method, that delete's the following 8 Files:
  1. cache
  2. code_cache
  3. shared_prefs
  4. files
  5. app_ACRA-unapproved
  6. app_ACRA-approved
  7. lib-main
  8. databases

These files contain data of the contributions and other preferences of the User

Solution

We can avoid deleting the data by removing these methods but then we need to take care of the case that this same information isn't used if the user is logged in using a different account

@neslihanturan Can you please share your opinion? :)

Does this happen just in master, or in an actual release? I experienced the same problem in master, but I have not received any reports from v2.10.2 users about it (and usually users are quite vocal about problems like this ;)).

If we can concur that it just happens in master, it may be a good idea to find out which commit is causing the problem rather than trying to solve from scratch.

BTW, I wonder why number of contributions are not fetched through the API anymore? They used to be IIRC.

@neslihanturan @misaochan Is this issue still there?

I have not noticed it recently, but I'm not sure. Could you test this and let us know what you find @madhurgupta10 ? :)

I would judge this "feature, not a bug", if I've understood it correctly. At least for failed contributions.

We delete our databases so that another user can login ,an unlikely scenario but possible.

To support this we would have to key the data in our databases by user and never delete them.

Previously successful contributions should be accessible from the endpoint though.

Previously successful contributions should be accessible from the endpoint though.

This is what I was thinking. AFAIK we DID have an API for this, but not sure what happened with that. @maskaravivek any idea?

I have not noticed it recently, but I'm not sure. Could you test this and let us know what you find @madhurgupta10 ? :)

I don't face this issue anymore, rather sometimes I get "Error occurred while loading images" error.

Happening no more on 2.13. Also as this is very old, closing this one, feel free to re-open if it happens again :)

Was this page helpful?
0 / 5 - 0 ratings