blob: f5b7142a1231ab94249ab1669ba04910afc9e110 [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
Jeff Sharkey88ddd942017-01-17 18:05:54 -070027#include <android-base/macros.h>
Jeff Sharkey0274c972016-12-06 09:32:04 -070028#include <binder/BinderService.h>
Andreas Gampe02d0de52015-11-11 20:43:16 -080029#include <cutils/multiuser.h>
30
Jeff Sharkey0274c972016-12-06 09:32:04 -070031#include "android/os/BnInstalld.h"
32#include "installd_constants.h"
Andreas Gampe02d0de52015-11-11 20:43:16 -080033
34namespace android {
35namespace installd {
36
Jeff Sharkey0274c972016-12-06 09:32:04 -070037class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld {
38public:
39 static status_t start();
40 static char const* getServiceName() { return "installd"; }
41 virtual status_t dump(int fd, const Vector<String16> &args) override;
Andreas Gamped089ca12016-06-27 14:25:30 -070042
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070043 binder::Status createUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
44 int32_t userSerial, int32_t flags);
45 binder::Status destroyUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
46 int32_t flags);
47
Jeff Sharkey0274c972016-12-06 09:32:04 -070048 binder::Status createAppData(const std::unique_ptr<std::string>& uuid,
49 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
Jeff Sharkey36a900a2016-12-19 16:39:18 -070050 const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return);
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070051 binder::Status restoreconAppData(const std::unique_ptr<std::string>& uuid,
52 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
53 const std::string& seInfo);
54 binder::Status migrateAppData(const std::unique_ptr<std::string>& uuid,
55 const std::string& packageName, int32_t userId, int32_t flags);
56 binder::Status clearAppData(const std::unique_ptr<std::string>& uuid,
57 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
58 binder::Status destroyAppData(const std::unique_ptr<std::string>& uuid,
59 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
Jeff Sharkeydf2d7542017-01-07 09:19:35 -070060
Jeff Sharkeye12d5962017-04-03 16:41:02 -060061 binder::Status fixupAppData(const std::unique_ptr<std::string>& uuid, int32_t flags);
62
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070063 binder::Status getAppSize(const std::unique_ptr<std::string>& uuid,
Jeff Sharkeydf2d7542017-01-07 09:19:35 -070064 const std::vector<std::string>& packageNames, int32_t userId, int32_t flags,
65 int32_t appId, const std::vector<int64_t>& ceDataInodes,
66 const std::vector<std::string>& codePaths, std::vector<int64_t>* _aidl_return);
67 binder::Status getUserSize(const std::unique_ptr<std::string>& uuid,
68 int32_t userId, int32_t flags, const std::vector<int32_t>& appIds,
69 std::vector<int64_t>* _aidl_return);
70 binder::Status getExternalSize(const std::unique_ptr<std::string>& uuid,
71 int32_t userId, int32_t flags, std::vector<int64_t>* _aidl_return);
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070072
Jeff Sharkey88ddd942017-01-17 18:05:54 -070073 binder::Status setAppQuota(const std::unique_ptr<std::string>& uuid,
74 int32_t userId, int32_t appId, int64_t cacheQuota);
75
Jeff Sharkey0274c972016-12-06 09:32:04 -070076 binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid,
77 const std::unique_ptr<std::string>& toUuid, const std::string& packageName,
78 const std::string& dataAppName, int32_t appId, const std::string& seInfo,
79 int32_t targetSdkVersion);
Jeff Sharkey475c6f92016-12-07 10:37:27 -070080
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070081 binder::Status dexopt(const std::string& apkPath, int32_t uid,
82 const std::unique_ptr<std::string>& packageName, const std::string& instructionSet,
83 int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags,
84 const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid,
85 const std::unique_ptr<std::string>& sharedLibraries);
86
Jeff Sharkey475c6f92016-12-07 10:37:27 -070087 binder::Status rmdex(const std::string& codePath, const std::string& instructionSet);
88
89 binder::Status mergeProfiles(int32_t uid, const std::string& packageName, bool* _aidl_return);
90 binder::Status dumpProfiles(int32_t uid, const std::string& packageName,
91 const std::string& codePaths, bool* _aidl_return);
92 binder::Status clearAppProfiles(const std::string& packageName);
93 binder::Status destroyAppProfiles(const std::string& packageName);
94
Jeff Sharkey6c2c0562016-12-07 12:12:00 -070095 binder::Status idmap(const std::string& targetApkPath, const std::string& overlayApkPath,
96 int32_t uid);
MÃ¥rten Kongstad5c6944c2015-12-15 14:02:30 +010097 binder::Status removeIdmap(const std::string& overlayApkPath);
Jeff Sharkey475c6f92016-12-07 10:37:27 -070098 binder::Status rmPackageDir(const std::string& packageDir);
99 binder::Status markBootComplete(const std::string& instructionSet);
Jeff Sharkey88ddd942017-01-17 18:05:54 -0700100 binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t freeStorageSize,
101 int32_t flags);
Jeff Sharkey6c2c0562016-12-07 12:12:00 -0700102 binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid,
103 const std::string& packageName, const std::string& nativeLibPath32, int32_t userId);
Jeff Sharkey475c6f92016-12-07 10:37:27 -0700104 binder::Status createOatDir(const std::string& oatDir, const std::string& instructionSet);
Jeff Sharkey6c2c0562016-12-07 12:12:00 -0700105 binder::Status linkFile(const std::string& relativePath, const std::string& fromBase,
106 const std::string& toBase);
107 binder::Status moveAb(const std::string& apkPath, const std::string& instructionSet,
108 const std::string& outputPath);
109 binder::Status deleteOdex(const std::string& apkPath, const std::string& instructionSet,
110 const std::string& outputPath);
Calin Juravlebd968362017-01-25 01:17:17 -0800111 binder::Status reconcileSecondaryDexFile(const std::string& dexPath,
112 const std::string& packageName, int32_t uid, const std::vector<std::string>& isa,
113 const std::unique_ptr<std::string>& volumeUuid, int32_t storage_flag, bool* _aidl_return);
Jeff Sharkey7a9059e2017-01-16 19:07:18 -0700114
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700115 binder::Status invalidateMounts();
Jeff Sharkey325b8c92017-02-21 10:00:53 -0700116 binder::Status isQuotaSupported(const std::unique_ptr<std::string>& volumeUuid,
117 bool* _aidl_return);
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700118
Jeff Sharkey7a9059e2017-01-16 19:07:18 -0700119private:
120 std::recursive_mutex mLock;
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700121
Jeff Sharkeyb26786d2017-03-11 19:40:29 -0700122 std::recursive_mutex mQuotaDevicesLock;
123 std::recursive_mutex mCacheQuotasLock;
124
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700125 /* Map from mount point to underlying device node */
126 std::unordered_map<std::string, std::string> mQuotaDevices;
Jeff Sharkey88ddd942017-01-17 18:05:54 -0700127 /* Map from UID to cache quota size */
128 std::unordered_map<uid_t, int64_t> mCacheQuotas;
Jeff Sharkey66b1a122017-01-16 20:57:45 -0700129
130 std::string findQuotaDeviceForUuid(const std::unique_ptr<std::string>& uuid);
Jeff Sharkey0274c972016-12-06 09:32:04 -0700131};
132
Andreas Gampe02d0de52015-11-11 20:43:16 -0800133} // namespace installd
134} // namespace android
135
136#endif // COMMANDS_H_