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

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

Merge "Disallow non-emergency phone calls for restricted users" into lmp-dev

parents 0fbe6321 35bcc89c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -91,6 +91,10 @@
    <!-- Indication to not use a SIM call manager -->
    <string name="do_not_use_sim_call_manager">Do not use Wi-Fi calling</string>

    <!-- Message indicating that the user is not allowed to make non-emergency outgoing phone calls
         due to a user restriction -->
    <string name="outgoing_call_not_allowed">This user is not allowed to make non-emergency phone calls</string>

    <!-- DO NOT TRANSLATE. Label for test Subscription 0. -->
    <string name="test_account_0_label">Q Mobile</string>
    <!-- DO NOT TRANSLATE. Label for test Subscription 1. -->
+15 −1
Original line number Diff line number Diff line
@@ -23,11 +23,12 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserManager;
import android.telecomm.PhoneAccountHandle;
import android.telecomm.TelecommManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.widget.Toast;

/**
 * Activity that handles system CALL actions and forwards them to {@link CallsManager}.
@@ -120,6 +121,19 @@ public class CallActivity extends Activity {
        String uriString = intent.getData().getSchemeSpecificPart();
        Uri handle = Uri.fromParts(
                PhoneNumberUtils.isUriNumber(uriString) ? "sip" : "tel", uriString, null);

        UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
        if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS)
                && !TelephonyUtil.shouldProcessAsEmergency(this, handle)) {
            // Only emergency calls are allowed for users with the DISALLOW_OUTGOING_CALLS
            // restriction.
            Toast.makeText(this, getResources().getString(R.string.outgoing_call_not_allowed),
                    Toast.LENGTH_SHORT).show();
            Log.d(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS "
                    + "restriction");
            return;
        }

        PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
                TelecommManager.EXTRA_PHONE_ACCOUNT_HANDLE);