Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2008, The Android Open Source Project |
| 4 | ** |
| 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 |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 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 |
| 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> |
| 25 | |
| 26 | #include <binder/BinderService.h> |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 27 | #include <cutils/multiuser.h> |
| 28 | |
Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame^] | 29 | #include "android/os/BnInstalld.h" |
| 30 | #include "installd_constants.h" |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | namespace installd { |
| 34 | |
Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame^] | 35 | class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld { |
| 36 | public: |
| 37 | static status_t start(); |
| 38 | static char const* getServiceName() { return "installd"; } |
| 39 | virtual status_t dump(int fd, const Vector<String16> &args) override; |
Andreas Gampe | d089ca1 | 2016-06-27 14:25:30 -0700 | [diff] [blame] | 40 | |
Jeff Sharkey | 0274c97 | 2016-12-06 09:32:04 -0700 | [diff] [blame^] | 41 | binder::Status createAppData(const std::unique_ptr<std::string>& uuid, |
| 42 | const std::string& packageName, int32_t userId, int32_t flags, int32_t appId, |
| 43 | const std::string& seInfo, int32_t targetSdkVersion); |
| 44 | binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid, |
| 45 | const std::unique_ptr<std::string>& toUuid, const std::string& packageName, |
| 46 | const std::string& dataAppName, int32_t appId, const std::string& seInfo, |
| 47 | int32_t targetSdkVersion); |
| 48 | }; |
| 49 | |
Jeff Sharkey | c7d1b22 | 2016-01-11 13:07:09 -0700 | [diff] [blame] | 50 | int restorecon_app_data(const char* uuid, const char* pkgName, userid_t userid, int flags, |
| 51 | appid_t appid, const char* seinfo); |
Jeff Sharkey | cc6281c | 2016-02-06 19:46:09 -0700 | [diff] [blame] | 52 | int migrate_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags); |
Jeff Sharkey | 2f720f7 | 2016-04-10 20:51:40 -0600 | [diff] [blame] | 53 | int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags, |
| 54 | ino_t ce_data_inode); |
| 55 | int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags, |
| 56 | ino_t ce_data_inode); |
Jeff Sharkey | c7d1b22 | 2016-01-11 13:07:09 -0700 | [diff] [blame] | 57 | |
Jeff Sharkey | 2f720f7 | 2016-04-10 20:51:40 -0600 | [diff] [blame] | 58 | int get_app_size(const char *uuid, const char *pkgname, int userid, int flags, ino_t ce_data_inode, |
| 59 | const char* code_path, int64_t *codesize, int64_t *datasize, int64_t *cachesize, |
| 60 | int64_t *asecsize); |
| 61 | int get_app_data_inode(const char *uuid, const char *pkgname, int userid, int flags, ino_t *inode); |
Jeff Sharkey | c7d1b22 | 2016-01-11 13:07:09 -0700 | [diff] [blame] | 62 | |
Jeff Sharkey | 379a12b | 2016-04-14 20:45:06 -0600 | [diff] [blame] | 63 | int create_user_data(const char *uuid, userid_t userid, int user_serial, int flags); |
| 64 | int destroy_user_data(const char *uuid, userid_t userid, int flags); |
| 65 | |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 66 | int rm_dex(const char *path, const char *instruction_set); |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 67 | int free_cache(const char *uuid, int64_t free_size); |
Andreas Gampe | 4d0f825 | 2016-03-20 11:30:28 -0700 | [diff] [blame] | 68 | |
| 69 | bool merge_profiles(uid_t uid, const char *pkgname); |
| 70 | |
David Sehr | 6727c2d | 2016-05-17 16:06:22 -0700 | [diff] [blame] | 71 | bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files); |
| 72 | |
Andreas Gampe | 548bdb9 | 2016-06-02 17:56:45 -0700 | [diff] [blame] | 73 | int dexopt(const char *apk_path, |
| 74 | uid_t uid, |
| 75 | const char *pkgName, |
| 76 | const char *instruction_set, |
| 77 | int dexopt_needed, |
| 78 | const char* oat_dir, |
| 79 | int dexopt_flags, |
| 80 | const char* compiler_filter, |
| 81 | const char* volume_uuid, |
| 82 | const char* shared_libraries); |
| 83 | static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size"); |
| 84 | |
| 85 | // Helper for the above, converting arguments. |
Andreas Gampe | d089ca1 | 2016-06-27 14:25:30 -0700 | [diff] [blame] | 86 | int dexopt(const char* const params[DEXOPT_PARAM_COUNT]); |
Andreas Gampe | 548bdb9 | 2016-06-02 17:56:45 -0700 | [diff] [blame] | 87 | |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 88 | int mark_boot_complete(const char *instruction_set); |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 89 | int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); |
| 90 | int idmap(const char *target_path, const char *overlay_path, uid_t uid); |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 91 | int create_oat_dir(const char* oat_dir, const char *instruction_set); |
| 92 | int rm_package_dir(const char* apk_path); |
Calin Juravle | edae669 | 2016-03-23 13:55:31 +0000 | [diff] [blame] | 93 | int clear_app_profiles(const char* pkgname); |
| 94 | int destroy_app_profiles(const char* pkgname); |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 95 | int link_file(const char *relative_path, const char *from_base, const char *to_base); |
| 96 | |
Andreas Gampe | e65b4fa | 2016-03-01 11:46:45 -0800 | [diff] [blame] | 97 | // Move a B version over to the A location. Only works for oat_dir != nullptr. |
| 98 | int move_ab(const char *apk_path, const char *instruction_set, const char* oat_dir); |
| 99 | |
Andreas Gampe | b31206b | 2016-09-09 17:07:04 -0700 | [diff] [blame] | 100 | // Delete odex files generated by dexopt. |
| 101 | bool delete_odex(const char *apk_path, const char *instruction_set, const char *oat_dir); |
| 102 | |
Andreas Gampe | 02d0de5 | 2015-11-11 20:43:16 -0800 | [diff] [blame] | 103 | } // namespace installd |
| 104 | } // namespace android |
| 105 | |
| 106 | #endif // COMMANDS_H_ |