Skip to content

Commit 23580ca

Browse files
author
The Android Open Source Project
committed
Initial Contribution
0 parents  commit 23580ca

File tree

134 files changed

+14144
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+14144
-0
lines changed

Android.mk

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
LOCAL_PATH := $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
commands_recovery_local_path := $(LOCAL_PATH)
5+
6+
ifneq ($(TARGET_SIMULATOR),true)
7+
8+
LOCAL_SRC_FILES := \
9+
recovery.c \
10+
bootloader.c \
11+
commands.c \
12+
firmware.c \
13+
install.c \
14+
roots.c \
15+
ui.c \
16+
verifier.c
17+
18+
LOCAL_SRC_FILES += test_roots.c
19+
20+
LOCAL_MODULE := recovery
21+
22+
LOCAL_FORCE_STATIC_EXECUTABLE := true
23+
24+
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
25+
# It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses
26+
# a (redundant) copy of the binary in /system/bin for user builds.
27+
# TODO: Build the ramdisk image in a more principled way.
28+
29+
LOCAL_MODULE_TAGS := eng
30+
31+
LOCAL_STATIC_LIBRARIES := libminzip libunz libamend libmtdutils libmincrypt
32+
LOCAL_STATIC_LIBRARIES += libminui libpixelflinger_static libcutils
33+
LOCAL_STATIC_LIBRARIES += libstdc++ libc
34+
35+
# Specify a C-includable file containing the OTA public keys.
36+
# This is built in config/Makefile.
37+
# *** THIS IS A TOTAL HACK; EXECUTABLES MUST NOT CHANGE BETWEEN DIFFERENT
38+
# PRODUCTS/BUILD TYPES. ***
39+
# TODO: make recovery read the keys from an external file.
40+
RECOVERY_INSTALL_OTA_KEYS_INC := \
41+
$(call intermediates-dir-for,PACKAGING,ota_keys_inc)/keys.inc
42+
# Let install.c say #include "keys.inc"
43+
LOCAL_C_INCLUDES += $(dir $(RECOVERY_INSTALL_OTA_KEYS_INC))
44+
45+
include $(BUILD_EXECUTABLE)
46+
47+
# Depend on the generated keys.inc containing the OTA public keys.
48+
$(intermediates)/install.o: $(RECOVERY_INSTALL_OTA_KEYS_INC)
49+
50+
include $(commands_recovery_local_path)/minui/Android.mk
51+
52+
endif # !TARGET_SIMULATOR
53+
54+
include $(commands_recovery_local_path)/amend/Android.mk
55+
include $(commands_recovery_local_path)/minzip/Android.mk
56+
include $(commands_recovery_local_path)/mtdutils/Android.mk
57+
commands_recovery_local_path :=

amend/Android.mk

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2007 The Android Open Source Project
2+
#
3+
4+
LOCAL_PATH := $(call my-dir)
5+
6+
amend_src_files := \
7+
amend.c \
8+
lexer.l \
9+
parser_y.y \
10+
ast.c \
11+
symtab.c \
12+
commands.c \
13+
permissions.c \
14+
execute.c
15+
16+
amend_test_files := \
17+
test_symtab.c \
18+
test_commands.c \
19+
test_permissions.c
20+
21+
# "-x c" forces the lex/yacc files to be compiled as c;
22+
# the build system otherwise forces them to be c++.
23+
amend_cflags := -Wall -x c
24+
25+
#
26+
# Build the host-side command line tool
27+
#
28+
include $(CLEAR_VARS)
29+
30+
LOCAL_SRC_FILES := \
31+
$(amend_src_files) \
32+
$(amend_test_files) \
33+
register.c \
34+
main.c
35+
36+
LOCAL_CFLAGS := $(amend_cflags) -g -O0
37+
LOCAL_MODULE := amend
38+
LOCAL_YACCFLAGS := -v
39+
40+
include $(BUILD_HOST_EXECUTABLE)
41+
42+
#
43+
# Build the device-side library
44+
#
45+
include $(CLEAR_VARS)
46+
47+
LOCAL_SRC_FILES := $(amend_src_files)
48+
LOCAL_SRC_FILES += $(amend_test_files)
49+
50+
LOCAL_CFLAGS := $(amend_cflags)
51+
LOCAL_MODULE := libamend
52+
53+
include $(BUILD_STATIC_LIBRARY)

amend/amend.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2007 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 <stdlib.h>
18+
#include "amend.h"
19+
#include "lexer.h"
20+
21+
extern const AmCommandList *gCommands;
22+
23+
const AmCommandList *
24+
parseAmendScript(const char *buf, size_t bufLen)
25+
{
26+
setLexerInputBuffer(buf, bufLen);
27+
int ret = yyparse();
28+
if (ret != 0) {
29+
return NULL;
30+
}
31+
return gCommands;
32+
}

amend/amend.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2007 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+
#ifndef AMEND_H_
18+
#define AMEND_H_
19+
20+
#include "ast.h"
21+
#include "execute.h"
22+
23+
const AmCommandList *parseAmendScript(const char *buf, size_t bufLen);
24+
25+
#endif // AMEND_H_

