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

Commit 4fc601a6 authored by Yorke Lee's avatar Yorke Lee
Browse files

Catch ActivityNotFoundException in quick contacts badge

Bug: 12015287
Change-Id: I2fa5daaa54cc7cc0cad9dee0828d751302cb5be7
parent 6018d014
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.provider;

import android.accounts.Account;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
@@ -40,6 +41,7 @@ import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.View;
import android.widget.Toast;

import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -7978,7 +7980,7 @@ public final class ContactsContract {
            // Trigger with obtained rectangle
            Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
                    excludeMimes);
            context.startActivity(intent);
            startActivityWithErrorToast(context, intent);
        }

        /**
@@ -8011,7 +8013,16 @@ public final class ContactsContract {
                String[] excludeMimes) {
            Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
                    excludeMimes);
            startActivityWithErrorToast(context, intent);
        }

        private static void startActivityWithErrorToast(Context context, Intent intent) {
            try {
              context.startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(context, com.android.internal.R.string.quick_contacts_not_available,
                                Toast.LENGTH_SHORT).show();
            }
        }
    }

+6 −2
Original line number Diff line number Diff line
@@ -2252,6 +2252,10 @@
    <!-- Other SIP address type. Same context as Other phone type. -->
    <string name="sipAddressTypeOther">Other</string>

    <!-- Error message that is displayed when the user clicks on a quick contacts badge, but
         there is no contacts application installed that can display the quick contact -->
    <string name="quick_contacts_not_available">No activity found to view contact.</string>

    <!-- Instructions telling the user to enter their SIM PIN to unlock the keyguard.
         Displayed in one line in a large font.  -->
    <string name="keyguard_password_enter_pin_code">Type PIN code</string>
+1 −0
Original line number Diff line number Diff line
@@ -687,6 +687,7 @@
  <java-symbol type="string" name="mobile_provisioning_apn" />
  <java-symbol type="string" name="mobile_provisioning_url" />
  <java-symbol type="string" name="mobile_redirected_provisioning_url" />
  <java-symbol type="string" name="quick_contacts_not_available" />
  <java-symbol type="string" name="reboot_safemode_confirm" />
  <java-symbol type="string" name="reboot_safemode_title" />
  <java-symbol type="string" name="relationTypeAssistant" />