blob: 0208fb147ca8da5cbed5857070823ef58c3758dd [file] [log] [blame]
Andreas Gampe02d0de52015-11-11 20:43:16 -08001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
Jeff Sharkeyf3e30b92016-12-09 17:06:57 -07005** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
Andreas Gampe02d0de52015-11-11 20:43:16 -08008**
Jeff Sharkeyf3e30b92016-12-09 17:06:57 -07009** http://www.apache.org/licenses/LICENSE-2.0
Andreas Gampe02d0de52015-11-11 20:43:16 -080010**
Jeff Sharkeyf3e30b92016-12-09 17:06:57 -070011** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
Andreas Gampe02d0de52015-11-11 20:43:16 -080015** limitations under the License.
16*/
17
18#ifndef COMMANDS_H_
19#define COMMANDS_H_
20
21#include <inttypes.h>
22#include <unistd.h>
23
Jeff Sharkey0274c972016-12-06 09:32:04 -070024#include <vector>
Jeff Sharkey66b1a122017-01-16 20:57:45 -070025#include <unordered_map>
Jeff Sharkey0274c972016-12-06 09:32:04 -070026
27#include <binder/BinderService.h>
Andreas Gampe02d0de52015-11-11 20:43:16 -080028#include <cutils/multiuser.h>
29
Jeff Sharkey0274c972016-12-06 09:32:04 -070030#include "android/os/BnInstalld.h"
31#include "installd_constants.h"
Andreas Gampe02d0de52015-11-11 20:43:16 -080032
33namespace android {
34namespace installd {
35
Jeff Sharkey0274c972016-12-06 09:32:04 -070036class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld {
37public:
38 static status_t start();
39 static char const* getServiceName() { return "installd"; }
40 virtual status_t dump(int fd, const Vector<String16> &args) override;
Andreas Gamped089ca12016-06-27 14:25:30 -070041
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070042 binder::Status createUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
43 int32_t userSerial, int32_t flags);
44 binder::Status destroyUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
45 int32_t flags);
46
Jeff Sharkey0274c972016-12-06 09:32:04 -070047 binder::Status createAppData(const std::unique_ptr<std::string>& uuid,
48 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
Jeff Sharkey36a900a2016-12-19 16:39:18 -070049 const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return);
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070050 binder::Status restoreconAppData(const std::unique_ptr<std::string>& uuid,
51 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
52 const std::string& seInfo);
53 binder::Status migrateAppData(const std::unique_ptr<std::string>& uuid,
54 const std::string& packageName, int32_t userId, int32_t flags);
55 binder::Status clearAppData(const std::unique_ptr<std::string>& uuid,
56 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
57 binder::Status destroyAppData(const std::unique_ptr<std::string>& uuid,
58 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
Jeff Sharkeydf2d7542017-01-07 09:19:35 -070059
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070060 binder::Status getAppSize(const std::unique_ptr<std::string>& uuid,
Jeff Sharkeydf2d7542017-01-07 09:19:35 -070061 const std::vector<std::string>& packageNames, int32_t userId, int32_t flags,
62 int32_t appId, const std::vector<int64_t>& ceDataInodes,
63 const std::vector<std::string>& codePaths, std::vector<int64_t>* _aidl_return);
64 binder::Status getUserSize(const std::unique_ptr<std::string>& uuid,
65 int32_t userId, int32_t flags, const std::vector<int32_t>& appIds,
66 std::vector<int64_t>* _aidl_return);
67 binder::Status getExternalSize(const std::unique_ptr<std::string>& uuid,
68 int32_t userId, int32_t flags, std::vector<int64_t>* _aidl_return);
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070069
Jeff Sharkey0274c972016-12-06 09:32:04 -070070 binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid,
71 const std::unique_ptr<std::string>& toUuid, const std::string& packageName,
72 const std::string& dataAppName, int32_t appId, const std::string& seInfo,
73 int32_t targetSdkVersion);
Jeff Sharkey475c6f92016-12-07 10:37:27 -070074
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070075 binder::Status dexopt(const std::string& apkPath, int32_t uid,
76 const std::unique_ptr<std::string>& packageName, const std::string& instructionSet,
77 int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags,
78 const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid,
79 const std::unique_ptr<std::string>& sharedLibraries);
80
Jeff Sharkey475c6f92016-12-07 10:37:27 -070081 binder::Status rmdex(const std::string& codePath, const std::string& instructionSet);
82
83 binder::Status mergeProfiles(int32_t uid, const std::string& packageName, bool* _aidl_return);
84 binder::Status dumpProfiles(int32_t uid, const std::string& packageName,
85 const std::string& codePaths, bool* _aidl_return);
86 binder::Status clearAppProfiles(const std::string& packageName);
87 binder::Status destroyAppProfiles(const std::string& packageName);
88
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070089 binder::Status idmap(const std::string& targetApkPath, const std::string& overlayApkPath,
90 int32_t uid);
Jeff Sharkey475c6f92016-12-07 10:37:27 -070091 binder::Status rmPackageDir(const std::string& packageDir);
92 binder::Status markBootComplete(const std::string& instructionSet);
93 binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t freeStorageSize);
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070094 binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid,
95 const std::string& packageName, const std::string& nativeLibPath32, int32_t userId);
Jeff Sharkey475c6f92016-12-07 10:37:27 -070096 binder::Status createOatDir(const std::string& oatDir, const std::string& instructionSet);
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070097 binder::Status linkFile(const std::string& relativePath, const std::string& fromBase,
98 const std::string& toBase);
99 binder::Status moveAb(const std::string& apkPath, const std::string& instructionSet,
100 const std::string& outputPath);
101 binder::Status deleteOdex(const std::string& apkPath, const std::string& instructionSet,
102 const std::string& outputPath);
Jeff Sharkey7a9059e2017-01-16 19:07:18 -0700103
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700104 binder::Status invalidateMounts();
105
Jeff Sharkey7a9059e2017-01-16 19:07:18 -0700106private:
107 std::recursive_mutex mLock;
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700108
109 /* Map from mount point to underlying device node */
110 std::unordered_map<std::string, std::string> mQuotaDevices;
111
112 std::string findQuotaDeviceForUuid(const std::unique_ptr<std::string>& uuid);
Jeff Sharkey0274c972016-12-06 09:32:04 -0700113};
114
Andreas Gampe02d0de52015-11-11 20:43:16 -0800115} // namespace installd
116} // namespace android
117
118#endif // COMMANDS_H_