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.Nullable; 20 import android.os.IVold; 21 22 /** 23 * Mount service local interface. 24 * 25 * @hide Only for use within the system server. 26 */ 27 public abstract class StorageManagerInternal { 28 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 */ getMountMode(int uid, String packageName)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 */ hasExternalStorage(int uid, String packageName)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 */ addExternalStoragePolicy(ExternalStorageMountPolicy policy)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 */ onExternalStoragePolicyChanged(int uid, String packageName)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 */ getExternalStorageMountMode(int uid, String packageName)84 public abstract int getExternalStorageMountMode(int uid, String packageName); 85 86 /** 87 * 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 */ onReset(IVold vold)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 */ addResetListener(ResetListener listener)104 public abstract void addResetListener(ResetListener listener); 105 106 /** 107 * Notified when any app op changes so that storage mount points can be updated if the app op 108 * affects them. 109 */ onAppOpsChanged(int code, int uid, @Nullable String packageName, int mode)110 public abstract void onAppOpsChanged(int code, int uid, 111 @Nullable String packageName, int mode); 112 } 113