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 /**
20  * Mount service local interface.
21  *
22  * @hide Only for use within the system server.
23  */
24 public abstract class MountServiceInternal {
25 
26     /**
27      * Policy that influences how external storage is mounted and reported.
28      */
29     public interface ExternalStorageMountPolicy {
30         /**
31          * Gets the external storage mount mode for the given uid.
32          *
33          * @param uid The UID for which to determine mount mode.
34          * @param packageName The package in the UID for making the call.
35          * @return The mount mode.
36          *
37          * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_NONE
38          * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_DEFAULT
39          * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_READ
40          * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_WRITE
41          */
getMountMode(int uid, String packageName)42         public int getMountMode(int uid, String packageName);
43 
44         /**
45          * Gets whether external storage should be reported to the given UID.
46          *
47          * @param uid The UID for which to determine whether it has external storage.
48          * @param packageName The package in the UID for making the call.
49          * @return Weather to report external storage.
50          * @return True to report the state of external storage, false to
51          *     report it as unmounted.
52          */
hasExternalStorage(int uid, String packageName)53         public boolean hasExternalStorage(int uid, String packageName);
54     }
55 
56     /**
57      * Adds a policy for determining how external storage is mounted and reported.
58      * The mount mode is the most conservative result from querying all registered
59      * policies. Similarly, the reported state is the most conservative result from
60      * querying all registered policies.
61      *
62      * @param policy The policy to add.
63      */
addExternalStoragePolicy(ExternalStorageMountPolicy policy)64     public abstract void addExternalStoragePolicy(ExternalStorageMountPolicy policy);
65 
66     /**
67      * Notify the mount service that the mount policy for a UID changed.
68      * @param uid The UID for which policy changed.
69      * @param packageName The package in the UID for making the call.
70      */
onExternalStoragePolicyChanged(int uid, String packageName)71     public abstract void onExternalStoragePolicyChanged(int uid, String packageName);
72 
73     /**
74      * Gets the mount mode to use for a given UID as determined by consultin all
75      * policies.
76      *
77      * @param uid The UID for which to get mount mode.
78      * @param packageName The package in the UID for making the call.
79      * @return The mount mode.
80      */
getExternalStorageMountMode(int uid, String packageName)81     public abstract int getExternalStorageMountMode(int uid, String packageName);
82 }
83