Merge "Fixed a race contidion in StorageManagerService" am: 782ef476df

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1508499

Change-Id: Ib0a2065b098399f2464463817967ed36e61b4980
This commit is contained in:
Zimuzo Ezeozue
2020-12-01 11:19:19 +00:00
committed by Automerger Merge Worker
2 changed files with 18 additions and 2 deletions

View File

@@ -200,6 +200,21 @@ public class VolumeInfo implements Parcelable {
internalPath = parcel.readString8();
}
public VolumeInfo(VolumeInfo volumeInfo) {
this.id = volumeInfo.id;
this.type = volumeInfo.type;
this.disk = volumeInfo.disk;
this.partGuid = volumeInfo.partGuid;
this.mountFlags = volumeInfo.mountFlags;
this.mountUserId = volumeInfo.mountUserId;
this.state = volumeInfo.state;
this.fsType = volumeInfo.fsType;
this.fsUuid = volumeInfo.fsUuid;
this.fsLabel = volumeInfo.fsLabel;
this.path = volumeInfo.path;
this.internalPath = volumeInfo.internalPath;
}
@UnsupportedAppUsage
public static @NonNull String getEnvironmentForState(int state) {
final String envState = sStateToEnvironment.get(state);

View File

@@ -1391,12 +1391,13 @@ class StorageManagerService extends IStorageManager.Stub
final int oldState = vol.state;
final int newState = state;
vol.state = newState;
final VolumeInfo vInfo = new VolumeInfo(vol);
final SomeArgs args = SomeArgs.obtain();
args.arg1 = vol;
args.arg1 = vInfo;
args.arg2 = oldState;
args.arg3 = newState;
mHandler.obtainMessage(H_VOLUME_STATE_CHANGED, args).sendToTarget();
onVolumeStateChangedLocked(vol, oldState, newState);
onVolumeStateChangedLocked(vInfo, oldState, newState);
}
}
}