Rename MountService to StorageManagerService.
Bug: 30977067
Test: Existing tests pass
Change-Id: Ieac0f11c2b249dcd60441b14c1f391e6f8131d42
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 7c2eea3f..570843e 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -54,7 +54,7 @@
import android.os.ShellCallback;
import android.os.ShellCommand;
import android.os.UserHandle;
-import android.os.storage.MountServiceInternal;
+import android.os.storage.StorageManagerInternal;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
@@ -294,10 +294,10 @@
}
}
- MountServiceInternal mountServiceInternal = LocalServices.getService(
- MountServiceInternal.class);
- mountServiceInternal.addExternalStoragePolicy(
- new MountServiceInternal.ExternalStorageMountPolicy() {
+ StorageManagerInternal storageManagerInternal = LocalServices.getService(
+ StorageManagerInternal.class);
+ storageManagerInternal.addExternalStoragePolicy(
+ new StorageManagerInternal.ExternalStorageMountPolicy() {
@Override
public int getMountMode(int uid, String packageName) {
if (Process.isIsolated(uid)) {
diff --git a/services/core/java/com/android/server/EventLogTags.logtags b/services/core/java/com/android/server/EventLogTags.logtags
index 74ff41c..eb2cd0b 100644
--- a/services/core/java/com/android/server/EventLogTags.logtags
+++ b/services/core/java/com/android/server/EventLogTags.logtags
@@ -248,7 +248,7 @@
51501 idle_maintenance_window_finish (time|2|3), (lastUserActivity|2|3), (batteryLevel|1|6), (batteryCharging|1|5)
# ---------------------------
-# MountService.java
+# StorageManagerService.java
# ---------------------------
2755 fstrim_start (time|2|3)
2756 fstrim_finish (time|2|3)
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index 991ce45..6701431 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -51,7 +51,7 @@
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ShellCallback;
-import android.os.storage.IMountService;
+import android.os.storage.IStorageManager;
import android.os.storage.StorageManager;
import android.os.ServiceManager;
import android.os.StrictMode;
@@ -1160,10 +1160,10 @@
private void addUserKeyAuth(int userId, byte[] token, byte[] secret)
throws RemoteException {
final UserInfo userInfo = UserManager.get(mContext).getUserInfo(userId);
- final IMountService mountService = getMountService();
+ final IStorageManager storageManager = getStorageManager();
final long callingId = Binder.clearCallingIdentity();
try {
- mountService.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
+ storageManager.addUserKeyAuth(userId, userInfo.serialNumber, token, secret);
} finally {
Binder.restoreCallingIdentity(callingId);
}
@@ -1171,10 +1171,10 @@
private void fixateNewestUserKeyAuth(int userId)
throws RemoteException {
- final IMountService mountService = getMountService();
+ final IStorageManager storageManager = getStorageManager();
final long callingId = Binder.clearCallingIdentity();
try {
- mountService.fixateNewestUserKeyAuth(userId);
+ storageManager.fixateNewestUserKeyAuth(userId);
} finally {
Binder.restoreCallingIdentity(callingId);
}
@@ -1488,7 +1488,7 @@
// we should, within the first minute of decrypting the phone if this
// service can't connect to vold, it restarts, and then the new instance
// does successfully connect.
- final IMountService service = getMountService();
+ final IStorageManager service = getStorageManager();
String password;
long identity = Binder.clearCallingIdentity();
try {
@@ -1651,10 +1651,10 @@
Secure.LOCK_SCREEN_OWNER_INFO
};
- private IMountService getMountService() {
+ private IStorageManager getStorageManager() {
final IBinder service = ServiceManager.getService("mount");
if (service != null) {
- return IMountService.Stub.asInterface(service);
+ return IStorageManager.Stub.asInterface(service);
}
return null;
}
diff --git a/services/core/java/com/android/server/MountServiceIdler.java b/services/core/java/com/android/server/MountServiceIdler.java
index 956568d..d8bd0bb 100644
--- a/services/core/java/com/android/server/MountServiceIdler.java
+++ b/services/core/java/com/android/server/MountServiceIdler.java
@@ -67,7 +67,7 @@
// that lets us cleanly end our idle timeslice. It's safe to call
// finishIdle() from any thread.
mJobParams = params;
- MountService ms = MountService.sSelf;
+ StorageManagerService ms = StorageManagerService.sSelf;
if (ms != null) {
synchronized (mFinishCallback) {
mStarted = true;
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/StorageManagerService.java
similarity index 98%
rename from services/core/java/com/android/server/MountService.java
rename to services/core/java/com/android/server/StorageManagerService.java
index ee625d9..11fabb4 100644
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -68,11 +68,11 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.DiskInfo;
-import android.os.storage.IMountService;
-import android.os.storage.IMountServiceListener;
-import android.os.storage.IMountShutdownObserver;
+import android.os.storage.IStorageEventListener;
+import android.os.storage.IStorageShutdownObserver;
import android.os.storage.IObbActionListener;
-import android.os.storage.MountServiceInternal;
+import android.os.storage.IStorageManager;
+import android.os.storage.StorageManagerInternal;
import android.os.storage.OnObbStateChangeListener;
import android.os.storage.StorageManager;
import android.os.storage.StorageResultCode;
@@ -149,14 +149,14 @@
* watch for and manage dynamically added storage, such as SD cards and USB mass
* storage. Also decides how storage should be presented to users on the device.
*/
-class MountService extends IMountService.Stub
+class StorageManagerService extends IStorageManager.Stub
implements INativeDaemonConnectorCallbacks, Watchdog.Monitor {
// Static direct instance pointer for the tightly-coupled idle service to use
- static MountService sSelf = null;
+ static StorageManagerService sSelf = null;
public static class Lifecycle extends SystemService {
- private MountService mMountService;
+ private StorageManagerService mStorageManagerService;
public Lifecycle(Context context) {
super(context);
@@ -164,33 +164,33 @@
@Override
public void onStart() {
- mMountService = new MountService(getContext());
- publishBinderService("mount", mMountService);
- mMountService.start();
+ mStorageManagerService = new StorageManagerService(getContext());
+ publishBinderService("mount", mStorageManagerService);
+ mStorageManagerService.start();
}
@Override
public void onBootPhase(int phase) {
if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) {
- mMountService.systemReady();
+ mStorageManagerService.systemReady();
} else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
- mMountService.bootCompleted();
+ mStorageManagerService.bootCompleted();
}
}
@Override
public void onSwitchUser(int userHandle) {
- mMountService.mCurrentUserId = userHandle;
+ mStorageManagerService.mCurrentUserId = userHandle;
}
@Override
public void onUnlockUser(int userHandle) {
- mMountService.onUnlockUser(userHandle);
+ mStorageManagerService.onUnlockUser(userHandle);
}
@Override
public void onCleanupUser(int userHandle) {
- mMountService.onCleanupUser(userHandle);
+ mStorageManagerService.onCleanupUser(userHandle);
}
}
@@ -209,7 +209,7 @@
*/
private static final boolean EMULATE_FBE_SUPPORTED = true;
- private static final String TAG = "MountService";
+ private static final String TAG = "StorageManagerService";
private static final String TAG_STORAGE_BENCHMARK = "storage_benchmark";
private static final String TAG_STORAGE_TRIM = "storage_trim";
@@ -500,7 +500,8 @@
final private Map<String, ObbState> mObbPathToStateMap = new HashMap<String, ObbState>();
// Not guarded by a lock.
- private final MountServiceInternalImpl mMountServiceInternal = new MountServiceInternalImpl();
+ private final StorageManagerInternalImpl mStorageManagerInternal
+ = new StorageManagerInternalImpl();
class ObbState implements IBinder.DeathRecipient {
public ObbState(String rawPath, String canonicalPath, int callingUid,
@@ -609,8 +610,8 @@
private static final int H_PARTITION_FORGET = 9;
private static final int H_RESET = 10;
- class MountServiceHandler extends Handler {
- public MountServiceHandler(Looper looper) {
+ class StorageManagerServiceHandler extends Handler {
+ public StorageManagerServiceHandler(Looper looper) {
super(looper);
}
@@ -661,7 +662,7 @@
break;
}
case H_SHUTDOWN: {
- final IMountShutdownObserver obs = (IMountShutdownObserver) msg.obj;
+ final IStorageShutdownObserver obs = (IStorageShutdownObserver) msg.obj;
boolean success = false;
try {
success = mConnector.execute("volume", "shutdown").isClassOk();
@@ -1481,11 +1482,11 @@
}
/**
- * Constructs a new MountService instance
+ * Constructs a new StorageManagerService instance
*
* @param context Binder context for this service
*/
- public MountService(Context context) {
+ public StorageManagerService(Context context) {
sSelf = this;
mContext = context;
@@ -1497,9 +1498,9 @@
HandlerThread hthread = new HandlerThread(TAG);
hthread.start();
- mHandler = new MountServiceHandler(hthread.getLooper());
+ mHandler = new StorageManagerServiceHandler(hthread.getLooper());
- // Add OBB Action Handler to MountService thread.
+ // Add OBB Action Handler to StorageManagerService thread.
mObbActionHandler = new ObbActionHandler(IoThread.get().getLooper());
// Initialize the last-fstrim tracking if necessary
@@ -1525,7 +1526,7 @@
readSettingsLocked();
}
- LocalServices.addService(MountServiceInternal.class, mMountServiceInternal);
+ LocalServices.addService(StorageManagerInternal.class, mStorageManagerInternal);
/*
* Create the connection to vold with a maximum queue of twice the
@@ -1685,17 +1686,17 @@
*/
@Override
- public void registerListener(IMountServiceListener listener) {
+ public void registerListener(IStorageEventListener listener) {
mCallbacks.register(listener);
}
@Override
- public void unregisterListener(IMountServiceListener listener) {
+ public void unregisterListener(IStorageEventListener listener) {
mCallbacks.unregister(listener);
}
@Override
- public void shutdown(final IMountShutdownObserver observer) {
+ public void shutdown(final IStorageShutdownObserver observer) {
enforcePermission(android.Manifest.permission.SHUTDOWN);
Slog.i(TAG, "Shutting down");
@@ -3045,7 +3046,7 @@
final long token = Binder.clearCallingIdentity();
try {
userKeyUnlocked = isUserKeyUnlocked(userId);
- storagePermission = mMountServiceInternal.hasExternalStorage(uid, packageName);
+ storagePermission = mStorageManagerInternal.hasExternalStorage(uid, packageName);
} finally {
Binder.restoreCallingIdentity(token);
}
@@ -3162,7 +3163,7 @@
for (final ObbState o : obbStates) {
if (o.rawPath.equals(obbState.rawPath)) {
throw new IllegalStateException("Attempt to add ObbState twice. "
- + "This indicates an error in the MountService logic.");
+ + "This indicates an error in the StorageManagerService logic.");
}
}
}
@@ -3424,7 +3425,7 @@
try {
mObbState.token.onObbResult(mObbState.rawPath, mObbState.nonce, status);
} catch (RemoteException e) {
- Slog.w(TAG, "MountServiceListener went away while calling onObbStateChanged");
+ Slog.w(TAG, "StorageEventListener went away while calling onObbStateChanged");
}
}
}
@@ -3614,18 +3615,18 @@
private static final int MSG_DISK_SCANNED = 5;
private static final int MSG_DISK_DESTROYED = 6;
- private final RemoteCallbackList<IMountServiceListener>
+ private final RemoteCallbackList<IStorageEventListener>
mCallbacks = new RemoteCallbackList<>();
public Callbacks(Looper looper) {
super(looper);
}
- public void register(IMountServiceListener callback) {
+ public void register(IStorageEventListener callback) {
mCallbacks.register(callback);
}
- public void unregister(IMountServiceListener callback) {
+ public void unregister(IStorageEventListener callback) {
mCallbacks.unregister(callback);
}
@@ -3634,7 +3635,7 @@
final SomeArgs args = (SomeArgs) msg.obj;
final int n = mCallbacks.beginBroadcast();
for (int i = 0; i < n; i++) {
- final IMountServiceListener callback = mCallbacks.getBroadcastItem(i);
+ final IStorageEventListener callback = mCallbacks.getBroadcastItem(i);
try {
invokeCallback(callback, msg.what, args);
} catch (RemoteException ignored) {
@@ -3644,7 +3645,7 @@
args.recycle();
}
- private void invokeCallback(IMountServiceListener callback, int what, SomeArgs args)
+ private void invokeCallback(IStorageEventListener callback, int what, SomeArgs args)
throws RemoteException {
switch (what) {
case MSG_STORAGE_STATE_CHANGED: {
@@ -3829,7 +3830,7 @@
}
}
- private final class MountServiceInternalImpl extends MountServiceInternal {
+ private final class StorageManagerInternalImpl extends StorageManagerInternal {
// Not guarded by a lock.
private final CopyOnWriteArrayList<ExternalStorageMountPolicy> mPolicies =
new CopyOnWriteArrayList<>();
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e080fd9..787a7d6 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -196,8 +196,8 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.WorkSource;
-import android.os.storage.IMountService;
-import android.os.storage.MountServiceInternal;
+import android.os.storage.IStorageManager;
+import android.os.storage.StorageManagerInternal;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.service.voice.IVoiceInteractionSession;
@@ -2097,9 +2097,9 @@
try {
Locale l = (Locale) msg.obj;
IBinder service = ServiceManager.getService("mount");
- IMountService mountService = IMountService.Stub.asInterface(service);
+ IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
Log.d(TAG, "Storing locale " + l.toLanguageTag() + " for decryption UI");
- mountService.setField(StorageManager.SYSTEM_LOCALE_KEY, l.toLanguageTag());
+ storageManager.setField(StorageManager.SYSTEM_LOCALE_KEY, l.toLanguageTag());
} catch (RemoteException e) {
Log.e(TAG, "Error storing locale for decryption UI", e);
}
@@ -3599,9 +3599,9 @@
final IPackageManager pm = AppGlobals.getPackageManager();
permGids = pm.getPackageGids(app.info.packageName,
MATCH_DEBUG_TRIAGED_MISSING, app.userId);
- MountServiceInternal mountServiceInternal = LocalServices.getService(
- MountServiceInternal.class);
- mountExternal = mountServiceInternal.getExternalStorageMountMode(uid,
+ StorageManagerInternal storageManagerInternal = LocalServices.getService(
+ StorageManagerInternal.class);
+ mountExternal = storageManagerInternal.getExternalStorageMountMode(uid,
app.info.packageName);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 9697855..a0a04bb 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -75,7 +75,7 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
-import android.os.storage.IMountService;
+import android.os.storage.IStorageManager;
import android.os.storage.StorageManager;
import android.util.ArraySet;
import android.util.IntArray;
@@ -735,8 +735,8 @@
}
}
- private IMountService getMountService() {
- return IMountService.Stub.asInterface(ServiceManager.getService("mount"));
+ private IStorageManager getStorageManager() {
+ return IStorageManager.Stub.asInterface(ServiceManager.getService("mount"));
}
/**
@@ -980,10 +980,10 @@
// TODO Move this block outside of synchronized if it causes lock contention
if (!StorageManager.isUserKeyUnlocked(userId)) {
final UserInfo userInfo = getUserInfo(userId);
- final IMountService mountService = getMountService();
+ final IStorageManager storageManager = getStorageManager();
try {
// We always want to unlock user storage, even user is not started yet
- mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret);
+ storageManager.unlockUserKey(userId, userInfo.serialNumber, token, secret);
} catch (RemoteException | RuntimeException e) {
Slog.w(TAG, "Failed to unlock: " + e.getMessage());
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index d9e7019..de801a5 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -192,8 +192,8 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
-import android.os.storage.IMountService;
-import android.os.storage.MountServiceInternal;
+import android.os.storage.IStorageManager;
+import android.os.storage.StorageManagerInternal;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
@@ -1470,10 +1470,11 @@
}
if (reportStatus) {
try {
- if (DEBUG_SD_INSTALL) Log.i(TAG, "Invoking MountService call back");
- PackageHelper.getMountService().finishMediaUpdate();
+ if (DEBUG_SD_INSTALL) Log.i(TAG,
+ "Invoking StorageManagerService call back");
+ PackageHelper.getStorageManager().finishMediaUpdate();
} catch (RemoteException e) {
- Log.e(TAG, "MountService not running?");
+ Log.e(TAG, "StorageManagerService not running?");
}
}
} break;
@@ -4133,9 +4134,9 @@
final long token = Binder.clearCallingIdentity();
try {
if (sUserManager.isInitialized(userId)) {
- MountServiceInternal mountServiceInternal = LocalServices.getService(
- MountServiceInternal.class);
- mountServiceInternal.onExternalStoragePolicyChanged(uid, packageName);
+ StorageManagerInternal storageManagerInternal = LocalServices.getService(
+ StorageManagerInternal.class);
+ storageManagerInternal.onExternalStoragePolicyChanged(uid, packageName);
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -7238,15 +7239,15 @@
// Before everything else, see whether we need to fstrim.
try {
- IMountService ms = PackageHelper.getMountService();
- if (ms != null) {
+ IStorageManager sm = PackageHelper.getStorageManager();
+ if (sm != null) {
boolean doTrim = false;
final long interval = android.provider.Settings.Global.getLong(
mContext.getContentResolver(),
android.provider.Settings.Global.FSTRIM_MANDATORY_INTERVAL,
DEFAULT_MANDATORY_FSTRIM_INTERVAL);
if (interval > 0) {
- final long timeSinceLast = System.currentTimeMillis() - ms.lastMaintenance();
+ final long timeSinceLast = System.currentTimeMillis() - sm.lastMaintenance();
if (timeSinceLast > interval) {
doTrim = true;
Slog.w(TAG, "No disk maintenance in " + timeSinceLast
@@ -7266,13 +7267,13 @@
} catch (RemoteException e) {
}
}
- ms.runMaintenance();
+ sm.runMaintenance();
}
} else {
- Slog.e(TAG, "Mount service unavailable!");
+ Slog.e(TAG, "storageManager service unavailable!");
}
} catch (RemoteException e) {
- // Can't happen; MountService is local
+ // Can't happen; StorageManagerService is local
}
}
@@ -13810,7 +13811,7 @@
}
/**
- * Extract the MountService "container ID" from the full code path of an
+ * Extract the StorageManagerService "container ID" from the full code path of an
* .apk.
*/
static String cidFromCodePath(String fullCodePath) {
@@ -18411,10 +18412,10 @@
mInstallerService.systemReady();
mPackageDexOptimizer.systemReady();
- MountServiceInternal mountServiceInternal = LocalServices.getService(
- MountServiceInternal.class);
- mountServiceInternal.addExternalStoragePolicy(
- new MountServiceInternal.ExternalStorageMountPolicy() {
+ StorageManagerInternal StorageManagerInternal = LocalServices.getService(
+ StorageManagerInternal.class);
+ StorageManagerInternal.addExternalStoragePolicy(
+ new StorageManagerInternal.ExternalStorageMountPolicy() {
@Override
public int getMountMode(int uid, String packageName) {
if (Process.isIsolated(uid)) {
@@ -19292,7 +19293,7 @@
}
/**
- * Called by MountService when the initial ASECs to scan are available.
+ * Called by StorageManagerService when the initial ASECs to scan are available.
* Should block until all the ASEC containers are finished being scanned.
*/
public void scanAvailableAsecs() {
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index a920d54..cd966ef 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -43,8 +43,8 @@
import android.os.UserManager;
import android.os.Vibrator;
import android.os.SystemVibrator;
-import android.os.storage.IMountService;
-import android.os.storage.IMountShutdownObserver;
+import android.os.storage.IStorageShutdownObserver;
+import android.os.storage.IStorageManager;
import android.system.ErrnoException;
import android.system.Os;
@@ -442,30 +442,30 @@
sInstance.setRebootProgress(RADIO_STOP_PERCENT, null);
}
- // Shutdown MountService to ensure media is in a safe state
- IMountShutdownObserver observer = new IMountShutdownObserver.Stub() {
+ // Shutdown StorageManagerService to ensure media is in a safe state
+ IStorageShutdownObserver observer = new IStorageShutdownObserver.Stub() {
public void onShutDownComplete(int statusCode) throws RemoteException {
- Log.w(TAG, "Result code " + statusCode + " from MountService.shutdown");
+ Log.w(TAG, "Result code " + statusCode + " from StorageManagerService.shutdown");
actionDone();
}
};
- Log.i(TAG, "Shutting down MountService");
+ Log.i(TAG, "Shutting down StorageManagerService");
// Set initial variables and time out time.
mActionDone = false;
final long endShutTime = SystemClock.elapsedRealtime() + MAX_SHUTDOWN_WAIT_TIME;
synchronized (mActionDoneSync) {
try {
- final IMountService mount = IMountService.Stub.asInterface(
+ final IStorageManager storageManager = IStorageManager.Stub.asInterface(
ServiceManager.checkService("mount"));
- if (mount != null) {
- mount.shutdown(observer);
+ if (storageManager != null) {
+ storageManager.shutdown(observer);
} else {
- Log.w(TAG, "MountService unavailable for shutdown");
+ Log.w(TAG, "StorageManagerService unavailable for shutdown");
}
} catch (Exception e) {
- Log.e(TAG, "Exception during MountService shutdown", e);
+ Log.e(TAG, "Exception during StorageManagerService shutdown", e);
}
while (!mActionDone) {
long delay = endShutTime - SystemClock.elapsedRealtime();