• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.os.storage;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.IVold;
22 
23 import java.util.List;
24 import java.util.Set;
25 
26 /**
27  * Mount service local interface.
28  *
29  * @hide Only for use within the system server.
30  */
31 public abstract class StorageManagerInternal {
32     /**
33      * Gets the mount mode to use for a given UID
34      *
35      * @param uid The UID for which to get mount mode.
36      * @param packageName The package in the UID for making the call.
37      * @return The mount mode.
38      */
getExternalStorageMountMode(int uid, String packageName)39     public abstract int getExternalStorageMountMode(int uid, String packageName);
40 
41     /**
42      * Checks whether the {@code packageName} with {@code uid} has full external storage access via
43      * the {@link MANAGE_EXTERNAL_STORAGE} permission.
44      *
45      * @param uid the UID for which to check access.
46      * @param packageName the package in the UID for making the call.
47      * @return whether the {@code packageName} has full external storage access.
48      * Returns {@code true} if it has access, {@code false} otherwise.
49      */
hasExternalStorageAccess(int uid, String packageName)50     public abstract boolean hasExternalStorageAccess(int uid, String packageName);
51 
52     /**
53      * A listener for reset events in the StorageManagerService.
54      */
55     public interface ResetListener {
56         /**
57          * A method that should be triggered internally by StorageManagerInternal
58          * when StorageManagerService reset happens.
59          *
60          * @param vold The binder object to vold.
61          */
onReset(IVold vold)62         void onReset(IVold vold);
63     }
64 
65     /**
66      * Return true if fuse is mounted.
67      */
isFuseMounted(int userId)68     public abstract boolean isFuseMounted(int userId);
69 
70     /**
71      * Create storage directories if it does not exist.
72      * Return true if the directories were setup correctly, otherwise false.
73      */
prepareStorageDirs(int userId, Set<String> packageList, String processName)74     public abstract boolean prepareStorageDirs(int userId, Set<String> packageList,
75             String processName);
76 
77     /**
78      * Add a listener to listen to reset event in StorageManagerService.
79      *
80      * @param listener The listener that will be notified on reset events.
81      */
addResetListener(ResetListener listener)82     public abstract void addResetListener(ResetListener listener);
83 
84     /**
85      * Notified when any app op changes so that storage mount points can be updated if the app op
86      * affects them.
87      */
onAppOpsChanged(int code, int uid, @Nullable String packageName, int mode, int previousMode)88     public abstract void onAppOpsChanged(int code, int uid,
89             @Nullable String packageName, int mode, int previousMode);
90 
91     /**
92      * Asks the StorageManager to reset all state for the provided user; this will result
93      * in the unmounting for all volumes of the user, and, if the user is still running, the
94      * volumes will be re-mounted as well.
95      *
96      * @param userId the userId for which to reset storage
97      */
resetUser(int userId)98     public abstract void resetUser(int userId);
99 
100     /**
101      * Returns {@code true} if the immediate last installed version of an app with {@code uid} had
102      * legacy storage, {@code false} otherwise.
103      */
hasLegacyExternalStorage(int uid)104     public abstract boolean hasLegacyExternalStorage(int uid);
105 
106     /**
107      * Makes sure app-private data directories on external storage are setup correctly
108      * after an application is installed or upgraded. The main use for this is OBB dirs,
109      * which can be created/modified by the installer.
110      *
111      * @param packageName the package name of the package
112      * @param uid the uid of the package
113      */
prepareAppDataAfterInstall(@onNull String packageName, int uid)114     public abstract void prepareAppDataAfterInstall(@NonNull String packageName, int uid);
115 
116 
117     /**
118      * Return true if uid is external storage service.
119      */
isExternalStorageService(int uid)120     public abstract boolean isExternalStorageService(int uid);
121 
122     /**
123      * Frees cache held by ExternalStorageService.
124      *
125      * <p> Blocks until the service frees the cache or fails in doing so.
126      *
127      * @param volumeUuid uuid of the {@link StorageVolume} from which cache needs to be freed,
128      *                   null value indicates private internal volume.
129      * @param bytes number of bytes which need to be freed
130      */
freeCache(@ullable String volumeUuid, long bytes)131     public abstract void freeCache(@Nullable String volumeUuid, long bytes);
132 
133     /**
134      * Returns the {@link VolumeInfo#getId()} values for the volumes matching
135      * {@link VolumeInfo#isPrimary()}
136      */
getPrimaryVolumeIds()137     public abstract List<String> getPrimaryVolumeIds();
138 }
139