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

Commit 2f09e604 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Check if the handler is registered before showing "Export database files"

Change-Id: I528532d00b482c7eaf5f38ce5f877e0b6e8b2e57
parent aefa2719
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.ActivityNotFoundException;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
@@ -188,8 +190,7 @@ public class PeopleActivity extends ContactsActivity implements
    }

    public boolean areContactsAvailable() {
        return (mProviderStatus != null)
                && mProviderStatus.equals(ProviderStatus.STATUS_NORMAL);
        return (mProviderStatus != null) && mProviderStatus.equals(ProviderStatus.STATUS_NORMAL);
    }

    private boolean areContactWritableAccountsAvailable() {
@@ -1128,11 +1129,20 @@ public class PeopleActivity extends ContactsActivity implements
        makeMenuItemEnabled(menu, R.id.menu_join, mAllFragment.getSelectedContactIds().size() > 1);

        // Debug options need to be visible even in search mode.
        makeMenuItemVisible(menu, R.id.export_database, mEnableDebugMenuOptions);
        makeMenuItemVisible(menu, R.id.export_database, mEnableDebugMenuOptions &&
                hasExportIntentHandler());

        return true;
    }

    private boolean hasExportIntentHandler() {
        final Intent intent = new Intent();
        intent.setAction("com.android.providers.contacts.DUMP_DATABASE");
        final List<ResolveInfo> receivers = getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return receivers != null && receivers.size() > 0;
    }

    /**
     * Returns whether there are any frequently contacted people being displayed
     * @return