Search in sources :

Example 1 with R

use of android.os.Build.VERSION_CODES.R in project robolectric by robolectric.

the class ShadowTelecomManager method createLaunchEmergencyDialerIntent.

@Implementation(minSdk = R)
@SystemApi
protected Intent createLaunchEmergencyDialerIntent(String number) {
    // copy of logic from TelecomManager service
    Context context = ReflectionHelpers.getField(realObject, "mContext");
    // use reflection to get resource id since it can vary based on SDK version, and compiler will
    // inline the value if used explicitly
    int configEmergencyDialerPackageId = ReflectionHelpers.getStaticField(com.android.internal.R.string.class, "config_emergency_dialer_package");
    String packageName = context.getString(configEmergencyDialerPackageId);
    Intent intent = new Intent(Intent.ACTION_DIAL_EMERGENCY).setPackage(packageName);
    ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, 0);
    if (resolveInfo == null) {
        // No matching activity from config, fallback to default platform implementation
        intent.setPackage(null);
    }
    if (!TextUtils.isEmpty(number) && TextUtils.isDigitsOnly(number)) {
        intent.setData(Uri.parse("tel:" + number));
    }
    return intent;
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) R(android.os.Build.VERSION_CODES.R) Intent(android.content.Intent) SystemApi(android.annotation.SystemApi) Implementation(org.robolectric.annotation.Implementation)

Aggregations

SystemApi (android.annotation.SystemApi)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 R (android.os.Build.VERSION_CODES.R)1 Implementation (org.robolectric.annotation.Implementation)1