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 "Log.h"
18 #include "audio/AudioSignalFactory.h"
19 #include "audio/RemoteAudio.h"
20 #include "StringUtil.h"
21 #include "task/TaskCase.h"
22 #include "task/TaskDownload.h"
23
24 static const android::String8 STR_ID("id");
25
TaskDownload()26 TaskDownload::TaskDownload()
27 : TaskGeneric(TaskGeneric::ETaskDownload)
28 {
29 const android::String8* list[] = {&STR_ID, NULL};
30 registerSupportedStringAttributes(list);
31 }
32
~TaskDownload()33 TaskDownload::~TaskDownload()
34 {
35
36 }
37
run()38 TaskGeneric::ExecutionResult TaskDownload::run()
39 {
40 android::String8 id;
41 if (!findStringAttribute(STR_ID, id)) {
42 LOGE("TaskDownload::run %s string not found", STR_ID.string());
43 return TaskGeneric::EResultError;
44 }
45
46 android::sp<Buffer> buffer = getTestCase()->findBuffer(id);
47 if (buffer.get() == NULL) {
48 LOGE("TaskDownload::run cannot find buffer %s", id.string());
49 return TaskGeneric::EResultError;
50 }
51 int downloadId;
52 if (!getTestCase()->getRemoteAudio()->downloadData(id, buffer, downloadId)) {
53 return TaskGeneric::EResultError;
54 }
55 LOGI("Downloaded buffer %s to DUT with id %d", id.string(), downloadId);
56 return TaskGeneric::EResultOK;
57 }
58
59
60
61