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 <errno.h>
18 #include <fcntl.h>
19 #include <linux/fb.h>
20 #include <pthread.h>
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/ioctl.h>
26 #include <sys/time.h>
27 #include <sys/types.h>
28 #include <time.h>
29 #include <unistd.h>
30
31 #include "common.h"
32 #include "debug_cmd.h"
33 #include "device.h"
34 #include "edify/expr.h"
35 #include "flash_device.h"
36 #include "fmap.h"
37 #include "screen_ui.h"
38 #include "ui.h"
39 #include "update_fw.h"
40 #include "vboot_interface.h"
41
42 extern char *reason;
43
44 class DragonDevice : public Device {
45 public:
DragonDevice(RecoveryUI * ui)46 DragonDevice(RecoveryUI* ui) : Device(ui) { }
47
PostWipeData()48 virtual bool PostWipeData() {
49
50 if (reason) {
51 struct flash_device *spi = flash_open("spi", NULL);
52
53 if (spi == NULL)
54 return true;
55
56 if (!strcmp(reason, "fastboot_oem_unlock")) {
57 vbnv_set_flag(spi, "dev_boot_fastboot_full_cap", 0x1);
58 vbnv_set_flag(spi, "recovery_reason", 0xC3);
59 } else if (!strcmp(reason, "fastboot_oem_lock")) {
60 vbnv_set_flag(spi, "dev_boot_fastboot_full_cap", 0x0);
61 vbnv_set_flag(spi, "recovery_reason", 0xC3);
62 }
63
64 flash_close(spi);
65 }
66
67 return true;
68 };
69 };
70
71
make_device()72 Device* make_device() {
73 return new DragonDevice(new ScreenRecoveryUI);
74 }
75