Merge "Move dump() to dumpAsync(), more oneway calls."
diff --git a/core/java/com/android/internal/os/TransferPipe.java b/core/java/com/android/internal/os/TransferPipe.java
index e76b395..f904150 100644
--- a/core/java/com/android/internal/os/TransferPipe.java
+++ b/core/java/com/android/internal/os/TransferPipe.java
@@ -16,6 +16,7 @@
package com.android.internal.os;
+import java.io.Closeable;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -32,13 +33,13 @@
/**
* Helper for transferring data through a pipe from a client app.
*/
-public final class TransferPipe implements Runnable {
+public final class TransferPipe implements Runnable, Closeable {
static final String TAG = "TransferPipe";
static final boolean DEBUG = false;
static final long DEFAULT_TIMEOUT = 5000; // 5 seconds
- final Thread mThread;;
+ final Thread mThread;
final ParcelFileDescriptor[] mFds;
FileDescriptor mOutFd;
@@ -54,8 +55,13 @@
}
public TransferPipe() throws IOException {
+ this(null);
+ }
+
+ public TransferPipe(String bufferPrefix) throws IOException {
mThread = new Thread(this, "TransferPipe");
mFds = ParcelFileDescriptor.createPipe();
+ mBufferPrefix = bufferPrefix;
}
ParcelFileDescriptor getReadFd() {
@@ -70,6 +76,11 @@
mBufferPrefix = prefix;
}
+ public static void dumpAsync(IBinder binder, FileDescriptor out, String[] args)
+ throws IOException, RemoteException {
+ goDump(binder, out, args);
+ }
+
static void go(Caller caller, IInterface iface, FileDescriptor out,
String prefix, String[] args) throws IOException, RemoteException {
go(caller, iface, out, prefix, args, DEFAULT_TIMEOUT);
@@ -86,12 +97,9 @@
return;
}
- TransferPipe tp = new TransferPipe();
- try {
+ try (TransferPipe tp = new TransferPipe()) {
caller.go(iface, tp.getWriteFd().getFileDescriptor(), prefix, args);
tp.go(out, timeout);
- } finally {
- tp.kill();
}
}
@@ -111,12 +119,9 @@
return;
}
- TransferPipe tp = new TransferPipe();
- try {
+ try (TransferPipe tp = new TransferPipe()) {
binder.dumpAsync(tp.getWriteFd().getFileDescriptor(), args);
tp.go(out, timeout);
- } finally {
- tp.kill();
}
}
@@ -173,6 +178,11 @@
}
}
+ @Override
+ public void close() {
+ kill();
+ }
+
public void kill() {
synchronized (this) {
closeFd(0);
diff --git a/location/java/android/location/IFusedProvider.aidl b/location/java/android/location/IFusedProvider.aidl
index 8870d2a..e86ad1a 100644
--- a/location/java/android/location/IFusedProvider.aidl
+++ b/location/java/android/location/IFusedProvider.aidl
@@ -22,11 +22,11 @@
* Interface definition for Location providers that require FLP services.
* @hide
*/
-interface IFusedProvider {
+oneway interface IFusedProvider {
/**
* Provides access to a FusedLocationHardware instance needed for the provider to work.
*
* @param instance The FusedLocationHardware available for the provider to use.
*/
void onFusedLocationHardwareChange(in IFusedLocationHardware instance);
-}
\ No newline at end of file
+}
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 5d8fe7c..6218abb 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -24,6 +24,7 @@
import com.android.internal.inputmethod.InputMethodUtils.InputMethodSettings;
import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;
+import com.android.internal.os.TransferPipe;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethod;
@@ -3976,9 +3977,9 @@
if (client != null) {
pw.flush();
try {
- client.client.asBinder().dump(fd, args);
- } catch (RemoteException e) {
- p.println("Input method client dead: " + e);
+ TransferPipe.dumpAsync(client.client.asBinder(), fd, args);
+ } catch (IOException | RemoteException e) {
+ p.println("Failed to dump input method client: " + e);
}
} else {
p.println("No input method client.");
@@ -3992,9 +3993,9 @@
p.println(" ");
pw.flush();
try {
- focusedWindowClient.client.asBinder().dump(fd, args);
- } catch (RemoteException e) {
- p.println("Input method client in focused window dead: " + e);
+ TransferPipe.dumpAsync(focusedWindowClient.client.asBinder(), fd, args);
+ } catch (IOException | RemoteException e) {
+ p.println("Failed to dump input method client in focused window: " + e);
}
}
@@ -4002,9 +4003,9 @@
if (method != null) {
pw.flush();
try {
- method.asBinder().dump(fd, args);
- } catch (RemoteException e) {
- p.println("Input method service dead: " + e);
+ TransferPipe.dumpAsync(method.asBinder(), fd, args);
+ } catch (IOException | RemoteException e) {
+ p.println("Failed to dump input method service: " + e);
}
} else {
p.println("No input method service.");
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index 756cb30..72fa1e3 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -43,8 +43,10 @@
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
+import com.android.internal.os.TransferPipe;
import java.io.FileDescriptor;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -426,12 +428,9 @@
for (INetworkScoreCache scoreCache : getScoreCaches()) {
try {
- scoreCache.asBinder().dump(fd, args);
- } catch (RemoteException e) {
- writer.println("Unable to dump score cache");
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, "Unable to dump score cache", e);
- }
+ TransferPipe.dumpAsync(scoreCache.asBinder(), fd, args);
+ } catch (IOException | RemoteException e) {
+ writer.println("Failed to dump score cache: " + e);
}
}
if (mServiceConnection != null) {
diff --git a/services/core/java/com/android/server/location/LocationProviderProxy.java b/services/core/java/com/android/server/location/LocationProviderProxy.java
index 5eb06ed..b44087c 100644
--- a/services/core/java/com/android/server/location/LocationProviderProxy.java
+++ b/services/core/java/com/android/server/location/LocationProviderProxy.java
@@ -17,6 +17,7 @@
package com.android.server.location;
import java.io.FileDescriptor;
+import java.io.IOException;
import java.io.PrintWriter;
import android.content.Context;
@@ -30,6 +31,7 @@
import com.android.internal.location.ProviderProperties;
import com.android.internal.location.ILocationProvider;
import com.android.internal.location.ProviderRequest;
+import com.android.internal.os.TransferPipe;
import com.android.server.LocationManagerService;
import com.android.server.ServiceWatcher;
@@ -230,14 +232,9 @@
pw.flush();
try {
- service.asBinder().dump(fd, args);
- } catch (RemoteException e) {
- pw.println("service down (RemoteException)");
- Log.w(TAG, e);
- } catch (Exception e) {
- pw.println("service down (Exception)");
- // never let remote service crash system server
- Log.e(TAG, "Exception from " + mServiceWatcher.getBestPackageName(), e);
+ TransferPipe.dumpAsync(service.asBinder(), fd, args);
+ } catch (IOException | RemoteException e) {
+ pw.println("Failed to dump location provider: " + e);
}
}
diff --git a/services/core/java/com/android/server/pm/EphemeralResolverConnection.java b/services/core/java/com/android/server/pm/EphemeralResolverConnection.java
index fe6fb1f..69accf3 100644
--- a/services/core/java/com/android/server/pm/EphemeralResolverConnection.java
+++ b/services/core/java/com/android/server/pm/EphemeralResolverConnection.java
@@ -32,8 +32,10 @@
import com.android.internal.app.EphemeralResolverService;
import com.android.internal.app.IEphemeralResolver;
+import com.android.internal.os.TransferPipe;
import java.io.FileDescriptor;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
@@ -85,13 +87,11 @@
.append((mRemoteInstance != null) ? "true" : "false").println();
pw.flush();
-
try {
- getRemoteInstanceLazy().asBinder().dump(fd, new String[] { prefix });
- } catch (TimeoutException te) {
- /* ignore */
- } catch (RemoteException re) {
- /* ignore */
+ TransferPipe.dumpAsync(getRemoteInstanceLazy().asBinder(), fd,
+ new String[] { prefix });
+ } catch (IOException | TimeoutException | RemoteException e) {
+ pw.println("Failed to dump remote instance: " + e);
}
}
}
diff --git a/services/print/java/com/android/server/print/RemotePrintSpooler.java b/services/print/java/com/android/server/print/RemotePrintSpooler.java
index 07cc9c0..62b5199 100644
--- a/services/print/java/com/android/server/print/RemotePrintSpooler.java
+++ b/services/print/java/com/android/server/print/RemotePrintSpooler.java
@@ -43,9 +43,12 @@
import android.util.Slog;
import android.util.TimedRemoteCaller;
+import com.android.internal.os.TransferPipe;
+
import libcore.io.IoUtils;
import java.io.FileDescriptor;
+import java.io.IOException;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.List;
@@ -569,13 +572,11 @@
.append((mRemoteInstance != null) ? "true" : "false").println();
pw.flush();
-
try {
- getRemoteInstanceLazy().asBinder().dump(fd, new String[]{prefix});
- } catch (TimeoutException te) {
- /* ignore */
- } catch (RemoteException re) {
- /* ignore */
+ TransferPipe.dumpAsync(getRemoteInstanceLazy().asBinder(), fd,
+ new String[] { prefix });
+ } catch (IOException | TimeoutException | RemoteException e) {
+ pw.println("Failed to dump remote instance: " + e);
}
}
}