blob: 24d7fc6490ba764adf5f4930672108521c12ecc3 [file] [log] [blame]
Andreas Gampe02d0de52015-11-11 20:43:16 -08001/*
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 Sharkey0274c972016-12-06 09:32:04 -070024#include <vector>
25
26#include <binder/BinderService.h>
Andreas Gampe02d0de52015-11-11 20:43:16 -080027#include <cutils/multiuser.h>
28
Jeff Sharkey0274c972016-12-06 09:32:04 -070029#include "android/os/BnInstalld.h"
30#include "installd_constants.h"
Andreas Gampe02d0de52015-11-11 20:43:16 -080031
32namespace android {
33namespace installd {
34
Jeff Sharkey0274c972016-12-06 09:32:04 -070035class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld {
36public:
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 Gamped089ca12016-06-27 14:25:30 -070040
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070041 binder::Status createUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
42 int32_t userSerial, int32_t flags);
43 binder::Status destroyUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
44 int32_t flags);
45
Jeff Sharkey0274c972016-12-06 09:32:04 -070046 binder::Status createAppData(const std::unique_ptr<std::string>& uuid,
47 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
48 const std::string& seInfo, int32_t targetSdkVersion);
Jeff Sharkeyc1e93e72016-12-05 23:39:32 -070049 binder::Status restoreconAppData(const std::unique_ptr<std::string>& uuid,
50 const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
51 const std::string& seInfo);
52 binder::Status migrateAppData(const std::unique_ptr<std::string>& uuid,
53 const std::string& packageName, int32_t userId, int32_t flags);
54 binder::Status clearAppData(const std::unique_ptr<std::string>& uuid,
55 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
56 binder::Status destroyAppData(const std::unique_ptr<std::string>& uuid,
57 const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
58 binder::Status getAppDataInode(const std::unique_ptr<std::string>& uuid,
59 const std::string& packageName, int32_t userId, int32_t flags, int64_t* _aidl_return);
60
Jeff Sharkey0274c972016-12-06 09:32:04 -070061 binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid,
62 const std::unique_ptr<std::string>& toUuid, const std::string& packageName,
63 const std::string& dataAppName, int32_t appId, const std::string& seInfo,
64 int32_t targetSdkVersion);
65};
66
Jeff Sharkey2f720f72016-04-10 20:51:40 -060067int get_app_size(const char *uuid, const char *pkgname, int userid, int flags, ino_t ce_data_inode,
68 const char* code_path, int64_t *codesize, int64_t *datasize, int64_t *cachesize,
69 int64_t *asecsize);
Jeff Sharkey379a12b2016-04-14 20:45:06 -060070
Andreas Gampe02d0de52015-11-11 20:43:16 -080071int rm_dex(const char *path, const char *instruction_set);
Andreas Gampe02d0de52015-11-11 20:43:16 -080072int free_cache(const char *uuid, int64_t free_size);
Andreas Gampe4d0f8252016-03-20 11:30:28 -070073
74bool merge_profiles(uid_t uid, const char *pkgname);
75
David Sehr6727c2d2016-05-17 16:06:22 -070076bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files);
77
Andreas Gampe548bdb92016-06-02 17:56:45 -070078int dexopt(const char *apk_path,
79 uid_t uid,
80 const char *pkgName,
81 const char *instruction_set,
82 int dexopt_needed,
83 const char* oat_dir,
84 int dexopt_flags,
85 const char* compiler_filter,
86 const char* volume_uuid,
87 const char* shared_libraries);
88static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size");
89
90// Helper for the above, converting arguments.
Andreas Gamped089ca12016-06-27 14:25:30 -070091int dexopt(const char* const params[DEXOPT_PARAM_COUNT]);
Andreas Gampe548bdb92016-06-02 17:56:45 -070092
Andreas Gampe02d0de52015-11-11 20:43:16 -080093int mark_boot_complete(const char *instruction_set);
Andreas Gampe02d0de52015-11-11 20:43:16 -080094int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId);
95int idmap(const char *target_path, const char *overlay_path, uid_t uid);
Andreas Gampe02d0de52015-11-11 20:43:16 -080096int create_oat_dir(const char* oat_dir, const char *instruction_set);
97int rm_package_dir(const char* apk_path);
Calin Juravleedae6692016-03-23 13:55:31 +000098int clear_app_profiles(const char* pkgname);
99int destroy_app_profiles(const char* pkgname);
Andreas Gampe02d0de52015-11-11 20:43:16 -0800100int link_file(const char *relative_path, const char *from_base, const char *to_base);
101
Andreas Gampee65b4fa2016-03-01 11:46:45 -0800102// Move a B version over to the A location. Only works for oat_dir != nullptr.
103int move_ab(const char *apk_path, const char *instruction_set, const char* oat_dir);
104
Andreas Gampeb31206b2016-09-09 17:07:04 -0700105// Delete odex files generated by dexopt.
106bool delete_odex(const char *apk_path, const char *instruction_set, const char *oat_dir);
107
Andreas Gampe02d0de52015-11-11 20:43:16 -0800108} // namespace installd
109} // namespace android
110
111#endif // COMMANDS_H_