Guard against null server
If MtpService stops before MtpServer shuts down, the server will be null, so don't attempt to use it in that case. Bug: 76433619 Test: no errors Change-Id: I6744cb78908e6a0663a4b60107d5c9c18dda62bb
This commit is contained in:
@@ -314,7 +314,9 @@ public class MtpDatabase implements AutoCloseable {
|
||||
public void addStorage(StorageVolume storage) {
|
||||
MtpStorage mtpStorage = mManager.addMtpStorage(storage);
|
||||
mStorageMap.put(storage.getPath(), mtpStorage);
|
||||
mServer.addStorage(mtpStorage);
|
||||
if (mServer != null) {
|
||||
mServer.addStorage(mtpStorage);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeStorage(StorageVolume storage) {
|
||||
@@ -322,7 +324,9 @@ public class MtpDatabase implements AutoCloseable {
|
||||
if (mtpStorage == null) {
|
||||
return;
|
||||
}
|
||||
mServer.removeStorage(mtpStorage);
|
||||
if (mServer != null) {
|
||||
mServer.removeStorage(mtpStorage);
|
||||
}
|
||||
mManager.removeMtpStorage(mtpStorage);
|
||||
mStorageMap.remove(storage.getPath());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user