blob: 5cac5f580af1079ad6e95031ebf1125a968b5c7a [file] [log] [blame]
Svet Ganov6ee871e2015-07-10 14:29:33 -07001/*
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
17package android.os.storage;
18
Sudheer Shankab1613982019-05-16 16:55:50 -070019import android.annotation.Nullable;
Risanaec0ee72018-10-31 10:10:12 +090020import android.os.IVold;
Sudheer Shanka584b0682018-10-04 16:26:16 -070021
Svet Ganov6ee871e2015-07-10 14:29:33 -070022/**
23 * Mount service local interface.
24 *
25 * @hide Only for use within the system server.
26 */
Sudheer Shanka2250d562016-11-07 15:41:02 -080027public abstract class StorageManagerInternal {
Svet Ganov6ee871e2015-07-10 14:29:33 -070028
29 /**
30 * Policy that influences how external storage is mounted and reported.
31 */
32 public interface ExternalStorageMountPolicy {
33 /**
34 * Gets the external storage mount mode for the given uid.
35 *
36 * @param uid The UID for which to determine mount mode.
37 * @param packageName The package in the UID for making the call.
38 * @return The mount mode.
39 *
40 * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_NONE
41 * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_DEFAULT
42 * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_READ
43 * @see com.android.internal.os.Zygote#MOUNT_EXTERNAL_WRITE
44 */
45 public int getMountMode(int uid, String packageName);
46
47 /**
48 * Gets whether external storage should be reported to the given UID.
49 *
50 * @param uid The UID for which to determine whether it has external storage.
51 * @param packageName The package in the UID for making the call.
52 * @return Weather to report external storage.
53 * @return True to report the state of external storage, false to
54 * report it as unmounted.
55 */
56 public boolean hasExternalStorage(int uid, String packageName);
57 }
58
59 /**
60 * Adds a policy for determining how external storage is mounted and reported.
61 * The mount mode is the most conservative result from querying all registered
62 * policies. Similarly, the reported state is the most conservative result from
63 * querying all registered policies.
64 *
65 * @param policy The policy to add.
66 */
67 public abstract void addExternalStoragePolicy(ExternalStorageMountPolicy policy);
68
69 /**
70 * Notify the mount service that the mount policy for a UID changed.
71 * @param uid The UID for which policy changed.
72 * @param packageName The package in the UID for making the call.
73 */
74 public abstract void onExternalStoragePolicyChanged(int uid, String packageName);
75
76 /**
77 * Gets the mount mode to use for a given UID as determined by consultin all
78 * policies.
79 *
80 * @param uid The UID for which to get mount mode.
81 * @param packageName The package in the UID for making the call.
82 * @return The mount mode.
83 */
84 public abstract int getExternalStorageMountMode(int uid, String packageName);
Sudheer Shanka8ff30b12018-08-06 17:29:44 -070085
86 /**
Risanaec0ee72018-10-31 10:10:12 +090087 * A listener for reset events in the StorageManagerService.
88 */
89 public interface ResetListener {
90 /**
91 * A method that should be triggered internally by StorageManagerInternal
92 * when StorageManagerService reset happens.
93 *
94 * @param vold The binder object to vold.
95 */
96 void onReset(IVold vold);
97 }
98
99 /**
100 * Add a listener to listen to reset event in StorageManagerService.
101 *
102 * @param listener The listener that will be notified on reset events.
103 */
104 public abstract void addResetListener(ResetListener listener);
Sudheer Shankab1613982019-05-16 16:55:50 -0700105
106 /**
107 * Notified when any app op changes so that storage mount points can be updated if the app op
108 * affects them.
109 */
110 public abstract void onAppOpsChanged(int code, int uid,
111 @Nullable String packageName, int mode);
Martijn Coenen73918202019-12-09 17:02:44 +0100112
113 /**
114 * Asks the StorageManager to reset all state for the provided user; this will result
115 * in the unmounting for all volumes of the user, and, if the user is still running, the
116 * volumes will be re-mounted as well.
117 *
118 * @param userId the userId for which to reset storage
119 */
120 public abstract void resetUser(int userId);
Svet Ganov6ee871e2015-07-10 14:29:33 -0700121}