ECode CInstrumentationTestRunner::WatcherResultPrinter::AddFailure(
    /* [in] */ ITest* test,
    /* [in] */ ITestFailure* failure)
{
    String message;
    failure->ExceptionMessage(&message);
    String trace;
    failure->Trace(&trace);
    message.Append("\n");
    message.Append(trace);
    trace = message;
    String prevTrace;
    mTestResult->GetString(REPORT_KEY_STACK, &prevTrace);
    if (!prevTrace.IsNull()) {
        prevTrace.Append("\n");
        prevTrace.Append(trace);
        trace = prevTrace;
    }
    mTestResult->PutString(REPORT_KEY_STACK, trace);
    mTestResultCode = IInstrumentationTestRunner::REPORT_VALUE_RESULT_FAILURE;
    // pretty printing
    String name;
    ITestCase::Probe(test)->GetName(&name);
    String result;
    result.AppendFormat("\nFailure in %s:\n%s", name.string(), trace.string());
    mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT, result);
    return NOERROR;
}
Exemple #2
0
Boolean Connection::HttpFailure(
    /* [in] */ IRequest* req,
    /* [in] */ Int32 errorId,
    /* [in] */ ECode e)
{
    Boolean ret = TRUE;

    if (HttpLog::LOGV)
        HttpLog::V("httpFailure() ******* %d count %d %s %s", e, ((Request*)req)->mFailCount,
            TO_CSTR(mHost), Ptr(((Request*)req))->Func(((Request*)req)->GetUri).string());

    if (++((Request*)req)->mFailCount >= RETRY_REQUEST_LIMIT) {
        ret = FALSE;
        String error;
        if (errorId < 0) {
            ErrorStrings::GetString(errorId, mContext, &error);
        } else {
            error.AppendFormat("%d", e);
        }
        ((Request*)req)->mEventHandler->Error(errorId, error);
        ((Request*)req)->Complete();
    }

    CloseConnection();
    AutoPtr<IInterface> tmpObj;
    mHttpContext->RemoveAttribute(HTTP_CONNECTION, (IInterface**)&tmpObj);

    return ret;
}
String CountdownConditionProvider::TryParseDescription(
    /* [in] */ IUri* conditionUri)
{
    AutoPtr<IZenModeConfigHelper> helper;
    CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper);
    Int64 time;
    helper->TryParseCountdownConditionId(conditionUri, &time);
    if (time == 0) return String(NULL);

    AutoPtr<ISystem> sys;
    CSystem::AcquireSingleton((ISystem**)&sys);
    Int64 now;
    sys->GetCurrentTimeMillis(&now);

    AutoPtr<ICharSequence> span =
            DateUtils::GetRelativeTimeSpanString(time, now, IDateUtils::MINUTE_IN_MILLIS);

    String spanStr;
    span->ToString(&spanStr);

    String str;
    str = "";
    str.AppendFormat("Scheduled for %s, %s in the future (%s), now=%s",
            Ts(time).string(),
            StringUtils::ToString(time - now).string(),
            spanStr.string(),
            Ts(now).string());

    return str;
}
Exemple #4
0
Boolean IconPackHelper::ParseComposedIconComponent(
    /* [in] */ IXmlPullParser* parser,
    /* [in] */ IMap* iconPackResources)
{
    String icon;
    String tag;
    parser->GetName(&tag);
    if (!IsComposedIconComponent(tag)) {
        return FALSE;
    }

    Int32 count;
    if (parser->GetAttributeCount(&count), count >= 1) {
        if (tag.EqualsIgnoreCase(ICON_BACK_TAG)) {
            parser->GetAttributeCount(&mIconBackCount);
            for (Int32 i = 0; i < mIconBackCount; i++) {
                tag = "";
                tag.AppendFormat(ICON_BACK_FORMAT.string(), i);
                parser->GetAttributeValue(i, &icon);
                AutoPtr<IComponentName> component;
                CComponentName::New(tag, String(""), (IComponentName**)&component);
                iconPackResources->Put(component, CoreUtils::Convert(icon));
            }
        }
        else {
            parser->GetAttributeValue(0, &icon);
            AutoPtr<IComponentName> component;
            CComponentName::New(tag, String(""), (IComponentName**)&component);
            iconPackResources->Put(component, CoreUtils::Convert(icon));
        }
        return TRUE;
    }

    return FALSE;
}
Exemple #5
0
String FileDataCacheItem::VectorAsString( const DVector& v )
{
   String s = String().Format( "\n%d", v.Length() );
   for ( int i = 0; i < v.Length(); ++i )
      s.AppendFormat( "\n%.8e", v[i] );
   return s;
}
ECode CountdownConditionProvider::OnSubscribe(
    /* [in] */ IUri* conditionId)
{
    if (DEBUG) Slogger::D(TAG, "onSubscribe %p", conditionId);
    AutoPtr<IZenModeConfigHelper> helper;
    CZenModeConfigHelper::AcquireSingleton((IZenModeConfigHelper**)&helper);
    helper->TryParseCountdownConditionId(conditionId, &mTime);

    AutoPtr<IInterface> obj;
    mContext->GetSystemService(IContext::ALARM_SERVICE, (IInterface**)&obj);
    AutoPtr<IAlarmManager> alarms = IAlarmManager::Probe(obj);
    String str;
    IObject::Probe(conditionId)->ToString(&str);
    AutoPtr<IIntent> intent;
    CIntent::New(ACTION, (IIntent**)&intent);
    intent->PutExtra(EXTRA_CONDITION_ID, str);
    intent->SetFlags(IIntent::FLAG_RECEIVER_REGISTERED_ONLY);

    AutoPtr<IPendingIntentHelper> pendingIntentHelper;
    CPendingIntentHelper::AcquireSingleton((IPendingIntentHelper**)&pendingIntentHelper);
    AutoPtr<IPendingIntent> pendingIntent;
    pendingIntentHelper->GetBroadcast(mContext, REQUEST_CODE,
            intent, IPendingIntent::FLAG_UPDATE_CURRENT, (IPendingIntent**)&pendingIntent);
    alarms->Cancel(pendingIntent);
    if (mTime > 0) {
        AutoPtr<ISystem> sys;
        CSystem::AcquireSingleton((ISystem**)&sys);
        Int64 now;
        sys->GetCurrentTimeMillis(&now);

        AutoPtr<ICharSequence> span =
                DateUtils::GetRelativeTimeSpanString(mTime, now, IDateUtils::MINUTE_IN_MILLIS);
        if (mTime <= now) {
            // in the past, already false
            NotifyCondition(NewCondition(mTime, ICondition::STATE_FALSE));
        }
        else {
            // in the future, set an alarm
            alarms->SetExact(IAlarmManager::RTC_WAKEUP, mTime, pendingIntent);
        }

        String spanStr;
        span->ToString(&spanStr);

        str = "";
        str.AppendFormat("%s %s for %s, %s in the future (%s), now=%s",
                (mTime <= now ? "Not scheduling" : "Scheduling"),
                ACTION.string(),
                Ts(mTime).string(),
                StringUtils::ToString(mTime - now).string(),
                spanStr.string(),
                Ts(now).string());
        if (DEBUG) Slogger::D(TAG, str);
    }
    return NOERROR;
}
Exemple #7
0
String File::Join(
    /* [in] */ const String& prefix,
    /* [in] */ const String& suffix)
{
    Int32 prefixLength = prefix.GetLength();
    Boolean haveSlash = (prefixLength > 0 && prefix.GetChar(prefixLength - 1) == sSeparatorChar);
    if (!haveSlash) {
        haveSlash = (suffix.GetLength() > 0 && suffix.GetChar(0) == sSeparatorChar);
    }
    String joinStr = prefix;
    if (!haveSlash) joinStr.AppendFormat("%c", sSeparatorChar);
    joinStr += suffix;
    return joinStr;
}
Exemple #8
0
String SourceCodeError::Message() const
{
   String s = m_message;

   if ( m_lineNumber >= 0 || m_columnNumber >= 0 )
   {
      s += " (";

      if ( m_lineNumber >= 0 )
      {
         s.AppendFormat( "line=%d", m_lineNumber );
         if ( m_columnNumber >= 0 )
            s += ',';
      }

      if ( m_columnNumber >= 0 )
         s.AppendFormat( "column=%d", m_columnNumber );

      s += ")";
   }

   return s;
}
String PackageManager::GetDataDirForUser(
    /* [in] */ Int32 userId,
    /* [in] */ const String& packageName)
{
    // TODO: This should be shared with Installer's knowledge of user directory
    AutoPtr<IEnvironment> env;
    CEnvironment::AcquireSingleton((IEnvironment**)&env);
    AutoPtr<IFile> file;
    env->GetDataDirectory((IFile**)&file);
    String strFile;
    file->ToString(&strFile);
    strFile.AppendFormat("/user/%d/%s", userId, packageName.string());
    return strFile;
}
ECode MyActivityController::WaitControllerLocked(
    /* [in] */ Int32 pid,
    /* [in] */ Int32 state,
    /* [out] */ Int32* result)
{
    VALIDATE_NOT_NULL(result);
    if (!mGdbPort.IsNull()) {
        KillGdbLocked();

        PFL_EX("Starting gdbserver on port %s", mGdbPort.string());
        PFL_EX("Do the following:");
        PFL_EX("  adb forward tcp:%s tcp:%s", mGdbPort.string(), mGdbPort.string());
        PFL_EX("  gdbclient app_process :%s", mGdbPort.string());

        String cmd;
        cmd.AppendFormat("gdbserver :%s --attach %d", mGdbPort.string(), pid);
        mFile = popen(cmd.string(), "r");

        mGdbThread = NULL;
        AutoPtr<GdbThreadRunnable> runable = new GdbThreadRunnable(this);
        CThread::New(runable, (IThread**)&mGdbThread);
        mGdbThread->Start();
        mLock.Wait(500);
    }

    mState = state;
    PFL_EX("");
    PrintMessageForState();

    while (mState != STATE_NORMAL) {
        mLock.Wait(500);
    }
    KillGdbLocked();
    *result = mResult;
    return NOERROR;
}
Exemple #11
0
   template <class P> inline
   static void Apply( GenericImage<P>& image, const IntegerResample& Z )
   {
      int width = image.Width();
      int w0 = width;
      int height = image.Height();
      int h0 = height;

      Z.GetNewSizes( width, height );

      if ( width == w0 && height == h0 )
         return;

      if ( width == 0 || height == 0 )
      {
         image.FreeData();
         return;
      }

      image.EnsureUnique();

      typename P::sample* f = 0;
      typename P::sample** f0 = 0;

      int n = image.NumberOfChannels();
      size_type N = image.NumberOfPixels();
      typename GenericImage<P>::color_space cs0 = image.ColorSpace();

      StatusMonitor status = image.Status();

      int z = pcl::Abs( Z.ZoomFactor() );
      int z2 = z*z;
      int n2 = z2 >> 1;

      try
      {
         if ( status.IsInitializationEnabled() )
         {
            String info = (Z.ZoomFactor() > 0) ? "Upsampling" : "Downsampling";

            info.AppendFormat( " %d:%d, %dx%d",
               (Z.ZoomFactor() > 0) ? z : 1, (Z.ZoomFactor() > 0) ? 1 : z, width, height );

            if ( Z.ZoomFactor() < 0 )
            {
               info += ", ";
               switch ( Z.DownsampleMode() )
               {
               default:
               case IntegerDownsampleMode::Average: info += "average"; break;
               case IntegerDownsampleMode::Median:  info += "median"; break;
               case IntegerDownsampleMode::Maximum: info += "maximum"; break;
               case IntegerDownsampleMode::Minimum: info += "minimum"; break;
               }
            }

            status.Initialize( info, n*N );
         }

         GenericVector<typename P::sample> fm;
         if ( Z.ZoomFactor() < 0 && Z.DownsampleMode() == IntegerDownsampleMode::Median )
            fm = GenericVector<typename P::sample>( z2 );

         f0 = image.ReleaseData();

         for ( int c = 0; c < n; ++c, status += N )
         {
            f = image.Allocator().AllocatePixels( width, height );

            if ( Z.ZoomFactor() > 0 )
            {
               const typename P::sample* f0c = f0[c];

               for ( int y = 0; y < h0; ++y )
               {
                  int yz = y*z;

                  for ( int x = 0; x < w0; ++x )
                  {
                     int xz = x*z;
                     typename P::sample v = *f0c++;

                     for ( int i = 0; i < z; ++i )
                     {
                        typename P::sample* fi = f + (size_type( yz + i )*width + xz);

                        for ( int j = 0; j < z; ++j )
                           *fi++ = v;
                     }
                  }
               }
            }
            else
            {
               typename P::sample* fz = f;

               for ( int y = 0; y < height; ++y )
               {
                  const typename P::sample* fy = f0[c] + size_type( y )*z*w0;

                  for ( int x = 0; x < width; ++x )
                  {
                     const typename P::sample* fyx = fy + x*z;

                     switch ( Z.DownsampleMode() )
                     {
                     default:
                     case IntegerDownsampleMode::Average:
                        {
                           double s = 0;
                           for ( int i = 0; i < z; ++i, fyx += w0 )
                              for ( int j = 0; j < z; ++j )
                                 s += fyx[j];
                           *fz++ = typename P::sample( P::IsFloatSample() ? s/z2 : Round( s/z2 ) );
                        }
                        break;

                     case IntegerDownsampleMode::Median:
                        {
                           typename P::sample* fmi = *fm;
                           for ( int i = 0; i < z; ++i, fyx += w0 )
                              for ( int j = 0; j < z; ++j )
                                 *fmi++ = fyx[j];

                           *fz++ = (z & 1) ?
                                 *Select( *fm, fm.At( z2 ), n2 ) :
                                 P::FloatToSample( 0.5*(double( *Select( *fm, fm.At( z2 ), n2   ) ) +
                                                        double( *Select( *fm, fm.At( z2 ), n2-1 ) )) );
                        }
                        break;

                     case IntegerDownsampleMode::Maximum:
                        {
                           *fz = P::MinSampleValue();
                           for ( int i = 0; i < z; ++i, fyx += w0 )
                              for ( int j = 0; j < z; ++j )
                                 if ( fyx[j] > *fz )
                                    *fz = fyx[j];
                           ++fz;
                        }
                        break;

                     case IntegerDownsampleMode::Minimum:
                        {
                           *fz = P::MaxSampleValue();
                           for ( int i = 0; i < z; ++i, fyx += w0 )
                              for ( int j = 0; j < z; ++j )
                                 if ( fyx[j] < *fz )
                                    *fz = fyx[j];
                           ++fz;
                        }
                        break;
                     }
                  }
               }
            }

            image.Allocator().Deallocate( f0[c] );
            f0[c] = f;
            f = 0;
         }

         image.ImportData( f0, width, height, n, cs0 ).Status() = status;
      }
      catch ( ... )
      {
         if ( f != 0 )
            image.Allocator().Deallocate( f );
         if ( f0 != 0 )
         {
            for ( int c = 0; c < n; ++c )
               if ( f0[c] != 0 )
                  image.Allocator().Deallocate( f0[c] );
            image.Allocator().Deallocate( f0 );
         }
         image.FreeData();
         throw;
      }
   }
