Loading core/java/android/os/Binder.java +21 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,27 @@ public class Binder implements IBinder { } } static ThreadLocal<Boolean> sWarnOnBlockingOnCurrentThread = ThreadLocal.withInitial(() -> sWarnOnBlocking); /** * Allow blocking calls for the current thread. See {@link #allowBlocking}. * * @hide */ public static void allowBlockingForCurrentThread() { sWarnOnBlockingOnCurrentThread.set(false); } /** * Reset the current thread to the default blocking behavior. See {@link #defaultBlocking}. * * @hide */ public static void defaultBlockingForCurrentThread() { sWarnOnBlockingOnCurrentThread.set(sWarnOnBlocking); } /** * Raw native pointer to JavaBBinderHolder object. Owned by this Java object. Not null. */ Loading core/java/android/os/BinderProxy.java +8 −3 Original line number Diff line number Diff line Loading @@ -479,16 +479,21 @@ public final class BinderProxy implements IBinder { public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { Binder.checkParcel(this, code, data, "Unreasonably large binder buffer"); if (mWarnOnBlocking && ((flags & FLAG_ONEWAY) == 0)) { if (mWarnOnBlocking && ((flags & FLAG_ONEWAY) == 0) && Binder.sWarnOnBlockingOnCurrentThread.get()) { // For now, avoid spamming the log by disabling after we've logged // about this interface at least once mWarnOnBlocking = false; if (Build.IS_USERDEBUG) { // Log this as a WTF on userdebug builds. Log.wtf(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", Log.wtf(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", new Throwable()); } else { Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", new Throwable()); } } Loading services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java +7 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Binder; import android.util.EventLog; import android.util.Slog; Loading Loading @@ -134,7 +135,12 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver { private BufferedInputStream getAltContent(Context c, Intent i) throws IOException { Uri content = getContentFromIntent(i); Binder.allowBlockingForCurrentThread(); try { return new BufferedInputStream(c.getContentResolver().openInputStream(content)); } finally { Binder.defaultBlockingForCurrentThread(); } } private byte[] getCurrentContent() { Loading Loading
core/java/android/os/Binder.java +21 −0 Original line number Diff line number Diff line Loading @@ -248,6 +248,27 @@ public class Binder implements IBinder { } } static ThreadLocal<Boolean> sWarnOnBlockingOnCurrentThread = ThreadLocal.withInitial(() -> sWarnOnBlocking); /** * Allow blocking calls for the current thread. See {@link #allowBlocking}. * * @hide */ public static void allowBlockingForCurrentThread() { sWarnOnBlockingOnCurrentThread.set(false); } /** * Reset the current thread to the default blocking behavior. See {@link #defaultBlocking}. * * @hide */ public static void defaultBlockingForCurrentThread() { sWarnOnBlockingOnCurrentThread.set(sWarnOnBlocking); } /** * Raw native pointer to JavaBBinderHolder object. Owned by this Java object. Not null. */ Loading
core/java/android/os/BinderProxy.java +8 −3 Original line number Diff line number Diff line Loading @@ -479,16 +479,21 @@ public final class BinderProxy implements IBinder { public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { Binder.checkParcel(this, code, data, "Unreasonably large binder buffer"); if (mWarnOnBlocking && ((flags & FLAG_ONEWAY) == 0)) { if (mWarnOnBlocking && ((flags & FLAG_ONEWAY) == 0) && Binder.sWarnOnBlockingOnCurrentThread.get()) { // For now, avoid spamming the log by disabling after we've logged // about this interface at least once mWarnOnBlocking = false; if (Build.IS_USERDEBUG) { // Log this as a WTF on userdebug builds. Log.wtf(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", Log.wtf(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", new Throwable()); } else { Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY", new Throwable()); } } Loading
services/core/java/com/android/server/updates/ConfigUpdateInstallReceiver.java +7 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Binder; import android.util.EventLog; import android.util.Slog; Loading Loading @@ -134,7 +135,12 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver { private BufferedInputStream getAltContent(Context c, Intent i) throws IOException { Uri content = getContentFromIntent(i); Binder.allowBlockingForCurrentThread(); try { return new BufferedInputStream(c.getContentResolver().openInputStream(content)); } finally { Binder.defaultBlockingForCurrentThread(); } } private byte[] getCurrentContent() { Loading