Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1cc78a9 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix bug 6479405 On tablet, sometimes, QC -> full contact...

card yields in an empty details screen.

In the old code, we even copied the requested URI, which caused the issue
if the URIs for the first request and the second request are different
but still point at the same contact.  If we do this, the second result
will have a different requested URI than the actual requeseted URI,
which makes ContactLoaderFragment ignore the result.

This really happens because the lookup URI has variations.

Also make sure not to cache error results.

Bug 6479405

Change-Id: I71254578f0513b391804ee27a21a810bdb6881ac
parent 254bbae7
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -226,10 +226,11 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
            mIsUserProfile = isUserProfile;
        }

        private Result(Result from) {
        private Result(Uri requestedUri, Result from) {
            mRequestedUri = requestedUri;

            mStatus = from.mStatus;
            mException = from.mException;
            mRequestedUri = from.mRequestedUri;
            mLookupUri = from.mLookupUri;
            mUri = from.mUri;
            mDirectoryId = from.mDirectoryId;
@@ -520,6 +521,12 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
        public boolean isUserProfile() {
            return mIsUserProfile;
        }

        @Override
        public String toString() {
            return "{requested=" + mRequestedUri + ",lookupkey=" + mLookupKey +
                    ",uri=" + mUri + ",status=" + mStatus + "}";
        }
    }

    /**
@@ -730,13 +737,13 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
                    UriUtils.areEqual(cachedResult.getLookupUri(), mLookupUri)) {
                // We are using a cached result from earlier. Below, we should make sure
                // we are not doing any more network or disc accesses
                result = cachedResult;
                result = new Result(mRequestedUri, cachedResult);
                resultIsCached = true;
            } else {
                result = loadContactEntity(resolver, uriCurrentFormat);
                resultIsCached = false;
            }
            if (!result.isNotFound()) {
            if (result.isLoaded()) {
                if (result.isDirectoryEntry()) {
                    if (!resultIsCached) {
                        loadDirectoryMetaData(result);
@@ -1345,10 +1352,10 @@ public class ContactLoader extends AsyncTaskLoader<ContactLoader.Result> {
     * contact. If the next load is for a different contact, the cached result will be dropped
     */
    public void cacheResult() {
        if (mContact == null) {
        if (mContact == null || !mContact.isLoaded()) {
            sCachedResult = null;
        } else {
            sCachedResult = new Result(mContact);
            sCachedResult = mContact;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ public class ContactLoaderFragment extends Fragment implements FragmentKeyListen
        @Override
        public void onLoadFinished(Loader<ContactLoader.Result> loader, ContactLoader.Result data) {
            if (!mLookupUri.equals(data.getRequestedUri())) {
                Log.e(TAG, "Different URI: requested=" + mLookupUri + "  actual=" + data);
                return;
            }