Exemple #12
0
   void
   Messages::Refresh(bool update_recent_flags)
   {
      boost::lock_guard<boost::recursive_mutex> guard(_mutex);

	  // int startTime = GetTickCount();

      bool retrieveQueue = account_id_ == -1;

      if (retrieveQueue && last_refreshed_uid_ > 0)
      {
         /*
            We can't do partial refreshes of messages in the queue. Why? 
            Because we use the message UID to determine which part of the
            queue we need to read from the database, and UID's aren't given
            to messages before they are inserted into the queue.
         */
         ErrorManager::Instance()->ReportError(ErrorManager::Medium, 5204, "Messages::Refresh", "Refresh not supported on the current collection.");
         return;

      }

      SQLCommand command;

      // Build SQL statement that will be used to fetch list of messages.
      String sSQL;
      sSQL = "select * from hm_messages where "; 

      if (retrieveQueue)
         sSQL += " messagetype = 1 ";
      else
      {
         // Messages connected to a specific account
         sSQL += _T(" messageaccountid = @MESSAGEACCOUNTID ");
         command.AddParameter("@MESSAGEACCOUNTID", account_id_); 
      }
  
      // Should we fetch a specific folder?
      if (folder_id_ != -1)
      {
         sSQL.AppendFormat(_T(" and messagefolderid = @MESSAGEFOLDERID "));
         command.AddParameter("@MESSAGEFOLDERID", folder_id_); 
      }

      // Should we do an incremental refresh?
      if (last_refreshed_uid_ > 0)
      {
         sSQL.AppendFormat(_T(" and messageuid > @MESSAGEUID "));
         command.AddParameter("@MESSAGEUID", last_refreshed_uid_); 
      }

      if (retrieveQueue)
         sSQL += " order by messageid asc";
      else
         sSQL += " order by messageuid asc";


      command.SetQueryString(sSQL);

      std::shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(command);
      if (!pRS)
         return;

      AddToCollection(pRS);

     
   }
