1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_APEXD_APEXD_H_
#define ANDROID_APEXD_APEXD_H_
#include <string>
#include <vector>
#include <android-base/macros.h>
#include <android-base/result.h>
#include "apex_constants.h"
#include "apex_file.h"
namespace android {
namespace apex {
class CheckpointInterface;
android::base::Result<void> resumeRevertIfNeeded();
// Keep it for now to make otapreopt_chroot keep happy.
// TODO(b/137086602): remove this function.
android::base::Result<void> scanPackagesDirAndActivate(
const char* apex_package_dir);
void scanStagedSessionsDirAndStage();
android::base::Result<void> preinstallPackages(
const std::vector<std::string>& paths) WARN_UNUSED;
android::base::Result<void> postinstallPackages(
const std::vector<std::string>& paths) WARN_UNUSED;
android::base::Result<void> stagePackages(
const std::vector<std::string>& tmpPaths) WARN_UNUSED;
android::base::Result<void> unstagePackages(
const std::vector<std::string>& paths) WARN_UNUSED;
android::base::Result<std::vector<ApexFile>> submitStagedSession(
const int session_id, const std::vector<int>& child_session_ids,
const bool has_rollback_enabled, const bool is_rollback,
const int rollback_id) WARN_UNUSED;
android::base::Result<void> markStagedSessionReady(const int session_id)
WARN_UNUSED;
android::base::Result<void> markStagedSessionSuccessful(const int session_id)
WARN_UNUSED;
android::base::Result<void> revertActiveSessions(
const std::string& crashing_native_process);
android::base::Result<void> revertActiveSessionsAndReboot(
const std::string& crashing_native_process);
android::base::Result<void> activatePackage(const std::string& full_path)
WARN_UNUSED;
android::base::Result<void> deactivatePackage(const std::string& full_path)
WARN_UNUSED;
std::vector<ApexFile> getActivePackages();
android::base::Result<ApexFile> getActivePackage(
const std::string& package_name);
std::vector<ApexFile> getFactoryPackages();
android::base::Result<void> abortStagedSession(const int session_id);
android::base::Result<void> abortActiveSession();
android::base::Result<ino_t> snapshotCeData(const int user_id,
const int rollback_id,
const std::string& apex_name);
android::base::Result<void> restoreCeData(const int user_id,
const int rollback_id,
const std::string& apex_name);
android::base::Result<void> destroyDeSnapshots(const int rollback_id);
android::base::Result<void> destroyCeSnapshotsNotSpecified(
int user_id, const std::vector<int>& retain_rollback_ids);
int onBootstrap();
// Small helper function to tell if device is currently booting.
bool isBooting();
// Sets the values of gVoldService and gInFsCheckpointMode.
void initializeVold(CheckpointInterface* checkpoint_service);
// Initializes in-memory state (e.g. pre-installed data, activated apexes).
// Must be called first before calling any other boot sequence related function.
void initialize(CheckpointInterface* checkpoint_service);
// Migrates sessions from /data/apex/session to /metadata/session.i
// Must only be called during boot (i.e apexd.status is not "ready" or
// "activated").
android::base::Result<void> migrateSessionsDirIfNeeded();
// Apex activation logic. Scans staged apex sessions and activates apexes.
// Must only be called during boot (i.e apexd.status is not "ready" or
// "activated").
void onStart();
// Notifies system that apexes are activated by setting apexd.status property to
// "activated".
// Must only be called during boot (i.e. apexd.status is not "ready" or
// "activated").
void onAllPackagesActivated();
// Notifies system that apexes are ready by setting apexd.status property to
// "ready".
// Must only be called during boot (i.e. apexd.status is not "ready" or
// "activated").
void onAllPackagesReady();
void bootCompletedCleanup();
int snapshotOrRestoreDeUserData();
int unmountAll();
// Optimistically tries to remount as many APEX packages as possible.
// For more documentation see corresponding binder call in IApexService.aidl.
android::base::Result<void> remountPackages();
} // namespace apex
} // namespace android
#endif // ANDROID_APEXD_APEXD_H_
|