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

Commit 0c671305 authored by Yorke Lee's avatar Yorke Lee Committed by Android (Google) Code Review
Browse files

Merge "Handle runtime phone permission" into mnc-dev

parents 44ed26cf b7330e38
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -257,6 +257,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O

            menu.findItem(R.id.menu_import_export).setVisible(hasContactsPermission);
            menu.findItem(R.id.menu_add_contact).setVisible(hasContactsPermission);

            menu.findItem(R.id.menu_history).setVisible(
                    PermissionsUtil.hasPhonePermissions(DialtactsActivity.this));
            super.show();
        }
    }
+3 −4
Original line number Diff line number Diff line
@@ -188,7 +188,6 @@ public class CallLogFragment extends Fragment
                mContactsObserver);
        resolver.registerContentObserver(Status.CONTENT_URI, true, mVoicemailStatusObserver);
        setHasOptionsMenu(true);
        fetchCalls();
    }

    /** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */
@@ -203,7 +202,7 @@ public class CallLogFragment extends Fragment
        // This will update the state of the "Clear call log" menu item.
        getActivity().invalidateOptionsMenu();

        boolean showListView = cursor.getCount() > 0;
        boolean showListView = cursor != null && cursor.getCount() > 0;
        mRecyclerView.setVisibility(showListView ? View.VISIBLE : View.GONE);
        mEmptyListView.setVisibility(!showListView ? View.VISIBLE : View.GONE);

@@ -266,6 +265,7 @@ public class CallLogFragment extends Fragment
        mRecyclerView.setHasFixedSize(true);
        mLayoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(mLayoutManager);
        mEmptyListView = view.findViewById(R.id.empty_list_view);

        String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity());
        boolean isShowingRecentsTab = mLogLimit != NO_LOG_LIMIT || mDateLimit != NO_DATE_LIMIT;
@@ -278,14 +278,13 @@ public class CallLogFragment extends Fragment
        mRecyclerView.setAdapter(mAdapter);

        mVoicemailStatusHelper = new VoicemailStatusHelperImpl();
        fetchCalls();
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mEmptyListView = view.findViewById(R.id.empty_list_view);

        updateEmptyMessage(mCallTypeFilter);
    }

+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.util.TelecomUtil;

/**
@@ -78,6 +79,10 @@ public class CallLogNotificationsService extends IntentService {
            return;
        }

        if (!PermissionsUtil.hasPhonePermissions(this)) {
            return;
        }

        if (ACTION_MARK_NEW_VOICEMAILS_AS_OLD.equals(intent.getAction())) {
            mVoicemailQueryHandler.markNewVoicemailsAsOld();
        } else if (ACTION_UPDATE_NOTIFICATIONS.equals(intent.getAction())) {
+16 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.provider.VoicemailContract.Voicemails;
import android.util.Log;

import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.util.TelecomUtil;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;

@@ -93,6 +94,10 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
                Log.w(TAG, "Exception on background worker thread", e);
            } catch (IllegalArgumentException e) {
                Log.w(TAG, "ContactsProvider not present on device", e);
            } catch (SecurityException e) {
                // Shouldn't happen if we are protecting the entry points correctly,
                // but just in case.
                Log.w(TAG, "No permission to access ContactsProvider.", e);
            }
        }
    }
@@ -124,7 +129,11 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {
     */
    public void fetchCalls(int callType, long newerThan) {
        cancelFetch();
        if (PermissionsUtil.hasPhonePermissions(mContext)) {
            fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, newerThan);
        } else {
            updateAdapterData(null);
        }
    }

    public void fetchCalls(int callType) {
@@ -187,6 +196,9 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {

    /** Updates all new calls to mark them as old. */
    public void markNewCallsAsOld() {
        if (!PermissionsUtil.hasPhonePermissions(mContext)) {
            return;
        }
        // Mark all "new" calls as not new anymore.
        StringBuilder where = new StringBuilder();
        where.append(Calls.NEW);
@@ -201,6 +213,9 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler {

    /** Updates all missed calls to mark them as read. */
    public void markMissedCallsAsRead() {
        if (!PermissionsUtil.hasPhonePermissions(mContext)) {
            return;
        }
        // Mark all "new" calls as not new anymore.
        StringBuilder where = new StringBuilder();
        where.append(Calls.IS_READ).append(" = 0");
+3 −0
Original line number Diff line number Diff line
@@ -1600,6 +1600,9 @@ public class DialpadFragment extends Fragment
     */
    private void queryLastOutgoingCall() {
        mLastNumberDialed = EMPTY_NUMBER;
        if (!PermissionsUtil.hasPhonePermissions(getActivity())) {
            return;
        }
        CallLogAsync.GetLastOutgoingCallArgs lastCallArgs =
                new CallLogAsync.GetLastOutgoingCallArgs(
                    getActivity(),