ECode Media_Utils::ConvertMessageToMap(
   /* [in] */ android::sp<android::AMessage>& msg,
   /* [out] */ IObjectStringMap** mymap)
{
    VALIDATE_NOT_NULL(mymap);
    *mymap = NULL;

    AutoPtr<IObjectStringMap> returnMap;
    CObjectStringMap::New( (IObjectStringMap**)&returnMap);

    for (Int32 i = 0; i < msg->countEntries(); i++) {
        android::AMessage::Type valueType;
        const char *key = msg->getEntryNameAt(i,&valueType);

        AutoPtr<IInterface> valueObj;
        switch (valueType){
            case android::AMessage::kTypeInt32: {
                Int32 val;
                msg->findInt32(key, &val);
                AutoPtr<IInteger32> value;
                CInteger32::New(val, (IInteger32**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeInt64: {
                Int64 val;
                msg->findInt64(key, &val);
                AutoPtr<IInteger64> value;
                CInteger64::New(val, (IInteger64**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeFloat: {
                Float val;
                msg->findFloat(key, &val);
                AutoPtr<IFloat> value;
                CFloat::New(val, (IFloat**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeString: {
                android::AString val;
                msg->findString(key, &val);
                AutoPtr<ICharSequence> value;
                CString::New(String(val.c_str()), (ICharSequence**)&value);
                valueObj = value->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeBuffer: {
                android::sp<android::ABuffer> val;
                msg->findBuffer(key, &val);
                Int32 size = val->size();
                ArrayOf<Byte> bytes((Byte*)val->data(), size);

                AutoPtr<IByteBufferHelper> helper;
                CByteBufferHelper::AcquireSingleton((IByteBufferHelper**)&helper);
                AutoPtr<IByteBuffer> buffer;
                helper->Allocate(size, (IByteBuffer**)&buffer);
                buffer->PutBytes(bytes);
                valueObj = buffer->Probe(EIID_IInterface);
                break;
            }
            case android::AMessage::kTypeRect: {
                Int32 left, top, right, bottom;
                msg->findRect(key, &left, &top, &right, &bottom);

                AutoPtr<IInteger32> tmpInt;

                String strLeft;
                strLeft.AppendFormat("%s-left", key);
                CInteger32::New(left, (IInteger32**)&tmpInt);
                returnMap->Put(strLeft ,tmpInt->Probe(EIID_IInterface));

                String strTop;
                strLeft.AppendFormat("%s-top", key);
                tmpInt = NULL;
                CInteger32::New(top, (IInteger32**)&tmpInt);
                returnMap->Put(strTop ,tmpInt->Probe(EIID_IInterface));

                String strRight;
                strLeft.AppendFormat("%s-right", key);
                tmpInt = NULL;
                CInteger32::New(right, (IInteger32**)&tmpInt);
                returnMap->Put(strRight ,tmpInt->Probe(EIID_IInterface));

                String strBottom;
                strLeft.AppendFormat("%s-bottom", key);
                tmpInt = NULL;
                CInteger32::New(bottom, (IInteger32**)&tmpInt);
                returnMap->Put(strBottom ,tmpInt->Probe(EIID_IInterface));
                break;
            }

            default:
                break;
        }//end switch

        if (valueObj != NULL)  {
            String keyObj(key);
            returnMap->Put(keyObj ,valueObj);
        }
    }//end for

    *mymap = returnMap;
    REFCOUNT_ADD(*mymap);
    return NOERROR;
}
ECode CInstrumentationTestRunner::WatcherResultPrinter::StartTest(
    /* [in] */ ITest* test)
{
    AutoPtr<IClassInfo> clsInfo;
    _CObject_ReflectClassInfo(test, (IClassInfo**)&clsInfo);
    StringBuf_<512> nameBuf;
    clsInfo->GetName(&nameBuf);
    String testClass((const char*)nameBuf);
    String testName;
    ITestCase::Probe(test)->GetName(&testName);
    mTestResult = NULL;
    CBundle::New(mResultTemplate, (IBundle**)&mTestResult);
    mTestResult->PutString(IInstrumentationTestRunner::REPORT_KEY_NAME_CLASS, testClass);
    mTestResult->PutString(IInstrumentationTestRunner::REPORT_KEY_NAME_TEST, testName);
    mTestResult->PutInt32(IInstrumentationTestRunner::REPORT_KEY_NUM_CURRENT, ++mTestNum);
    // pretty printing
    if (!testClass.IsNull() && !testClass.Equals(mTestClass)) {
        String formatStr;
        formatStr.AppendFormat("\n%s:", testClass.string());
        mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT,
                formatStr);
        mTestClass = testClass;
    }
    else {
        mTestResult->PutString(IInstrumentation::REPORT_KEY_STREAMRESULT, String(""));
    }

//    Method testMethod = null;
//    try {
//        testMethod = test.getClass().getMethod(testName);
//        // Report total number of iterations, if test is repetitive
//        if (testMethod.isAnnotationPresent(RepetitiveTest.class)) {
//            int numIterations = testMethod.getAnnotation(
//                RepetitiveTest.class).numIterations();
//            mTestResult.putInt(REPORT_KEY_NUM_ITERATIONS, numIterations);
//        }
//    } catch (NoSuchMethodException e) {
//        // ignore- the test with given name does not exist. Will be handled during test
//        // execution
//    }

    AutoPtr<ITestAnnotation> annotation;
    test->GetTestAnnotation((ITestAnnotation**)&annotation);
    if (annotation != NULL) {
        Int32 numIterations;
        annotation->GetNumIterations(testName, &numIterations);
        mTestResult->PutInt32(REPORT_KEY_NUM_ITERATIONS, numIterations);
    }

    // The delay_msec parameter is normally used to provide buffers of idle time
    // for power measurement purposes. To make sure there is a delay before and after
    // every test in a suite, we delay *after* every test (see endTest below) and also
    // delay *before* the first test. So, delay test1 delay test2 delay.

    // try {
    if (mTestNum == 1) {
        ECode ec = Thread::Sleep(mHost->mDelayMsec);
        if (ec == (ECode)E_INTERRUPTED_EXCEPTION) return E_ILLEGAL_STATE_EXCEPTION;
    }
    // } catch (InterruptedException e) {
    //     throw new IllegalStateException(e);
    // }

    mHost->SendStatus(IInstrumentationTestRunner::REPORT_VALUE_RESULT_START, mTestResult);
    mTestResultCode = 0;

    mIsTimedTest = FALSE;
    mIncludeDetailedStats = FALSE;
    if (annotation != NULL) {
        annotation->IsTimedTest(testName, &mIsTimedTest);
        annotation->IsIncludeDetailedStats(testName, &mIncludeDetailedStats);
    }
//    try {
//        // Look for TimedTest annotation on both test class and test method
//        if (testMethod != null && testMethod.isAnnotationPresent(TimedTest.class)) {
//            mIsTimedTest = true;
//            mIncludeDetailedStats = testMethod.getAnnotation(
//                    TimedTest.class).includeDetailedStats();
//        } else if (test.getClass().isAnnotationPresent(TimedTest.class)) {
//            mIsTimedTest = true;
//            mIncludeDetailedStats = test.getClass().getAnnotation(
//                    TimedTest.class).includeDetailedStats();
//        }
//    } catch (SecurityException e) {
//        // ignore - the test with given name cannot be accessed. Will be handled during
//        // test execution
//    }

    // TODO
    // if (mIsTimedTest && mIncludeDetailedStats) {
    //     mPerfCollector.beginSnapshot("");
    // }
    // else if (mIsTimedTest) {
    //     mPerfCollector.startTiming("");
    // }

    return NOERROR;
}
AutoPtr<ICharSequence> DateUtils::GetRelativeTimeSpanString(
    /* [in] */ Int64 time,
    /* [in] */ Int64 now,
    /* [in] */ Int64 minResolution,
    /* [in] */ Int32 flags)
{
    AutoPtr<IResources> r = CResources::GetSystem();
    Boolean abbrevRelative = ( (flags & (IDateUtils::FORMAT_ABBREV_RELATIVE | IDateUtils::FORMAT_ABBREV_ALL)) != 0 );

    Boolean past = (now >= time);
    Int64 duration = Elastos::Core::Math::Abs(now - time);

    Int32 resId;
    Int64 count;
    if ( (duration < IDateUtils::MINUTE_IN_MILLIS) && (minResolution < IDateUtils::MINUTE_IN_MILLIS) ) {
        count = duration / IDateUtils::SECOND_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_seconds_ago;
            }
            else {
                resId = R::plurals::num_seconds_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_seconds;
            }
            else {
                resId = R::plurals::in_num_seconds;
            }
        }
    }
    else if ( (duration < IDateUtils::HOUR_IN_MILLIS) && (minResolution < IDateUtils::HOUR_IN_MILLIS) ) {
        count = duration / IDateUtils::MINUTE_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_minutes_ago;
            }
            else {
                resId = R::plurals::num_minutes_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_minutes;
            }
            else {
                resId = R::plurals::in_num_minutes;
            }
        }
    }
    else if (duration < IDateUtils::DAY_IN_MILLIS && minResolution < IDateUtils::DAY_IN_MILLIS) {
        count = duration / IDateUtils::HOUR_IN_MILLIS;
        if (past) {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_num_hours_ago;
            }
            else {
                resId = R::plurals::num_hours_ago;
            }
        }
        else {
            if (abbrevRelative) {
                resId = R::plurals::abbrev_in_num_hours;
            }
            else {
                resId = R::plurals::in_num_hours;
            }
        }
    }
    else if (duration < IDateUtils::WEEK_IN_MILLIS && minResolution < IDateUtils::WEEK_IN_MILLIS) {
        return GetRelativeDayString(r, time, now);
    } else {
        // We know that we won't be showing the time, so it is safe to pass
        // in a null context.
        String fdrRet = FormatDateRange(NULL, time, time, flags);
        AutoPtr<ICharSequence> cs;
        CString::New(fdrRet, (ICharSequence**)&cs);
        return cs;
    }

    String format;
    r->GetQuantityString(resId, (Int32) count, &format);

    String retVal;
    retVal.AppendFormat(format.string(), count);

    AutoPtr<ICharSequence> cs;
    CString::New(retVal, (ICharSequence**)&cs);
    return cs;
}