Start paving the way for vold calls over Binder.

This change is the bare minimum needed to connect to a new vold
Binder service and move the simple "reset" call over to go through
the new interface.

Test: builds, boots
Bug: 13758960
Change-Id: I2d8c406cd98728e5ac0a310e07048253ec8dce86
This commit is contained in:
Jeff Sharkey
2017-09-06 13:47:03 -06:00
parent f3e4749b82
commit 1019de990a
2 changed files with 41 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ LOCAL_SRC_FILES += \
java/com/android/server/am/EventLogTags.logtags \
../../../../system/netd/server/binder/android/net/INetd.aidl \
../../../../system/netd/server/binder/android/net/metrics/INetdEventListener.aidl \
../../../../system/vold/binder/android/os/IVold.aidl \
../../../native/cmds/installd/binder/android/os/IInstalld.aidl \
LOCAL_AIDL_INCLUDES += \

View File

@@ -56,6 +56,7 @@ import android.os.FileUtils;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.IVold;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelFileDescriptor;
@@ -96,6 +97,7 @@ import android.util.Xml;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.IMediaContainerService;
import com.android.internal.os.AppFuseMount;
import com.android.internal.os.BackgroundThread;
import com.android.internal.os.FuseUnavailableMountException;
import com.android.internal.os.SomeArgs;
import com.android.internal.os.Zygote;
@@ -108,7 +110,6 @@ import com.android.internal.util.Preconditions;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.NativeDaemonConnector.Command;
import com.android.server.NativeDaemonConnector.SensitiveArg;
import com.android.server.pm.PackageManagerException;
import com.android.server.pm.PackageManagerService;
import com.android.server.storage.AppFuseBridge;
@@ -201,6 +202,9 @@ class StorageManagerService extends IStorageManager.Stub
}
}
/** Flag to enable binder-based interface to vold */
private static final boolean ENABLE_BINDER = true;
private static final boolean DEBUG_EVENTS = false;
private static final boolean DEBUG_OBB = false;
@@ -471,6 +475,8 @@ class StorageManagerService extends IStorageManager.Stub
private final Thread mConnectorThread;
private final Thread mCryptConnectorThread;
private volatile IVold mVold;
private volatile boolean mSystemReady = false;
private volatile boolean mBootCompleted = false;
private volatile boolean mDaemonConnected = false;
@@ -916,7 +922,11 @@ class StorageManagerService extends IStorageManager.Stub
}
try {
mConnector.execute("volume", "reset");
if (ENABLE_BINDER) {
mVold.reset();
} else {
mConnector.execute("volume", "reset");
}
// Tell vold about all existing and started users
for (UserInfo user : users) {
@@ -925,7 +935,7 @@ class StorageManagerService extends IStorageManager.Stub
for (int userId : systemUnlockedUsers) {
mConnector.execute("volume", "user_started", userId);
}
} catch (NativeDaemonConnectorException e) {
} catch (RemoteException | NativeDaemonConnectorException e) {
Slog.w(TAG, "Failed to reset vold", e);
}
}
@@ -1574,10 +1584,37 @@ class StorageManagerService extends IStorageManager.Stub
}
private void start() {
connect();
mConnectorThread.start();
mCryptConnectorThread.start();
}
private void connect() {
IBinder binder = ServiceManager.getService("vold");
if (binder != null) {
try {
binder.linkToDeath(new DeathRecipient() {
@Override
public void binderDied() {
Slog.w(TAG, "vold died; reconnecting");
connect();
}
}, 0);
} catch (RemoteException e) {
binder = null;
}
}
if (binder != null) {
mVold = IVold.Stub.asInterface(binder);
} else {
Slog.w(TAG, "vold not found; trying again");
BackgroundThread.getHandler().postDelayed(() -> {
connect();
}, DateUtils.SECOND_IN_MILLIS);
}
}
private void systemReady() {
mSystemReady = true;
mHandler.obtainMessage(H_SYSTEM_READY).sendToTarget();