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

Commit 5545f56f authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Create unique files, root ordering, UI bugs.

When a file already exists on disk, try adding a counter suffix to
make a unique name.  Move services near top of roots list, just below
recents.  Remove "Documents" root.

Increase number of recents allowed from single provider, and add more
logging to diagnose wedged loaders.

When launching GET_CONTENT apps, wait for successful result before
relaying result; canceled requests now return to DocumentsUI.

Add CloseGuard to ContentProviderClients, since leaked instances can
keep the remote process alive.

Fix UI bug around trailing breadcrumbs.  Fix bug that dropped Recents
from roots list.  Add up action to Settings activity.  Give our
activity a default icon while waiting for async roots to load.

Bug: 10818683, 10819461, 10819461, 10819196, 10860199
Change-Id: I7b9e26b1cf8353dd3175458b23da2b4bda6c5831
parent 562ce888
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.os.RemoteException;
import android.os.ParcelFileDescriptor;
import android.content.res.AssetFileDescriptor;

import dalvik.system.CloseGuard;

import java.io.FileNotFoundException;
import java.util.ArrayList;

@@ -49,6 +51,8 @@ public class ContentProviderClient {
    private final boolean mStable;
    private boolean mReleased;

    private final CloseGuard mGuard = CloseGuard.get();

    /**
     * @hide
     */
@@ -58,6 +62,7 @@ public class ContentProviderClient {
        mContentResolver = contentResolver;
        mPackageName = contentResolver.mPackageName;
        mStable = stable;
        mGuard.open("release");
    }

    /** See {@link ContentProvider#query ContentProvider.query} */
@@ -324,6 +329,7 @@ public class ContentProviderClient {
                throw new IllegalStateException("Already released");
            }
            mReleased = true;
            mGuard.close();
            if (mStable) {
                return mContentResolver.releaseProvider(mContentProvider);
            } else {
@@ -332,6 +338,13 @@ public class ContentProviderClient {
        }
    }

    @Override
    protected void finalize() throws Throwable {
        if (mGuard != null) {
            mGuard.warnIfOpen();
        }
    }

    /**
     * Get a reference to the {@link ContentProvider} that is associated with this
     * client. If the {@link ContentProvider} is running in a different process then
+2 −1
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@
        <!-- TODO: allow rotation when state saving is in better shape -->
        <activity
            android:name=".DocumentsActivity"
            android:theme="@style/Theme">
            android:theme="@style/Theme"
            android:icon="@drawable/ic_doc_text">
            <intent-filter android:priority="100">
                <action android:name="android.intent.action.OPEN_DOCUMENT" />
                <category android:name="android.intent.category.DEFAULT" />
+19 −4
Original line number Diff line number Diff line
@@ -87,8 +87,8 @@ import libcore.io.IoUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

public class DocumentsActivity extends Activity {
@@ -96,6 +96,8 @@ public class DocumentsActivity extends Activity {

    private static final String EXTRA_STATE = "state";

    private static final int CODE_FORWARD = 42;

    private boolean mShowAsDialog;

    private SearchView mSearchView;
@@ -843,11 +845,24 @@ public class DocumentsActivity extends Activity {

    public void onAppPicked(ResolveInfo info) {
        final Intent intent = new Intent(getIntent());
        intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        intent.setComponent(new ComponentName(
                info.activityInfo.applicationInfo.packageName, info.activityInfo.name));
        startActivity(intent);
        startActivityForResult(intent, CODE_FORWARD);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Log.d(TAG, "onActivityResult() code=" + resultCode);

        // Only relay back results when not canceled; otherwise stick around to
        // let the user pick another app/backend.
        if (requestCode == CODE_FORWARD && resultCode != RESULT_CANCELED) {
            setResult(resultCode, data);
            finish();
        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

    public void onDocumentPicked(DocumentInfo doc) {
+7 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
    private static final boolean LOGD = true;

    public static final int MAX_OUTSTANDING_RECENTS = 2;

@@ -63,7 +64,7 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
    /**
     * Maximum documents from a single root.
     */
    public static final int MAX_DOCS_FROM_ROOT = 24;
    public static final int MAX_DOCS_FROM_ROOT = 64;

    private static final ExecutorService sExecutor = buildExecutor();

@@ -194,6 +195,11 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
            }
        }

        if (LOGD) {
            Log.d(TAG, "Found " + cursors.size() + " of " + mTasks.size() + " recent queries done");
            Log.d(TAG, sExecutor.toString());
        }

        final DirectoryResult result = new DirectoryResult();
        result.sortOrder = SORT_ORDER_LAST_MODIFIED;

+1 −4
Original line number Diff line number Diff line
@@ -195,12 +195,9 @@ public class RecentsCreateFragment extends Fragment {

            final SpannableStringBuilder builder = new SpannableStringBuilder();
            builder.append(stack.root.title);
            appendDrawable(builder, crumb);
            for (int i = stack.size() - 2; i >= 0; i--) {
                builder.append(stack.get(i).displayName);
                if (i > 0) {
                appendDrawable(builder, crumb);
                }
                builder.append(stack.get(i).displayName);
            }
            title.setText(builder);
            title.setEllipsize(TruncateAt.MIDDLE);
Loading