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);
}
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);
}
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);
}
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();
}
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);
}
};
}
}
}
Aggregations