1 // 2 // Copyright (C) 2019 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 #pragma once 18 19 #include <string> 20 21 namespace android { 22 namespace gsi { 23 24 static constexpr char kGsiServiceName[] = "gsiservice"; 25 26 static constexpr char kGsiBootedIndicatorFile[] = "/metadata/gsi/dsu/booted"; 27 28 static constexpr char kGsiBootedProp[] = "ro.gsid.image_running"; 29 30 static constexpr int kMaxBootAttempts = 1; 31 32 // Returns true if the currently running system image is a live GSI. 33 bool IsGsiRunning(); 34 35 // Return true if a GSI is installed (but not necessarily running). 36 bool IsGsiInstalled(); 37 38 // Set the GSI as no longer bootable. This effectively removes the GSI. If no 39 // GSI was bootable, false is returned. 40 bool UninstallGsi(); 41 42 // Set the GSI as no longer bootable, without removing its installed files. 43 bool DisableGsi(); 44 45 // Returns true if init should attempt to boot into a live GSI image, false 46 // otherwise. If true, then the path to the liblp metadata file is set. If 47 // false, an error message is set instead. 48 // 49 // This is only called by first-stage init. 50 bool CanBootIntoGsi(std::string* metadata_file, std::string* error); 51 52 // Called by first-stage init to indicate that we're about to boot into a 53 // GSI. 54 bool MarkSystemAsGsi(); 55 56 } // namespace gsi 57 } // namespace android 58