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);
getStagedApexInfos(in ApexSessionParams params)32    ApexInfo[] getStagedApexInfos(in ApexSessionParams params);
getActivePackages()33    ApexInfo[] getActivePackages();
getAllPackages()34    ApexInfo[] getAllPackages();
35 
abortStagedSession(int session_id)36    void abortStagedSession(int session_id);
revertActiveSessions()37    void revertActiveSessions();
38 
39    /**
40     * Copies the CE apex data directory for the given user to the backup
41     * location.
42     */
snapshotCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name)43    void snapshotCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name);
44 
45    /**
46     * Restores the snapshot of the CE apex data directory for the given user and
47     * apex. Note the snapshot will be deleted after restoration succeeded.
48     */
restoreCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name)49    void restoreCeData(int user_id, int rollback_id, in @utf8InCpp String apex_name);
50 
51    /**
52     * Deletes device-encrypted snapshots for the given rollback id.
53     */
destroyDeSnapshots(int rollback_id)54    void destroyDeSnapshots(int rollback_id);
55 
56    /**
57     * Deletes credential-encrypted snapshots for the given user, for the given rollback id.
58     */
destroyCeSnapshots(int user_id, int rollback_id)59    void destroyCeSnapshots(int user_id, int rollback_id);
60 
61    /**
62     * Deletes all credential-encrypted snapshots for the given user, except for
63     * those listed in retain_rollback_ids.
64     */
destroyCeSnapshotsNotSpecified(int user_id, in int[] retain_rollback_ids)65    void destroyCeSnapshotsNotSpecified(int user_id, in int[] retain_rollback_ids);
66 
unstagePackages(in @tf8InCpp List<String> active_package_paths)67    void unstagePackages(in @utf8InCpp List<String> active_package_paths);
68 
69    /**
70     * Returns the active package corresponding to |package_name| and null
71     * if none exists.
72     */
getActivePackage(in @tf8InCpp String package_name)73    ApexInfo getActivePackage(in @utf8InCpp String package_name);
74 
75    /**
76     * Not meant for use outside of testing. The call will not be
77     * functional on user builds.
78     */
stagePackages(in @tf8InCpp List<String> package_tmp_paths)79    void stagePackages(in @utf8InCpp List<String> package_tmp_paths);
80    /**
81     * Not meant for use outside of testing. The call will not be
82     * functional on user builds.
83     */
resumeRevertIfNeeded()84    void resumeRevertIfNeeded();
85    /**
86     * Forces apexd to remount all active packages.
87     *
88     * This call is mostly useful for speeding up development of APEXes.
89     * Instead of going through a full APEX installation that requires a reboot,
90     * developers can incorporate this method in much faster `adb sync` based
91     * workflow:
92     *
93     * 1. adb shell stop
94     * 2. adb sync
95     * 3. adb shell cmd -w apexservice remountPackages
96     * 4. adb shell start
97     *
98     * Note, that for an APEX package will be successfully remounted only if
99     * there are no alive processes holding a reference to it.
100     *
101     * Not meant for use outside of testing. This call will not be functional
102     * on user builds. Only root is allowed to call this method.
103     */
remountPackages()104    void remountPackages();
105    /**
106     * Forces apexd to recollect pre-installed data from the given |paths|.
107     *
108     * Not meant for use outside of testing. This call will not be functional
109     * on user builds. Only root is allowed to call this method.
110     */
recollectPreinstalledData(in @tf8InCpp List<String> paths)111    void recollectPreinstalledData(in @utf8InCpp List<String> paths);
112    /**
113     * Forces apexd to recollect data apex from the given |path|.
114     *
115     * Not meant for use outside of testing. This call will not be functional
116     * on user builds. Only root is allowed to call this method.
117     */
recollectDataApex(in @tf8InCpp String path, in@utf8InCpp String decompression_dir)118    void recollectDataApex(in @utf8InCpp String path, in@utf8InCpp String decompression_dir);
119 
120    /**
121     * Informs apexd that the boot has completed.
122     */
markBootCompleted()123    void markBootCompleted();
124 
125    /**
126    * Assuming the provided compressed APEX will be installed on next boot,
127    * calculate how much space will be required for decompression
128    */
calculateSizeForCompressedApex(in CompressedApexInfoList compressed_apex_info_list)129    long calculateSizeForCompressedApex(in CompressedApexInfoList compressed_apex_info_list);
130 
131    /**
132    * Reserve space on /data partition for compressed APEX decompression. Returns error if
133    * reservation fails. If empty list is passed, then reserved space is deallocated.
134    */
reserveSpaceForCompressedApex(in CompressedApexInfoList compressed_apex_info_list)135    void reserveSpaceForCompressedApex(in CompressedApexInfoList compressed_apex_info_list);
136 
137    /**
138     * Performs a non-staged install of the given APEX.
139     */
installAndActivatePackage(in @tf8InCpp String packagePath, boolean force)140    ApexInfo installAndActivatePackage(in @utf8InCpp String packagePath, boolean force);
141 }
142