diff options
author | Yorke Lee <yorkelee@google.com> | 2015-05-26 17:29:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-26 17:29:06 +0000 |
commit | 0c67130582059b989d8779ef59a0ac2d6eec04ca (patch) | |
tree | 14c6adf0267258aa70f00831edbd33f4d5dd589a /src | |
parent | 44ed26cfc052715acc7e3be088cb49b733ddef35 (diff) | |
parent | b7330e3802e8f9182ae1f5e54857a713b2f13547 (diff) |
Merge "Handle runtime phone permission" into mnc-dev
Diffstat (limited to 'src')
5 files changed, 30 insertions, 5 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index b159acf80..214f3206e 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -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(); } } diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index e8ed17ec6..f98fc2169 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -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); } diff --git a/src/com/android/dialer/calllog/CallLogNotificationsService.java b/src/com/android/dialer/calllog/CallLogNotificationsService.java index 22809db8c..9f48b0969 100644 --- a/src/com/android/dialer/calllog/CallLogNotificationsService.java +++ b/src/com/android/dialer/calllog/CallLogNotificationsService.java @@ -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())) { diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java index 49d6a4121..a0e563aef 100644 --- a/src/com/android/dialer/calllog/CallLogQueryHandler.java +++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java @@ -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(); - fetchCalls(QUERY_CALLLOG_TOKEN, callType, false /* newOnly */, newerThan); + 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"); diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index de1d44f89..89cab4162 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -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(), |