am e9fd5209: am 57231395: am 0ef3eee3: Merge "Disallow non-emergency phone calls for restricted users" into lmp-dev
* commit 'e9fd520985dd23c9356b9dc4a7d6262d8cc5587d':
Disallow non-emergency phone calls for restricted users
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f2f80ee..981c131 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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. -->
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 06cc9cb..10db104 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -23,11 +23,12 @@
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 @@
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);