Search in sources :

Example 1 with SubscriptionInfo

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

the class KeyguardUpdateMonitor method getNextSubIdForState.

/**
     * Find the next SubscriptionId for a SIM in the given state, favoring lower slot numbers first.
     * @param state
     * @return subid or {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID} if none found
     */
public int getNextSubIdForState(State state) {
    List<SubscriptionInfo> list = getSubscriptionInfo(false);
    int resultId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    // Favor lowest slot first
    int bestSlotId = Integer.MAX_VALUE;
    for (int i = 0; i < list.size(); i++) {
        final SubscriptionInfo info = list.get(i);
        final int id = info.getSubscriptionId();
        int slotId = SubscriptionManager.getSlotId(id);
        if (state == getSimState(id) && bestSlotId > slotId) {
            resultId = id;
            bestSlotId = slotId;
        }
    }
    return resultId;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 2 with SubscriptionInfo

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

the class KeyguardUpdateMonitor method handleSimSubscriptionInfoChanged.

protected void handleSimSubscriptionInfoChanged() {
    if (DEBUG_SIM_STATES) {
        Log.v(TAG, "onSubscriptionInfoChanged()");
        List<SubscriptionInfo> sil = mSubscriptionManager.getActiveSubscriptionInfoList();
        if (sil != null) {
            for (SubscriptionInfo subInfo : sil) {
                Log.v(TAG, "SubInfo:" + subInfo);
            }
        } else {
            Log.v(TAG, "onSubscriptionInfoChanged: list is null");
        }
    }
    List<SubscriptionInfo> subscriptionInfos = getSubscriptionInfo(true);
    // Hack level over 9000: Because the subscription id is not yet valid when we see the
    // first update in handleSimStateChange, we need to force refresh all all SIM states
    // so the subscription id for them is consistent.
    ArrayList<SubscriptionInfo> changedSubscriptions = new ArrayList<>();
    for (int i = 0; i < subscriptionInfos.size(); i++) {
        SubscriptionInfo info = subscriptionInfos.get(i);
        boolean changed = refreshSimState(info.getSubscriptionId(), info.getSimSlotIndex());
        if (changed) {
            changedSubscriptions.add(info);
        }
    }
    for (int i = 0; i < changedSubscriptions.size(); i++) {
        SimData data = mSimDatas.get(changedSubscriptions.get(i).getSubscriptionId());
        for (int j = 0; j < mCallbacks.size(); j++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get();
            if (cb != null) {
                cb.onSimStateChanged(data.subId, data.slotId, data.simState);
            }
        }
    }
    for (int j = 0; j < mCallbacks.size(); j++) {
        KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get();
        if (cb != null) {
            cb.onRefreshCarrierInfo();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) Fingerprint(android.hardware.fingerprint.Fingerprint)

Example 3 with SubscriptionInfo

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

the class NetworkControllerImpl method addSignalController.

private SubscriptionInfo addSignalController(int id, int simSlotIndex) {
    SubscriptionInfo info = new SubscriptionInfo(id, "", simSlotIndex, "", "", 0, 0, "", 0, null, 0, 0, "", 0);
    mMobileSignalControllers.put(id, new MobileSignalController(mContext, mConfig, mHasMobileDataFeature, mPhone, mCallbackHandler, this, info, mSubDefaults, mReceiverHandler.getLooper()));
    return info;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 4 with SubscriptionInfo

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

the class NetworkControllerBaseTest method setSubscriptions.

protected void setSubscriptions(int... subIds) {
    List<SubscriptionInfo> subs = new ArrayList<SubscriptionInfo>();
    for (int subId : subIds) {
        SubscriptionInfo subscription = mock(SubscriptionInfo.class);
        when(subscription.getSubscriptionId()).thenReturn(subId);
        subs.add(subscription);
    }
    when(mMockSm.getActiveSubscriptionInfoList()).thenReturn(subs);
    mNetworkController.doUpdateMobileControllers();
}
Also used : ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 5 with SubscriptionInfo

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

the class UserRestrictionsUtils method applyUserRestriction.

/**
     * Apply each user restriction.
     *
     * <p>See also {@link
     * com.android.providers.settings.SettingsProvider#isGlobalOrSecureSettingRestrictedForUser},
     * which should be in sync with this method.
     */
private static void applyUserRestriction(Context context, int userId, String key, boolean newValue) {
    if (UserManagerService.DBG) {
        Log.d(TAG, "Applying user restriction: userId=" + userId + " key=" + key + " value=" + newValue);
    }
    // When certain restrictions are cleared, we don't update the system settings,
    // because these settings are changeable on the Settings UI and we don't know the original
    // value -- for example LOCATION_MODE might have been off already when the restriction was
    // set, and in that case even if the restriction is lifted, changing it to ON would be
    // wrong.  So just don't do anything in such a case.  If the user hopes to enable location
    // later, they can do it on the Settings UI.
    // WARNING: Remember that Settings.Global and Settings.Secure are changeable via adb.
    // To prevent this from happening for a given user restriction, you have to add a check to
    // SettingsProvider.isGlobalOrSecureSettingRestrictedForUser.
    final ContentResolver cr = context.getContentResolver();
    final long id = Binder.clearCallingIdentity();
    try {
        switch(key) {
            case UserManager.DISALLOW_CONFIG_WIFI:
                if (newValue) {
                    android.provider.Settings.Secure.putIntForUser(cr, android.provider.Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0, userId);
                }
                break;
            case UserManager.DISALLOW_DATA_ROAMING:
                if (newValue) {
                    // DISALLOW_DATA_ROAMING user restriction is set.
                    // Multi sim device.
                    SubscriptionManager subscriptionManager = new SubscriptionManager(context);
                    final List<SubscriptionInfo> subscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
                    if (subscriptionInfoList != null) {
                        for (SubscriptionInfo subInfo : subscriptionInfoList) {
                            android.provider.Settings.Global.putStringForUser(cr, android.provider.Settings.Global.DATA_ROAMING + subInfo.getSubscriptionId(), "0", userId);
                        }
                    }
                    // Single sim device.
                    android.provider.Settings.Global.putStringForUser(cr, android.provider.Settings.Global.DATA_ROAMING, "0", userId);
                }
                break;
            case UserManager.DISALLOW_SHARE_LOCATION:
                if (newValue) {
                    android.provider.Settings.Secure.putIntForUser(cr, android.provider.Settings.Secure.LOCATION_MODE, android.provider.Settings.Secure.LOCATION_MODE_OFF, userId);
                }
                break;
            case UserManager.DISALLOW_DEBUGGING_FEATURES:
                if (newValue) {
                    // TODO: should this be admin user?
                    if (userId == UserHandle.USER_SYSTEM) {
                        android.provider.Settings.Global.putStringForUser(cr, android.provider.Settings.Global.ADB_ENABLED, "0", userId);
                    }
                }
                break;
            case UserManager.ENSURE_VERIFY_APPS:
                if (newValue) {
                    android.provider.Settings.Global.putStringForUser(context.getContentResolver(), android.provider.Settings.Global.PACKAGE_VERIFIER_ENABLE, "1", userId);
                    android.provider.Settings.Global.putStringForUser(context.getContentResolver(), android.provider.Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, "1", userId);
                }
                break;
            case UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES:
                if (newValue) {
                    android.provider.Settings.Secure.putIntForUser(cr, android.provider.Settings.Secure.INSTALL_NON_MARKET_APPS, 0, userId);
                }
                break;
            case UserManager.DISALLOW_RUN_IN_BACKGROUND:
                if (newValue) {
                    int currentUser = ActivityManager.getCurrentUser();
                    if (currentUser != userId && userId != UserHandle.USER_SYSTEM) {
                        try {
                            ActivityManagerNative.getDefault().stopUser(userId, false, null);
                        } catch (RemoteException e) {
                            throw e.rethrowAsRuntimeException();
                        }
                    }
                }
                break;
            case UserManager.DISALLOW_SAFE_BOOT:
                // Unlike with the other restrictions, we want to propagate the new value to
                // the system settings even if it is false. The other restrictions modify
                // settings which could be manually changed by the user from the Settings app
                // after the policies enforcing these restrictions have been revoked, so we
                // leave re-setting of those settings to the user.
                android.provider.Settings.Global.putInt(context.getContentResolver(), android.provider.Settings.Global.SAFE_BOOT_DISALLOWED, newValue ? 1 : 0);
                break;
            case UserManager.DISALLOW_FACTORY_RESET:
            case UserManager.DISALLOW_OEM_UNLOCK:
                if (newValue) {
                    PersistentDataBlockManager manager = (PersistentDataBlockManager) context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
                    if (manager != null && manager.getOemUnlockEnabled() && manager.getFlashLockState() != PersistentDataBlockManager.FLASH_LOCK_UNLOCKED) {
                        // Only disable OEM unlock if the bootloader is locked. If it's already
                        // unlocked, setting the OEM unlock enabled flag to false has no effect
                        // (the bootloader would remain unlocked).
                        manager.setOemUnlockEnabled(false);
                    }
                }
                break;
        }
    } finally {
        Binder.restoreCallingIdentity(id);
    }
}
Also used : PersistentDataBlockManager(android.service.persistentdata.PersistentDataBlockManager) SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Aggregations

SubscriptionInfo (android.telephony.SubscriptionInfo)335 TelephonyManager (android.telephony.TelephonyManager)64 SubscriptionManager (android.telephony.SubscriptionManager)63 ArrayList (java.util.ArrayList)53 Test (org.junit.Test)49 Context (android.content.Context)38 Intent (android.content.Intent)38 Preference (android.support.v7.preference.Preference)27 PhoneAccountHandle (android.telecom.PhoneAccountHandle)18 IntentFilter (android.content.IntentFilter)16 Resources (android.content.res.Resources)16 ConnectivityManager (android.net.ConnectivityManager)15 Preference (androidx.preference.Preference)15 AlertDialog (android.app.AlertDialog)14 DialogInterface (android.content.DialogInterface)14 DataUsageController (com.android.settingslib.net.DataUsageController)14 View (android.view.View)13 PhoneAccount (android.telecom.PhoneAccount)11 TelecomManager (android.telecom.TelecomManager)11 PendingIntent (android.app.PendingIntent)9