blob: 49c34dda4c743b1a3fc5fa04037187d15eadc10d [file] [log] [blame]
David Pursell54a8fe42017-09-29 16:05:26 -07001/*
2 * Copyright (C) 2017 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 _BOOTANIMATION_BOOT_PARAMETERS_H_
18#define _BOOTANIMATION_BOOT_PARAMETERS_H_
19
20#include <list>
Mickey Keeley953f1092018-04-26 11:06:06 -070021#include <string>
David Pursell54a8fe42017-09-29 16:05:26 -070022#include <vector>
23
David Pursell54a8fe42017-09-29 16:05:26 -070024#include <boot_action/boot_action.h> // libandroidthings native API.
Mickey Keeleydfaa9c52018-04-26 15:05:25 -070025#include <json/json.h>
David Pursell54a8fe42017-09-29 16:05:26 -070026
27namespace android {
28
29// Provides access to the parameters set by DeviceManager.reboot().
30class BootParameters {
31public:
32 // Constructor loads the parameters for this boot and swaps the param files
33 // to clear the parameters for next boot.
34 BootParameters();
35
Mickey Keeley1ffcc5e2018-05-07 09:42:19 -070036 // Returns whether or not this is a silent boot.
37 bool isSilentBoot() const { return mIsSilentBoot; }
David Pursell54a8fe42017-09-29 16:05:26 -070038
39 // Returns the additional boot parameters that were set on reboot.
40 const std::vector<ABootActionParameter>& getParameters() const { return mParameters; }
41
Mickey Keeley953f1092018-04-26 11:06:06 -070042 // Exposed for testing. Updates the parameters with new JSON values.
43 void loadParameters(const std::string& raw_json);
David Pursell54a8fe42017-09-29 16:05:26 -070044private:
David Pursell54a8fe42017-09-29 16:05:26 -070045 void loadParameters();
46
Mickey Keeley1ffcc5e2018-05-07 09:42:19 -070047 void parseBootParameters();
48
49 bool mIsSilentBoot = false;
50
David Pursell54a8fe42017-09-29 16:05:26 -070051 std::vector<ABootActionParameter> mParameters;
52
Mickey Keeleydfaa9c52018-04-26 15:05:25 -070053 // Store parsed JSON because mParameters makes a shallow copy.
54 Json::Value mJson;
Mickey Keeley1ffcc5e2018-05-07 09:42:19 -070055
56 // Store parameter keys because mParameters makes a shallow copy.
57 Json::Value::Members mKeys;
David Pursell54a8fe42017-09-29 16:05:26 -070058};
59
60} // namespace android
61
62
63#endif // _BOOTANIMATION_BOOT_PARAMETERS_H_