Search in sources :

Example 21 with ServiceState

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

the class NetworkControllerSignalTest method testNoEmengencyNoSubscriptions.

public void testNoEmengencyNoSubscriptions() {
    setupDefaultSignal();
    setSubscriptions();
    mNetworkController.mLastServiceState = new ServiceState();
    mNetworkController.mLastServiceState.setEmergencyOnly(false);
    mNetworkController.recalculateEmergency();
    verifyEmergencyOnly(false);
}
Also used : ServiceState(android.telephony.ServiceState)

Example 22 with ServiceState

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

the class NetworkControllerSignalTest method testEmergencyOnlyNoSubscriptions.

public void testEmergencyOnlyNoSubscriptions() {
    setupDefaultSignal();
    setSubscriptions();
    mNetworkController.mLastServiceState = new ServiceState();
    mNetworkController.mLastServiceState.setEmergencyOnly(true);
    mNetworkController.recalculateEmergency();
    verifyEmergencyOnly(true);
}
Also used : ServiceState(android.telephony.ServiceState)

Example 23 with ServiceState

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

the class TelephonyRegistry method notifyServiceStateForPhoneId.

public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
    if (!checkNotifyPermission("notifyServiceState()")) {
        return;
    }
    synchronized (mRecords) {
        if (VDBG) {
            log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId + " state=" + state);
        }
        if (validatePhoneId(phoneId)) {
            mServiceState[phoneId] = state;
            logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
            if (VDBG)
                toStringLogSSC("notifyServiceStateForSubscriber");
            for (Record r : mRecords) {
                if (VDBG) {
                    log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state);
                }
                if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && idMatch(r.subId, subId, phoneId)) {
                    try {
                        if (DBG) {
                            log("notifyServiceStateForSubscriber: callback.onSSC r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state);
                        }
                        r.callback.onServiceStateChanged(new ServiceState(state));
                    } catch (RemoteException ex) {
                        mRemoveList.add(r.binder);
                    }
                }
            }
        } else {
            log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
        }
        handleRemoveListLocked();
    }
    broadcastServiceStateChanged(state, phoneId, subId);
}
Also used : VoLteServiceState(android.telephony.VoLteServiceState) ServiceState(android.telephony.ServiceState) RemoteException(android.os.RemoteException)

Example 24 with ServiceState

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

the class GlobalActions method setupAirplaneModeListeners.

/**
     * Since there are two ways of handling airplane mode (with telephony, we depend on the internal
     * device telephony state), and MSIM devices do not report phone state for missing SIMs, we
     * need to dynamically setup listeners based on subscription changes.
     *
     * So if there is _any_ active SIM in the device, we can depend on the phone state,
     * otherwise fall back to {@link Settings.Global#AIRPLANE_MODE_ON}.
     */
private void setupAirplaneModeListeners() {
    TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    for (PhoneStateListener listener : mPhoneStateListeners) {
        telephonyManager.listen(listener, PhoneStateListener.LISTEN_NONE);
    }
    mPhoneStateListeners.clear();
    final List<SubscriptionInfo> subInfoList = SubscriptionManager.from(mContext).getActiveSubscriptionInfoList();
    if (subInfoList != null) {
        mHasTelephony = true;
        mAirplaneModeBits = new BitSet(subInfoList.size());
        for (int i = 0; i < subInfoList.size(); i++) {
            final int finalI = i;
            PhoneStateListener subListener = new PhoneStateListener(subInfoList.get(finalI).getSubscriptionId()) {

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
                    mAirplaneModeBits.set(finalI, inAirplaneMode);
                    // we're in airplane mode if _any_ of the subscriptions say we are
                    mAirplaneState = mAirplaneModeBits.cardinality() > 0 ? ToggleAction.State.On : ToggleAction.State.Off;
                    mAirplaneModeOn.updateState(mAirplaneState);
                    if (mAdapter != null) {
                        mAdapter.notifyDataSetChanged();
                    }
                }
            };
            mPhoneStateListeners.add(subListener);
            telephonyManager.listen(subListener, PhoneStateListener.LISTEN_SERVICE_STATE);
        }
    } else {
        mHasTelephony = false;
    }
    // Set the initial status of airplane mode toggle
    mAirplaneState = getUpdatedAirplaneToggleState();
}
Also used : ServiceState(android.telephony.ServiceState) TelephonyManager(android.telephony.TelephonyManager) PhoneStateListener(android.telephony.PhoneStateListener) BitSet(java.util.BitSet) SubscriptionInfo(android.telephony.SubscriptionInfo) Paint(android.graphics.Paint)

Example 25 with ServiceState

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

the class SimStatus method updatePhoneInfos.

private void updatePhoneInfos() {
    if (mSir != null) {
        // TODO: http://b/23763013
        final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(mSir.getSubscriptionId()));
        if (UserManager.get(getContext()).isAdminUser() && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
            if (phone == null) {
                Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
                return;
            }
            mPhone = phone;
            //avoid left at TelephonyManager Memory leak before create a new PhoneStateLister
            if (mPhoneStateListener != null && mTelephonyManager != null) {
                mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
            }
            mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) {

                @Override
                public void onDataConnectionStateChanged(int state) {
                    updateDataState();
                    updateNetworkType();
                }

                @Override
                public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                    updateSignalStrength(signalStrength);
                }

                @Override
                public void onServiceStateChanged(ServiceState serviceState) {
                    updateServiceState(serviceState);
                }
            };
        }
    }
}
Also used : ServiceState(android.telephony.ServiceState) Phone(com.android.internal.telephony.Phone) PhoneStateListener(android.telephony.PhoneStateListener) SignalStrength(android.telephony.SignalStrength)

Aggregations

ServiceState (android.telephony.ServiceState)55 RemoteException (android.os.RemoteException)19 VoLteServiceState (android.telephony.VoLteServiceState)15 Bundle (android.os.Bundle)11 PhoneStateListener (android.telephony.PhoneStateListener)10 SubscriptionInfo (android.telephony.SubscriptionInfo)7 IBinder (android.os.IBinder)6 SignalStrength (android.telephony.SignalStrength)6 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 State (com.android.internal.telephony.IccCardConstants.State)5 TelephonyManager (android.telephony.TelephonyManager)3 Paint (android.graphics.Paint)2 Fingerprint (android.hardware.fingerprint.Fingerprint)2 CdmaCellLocation (android.telephony.cdma.CdmaCellLocation)2 BitSet (java.util.BitSet)2 LinkCapabilities (android.net.LinkCapabilities)1 LinkProperties (android.net.LinkProperties)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 Phone (com.android.internal.telephony.Phone)1