Ensure access to multiple call settings is restricted.

This CL check if access to mobile network configurations are restricted before displaying the button to select CdmaCallForwardOptions, GsmUmtsCallForwardOptions, GsmUmtsAdditionalCallOptions, and GsmUmtsCallBarringOptions. This reolves a security vulnerability where users were able to configure these call settings mobile network setting even after the device owner had applied the no_config_mobile_networks restriction. This CL also prevents these classes from being exported and  reverts a less thorough fix to this issue that had been previously applied.

Fixes: 277579183
Test: Manual using adb + POC malicous apk
Change-Id: I9b12cbf5d5b9a1356e7d06ae7583d6c5047db31c
diff --git a/src/com/android/phone/GsmUmtsCallOptions.java b/src/com/android/phone/GsmUmtsCallOptions.java
index 51d1b66..8ff7ecc 100644
--- a/src/com/android/phone/GsmUmtsCallOptions.java
+++ b/src/com/android/phone/GsmUmtsCallOptions.java
@@ -16,13 +16,16 @@
 
 package com.android.phone;
 
+import android.content.Context;
 import android.os.Bundle;
 import android.os.PersistableBundle;
+import android.os.UserManager;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
 import android.provider.Settings;
 import android.telephony.CarrierConfigManager;
+import android.util.Log;
 import android.view.MenuItem;
 
 import com.android.internal.telephony.PhoneConstants;
@@ -79,10 +82,22 @@
             isAirplaneModeOff = PhoneGlobals.AIRPLANE_ON != airplaneMode;
         }
 
+        // If mobile network configs are restricted, then hide the GsmUmtsCallForwardOptions,
+        // GsmUmtsAdditionalCallOptions, and GsmUmtsCallBarringOptions.
+        UserManager userManager = (UserManager) subInfoHelper.getPhone().getContext()
+                .getSystemService(Context.USER_SERVICE);
+        boolean mobileNetworkConfigsRestricted =
+                userManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
+        if (mobileNetworkConfigsRestricted) {
+            Log.i(LOG_TAG, "Mobile network configs are restricted, hiding GSM call "
+                    + "forwarding, additional call settings, and call options.");
+        }
+
         Preference callForwardingPref = prefScreen.findPreference(CALL_FORWARDING_KEY);
         if (callForwardingPref != null) {
             if (b != null && b.getBoolean(
-                    CarrierConfigManager.KEY_CALL_FORWARDING_VISIBILITY_BOOL)) {
+                    CarrierConfigManager.KEY_CALL_FORWARDING_VISIBILITY_BOOL) &&
+                    !mobileNetworkConfigsRestricted) {
                 callForwardingPref.setIntent(
                         subInfoHelper.getIntent(GsmUmtsCallForwardOptions.class));
                 callForwardingPref.setEnabled(isAirplaneModeOff);
@@ -97,7 +112,8 @@
             if (b != null && (b.getBoolean(
                     CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL)
                     || b.getBoolean(
-                    CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL))) {
+                    CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL)) &&
+                    !mobileNetworkConfigsRestricted) {
                 additionalGsmSettingsPref.setIntent(
                         subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
                 additionalGsmSettingsPref.setEnabled(isAirplaneModeOff);
@@ -108,7 +124,8 @@
 
         Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
         if (callBarringPref != null) {
-            if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
+            if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL) &&
+                    !mobileNetworkConfigsRestricted) {
                 callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
                 callBarringPref.setEnabled(isAirplaneModeOff);
             } else {