當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceState.STATE_OUT_OF_SERVICE屬性代碼示例

本文整理匯總了Java中android.telephony.ServiceState.STATE_OUT_OF_SERVICE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ServiceState.STATE_OUT_OF_SERVICE屬性的具體用法?Java ServiceState.STATE_OUT_OF_SERVICE怎麽用?Java ServiceState.STATE_OUT_OF_SERVICE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.telephony.ServiceState的用法示例。


在下文中一共展示了ServiceState.STATE_OUT_OF_SERVICE屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServiceStateName

public String getServiceStateName (int state)
{
    String name = "";
    if (state >= 10)
    {
        name = "roam ";
        if (state == 10)
            return name;
        else
            state = state - 10;
    }
    switch (state)
    {
        case ServiceState.STATE_OUT_OF_SERVICE:
            name += "no service"; break;
        case ServiceState.STATE_EMERGENCY_ONLY:
            name += "911 only"; break;
        case PhoneState.SERVICE_STATE_AIRPLANE:
            name += "airplane"; break;
        case ServiceState.STATE_IN_SERVICE:
            name += "in service"; break;
        case ServiceState.STATE_POWER_OFF:
            name += "power off"; break;
    }
    return name;
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:26,代碼來源:QosInfo.java

示例2: onServiceStateChanged

@Override
public void onServiceStateChanged(ServiceState serviceState)
{
	switch (serviceState.getState())
	{
		case ServiceState.STATE_EMERGENCY_ONLY:
		case ServiceState.STATE_OUT_OF_SERVICE:
			NetworkStateService.setMobileOutOfService(true);
			LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
			break;

		default:
			{
				NetworkStateService.setMobileOutOfService(false);

				// If the device is network roaming but mobile data roaming is disabled, this
				// broadcast is necessary to properly update the widget on service state changes.
				if ((serviceState.getState() == ServiceState.STATE_IN_SERVICE) && serviceState.getRoaming())
					LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(Constants.ACTION_SERVICE_STATE_CHANGED));
			}
			break;
	}
}
 
開發者ID:ultrafunk,項目名稱:NetInfo,代碼行數:23,代碼來源:MobileDataStateListener.java

示例3: getServiceState

/**
 * Get the service state
 * 
 * @see ServiceState#STATE_EMERGENCY_ONLY
 * @see ServiceState#STATE_IN_SERVICE
 * @see ServiceState#STATE_OUT_OF_SERVICE
 * @see ServiceState#STATE_POWER_OFF
 * @return service state
 */
public String getServiceState() {
	if (DBG)
		Log.d(Config.TAG, TAG + "getServiceState called");
	switch (mServiceStage) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		return "Emergency Only";
	case ServiceState.STATE_IN_SERVICE:
		return "In Service";
	case ServiceState.STATE_POWER_OFF:
		return "Power Off";
	case ServiceState.STATE_OUT_OF_SERVICE:
		return "Out Of Service";
	default:
		return "Unknown";
	}
}
 
開發者ID:adetalhouet,項目名稱:SignalAnalysis,代碼行數:25,代碼來源:PhoneStateHelper.java

示例4: onServiceStateChanged

@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;
	}
}
 
開發者ID:godstale,項目名稱:retrowatch,代碼行數:24,代碼來源:RetroWatchService.java

示例5: onServiceStateChanged

@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;
	}
}
 
開發者ID:godstale,項目名稱:retrowatch,代碼行數:20,代碼來源:RetroWatchService.java

示例6: getOperatorState

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();
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:15,代碼來源:PieController.java

示例7: onServiceStateChanged

public void onServiceStateChanged(ServiceState serviceState)
{
	TextView myservicestate = (TextView)findViewById(R.id.myservicestate);
	int state = serviceState.getState();
	switch(state){
		case ServiceState.STATE_EMERGENCY_ONLY: myservicestate.setText("EMERGENCY ONLY"); break;
		case ServiceState.STATE_IN_SERVICE: myservicestate.setText("IN SERVICE"); break;
		case ServiceState.STATE_OUT_OF_SERVICE: myservicestate.setText("OUT OF SERVICE"); break;
		case ServiceState.STATE_POWER_OFF: myservicestate.setText("POWER OFF"); break;
	}
}
 
開發者ID:baharxy,項目名稱:mobility-logger,代碼行數:11,代碼來源:MainActivity.java

示例8: onServiceStateChanged

