Merge "Fix StorageManagerService linkToDeath more than one time when vold/storaged died."
am: d7f82d5766
Change-Id: I2a6fc7358c3c13cd67fc642d55c9973ab24331d1
This commit is contained in:
@@ -1557,10 +1557,11 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
connect();
|
connectStoraged();
|
||||||
|
connectVold();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect() {
|
private void connectStoraged() {
|
||||||
IBinder binder = ServiceManager.getService("storaged");
|
IBinder binder = ServiceManager.getService("storaged");
|
||||||
if (binder != null) {
|
if (binder != null) {
|
||||||
try {
|
try {
|
||||||
@@ -1569,7 +1570,7 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
Slog.w(TAG, "storaged died; reconnecting");
|
Slog.w(TAG, "storaged died; reconnecting");
|
||||||
mStoraged = null;
|
mStoraged = null;
|
||||||
connect();
|
connectStoraged();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1583,7 +1584,17 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
Slog.w(TAG, "storaged not found; trying again");
|
Slog.w(TAG, "storaged not found; trying again");
|
||||||
}
|
}
|
||||||
|
|
||||||
binder = ServiceManager.getService("vold");
|
if (mStoraged == null) {
|
||||||
|
BackgroundThread.getHandler().postDelayed(() -> {
|
||||||
|
connectStoraged();
|
||||||
|
}, DateUtils.SECOND_IN_MILLIS);
|
||||||
|
} else {
|
||||||
|
onDaemonConnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connectVold() {
|
||||||
|
IBinder binder = ServiceManager.getService("vold");
|
||||||
if (binder != null) {
|
if (binder != null) {
|
||||||
try {
|
try {
|
||||||
binder.linkToDeath(new DeathRecipient() {
|
binder.linkToDeath(new DeathRecipient() {
|
||||||
@@ -1591,7 +1602,7 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
Slog.w(TAG, "vold died; reconnecting");
|
Slog.w(TAG, "vold died; reconnecting");
|
||||||
mVold = null;
|
mVold = null;
|
||||||
connect();
|
connectVold();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1611,9 +1622,9 @@ class StorageManagerService extends IStorageManager.Stub
|
|||||||
Slog.w(TAG, "vold not found; trying again");
|
Slog.w(TAG, "vold not found; trying again");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mStoraged == null || mVold == null) {
|
if (mVold == null) {
|
||||||
BackgroundThread.getHandler().postDelayed(() -> {
|
BackgroundThread.getHandler().postDelayed(() -> {
|
||||||
connect();
|
connectVold();
|
||||||
}, DateUtils.SECOND_IN_MILLIS);
|
}, DateUtils.SECOND_IN_MILLIS);
|
||||||
} else {
|
} else {
|
||||||
onDaemonConnected();
|
onDaemonConnected();
|
||||||
|
|||||||
Reference in New Issue
Block a user