telephonyutils/telephonywatchers/src/signalstrengthwatcher.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 // SIGNALSTRENGHWATCHER.CPP
    14 // SIGNALSTRENGHWATCHER.CPP
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 // User includes
    18 // User includes
    19 
    19 #include "watcherlog.h"
    20 
       
    21 #include "OstTraceDefinitions.h"
       
    22 #ifdef OST_TRACE_COMPILER_IN_USE
       
    23 #include "signalstrengthwatcherTraces.h"
       
    24 #endif
       
    25 
       
    26 #include "signalstrengthwatcher.h"
    20 #include "signalstrengthwatcher.h"
    27 
    21 
    28 // System includes
    22 // System includes
    29 #include <sacls.h>
    23 #include <sacls.h>
    30 
    24 
    83 	{
    77 	{
    84 	switch(SignalStrengthState())
    78 	switch(SignalStrengthState())
    85 		{
    79 		{
    86 	case ESignalStrengthNotYetInitialised:
    80 	case ESignalStrengthNotYetInitialised:
    87 	case ESignalStrengthStateRequestInitialSignalStrength:
    81 	case ESignalStrengthStateRequestInitialSignalStrength:
    88 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLEPHONESTATEEVENTL_1, "SignalStrengthWatcher : Requesting initial signal strength");
    82 		LOGSIGNAL1("SignalStrengthWatcher : Requesting initial signal strength");
    89 		Phone().GetSignalStrength(iStatus, iSignalStrength, iSignalBars);
    83 		Phone().GetSignalStrength(iStatus, iSignalStrength, iSignalBars);
    90 		SignalStrengthState() = ESignalStrengthWaitingForInitialSignalStrength;
    84 		SignalStrengthState() = ESignalStrengthWaitingForInitialSignalStrength;
    91 		SetActive();
    85 		SetActive();
    92 		break;
    86 		break;
    93 
    87 
   134 //
   128 //
   135 //
   129 //
   136 
   130 
   137 void CSignalStrengthWatcher::HandleSignalStrengthUpdateL(TInt aCompletionCode)
   131 void CSignalStrengthWatcher::HandleSignalStrengthUpdateL(TInt aCompletionCode)
   138 	{
   132 	{
   139 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_1, "SignalStrengthNotifier : Handling signal strength update");
   133 	LOGSIGNAL1("SignalStrengthNotifier : Handling signal strength update");
   140 	if	(aCompletionCode < KErrNone)
   134 	if	(aCompletionCode < KErrNone)
   141 		{
   135 		{
   142 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_2, "SignalStrengthNotifier : Handling request error (%d)", aCompletionCode);
   136 		LOGSIGNAL2("SignalStrengthNotifier : Handling request error (%d)", aCompletionCode);
   143 
   137 
   144 		// Indicate we don't know what the signal strength is
   138 		// Indicate we don't know what the signal strength is
   145 		TInt ret = iNetworkStrengthProperty.Set(ESANetworkStrengthUnknown);
   139 		TInt ret = iNetworkStrengthProperty.Set(ESANetworkStrengthUnknown);
   146 		if (!(ret == KErrNone || ret == KErrNotFound))
   140 		if (!(ret == KErrNone || ret == KErrNotFound))
   147 			User::Leave(ret);
   141 			User::Leave(ret);
   181 			SuspendFor(KErrorRetryPausePeriod);
   175 			SuspendFor(KErrorRetryPausePeriod);
   182 			}
   176 			}
   183 		}
   177 		}
   184 	else
   178 	else
   185 		{
   179 		{
   186 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_3, "SignalStrengthNotifier : Signal strength is: %d", (TInt) iSignalStrength);
   180 		LOGSIGNAL2("SignalStrengthNotifier : Signal strength is: %d", (TInt) iSignalStrength);
   187 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_4, "SignalStrengthNotifier : Signal bars is: %d", iSignalBars);
   181 		LOGSIGNAL2("SignalStrengthNotifier : Signal bars is: %d", iSignalBars);
   188 
   182 
   189 		// What is the signal strength now?
   183 		// What is the signal strength now?
   190 		TInt newState = ESANetworkStrengthUnknown;
   184 		TInt newState = ESANetworkStrengthUnknown;
   191 		// iSignalStrength is in dBm - hence use of negative numbers
   185 		// iSignalStrength is in dBm - hence use of negative numbers
   192 		if	((iSignalStrength == KSignalStrengthNone) || (iSignalBars == KSignalZeroBars))
   186 		if	((iSignalStrength == KSignalStrengthNone) || (iSignalBars == KSignalZeroBars))
   197 			newState = ESANetworkStrengthMedium;
   191 			newState = ESANetworkStrengthMedium;
   198 		else
   192 		else
   199 			newState = ESANetworkStrengthHigh;
   193 			newState = ESANetworkStrengthHigh;
   200 
   194 
   201 		// Update properties
   195 		// Update properties
   202 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_5, "SignalStrengthNotifier : Informing properties of signal strength change");
   196 		LOGSIGNAL1("SignalStrengthNotifier : Informing properties of signal strength change");
   203 		TInt ret = iNetworkStrengthProperty.Set(newState);
   197 		TInt ret = iNetworkStrengthProperty.Set(newState);
   204 		if (!(ret == KErrNone || ret == KErrNotFound))
   198 		if (!(ret == KErrNone || ret == KErrNotFound))
   205 			User::Leave(ret);
   199 			User::Leave(ret);
   206 				
   200 				
   207 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIGNALSTRENGTHWATCHER_HANDLESIGNALSTRENGTHUPDATEL_6, "SignalStrengthNotifier : Requesting signal strength change notification");
   201 		LOGSIGNAL1("SignalStrengthNotifier : Requesting signal strength change notification");
   208 		Phone().NotifySignalStrengthChange(iStatus, iSignalStrength, iSignalBars);
   202 		Phone().NotifySignalStrengthChange(iStatus, iSignalStrength, iSignalBars);
   209 		SetActive();
   203 		SetActive();
   210 		}
   204 		}
   211 	}
   205 	}
   212 
   206