@Override
public void onServiceStateChanged(ServiceState serviceState) {
	super.onServiceStateChanged(serviceState);
	String phonestate = "";
	// set the state of the service - serviceState according to the value in
	// serviceState
	switch (serviceState.getState()) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		if (PhoneNumberUtils.isEmergencyNumber(this.number))
			phonestate = context.getResources().getString(
					R.string.state_in_service);
		else
			phonestate = context.getResources().getString(
					R.string.emergency_calls_only);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
		phonestate = context.getResources().getString(R.string.no_service);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_POWER_OFF:
		phonestate = context.getResources().getString(R.string.power_off);
		setServiceState(phonestate);
		break;
	case ServiceState.STATE_IN_SERVICE:
		phonestate = context.getResources().getString(
				R.string.state_in_service);
		setServiceState(phonestate);
		break;
	default:
		phonestate = context.getResources().getString(
				R.string.service_unknown_reason);
		setServiceState(phonestate);
	}
}
 
開發者ID:saurabh2590,項目名稱:EasyAccess,代碼行數:35,代碼來源:CallManager.java

示例9: onServiceStateChanged

public void onServiceStateChanged(ServiceState serviceState) {
	switch (serviceState.getState()) {
	case ServiceState.STATE_EMERGENCY_ONLY:
		powerEstimator.writeToLog("phone-service emergency-only\n");
		break;
	case ServiceState.STATE_IN_SERVICE:
		powerEstimator.writeToLog("phone-service in-service\n");
		switch (phoneManager.getNetworkType()) {
		case (TelephonyManager.NETWORK_TYPE_EDGE):
			powerEstimator.writeToLog("phone-network edge\n");
			break;
		case (TelephonyManager.NETWORK_TYPE_GPRS):
			powerEstimator.writeToLog("phone-network GPRS\n");
			break;
		case 8:
			powerEstimator.writeToLog("phone-network HSDPA\n");
			break;
		case (TelephonyManager.NETWORK_TYPE_UMTS):
			powerEstimator.writeToLog("phone-network UMTS\n");
			break;
		default:
			powerEstimator.writeToLog("phone-network "
					+ phoneManager.getNetworkType() + "\n");
		}
		break;
	case ServiceState.STATE_OUT_OF_SERVICE:
		powerEstimator.writeToLog("phone-service out-of-service\n");
		break;
	case ServiceState.STATE_POWER_OFF:
		powerEstimator.writeToLog("phone-service power-off\n");
		break;
	}
}
 
開發者ID:jackvt93,項目名稱:Open-Battery-Saver,代碼行數:33,代碼來源:UMLoggerService.java

示例10: sendSms

public static void sendSms(final Context context) {
    Log.v(CRDAlarmReceiver.class.getName(), "sendSms() => Sending SMS...");

    CRDSharedPreferences.getInstance(context).setSendingSmsEpoch();

    final TelephonyManager telephonyManager = (TelephonyManager) context.getApplicationContext().getSystemService(TELEPHONY_SERVICE);
    final PhoneStateListener phoneStateListener = new PhoneStateListener() {
        // Fired when the service state changes or immediately after registration via .listen()
        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
            super.onServiceStateChanged(serviceState);

            String serviceStateDebug;

            switch (serviceState.getState()) {
                case ServiceState.STATE_IN_SERVICE:
                    serviceStateDebug = "STATE_IN_SERVICE";
                    break;
                case ServiceState.STATE_OUT_OF_SERVICE:
                    serviceStateDebug = "OUT_OF_SERVICE";
                    break;
                case ServiceState.STATE_EMERGENCY_ONLY:
                    serviceStateDebug = "EMERGENCY_ONLY";
                    break;
                case ServiceState.STATE_POWER_OFF:
                    serviceStateDebug = "POWER_OFF";
                    break;
                default:
                    serviceStateDebug = "OTHER";
                    break;
            }

            Log.v(CRDAlarmReceiver.class.getName(), "onServiceStateChanged() => " + "serviceState = [" + serviceStateDebug + "]");

            if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
                CRDUtils.sendSmsToOrange(context);

                telephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
            }
        }
    };

    // We can't simply have the current state of the network. We have to register to its changes, then it will fire
    // immediately after the registration an event with the initial state. Super retarded imo.
    telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
 
開發者ID:NinoDLC,項目名稱:CineReminDay,代碼行數:46,代碼來源:CRDAlarmReceiver.java

