Search in sources :

Example 1 with CarrierConfigManager

use of android.telephony.CarrierConfigManager in project platform_frameworks_base by android.

the class CaptivePortalLoginActivity method getUrlForCaptivePortal.

private URL getUrlForCaptivePortal() {
    String url = getIntent().getStringExtra(TelephonyIntents.EXTRA_REDIRECTION_URL_KEY);
    if (url.isEmpty()) {
        url = mCm.getCaptivePortalServerUrl();
    }
    final CarrierConfigManager configManager = getApplicationContext().getSystemService(CarrierConfigManager.class);
    final int subId = getIntent().getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultVoiceSubscriptionId());
    final String[] portalURLs = configManager.getConfigForSubId(subId).getStringArray(CarrierConfigManager.KEY_CARRIER_DEFAULT_REDIRECTION_URL_STRING_ARRAY);
    if (!ArrayUtils.isEmpty(portalURLs)) {
        for (String portalUrl : portalURLs) {
            if (url.startsWith(portalUrl)) {
                break;
            }
        }
        url = null;
    }
    try {
        return new URL(url);
    } catch (MalformedURLException e) {
        loge("Invalid captive portal URL " + url);
    }
    return null;
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL)

Example 2 with CarrierConfigManager

use of android.telephony.CarrierConfigManager in project android_frameworks_base by DirtyUnicorns.

the class Tethering method isTetherProvisioningRequired.

/**
     * Check if the device requires a provisioning check in order to enable tethering.
     *
     * @return a boolean - {@code true} indicating tether provisioning is required by the carrier.
     */
private boolean isTetherProvisioningRequired() {
    String[] provisionApp = mContext.getResources().getStringArray(com.android.internal.R.array.config_mobile_hotspot_provision_app);
    if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) || provisionApp == null) {
        return false;
    }
    // Check carrier config for entitlement checks
    final CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
    if (configManager != null && configManager.getConfig() != null) {
        // we do have a CarrierConfigManager and it has a config.
        boolean isEntitlementCheckRequired = configManager.getConfig().getBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL);
        if (!isEntitlementCheckRequired) {
            return false;
        }
    }
    return (provisionApp.length == 2);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager)

Example 3 with CarrierConfigManager

use of android.telephony.CarrierConfigManager in project android_frameworks_base by AOSPA.

the class Tethering method isTetherProvisioningRequired.

/**
     * Check if the device requires a provisioning check in order to enable tethering.
     *
     * @return a boolean - {@code true} indicating tether provisioning is required by the carrier.
     */
private boolean isTetherProvisioningRequired() {
    String[] provisionApp = mContext.getResources().getStringArray(com.android.internal.R.array.config_mobile_hotspot_provision_app);
    if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) || provisionApp == null) {
        return false;
    }
    // Check carrier config for entitlement checks
    final CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
    if (configManager != null && configManager.getConfig() != null) {
        // we do have a CarrierConfigManager and it has a config.
        boolean isEntitlementCheckRequired = configManager.getConfig().getBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL);
        if (!isEntitlementCheckRequired) {
            return false;
        }
    }
    return (provisionApp.length == 2);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager)

Example 4 with CarrierConfigManager

use of android.telephony.CarrierConfigManager in project android_frameworks_base by ResurrectionRemix.

the class Tethering method isTetherProvisioningRequired.

/**
     * Check if the device requires a provisioning check in order to enable tethering.
     *
     * @return a boolean - {@code true} indicating tether provisioning is required by the carrier.
     */
private boolean isTetherProvisioningRequired() {
    String[] provisionApp = mContext.getResources().getStringArray(com.android.internal.R.array.config_mobile_hotspot_provision_app);
    if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) || provisionApp == null) {
        return false;
    }
    // Check carrier config for entitlement checks
    final CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
    if (configManager != null && configManager.getConfig() != null) {
        // we do have a CarrierConfigManager and it has a config.
        boolean isEntitlementCheckRequired = configManager.getConfig().getBoolean(CarrierConfigManager.KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL);
        if (!isEntitlementCheckRequired) {
            return false;
        }
    }
    return (provisionApp.length == 2);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager)

Example 5 with CarrierConfigManager

