Merge changes from topic 'bench' into mnc-dev
* changes: Command to change force adoptable state. Initial pass at storage benchmarks.
This commit is contained in:
@@ -71,6 +71,8 @@ public final class Sm {
|
||||
runHasAdoptable();
|
||||
} else if ("get-primary-storage-uuid".equals(op)) {
|
||||
runGetPrimaryStorageUuid();
|
||||
} else if ("set-force-adoptable".equals(op)) {
|
||||
runSetForceAdoptable();
|
||||
} else if ("partition".equals(op)) {
|
||||
runPartition();
|
||||
} else if ("mount".equals(op)) {
|
||||
@@ -116,14 +118,19 @@ public final class Sm {
|
||||
}
|
||||
|
||||
public void runHasAdoptable() {
|
||||
System.out.println(SystemProperties.getBoolean(StorageManager.PROP_HAS_ADOPTABLE, false)
|
||||
|| SystemProperties.getBoolean(StorageManager.PROP_FORCE_ADOPTABLE, false));
|
||||
System.out.println(SystemProperties.getBoolean(StorageManager.PROP_HAS_ADOPTABLE, false));
|
||||
}
|
||||
|
||||
public void runGetPrimaryStorageUuid() throws RemoteException {
|
||||
System.out.println(mSm.getPrimaryStorageUuid());
|
||||
}
|
||||
|
||||
public void runSetForceAdoptable() throws RemoteException {
|
||||
final boolean forceAdoptable = Boolean.parseBoolean(nextArg());
|
||||
mSm.setDebugFlags(forceAdoptable ? StorageManager.DEBUG_FORCE_ADOPTABLE : 0,
|
||||
StorageManager.DEBUG_FORCE_ADOPTABLE);
|
||||
}
|
||||
|
||||
public void runPartition() throws RemoteException {
|
||||
final String diskId = nextArg();
|
||||
final String type = nextArg();
|
||||
@@ -177,6 +184,7 @@ public final class Sm {
|
||||
System.err.println(" sm list-volumes [public|private|emulated|all]");
|
||||
System.err.println(" sm has-adoptable");
|
||||
System.err.println(" sm get-primary-storage-uuid");
|
||||
System.err.println(" sm set-force-adoptable [true|false]");
|
||||
System.err.println("");
|
||||
System.err.println(" sm partition DISK [public|private|mixed] [ratio]");
|
||||
System.err.println(" sm mount VOLUME");
|
||||
|
||||
@@ -1004,6 +1004,22 @@ public interface IMountService extends IInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long benchmark(String volId) throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeString(volId);
|
||||
mRemote.transact(Stub.TRANSACTION_benchmark, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
return _reply.readLong();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partitionPublic(String diskId) throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
@@ -1112,6 +1128,22 @@ public interface IMountService extends IInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebugFlags(int _flags, int _mask) throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
Parcel _reply = Parcel.obtain();
|
||||
try {
|
||||
_data.writeInterfaceToken(DESCRIPTOR);
|
||||
_data.writeInt(_flags);
|
||||
_data.writeInt(_mask);
|
||||
mRemote.transact(Stub.TRANSACTION_setDebugFlags, _data, _reply, 0);
|
||||
_reply.readException();
|
||||
} finally {
|
||||
_reply.recycle();
|
||||
_data.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryStorageUuid() throws RemoteException {
|
||||
Parcel _data = Parcel.obtain();
|
||||
@@ -1257,6 +1289,9 @@ public interface IMountService extends IInterface {
|
||||
static final int TRANSACTION_getPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 57;
|
||||
static final int TRANSACTION_setPrimaryStorageUuid = IBinder.FIRST_CALL_TRANSACTION + 58;
|
||||
|
||||
static final int TRANSACTION_benchmark = IBinder.FIRST_CALL_TRANSACTION + 59;
|
||||
static final int TRANSACTION_setDebugFlags = IBinder.FIRST_CALL_TRANSACTION + 60;
|
||||
|
||||
/**
|
||||
* Cast an IBinder object into an IMountService interface, generating a
|
||||
* proxy if needed.
|
||||
@@ -1726,6 +1761,14 @@ public interface IMountService extends IInterface {
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
}
|
||||
case TRANSACTION_benchmark: {
|
||||
data.enforceInterface(DESCRIPTOR);
|
||||
String volId = data.readString();
|
||||
long res = benchmark(volId);
|
||||
reply.writeNoException();
|
||||
reply.writeLong(res);
|
||||
return true;
|
||||
}
|
||||
case TRANSACTION_partitionPublic: {
|
||||
data.enforceInterface(DESCRIPTOR);
|
||||
String diskId = data.readString();
|
||||
@@ -1778,6 +1821,14 @@ public interface IMountService extends IInterface {
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
}
|
||||
case TRANSACTION_setDebugFlags: {
|
||||
data.enforceInterface(DESCRIPTOR);
|
||||
int _flags = data.readInt();
|
||||
int _mask = data.readInt();
|
||||
setDebugFlags(_flags, _mask);
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
}
|
||||
case TRANSACTION_getPrimaryStorageUuid: {
|
||||
data.enforceInterface(DESCRIPTOR);
|
||||
String volumeUuid = getPrimaryStorageUuid();
|
||||
@@ -2088,6 +2139,7 @@ public interface IMountService extends IInterface {
|
||||
public void mount(String volId) throws RemoteException;
|
||||
public void unmount(String volId) throws RemoteException;
|
||||
public void format(String volId) throws RemoteException;
|
||||
public long benchmark(String volId) throws RemoteException;
|
||||
|
||||
public void partitionPublic(String diskId) throws RemoteException;
|
||||
public void partitionPrivate(String diskId) throws RemoteException;
|
||||
@@ -2097,6 +2149,7 @@ public interface IMountService extends IInterface {
|
||||
public void setVolumeUserFlags(String fsUuid, int flags, int mask) throws RemoteException;
|
||||
public void forgetVolume(String fsUuid) throws RemoteException;
|
||||
public void forgetAllVolumes() throws RemoteException;
|
||||
public void setDebugFlags(int flags, int mask) throws RemoteException;
|
||||
|
||||
public String getPrimaryStorageUuid() throws RemoteException;
|
||||
public void setPrimaryStorageUuid(String volumeUuid, IPackageMoveObserver callback)
|
||||
|
||||
@@ -82,6 +82,9 @@ public class StorageManager {
|
||||
/** {@hide} */
|
||||
public static final String UUID_PRIMARY_PHYSICAL = "primary_physical";
|
||||
|
||||
/** {@hide} */
|
||||
public static final int DEBUG_FORCE_ADOPTABLE = 1 << 0;
|
||||
|
||||
private final Context mContext;
|
||||
private final ContentResolver mResolver;
|
||||
|
||||
@@ -640,6 +643,15 @@ public class StorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public long benchmark(String volId) {
|
||||
try {
|
||||
return mMountService.benchmark(volId);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public void partitionPublic(String diskId) {
|
||||
try {
|
||||
|
||||
@@ -95,6 +95,8 @@
|
||||
<uses-permission android:name="android.permission.MODIFY_APPWIDGET_BIND_PERMISSIONS"/>
|
||||
<uses-permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_APP_IDLE_STATE" />
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||
<uses-permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS" />
|
||||
|
||||
<application android:label="@string/app_label">
|
||||
<provider
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.android.server;
|
||||
|
||||
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
|
||||
import static com.android.internal.util.XmlUtils.readIntAttribute;
|
||||
import static com.android.internal.util.XmlUtils.readStringAttribute;
|
||||
import static com.android.internal.util.XmlUtils.writeBooleanAttribute;
|
||||
import static com.android.internal.util.XmlUtils.writeIntAttribute;
|
||||
import static com.android.internal.util.XmlUtils.writeStringAttribute;
|
||||
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
|
||||
@@ -37,6 +39,7 @@ import android.content.res.ObbInfo;
|
||||
import android.mtp.MtpStorage;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.DropBoxManager;
|
||||
import android.os.Environment;
|
||||
import android.os.Environment.UserEnvironment;
|
||||
import android.os.FileUtils;
|
||||
@@ -174,6 +177,7 @@ class MountService extends IMountService.Stub
|
||||
private static final boolean WATCHDOG_ENABLE = false;
|
||||
|
||||
private static final String TAG = "MountService";
|
||||
private static final String TAG_STORAGE_BENCHMARK = "storage_benchmark";
|
||||
|
||||
private static final String VOLD_TAG = "VoldConnector";
|
||||
|
||||
@@ -233,6 +237,7 @@ class MountService extends IMountService.Stub
|
||||
public static final int VOLUME_DESTROYED = 659;
|
||||
|
||||
public static final int MOVE_STATUS = 660;
|
||||
public static final int BENCHMARK_RESULT = 661;
|
||||
|
||||
/*
|
||||
* 700 series - fstrim
|
||||
@@ -247,6 +252,7 @@ class MountService extends IMountService.Stub
|
||||
private static final String TAG_VOLUMES = "volumes";
|
||||
private static final String ATTR_VERSION = "version";
|
||||
private static final String ATTR_PRIMARY_STORAGE_UUID = "primaryStorageUuid";
|
||||
private static final String ATTR_FORCE_ADOPTABLE = "forceAdoptable";
|
||||
private static final String TAG_VOLUME = "volume";
|
||||
private static final String ATTR_TYPE = "type";
|
||||
private static final String ATTR_FS_UUID = "fsUuid";
|
||||
@@ -276,6 +282,8 @@ class MountService extends IMountService.Stub
|
||||
private ArrayMap<String, VolumeRecord> mRecords = new ArrayMap<>();
|
||||
@GuardedBy("mLock")
|
||||
private String mPrimaryStorageUuid;
|
||||
@GuardedBy("mLock")
|
||||
private boolean mForceAdoptable;
|
||||
|
||||
/** Map from disk ID to latches */
|
||||
@GuardedBy("mLock")
|
||||
@@ -810,7 +818,8 @@ class MountService extends IMountService.Stub
|
||||
if (cooked.length != 3) break;
|
||||
final String id = cooked[1];
|
||||
int flags = Integer.parseInt(cooked[2]);
|
||||
if (SystemProperties.getBoolean(StorageManager.PROP_FORCE_ADOPTABLE, false)) {
|
||||
if (SystemProperties.getBoolean(StorageManager.PROP_FORCE_ADOPTABLE, false)
|
||||
|| mForceAdoptable) {
|
||||
flags |= DiskInfo.FLAG_ADOPTABLE;
|
||||
}
|
||||
mDisks.put(id, new DiskInfo(id, flags));
|
||||
@@ -927,6 +936,12 @@ class MountService extends IMountService.Stub
|
||||
break;
|
||||
}
|
||||
|
||||
case VoldResponseCode.BENCHMARK_RESULT: {
|
||||
final DropBoxManager dropBox = mContext.getSystemService(DropBoxManager.class);
|
||||
dropBox.addText(TAG_STORAGE_BENCHMARK, raw);
|
||||
break;
|
||||
}
|
||||
|
||||
case VoldResponseCode.FstrimCompleted: {
|
||||
EventLogTags.writeFstrimFinish(SystemClock.elapsedRealtime());
|
||||
break;
|
||||
@@ -1199,6 +1214,7 @@ class MountService extends IMountService.Stub
|
||||
private void readSettingsLocked() {
|
||||
mRecords.clear();
|
||||
mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
|
||||
mForceAdoptable = false;
|
||||
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
@@ -1220,6 +1236,7 @@ class MountService extends IMountService.Stub
|
||||
mPrimaryStorageUuid = readStringAttribute(in,
|
||||
ATTR_PRIMARY_STORAGE_UUID);
|
||||
}
|
||||
mForceAdoptable = readBooleanAttribute(in, ATTR_FORCE_ADOPTABLE, false);
|
||||
|
||||
} else if (TAG_VOLUME.equals(tag)) {
|
||||
final VolumeRecord rec = readVolumeRecord(in);
|
||||
@@ -1249,6 +1266,7 @@ class MountService extends IMountService.Stub
|
||||
out.startTag(null, TAG_VOLUMES);
|
||||
writeIntAttribute(out, ATTR_VERSION, VERSION_FIX_PRIMARY);
|
||||
writeStringAttribute(out, ATTR_PRIMARY_STORAGE_UUID, mPrimaryStorageUuid);
|
||||
writeBooleanAttribute(out, ATTR_FORCE_ADOPTABLE, mForceAdoptable);
|
||||
final int size = mRecords.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
final VolumeRecord rec = mRecords.valueAt(i);
|
||||
@@ -1405,6 +1423,19 @@ class MountService extends IMountService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long benchmark(String volId) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
|
||||
waitForReady();
|
||||
|
||||
try {
|
||||
final NativeDaemonEvent res = mConnector.execute("volume", "benchmark", volId);
|
||||
return Long.parseLong(res.getMessage());
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw e.rethrowAsParcelableException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partitionPublic(String diskId) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);
|
||||
@@ -1519,6 +1550,21 @@ class MountService extends IMountService.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebugFlags(int flags, int mask) {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
|
||||
waitForReady();
|
||||
|
||||
synchronized (mLock) {
|
||||
if ((mask & StorageManager.DEBUG_FORCE_ADOPTABLE) != 0) {
|
||||
mForceAdoptable = (flags & StorageManager.DEBUG_FORCE_ADOPTABLE) != 0;
|
||||
}
|
||||
|
||||
writeSettingsLocked();
|
||||
resetIfReadyAndConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryStorageUuid() {
|
||||
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
|
||||
@@ -3014,6 +3060,7 @@ class MountService extends IMountService.Stub
|
||||
|
||||
pw.println();
|
||||
pw.println("Primary storage UUID: " + mPrimaryStorageUuid);
|
||||
pw.println("Force adoptable: " + mForceAdoptable);
|
||||
}
|
||||
|
||||
synchronized (mObbMounts) {
|
||||
|
||||
Reference in New Issue
Block a user