示例11: processNewMMCSignal

public void processNewMMCSignal(SignalEx signal)  {
	ContentValues values = null;
	// if in a service outage, store a null signal
	// (I've seen cases where phone was out of service yet it was still returning a signal level)
	try
	{
		if (mPhoneState.getLastServiceState() == ServiceState.STATE_OUT_OF_SERVICE)
			signal = null;

		// avoid storing repeating identical signals
		if (mPhoneState.lastKnownMMCSignal != null && mPhoneState.lastKnownMMCSignal.getSignalStrength() != null && signal != null && signal.getSignalStrength() != null)
			if (mPhoneState.lastKnownMMCSignal.getSignalStrength().toString().equals(signal.getSignalStrength().toString()) && tmlastSig + 3000 > System.currentTimeMillis())
				return;
		tmlastSig = System.currentTimeMillis();
		Integer dbmValue = 0;
		boolean isLTE = false;
		if (signal == null)
			dbmValue = -256;
		else if (signal.getSignalStrength() == null)
			dbmValue = 0;

		//store the last known signal
		if (signal != null && signal.getSignalStrength() != null)
		{
			prevMMCSignal = mPhoneState.lastKnownMMCSignal; // used for looking at signal just before a call ended
			mPhoneState.lastKnownMMCSignal = signal;
		}
		else if (signal == null)
			mPhoneState.lastKnownMMCSignal = null;

		//push the new signal level into the sqlite database
		long stagedEventId = owner.getEventManager().getStagedEventId();
		int serviceState = mPhoneState.getLastServiceState();
		int wifiSignal = -1;
		WifiManager wifiManager = (WifiManager)owner.getSystemService(Context.WIFI_SERVICE);
		WifiInfo wifiinfo = wifiManager.getConnectionInfo() ;
		if (wifiinfo != null && wifiinfo.getBSSID() != null)
			wifiSignal =  wifiManager.getConnectionInfo().getRssi();

		//if (signal != null) //  disabled because we do want the no-signal to be written to the signals table
		{
			values = ContentValuesGenerator.generateFromSignal(signal, telephonyManager.getPhoneType(), telephonyManager.getNetworkType(),
					serviceState, telephonyManager.getDataState(), stagedEventId, wifiSignal, mPhoneState.mServicemode);
			Integer valSignal= (Integer)values.get("signal");
			if (mPhoneState.getNetworkType() == PhoneState.NETWORK_NEWTYPE_LTE) // && phoneStateListener.previousNetworkState == TelephonyManager.DATA_CONNECTED)
				valSignal= (Integer)values.get("lteRsrp");
			if (valSignal != null && dbmValue != null && valSignal > -130 && valSignal < -30) //  && (dbmValue <= -120 || dbmValue >= -1))
				dbmValue = valSignal;
			if ((dbmValue > -120 || mPhoneState.getNetworkType() == PhoneState.NETWORK_NEWTYPE_LTE) && dbmValue < -40)
				this.validSignal = true;
			if (this.validSignal) // make sure phone has at least one valid signal before recording
				owner.getDBProvider(owner).insert(TablesEnum.SIGNAL_STRENGTHS.getContentUri(), values);

		}
		//update the signal strength percentometer, chart, and look for low/high signal event
		if (dbmValue != null){
			if (dbmValue < -120) // might be -256 if no service, but want to display as -120 on livestatus chart
				dbmValue = -120;

			owner.getIntentDispatcher().updateSignalStrength(
					dbmValue, mPhoneState.getNetworkType(), owner.bWifiConnected, wifiSignal
			);

			// Store signal in a sharedPreference for tools such as Indoor/Transit sample mapper, which dont have reference to service
			if (isLTE == true)   // improve the value of the signal for LTE, so that Indoor samples don't look redder in LTE
				PreferenceManager.getDefaultSharedPreferences(owner).edit().putInt(PreferenceKeys.Miscellaneous.SIGNAL_STRENGTH, (dbmValue+15)).commit();
			else
				PreferenceManager.getDefaultSharedPreferences(owner).edit().putInt(PreferenceKeys.Miscellaneous.SIGNAL_STRENGTH, dbmValue).commit();

		}
	}
	catch (Exception e)
	{
		LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "exception", e);
		LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "values: " + values);
	}
	catch (Error err)
	{
		LoggerUtil.logToFile(LoggerUtil.Level.ERROR, TAG, "processNewMMCSignal", "error" + err.getMessage());
	}
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:81,代碼來源:LibPhoneStateListener.java