use of android.telephony.CarrierConfigManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DeviceInfoSettings method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference.getKey().equals(KEY_FIRMWARE_VERSION) || preference.getKey().equals(KEY_MOD_VERSION)) {
        System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
        mHits[mHits.length - 1] = SystemClock.uptimeMillis();
        if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
            if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
                if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
                    RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mFunDisallowedAdmin);
                }
                Log.d(LOG_TAG, "Sorry, no fun for you!");
                return false;
            }
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.putExtra("is_lineage", preference.getKey().equals(KEY_MOD_VERSION));
            intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
            try {
                startActivity(intent);
            } catch (Exception e) {
                Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
            }
        }
    } else if (preference.getKey().equals(KEY_BUILD_NUMBER)) {
        // Don't enable developer options for secondary users.
        if (!mUm.isAdminUser())
            return true;
        // Don't enable developer options until device has been provisioned
        if (!Utils.isDeviceProvisioned(getActivity())) {
            return true;
        }
        if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
            if (mDebuggingFeaturesDisallowedAdmin != null && !mDebuggingFeaturesDisallowedBySystem) {
                RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mDebuggingFeaturesDisallowedAdmin);
            }
            return true;
        }
        if (mDevHitCountdown > 0) {
            mDevHitCountdown--;
            if (mDevHitCountdown == 0) {
                getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).edit().putBoolean(DevelopmentSettings.PREF_SHOW, true).apply();
                if (mDevHitToast != null) {
                    mDevHitToast.cancel();
                }
                mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on_cm, Toast.LENGTH_LONG);
                mDevHitToast.show();
                // This is good time to index the Developer Options
                Index.getInstance(getActivity().getApplicationContext()).updateFromClassNameResource(DevelopmentSettings.class.getName(), true, true);
            } else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
                if (mDevHitToast != null) {
                    mDevHitToast.cancel();
                }
                mDevHitToast = Toast.makeText(getActivity(), getResources().getQuantityString(R.plurals.show_dev_countdown_cm, mDevHitCountdown, mDevHitCountdown), Toast.LENGTH_SHORT);
                mDevHitToast.show();
            }
        } else if (mDevHitCountdown < 0) {
            if (mDevHitToast != null) {
                mDevHitToast.cancel();
            }
            mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already_cm, Toast.LENGTH_LONG);
            mDevHitToast.show();
        }
    } else if (preference.getKey().equals(KEY_SECURITY_PATCH)) {
        if (getPackageManager().queryIntentActivities(preference.getIntent(), 0).isEmpty()) {
            // Don't send out the intent to stop crash
            Log.w(LOG_TAG, "Stop click action on " + KEY_SECURITY_PATCH + ": " + "queryIntentActivities() returns empty");
            return true;
        }
    } else if (preference.getKey().equals(KEY_BUILD_TYPE)) {
        sendFeedback();
    } else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) {
        sendFeedback();
    } else if (preference.getKey().equals(KEY_SYSTEM_UPDATE_SETTINGS)) {
        CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
        PersistableBundle b = configManager.getConfig();
        if (b != null && b.getBoolean(CarrierConfigManager.KEY_CI_ACTION_ON_SYS_UPDATE_BOOL)) {
            ciActionOnSysUpdate(b);
        }
    } else if (preference.getKey().equals(KEY_KERNEL_VERSION)) {
        setStringSummary(KEY_KERNEL_VERSION, getKernelVersion());
        return true;
    }
    return super.onPreferenceTreeClick(preference);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent) IOException(java.io.IOException)

Aggregations

CarrierConfigManager (android.telephony.CarrierConfigManager)14 PersistableBundle (android.os.PersistableBundle)8 Intent (android.content.Intent)4 IntentFilter (android.content.IntentFilter)2 Activity (android.app.Activity)1 ComponentName (android.content.ComponentName)1 ContentValues (android.content.ContentValues)1 Uri (android.net.Uri)1 UserManager (android.os.UserManager)1 Settings (android.provider.Settings)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 Preference (android.support.v7.preference.Preference)1 PreferenceGroup (android.support.v7.preference.PreferenceGroup)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 SubscriptionInfo (android.telephony.SubscriptionInfo)1 SubscriptionManager (android.telephony.SubscriptionManager)1 TelephonyManager (android.telephony.TelephonyManager)1 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)1 FingerprintSettings (com.android.settings.fingerprint.FingerprintSettings)1 RestrictedPreference (com.android.settingslib.RestrictedPreference)1