| Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | ** | 
|  | 3 | ** Copyright 2008, The Android Open Source Project | 
|  | 4 | ** | 
| Jeff Sharkey | f3e30b9 | 2016-12-09 17:06:57 -0700 | [diff] [blame] | 5 | ** 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 Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 8 | ** | 
| Jeff Sharkey | f3e30b9 | 2016-12-09 17:06:57 -0700 | [diff] [blame] | 9 | **     http://www.apache.org/licenses/LICENSE-2.0 | 
| Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 10 | ** | 
| Jeff Sharkey | f3e30b9 | 2016-12-09 17:06:57 -0700 | [diff] [blame] | 11 | ** 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 Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 15 | ** 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 Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 24 | #include <vector> | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 25 | #include <unordered_map> | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 26 |  | 
| Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 27 | #include <android-base/macros.h> | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 28 | #include <binder/BinderService.h> | 
| Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 29 | #include <cutils/multiuser.h> | 
|  | 30 |  | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 31 | #include "android/os/BnInstalld.h" | 
|  | 32 | #include "installd_constants.h" | 
| Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 33 |  | 
|  | 34 | namespace android { | 
|  | 35 | namespace installd { | 
|  | 36 |  | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 37 | class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld { | 
|  | 38 | public: | 
|  | 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 Gampe | d089ca1 | 2016-06-27 14:25:30 -0700 | [diff] [blame] | 42 |  | 
| Jeff Sharkey | c1e93e7 | 2016-12-05 23:39:32 -0700 | [diff] [blame] | 43 | 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 Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 48 | 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 Sharkey | 36a900a | 2016-12-19 16:39:18 -0700 | [diff] [blame] | 50 | const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return); | 
| Jeff Sharkey | c1e93e7 | 2016-12-05 23:39:32 -0700 | [diff] [blame] | 51 | 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 Sharkey | df2d754 | 2017-01-07 09:19:35 -0700 | [diff] [blame] | 60 |  | 
| Jeff Sharkey | e12d596 | 2017-04-03 16:41:02 -0600 | [diff] [blame] | 61 | binder::Status fixupAppData(const std::unique_ptr<std::string>& uuid, int32_t flags); | 
|  | 62 |  | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 63 | binder::Status getAppSize(const std::unique_ptr<std::string>& uuid, | 
| Jeff Sharkey | df2d754 | 2017-01-07 09:19:35 -0700 | [diff] [blame] | 64 | 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, | 
| Jeff Sharkey | a084fcd | 2017-04-17 16:44:41 -0600 | [diff] [blame] | 71 | int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, | 
|  | 72 | std::vector<int64_t>* _aidl_return); | 
| Jeff Sharkey | c1e93e7 | 2016-12-05 23:39:32 -0700 | [diff] [blame] | 73 |  | 
| Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 74 | binder::Status setAppQuota(const std::unique_ptr<std::string>& uuid, | 
|  | 75 | int32_t userId, int32_t appId, int64_t cacheQuota); | 
|  | 76 |  | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 77 | binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid, | 
|  | 78 | const std::unique_ptr<std::string>& toUuid, const std::string& packageName, | 
|  | 79 | const std::string& dataAppName, int32_t appId, const std::string& seInfo, | 
|  | 80 | int32_t targetSdkVersion); | 
| Jeff Sharkey | 475c6f9 | 2016-12-07 10:37:27 -0700 | [diff] [blame] | 81 |  | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 82 | binder::Status dexopt(const std::string& apkPath, int32_t uid, | 
|  | 83 | const std::unique_ptr<std::string>& packageName, const std::string& instructionSet, | 
|  | 84 | int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags, | 
|  | 85 | const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid, | 
| Calin Juravle | 52c4582 | 2017-07-13 22:50:21 -0700 | [diff] [blame] | 86 | const std::unique_ptr<std::string>& classLoaderContext, | 
| Shubham Ajmera | 54ef862 | 2017-06-22 11:10:27 -0700 | [diff] [blame] | 87 | const std::unique_ptr<std::string>& seInfo, bool downgrade); | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 88 |  | 
| Jeff Sharkey | 475c6f9 | 2016-12-07 10:37:27 -0700 | [diff] [blame] | 89 | binder::Status rmdex(const std::string& codePath, const std::string& instructionSet); | 
|  | 90 |  | 
|  | 91 | binder::Status mergeProfiles(int32_t uid, const std::string& packageName, bool* _aidl_return); | 
|  | 92 | binder::Status dumpProfiles(int32_t uid, const std::string& packageName, | 
|  | 93 | const std::string& codePaths, bool* _aidl_return); | 
| Mathieu Chartier | f966f2a | 2017-05-10 12:48:37 -0700 | [diff] [blame] | 94 | binder::Status copySystemProfile(const std::string& systemProfile, | 
|  | 95 | int32_t uid, const std::string& packageName, bool* _aidl_return); | 
| Jeff Sharkey | 475c6f9 | 2016-12-07 10:37:27 -0700 | [diff] [blame] | 96 | binder::Status clearAppProfiles(const std::string& packageName); | 
|  | 97 | binder::Status destroyAppProfiles(const std::string& packageName); | 
|  | 98 |  | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 99 | binder::Status idmap(const std::string& targetApkPath, const std::string& overlayApkPath, | 
|  | 100 | int32_t uid); | 
| MÃ¥rten Kongstad | 5c6944c | 2015-12-15 14:02:30 +0100 | [diff] [blame] | 101 | binder::Status removeIdmap(const std::string& overlayApkPath); | 
| Jeff Sharkey | 475c6f9 | 2016-12-07 10:37:27 -0700 | [diff] [blame] | 102 | binder::Status rmPackageDir(const std::string& packageDir); | 
|  | 103 | binder::Status markBootComplete(const std::string& instructionSet); | 
| Jeff Sharkey | 60f8a53 | 2017-05-30 14:38:42 -0600 | [diff] [blame] | 104 | binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t targetFreeBytes, | 
|  | 105 | int64_t cacheReservedBytes, int32_t flags); | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 106 | binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid, | 
|  | 107 | const std::string& packageName, const std::string& nativeLibPath32, int32_t userId); | 
| Jeff Sharkey | 475c6f9 | 2016-12-07 10:37:27 -0700 | [diff] [blame] | 108 | binder::Status createOatDir(const std::string& oatDir, const std::string& instructionSet); | 
| Jeff Sharkey | 6c2c056 | 2016-12-07 12:12:00 -0700 | [diff] [blame] | 109 | binder::Status linkFile(const std::string& relativePath, const std::string& fromBase, | 
|  | 110 | const std::string& toBase); | 
|  | 111 | binder::Status moveAb(const std::string& apkPath, const std::string& instructionSet, | 
|  | 112 | const std::string& outputPath); | 
|  | 113 | binder::Status deleteOdex(const std::string& apkPath, const std::string& instructionSet, | 
| Andreas Gampe | c523409 | 2017-05-31 16:39:58 -0700 | [diff] [blame] | 114 | const std::unique_ptr<std::string>& outputPath); | 
| Calin Juravle | bd96836 | 2017-01-25 01:17:17 -0800 | [diff] [blame] | 115 | binder::Status reconcileSecondaryDexFile(const std::string& dexPath, | 
|  | 116 | const std::string& packageName, int32_t uid, const std::vector<std::string>& isa, | 
|  | 117 | const std::unique_ptr<std::string>& volumeUuid, int32_t storage_flag, bool* _aidl_return); | 
| Jeff Sharkey | 7a9059e | 2017-01-16 19:07:18 -0700 | [diff] [blame] | 118 |  | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 119 | binder::Status invalidateMounts(); | 
| Jeff Sharkey | 325b8c9 | 2017-02-21 10:00:53 -0700 | [diff] [blame] | 120 | binder::Status isQuotaSupported(const std::unique_ptr<std::string>& volumeUuid, | 
|  | 121 | bool* _aidl_return); | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 122 |  | 
| Jeff Sharkey | 7a9059e | 2017-01-16 19:07:18 -0700 | [diff] [blame] | 123 | private: | 
|  | 124 | std::recursive_mutex mLock; | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 125 |  | 
| Jeff Sharkey | d712f0c | 2017-05-03 11:36:42 -0600 | [diff] [blame] | 126 | std::recursive_mutex mMountsLock; | 
|  | 127 | std::recursive_mutex mQuotasLock; | 
| Jeff Sharkey | b26786d | 2017-03-11 19:40:29 -0700 | [diff] [blame] | 128 |  | 
| Jeff Sharkey | d712f0c | 2017-05-03 11:36:42 -0600 | [diff] [blame] | 129 | /* Map of all storage mounts from source to target */ | 
|  | 130 | std::unordered_map<std::string, std::string> mStorageMounts; | 
|  | 131 | /* Map of all quota mounts from target to source */ | 
|  | 132 | std::unordered_map<std::string, std::string> mQuotaReverseMounts; | 
|  | 133 |  | 
| Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 134 | /* Map from UID to cache quota size */ | 
|  | 135 | std::unordered_map<uid_t, int64_t> mCacheQuotas; | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 136 |  | 
| Jeff Sharkey | d712f0c | 2017-05-03 11:36:42 -0600 | [diff] [blame] | 137 | std::string findDataMediaPath(const std::unique_ptr<std::string>& uuid, userid_t userid); | 
| Jeff Sharkey | 66b1a12 | 2017-01-16 20:57:45 -0700 | [diff] [blame] | 138 | std::string findQuotaDeviceForUuid(const std::unique_ptr<std::string>& uuid); | 
| Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame] | 139 | }; | 
|  | 140 |  | 
| Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 141 | }  // namespace installd | 
|  | 142 | }  // namespace android | 
|  | 143 |  | 
|  | 144 | #endif  // COMMANDS_H_ |