示例12: registerPhoneStateManager

/** 
 *	Register PhoneStateListener to permanently measuring cell signal strength
 */
private void registerPhoneStateManager() {
	mTelephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
	mPhoneListener = new PhoneStateListener() {
		@Override
		public void onSignalStrengthsChanged(final SignalStrength signalStrength) {
			// TODO we need a timestamp for signalstrength
			try {
				cdmaStrengthDbm = signalStrength.getCdmaDbm();
				cdmaEcIo = signalStrength.getCdmaEcio();
			} catch (final Exception e) {
				e.printStackTrace();
			}
			try {				
				signalStrengthEvdodBm = signalStrength.getEvdoDbm();
				signalStrengthEvdoEcio = signalStrength.getEvdoEcio();
				signalStrengthSnr = signalStrength.getEvdoSnr();
			} catch (final Exception e) {
				e.printStackTrace();
			}

			try {
				gsmBitErrorRate = signalStrength.getGsmBitErrorRate();
				gsmStrengthAsu = signalStrength.getGsmSignalStrength();
				gsmStrengthDbm = -113 + 2 * gsmStrengthAsu; // conversion ASU in dBm
			} catch (final Exception e) {
				e.printStackTrace();
			}
		}

		@Override
		public void onServiceStateChanged(final ServiceState serviceState) {

			switch(serviceState.getState()) {
				case ServiceState.STATE_POWER_OFF:
					try {
						final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
						final Date now = new Date();
						final String date = formatter.format(now);
					} catch (final Exception e) {
						e.printStackTrace();
					}

					//	powerOff = true;
					break;
				case ServiceState.STATE_OUT_OF_SERVICE:
					try {
						final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
						final Date now = new Date();
						final String date = formatter.format(now);
					} catch (final Exception e) {
						e.printStackTrace();
					}

					//outOfService = true;
					break;
				default:
					//alreadyWrittenNoCellular = false;
					//outOfService = false;
					//powerOff = false;
			}
		}
	};

	/** 
	 *	Register TelephonyManager updates
	 */
	mTelephonyManager.listen(mPhoneListener,
			PhoneStateListener.LISTEN_SERVICE_STATE
			| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
			| PhoneStateListener.LISTEN_CELL_LOCATION);
}
 
開發者ID:saintbyte,項目名稱:openbmap,代碼行數:74,代碼來源:WirelessLoggerService.java

示例13: onCreate

@Override
	public void onCreate() {
        super.onCreate();
		// Initialize global variables 
        Globals.is_vd_running 			= false;
        Globals.msisdn 			= VD_Settings.getStringPref(
						        				this,
						        				VD_Settings.PREF_MSIDN,
						        				Globals.DEF_MSISDN);
        Globals.callduration	 = Integer.parseInt(VD_Settings.getStringPref(
						        				this, 
						        				VD_Settings.PREF_CALL_DURATION,
						        				"20"));
        Globals.timebetweencalls = Integer.parseInt(VD_Settings.getStringPref(
						        				this, 
						        				VD_Settings.PREF_WAIT_TIME,
						        				"20"));
        boolean is_bgmode 	 	 = VD_Settings.getBoolPref(this, 
												VD_Settings.PREF_BGMODE, 
												false);
        if(is_bgmode) {
        	Globals.opmode = Globals.OPMODE_BG;
        }
        else {
        	boolean is_receiver  = VD_Settings.getBoolPref(this, 
        										VD_Settings.PREF_RECEIVER, 
        										false);
        	Globals.opmode = (is_receiver) ? Globals.OPMODE_MT : Globals.OPMODE_MO;
        }
        Globals.iservicestate 	= ServiceState.STATE_OUT_OF_SERVICE;	// default initial service state
        Globals.icallnumber 	= 0;
        Globals.is_mtc_ongoing	= false;
//        Logger.initializeValues();
        try {
        	SP_Logger.setup();
        } catch (IOException e) {
            Log.d("VOLTE_DIALER", "Problem creating log file");
        }
        VD_Settings settings = new VD_Settings(); // initialize log level
        settings = null;	// not needed anymore
    }
 
開發者ID:Spinlogic,項目名稱:VoLTE_Dialer,代碼行數:41,代碼來源:volte_dialer.java


注:本文中的android.telephony.ServiceState.STATE_OUT_OF_SERVICE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。