amend/ast.c

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
/*
2+
* Copyright (C) 2007 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 <stdio.h>
18+
#include "ast.h"
19+
20+
static const char gSpaces[] =
21+
" "
22+
" "
23+
" "
24+
" "
25+
" "
26+
" "
27+
" ";
28+
const int gSpacesMax = sizeof(gSpaces) - 1;
29+
30+
static const char *
31+
pad(int level)
32+
{
33+
level *= 4;
34+
if (level > gSpacesMax) {
35+
level = gSpacesMax;
36+
}
37+
return gSpaces + gSpacesMax - level;
38+
}
39+
40+
void dumpBooleanValue(int level, const AmBooleanValue *booleanValue);
41+
void dumpStringValue(int level, const AmStringValue *stringValue);
42+
43+
void
44+
dumpBooleanExpression(int level, const AmBooleanExpression *booleanExpression)
45+
{
46+
const char *op;
47+
bool unary = false;
48+
49+
switch (booleanExpression->op) {
50+
case AM_BOP_NOT:
51+
op = "NOT";
52+
unary = true;
53+
break;
54+
case AM_BOP_EQ:
55+
op = "EQ";
56+
break;
57+
case AM_BOP_NE:
58+
op = "NE";
59+
break;
60+
case AM_BOP_AND:
61+
op = "AND";
62+
break;
63+
case AM_BOP_OR:
64+
op = "OR";
65+
break;
66+
default:
67+
op = "??";
68+
break;
69+
}
70+
71+
printf("%sBOOLEAN %s {\n", pad(level), op);
72+
dumpBooleanValue(level + 1, booleanExpression->arg1);
73+
if (!unary) {
74+
dumpBooleanValue(level + 1, booleanExpression->arg2);
75+
}
76+
printf("%s}\n", pad(level));
77+
}
78+
79+
void
80+
dumpFunctionArguments(int level, const AmFunctionArguments *functionArguments)
81+
{
82+
int i;
83+
for (i = 0; i < functionArguments->argc; i++) {
84+
dumpStringValue(level, &functionArguments->argv[i]);
85+
}
86+
}
87+
88+
void
89+
dumpFunctionCall(int level, const AmFunctionCall *functionCall)
90+
{
91+
printf("%sFUNCTION %s (\n", pad(level), functionCall->name);
92+
dumpFunctionArguments(level + 1, functionCall->args);
93+
printf("%s)\n", pad(level));
94+
}
95+
96+
void
97+
dumpStringValue(int level, const AmStringValue *stringValue)
98+
{
99+
switch (stringValue->type) {
100+
case AM_SVAL_LITERAL:
101+
printf("%s\"%s\"\n", pad(level), stringValue->u.literal);
102+
break;
103+
case AM_SVAL_FUNCTION:
104+
dumpFunctionCall(level, stringValue->u.function);
105+
break;
106+
default:
107+
printf("%s<UNKNOWN SVAL TYPE %d>\n", pad(level), stringValue->type);
108+
break;
109+
}
110+
}
111+
112+
void
113+
dumpStringComparisonExpression(int level,
114+
const AmStringComparisonExpression *stringComparisonExpression)
115+
{
116+
const char *op;
117+
118+
switch (stringComparisonExpression->op) {
119+
case AM_SOP_LT:
120+
op = "LT";
121+
break;
122+
case AM_SOP_LE:
123+
op = "LE";
124+
break;
125+
case AM_SOP_GT:
126+
op = "GT";
127+
break;
128+
case AM_SOP_GE:
129+
op = "GE";
130+
break;
131+
case AM_SOP_EQ:
132+
op = "EQ";
133+
break;
134+
case AM_SOP_NE:
135+
op = "NE";
136+
break;
137+
default:
138+
op = "??";
139+
break;
140+
}
141+
printf("%sSTRING %s {\n", pad(level), op);
142+
dumpStringValue(level + 1, stringComparisonExpression->arg1);
143+
dumpStringValue(level + 1, stringComparisonExpression->arg2);
144+
printf("%s}\n", pad(level));
145+
}
146+
147+
void
148+
dumpBooleanValue(int level, const AmBooleanValue *booleanValue)
149+
{
150+
switch (booleanValue->type) {
151+
case AM_BVAL_EXPRESSION:
152+
dumpBooleanExpression(level, &booleanValue->u.expression);
153+
break;
154+
case AM_BVAL_STRING_COMPARISON:
155+
dumpStringComparisonExpression(level,
156+
&booleanValue->u.stringComparison);
157+
break;
158+
default:
159+
printf("%s<UNKNOWN BVAL TYPE %d>\n", pad(1), booleanValue->type);
160+
break;
161+
}
162+
}
163+
164+
void
165+
dumpWordList(const AmWordList *wordList)
166+
{
167+
int i;
168+
for (i = 0; i < wordList->argc; i++) {
169+
printf("%s\"%s\"\n", pad(1), wordList->argv[i]);
170+
}
171+
}
172+
173+
void
174+
dumpCommandArguments(const AmCommandArguments *commandArguments)
175+
{
176+
if (commandArguments->booleanArgs) {
177+
dumpBooleanValue(1, commandArguments->u.b);
178+
} else {
179+
dumpWordList(commandArguments->u.w);
180+
}
181+
}
182+
183+
void
184+
dumpCommand(const AmCommand *command)
185+
{
186+
printf("command \"%s\" {\n", command->name);
187+
dumpCommandArguments(command->args);
188+
printf("}\n");
189+
}
190+
191+
void
192+
dumpCommandList(const AmCommandList *commandList)
193+
{
194+
int i;
195+
for (i = 0; i < commandList->commandCount; i++) {
196+
dumpCommand(commandList->commands[i]);
197+
}
198+
}

0 commit comments

Comments
 (0)