1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <ctype.h> 18 #include <errno.h> 19 #include <stdarg.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <string.h> 23 #include <sys/mount.h> 24 #include <sys/stat.h> 25 #include <sys/types.h> 26 #include <sys/wait.h> 27 #include <unistd.h> 28 #include <fcntl.h> 29 30 #include "cutils/misc.h" 31 #include "cutils/properties.h" 32 #include "edify/expr.h" 33 #include "mincrypt/sha.h" 34 #include "minzip/DirUtil.h" 35 #include "mtdutils/mounts.h" 36 #include "mtdutils/mtdutils.h" 37 #include "downloadFN.h" 38 39 Value* DownloadModemFn(const char* name, State* state, int argc, Expr* argv[]) { 40 41 char* modemImg; 42 int result = -1; 43 44 if (argc != 1) 45 return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); 46 47 if (ReadArgs(state, argv, 1, &modemImg) != 0) { 48 return NULL; 49 } 50 51 printf("DownloadModemFn: %s\n", modemImg); 52 53 result = DownloadFiles(modemImg); 54 55 if (result < 0) { 56 printf("Download failed!\n"); 57 } else { 58 printf("Download success!\n"); 59 ResetModem(); 60 sleep(6); 61 } 62 return StringValue(strdup(result >= 0 ? "t" : "")); 63 } 64 65 void Register_librecovery_updater_tilapia() { 66 printf("Register_librecovery_updater_tilapia is called\n"); 67 RegisterFunction("bach.update_modem", DownloadModemFn); 68 } 69