Fix createLaunchEmergencyDialerIntent API behavior when Telecom unavailable.

The API contract for createLaunchEmergencyDialerIntent indicates that
the return value is @NonNull, however the code clearly can return a null
value if either:
1. Telecom is unavailable.
2. There is a remote exception.

Since the API just returns a new ACTION_EMERGENCY_DIAL intent with the
package name of the emergency dialer (from Telecom string resources), we
can provide a reasonable fallback behavior by just returning a new
ACTION_EMERGENCY_DIAL intent with no targeted package.  The system will
still launch the emergency dialer in this case, but if there is a scenario
where multiple emergency dialers are installed on a device, the AOSP one
may get launched instead.  This is, however, better than there being NO
emergency dialer launched.

Test: Comment out call to Telecom service and verify the AOSP emergency
dialer still launches.
Bug: 152187752
Fixes: 155097434
Merged-In: I1665d456dace8e41cc035e792f319d98dd07219c
Change-Id: I06f8a5bebace5b22822f7bb714e14915126b904f
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 15b26dc..08f31a9 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -2202,15 +2202,23 @@
     @NonNull
     public Intent createLaunchEmergencyDialerIntent(@Nullable String number) {
         ITelecomService service = getTelecomService();
-        Intent result = null;
         if (service != null) {
             try {
-                result = service.createLaunchEmergencyDialerIntent(number);
+                return service.createLaunchEmergencyDialerIntent(number);
             } catch (RemoteException e) {
                 Log.e(TAG, "Error createLaunchEmergencyDialerIntent", e);
             }
+        } else {
+            Log.w(TAG, "createLaunchEmergencyDialerIntent - Telecom service not available.");
         }
-        return result;
+
+        // Telecom service knows the package name of the expected emergency dialer package; if it
+        // is not available, then fallback to not targeting a specific package.
+        Intent intent = new Intent(Intent.ACTION_DIAL_EMERGENCY);
+        if (!TextUtils.isEmpty(number) && TextUtils.isDigitsOnly(number)) {
+            intent.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null));
+        }
+        return intent;
     }
 
     /**