summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-04-30 18:58:05 -0700
committerxshu <xshu@google.com>2020-05-06 17:29:46 -0700
commitcf601559d982f5270e48a888a8826b86b8afc2ee (patch)
treecc57d38487805a4946890d4d23d49eadf3512d27 /service
parent11f1b3d49fc0c96e73eae0c993edda46228bba13 (diff)
Fix WifiLockManager Death link does not exist
The cause of the issue is that sometimes WifiLocks are added without linkToDeath working properly. Catches the NoSuchElementException inside WifiLockManager to prevent SystemServer from crashing. Bug: 155240535 Test: atest com.android.server.wifi Change-Id: Id9d56b9da184febef7915eb5281ea39f97e51b06
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiLockManager.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiLockManager.java b/service/java/com/android/server/wifi/WifiLockManager.java
index 7bbd3aa2e..7cbeea0d3 100644
--- a/service/java/com/android/server/wifi/WifiLockManager.java
+++ b/service/java/com/android/server/wifi/WifiLockManager.java
@@ -36,6 +36,7 @@ import com.android.server.wifi.util.WorkSourceUtil;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.NoSuchElementException;
/**
* WifiLockManager maintains the list of wake locks held by different applications.
@@ -189,7 +190,6 @@ public class WifiLockManager {
// This is to make sure worksource value can not be changed by caller
// after function returns.
WorkSource newWorkSource = new WorkSource(ws);
-
return addLock(new WifiLock(lockMode, tag, binder, newWorkSource));
}
@@ -804,6 +804,7 @@ public class WifiLockManager {
try {
mBinder.linkToDeath(this, 0);
} catch (RemoteException e) {
+ Log.e(TAG, "mBinder.linkToDeath failed: " + e.getMessage());
binderDied();
}
}
@@ -829,7 +830,11 @@ public class WifiLockManager {
}
public void unlinkDeathRecipient() {
- mBinder.unlinkToDeath(this, 0);
+ try {
+ mBinder.unlinkToDeath(this, 0);
+ } catch (NoSuchElementException e) {
+ Log.e(TAG, "mBinder.unlinkToDeath failed: " + e.getMessage());
+ }
}
public String toString() {