1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.apex;
18 
19 import android.apex.ApexInfo;
20 import android.apex.ApexInfoList;
21 import android.apex.ApexSessionInfo;
22 import android.apex.ApexSessionParams;
23 import android.apex.CompressedApexInfoList;
24 
25 interface IApexService {
submitStagedSession(in ApexSessionParams params, out ApexInfoList packages)26    void submitStagedSession(in ApexSessionParams params, out ApexInfoList packages);
markStagedSessionReady(int session_id)27    void markStagedSessionReady(int session_id);
markStagedSessionSuccessful(int session_id)28    void markStagedSessionSuccessful(int session_id);
29 
getSessions()30    ApexSessionInfo[] getSessions();
getStagedSessionInfo(int session_id)31    ApexSessionInfo getStagedSessionInfo(int session_id);
getActivePackages()32    ApexInfo[] getActivePackages();
getAllPackages()33    ApexInfo[] getAllPackages();
34 
abortStagedSession(int session_id)35    void abortStagedSession(int session_id);
revertActiveSessions()36    void revertActiveSessions();
37 
38    /**
39     * Copies the CE apex data directory for the given user to the backup
40     * location.
41     */
snapshotCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name)42    void snapshotCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name);
43 
44    /**
45     * Restores the snapshot of the CE apex data directory for the given user and
46     * apex. Note the snapshot will be deleted after restoration succeeded.
47     */
restoreCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name)48    void restoreCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name);
49 
50    /**
51     * Deletes device-encrypted snapshots for the given rollback id.
52     */
destroyDeSnapshots(int rollback_id)53    void destroyDeSnapshots(int rollback_id);
54 
55    /**
56     * Deletes credential-encrypted snapshots for the given user, for the given rollback id.
57     */
destroyCeSnapshots(int user_id, int rollback_id)58    void destroyCeSnapshots(int user_id, int rollback_id);
59 
60    /**
61     * Deletes all credential-encrypted snapshots for the given user, except for
62     * those listed in retain_rollback_ids.
63     */
destroyCeSnapshotsNotSpecified(int user_id, in int[] retain_rollback_ids)64    void destroyCeSnapshotsNotSpecified(int user_id, in int[] retain_rollback_ids);
65 
unstagePackages(in @tf8InCpp List<String> active_package_paths)66    void unstagePackages(in @utf8InCpp List<String> active_package_paths);
67 
68    /**
69     * Returns the active package corresponding to |package_name| and null
70     * if none exists.
71     */
getActivePackage(in @tf8InCpp String package_name)72    ApexInfo getActivePackage(in @utf8InCpp String package_name);
73 
74    /**
75     * Not meant for use outside of testing. The call will not be
76     * functional on user builds.
77     */
activatePackage(in @tf8InCpp String package_path)78    void activatePackage(in @utf8InCpp String package_path);
79    /**
80     * Not meant for use outside of testing. The call will not be
81     * functional on user builds.
82     */
deactivatePackage(in @tf8InCpp String package_path)83    void deactivatePackage(in @utf8InCpp String package_path);
84    /**
85     * Not meant for use outside of testing. The call will not be
86     * functional on user builds.
87     */
preinstallPackages(in @tf8InCpp List<String> package_tmp_paths)88    void preinstallPackages(in @utf8InCpp List<String> package_tmp_paths);
89    /**
90     * Not meant for use outside of testing. The call will not be
91     * functional on user builds.
92     */
postinstallPackages(in @tf8InCpp List<String> package_tmp_paths)93    void postinstallPackages(in @utf8InCpp List<String> package_tmp_paths);
94    /**
95     * Not meant for use outside of testing. The call will not be
96     * functional on user builds.
97     */
stagePackages(in @tf8InCpp List<String> package_tmp_paths)98    void stagePackages(in @utf8InCpp List<String> package_tmp_paths);
99    /**
100     * Not meant for use outside of testing. The call will not be
101     * functional on user builds.
102     */
resumeRevertIfNeeded()103    void resumeRevertIfNeeded();
104    /**
105     * Forces apexd to remount all active packages.
106     *
107     * This call is mostly useful for speeding up development of APEXes.
108     * Instead of going through a full APEX installation that requires a reboot,
109     * developers can incorporate this method in much faster `adb sync` based
110     * workflow:
111     *
112     * 1. adb shell stop
113     * 2. adb sync
114     * 3. adb shell cmd -w apexservice remountPackages
115     * 4. adb shell start
116     *
117     * Note, that for an APEX package will be successfully remounted only if
118     * there are no alive processes holding a reference to it.
119     *
120     * Not meant for use outside of testing. This call will not be functional
121     * on user builds. Only root is allowed to call this method.
122     */
remountPackages()123    void remountPackages();
124    /**
125     * Forces apexd to recollect pre-installed data from the given |paths|.
126     *
127     * Not meant for use outside of testing. This call will not be functional
128     * on user builds. Only root is allowed to call this method.
129     */
recollectPreinstalledData(in @tf8InCpp List<String> paths)130    void recollectPreinstalledData(in @utf8InCpp List<String> paths);
131    /**
132     * Forces apexd to recollect data apex from the given |path|.
133     *
134     * Not meant for use outside of testing. This call will not be functional
135     * on user builds. Only root is allowed to call this method.
136     */
recollectDataApex(in @tf8InCpp String path, in@utf8InCpp String decompression_dir)137    void recollectDataApex(in @utf8InCpp String path, in@utf8InCpp String decompression_dir);
138 
139    /**
140     * Informs apexd that the boot has completed.
141     */
markBootCompleted()142    void markBootCompleted();
143 
144    /**
145    * Assuming the provided compressed APEX will be installed on next boot,
146    * calculate how much space will be required for decompression
147    */
calculateSizeForCompressedApex(in CompressedApexInfoList compressed_apex_info_list)148    long calculateSizeForCompressedApex(in CompressedApexInfoList compressed_apex_info_list);
149 
150    /**
151    * Reserve space on /data partition for compressed APEX decompression. Returns error if
152    * reservation fails. If empty list is passed, then reserved space is deallocated.
153    */
reserveSpaceForCompressedApex(in CompressedApexInfoList compressed_apex_info_list)154    void reserveSpaceForCompressedApex(in CompressedApexInfoList compressed_apex_info_list);
155 
156    /**
157     * Performs a non-staged install of the given APEX.
158     * Note: don't confuse this to preInstall and postInstall binder calls which are only used to
159     * test corresponding features of APEX packages.
160     */
installAndActivatePackage(in @tf8InCpp String packagePath)161    ApexInfo installAndActivatePackage(in @utf8InCpp String packagePath);
162 }
163