Java Code Examples for android.telephony.ServiceState#STATE_POWER_OFF

The following examples show how to use android.telephony.ServiceState#STATE_POWER_OFF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RetroWatchService.java    From retrowatch with Apache License 2.0 6 votes vote down vote up
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	Logs.d("# PhoneStateListener - onServiceStateChanged();");
	int state = serviceState.getState();
	
	switch (state) {
	case ServiceState.STATE_IN_SERVICE:
		Logs.d("# PhoneStateListener - onServiceStateChanged(); - reserve update");
		reserveRemoteUpdate(DEFAULT_UPDATE_DELAY);
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
	case ServiceState.STATE_EMERGENCY_ONLY:
	case ServiceState.STATE_POWER_OFF:
		ContentObject co = mContentManager.addRFStateObject(state);
		if(mActivityHandler != null)
			mActivityHandler.obtainMessage(Constants.MESSAGE_RF_STATE_RECEIVED, co).sendToTarget();
		// send to device
		if(co != null)
			sendContentsToDevice(co);
		else
			deleteEmergencyOfDevice(EmergencyObject.EMERGENCY_TYPE_RF_STATE);
		break;
	}
}
 
Example 2
Source File: RetroWatchService.java    From retrowatch with Apache License 2.0 6 votes vote down vote up
@Override
public void onServiceStateChanged(ServiceState serviceState) {
	int state = serviceState.getState();
	
	switch (state) {
	case ServiceState.STATE_IN_SERVICE:
	case ServiceState.STATE_OUT_OF_SERVICE:
	case ServiceState.STATE_EMERGENCY_ONLY:
	case ServiceState.STATE_POWER_OFF:
		ContentObject co = mContentManager.addRFStateObject(state);
		if(mActivityHandler != null)
			mActivityHandler.obtainMessage(Constants.MESSAGE_RF_STATE_RECEIVED, co).sendToTarget();
		// send to device
		if(co != null)
			sendContentsToDevice(co);
		else
			deleteEmergencyOfDevice(EmergencyObject.EMERGENCY_TYPE_RF_STATE);
		break;
	}
}
 
Example 3
Source File: LegacyGlobalActions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onServiceStateChanged(ServiceState serviceState) {
    if (!mHasTelephony) return;
    final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
    mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off;
    mAirplaneModeOn.updateState(mAirplaneState);
    mAdapter.notifyDataSetChanged();
}
 
Example 4
Source File: PieController.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public String getOperatorState() {
    if (!mHasTelephony) {
        return null;
    }
    if (mServiceState == null || mServiceState.getState() == ServiceState.STATE_OUT_OF_SERVICE) {
        return mGbResources.getString(R.string.pie_phone_status_no_service);
    }
    if (mServiceState.getState() == ServiceState.STATE_POWER_OFF) {
        return mGbResources.getString(R.string.pie_phone_status_airplane_mode);
    }
    if ((Boolean)XposedHelpers.callMethod(mServiceState, "isEmergencyOnly")) {
        return mGbResources.getString(R.string.pie_phone_status_emergency_only);
    }
    return mServiceState.getOperatorAlphaLong();
}
 
Example 5
Source File: DataConnectionStats.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private boolean hasService() {
    return mServiceState != null
            && mServiceState.getState() != ServiceState.STATE_OUT_OF_SERVICE
            && mServiceState.getState() != ServiceState.STATE_POWER_OFF;
}