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