Home | History | Annotate | Download | only in task
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
      5  * use this file except in compliance with the License. You may obtain a copy of
      6  * the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     13  * License for the specific language governing permissions and limitations under
     14  * the License.
     15  */
     16 
     17 #include <UniquePtr.h>
     18 #include "Log.h"
     19 #include "audio/AudioSignalFactory.h"
     20 #include "audio/RemoteAudio.h"
     21 #include "StringUtil.h"
     22 #include "task/TaskCase.h"
     23 #include "task/TaskDownload.h"
     24 
     25 static const android::String8 STR_ID("id");
     26 
     27 TaskDownload::TaskDownload()
     28     : TaskGeneric(TaskGeneric::ETaskDownload)
     29 {
     30     const android::String8* list[] = {&STR_ID, NULL};
     31     registerSupportedStringAttributes(list);
     32 }
     33 
     34 TaskDownload::~TaskDownload()
     35 {
     36 
     37 }
     38 
     39 TaskGeneric::ExecutionResult TaskDownload::run()
     40 {
     41     android::String8 id;
     42     if (!findStringAttribute(STR_ID, id)) {
     43         LOGE("TaskDownload::run %s string not found", STR_ID.string());
     44         return TaskGeneric::EResultError;
     45     }
     46 
     47     android::sp<Buffer> buffer = getTestCase()->findBuffer(id);
     48     if (buffer.get() == NULL) {
     49         LOGE("TaskDownload::run cannot find buffer %s", id.string());
     50         return TaskGeneric::EResultError;
     51     }
     52     int downloadId;
     53     if (!getTestCase()->getRemoteAudio()->downloadData(id, buffer, downloadId)) {
     54         return TaskGeneric::EResultError;
     55     }
     56     LOGI("Downloaded buffer %s to DUT with id %d", id.string(), downloadId);
     57     return TaskGeneric::EResultOK;
     58 }
     59 
     60 
     61 
     62