• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <string.h>
18 
19 #include "common.h"
20 #include "device.h"
21 #include "flash_device.h"
22 #include "screen_ui.h"
23 #include "ui.h"
24 #include "vboot_interface.h"
25 
26 class DragonDevice : public Device {
27   public:
DragonDevice(RecoveryUI * ui)28     DragonDevice(RecoveryUI* ui) : Device(ui) { }
29 
PostWipeData()30     virtual bool PostWipeData() {
31         if (reason) {
32             struct flash_device *spi = flash_open("spi", NULL);
33 
34             if (spi == NULL) {
35                 return true;
36             }
37 
38             if (!strcmp(reason, "fastboot_oem_unlock")) {
39                 vbnv_set_flag(spi, "dev_boot_fastboot_full_cap", 0x1);
40                 vbnv_set_flag(spi, "recovery_reason", 0xC3);
41             } else if (!strcmp(reason, "fastboot_oem_lock")) {
42                 vbnv_set_flag(spi, "dev_boot_fastboot_full_cap", 0x0);
43                 vbnv_set_flag(spi, "recovery_reason", 0xC3);
44             }
45 
46             flash_close(spi);
47         }
48 
49         return true;
50     };
51 };
52 
53 
make_device()54 Device* make_device() {
55     return new DragonDevice(new ScreenRecoveryUI);
56 }
57