Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa3bd77f authored by Lucas Lin's avatar Lucas Lin Committed by Automerger Merge Worker
Browse files

Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity"...

Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity" am: c7906266 am: 3b6bae1f

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1537266

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I50c09f6f06ea624a44353f0a7870bd500a387eca
parents 37daa95e 3b6bae1f
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -623,32 +623,41 @@ public class ConnectivityDiagnosticsManager {
        /** @hide */
        @VisibleForTesting
        public void onConnectivityReportAvailable(@NonNull ConnectivityReport report) {
            Binder.withCleanCallingIdentity(() -> {
            final long token = Binder.clearCallingIdentity();
            try {
                mExecutor.execute(() -> {
                    mCb.onConnectivityReportAvailable(report);
                });
            });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        /** @hide */
        @VisibleForTesting
        public void onDataStallSuspected(@NonNull DataStallReport report) {
            Binder.withCleanCallingIdentity(() -> {
            final long token = Binder.clearCallingIdentity();
            try {
                mExecutor.execute(() -> {
                    mCb.onDataStallSuspected(report);
                });
            });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        /** @hide */
        @VisibleForTesting
        public void onNetworkConnectivityReported(
                @NonNull Network network, boolean hasConnectivity) {
            Binder.withCleanCallingIdentity(() -> {
            final long token = Binder.clearCallingIdentity();
            try {
                mExecutor.execute(() -> {
                    mCb.onNetworkConnectivityReported(network, hasConnectivity);
                });
            });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }

+27 −15
Original line number Diff line number Diff line
@@ -1833,30 +1833,42 @@ public class ConnectivityManager {
            mCallback = new ISocketKeepaliveCallback.Stub() {
                @Override
                public void onStarted(int slot) {
                    Binder.withCleanCallingIdentity(() ->
                    final long token = Binder.clearCallingIdentity();
                    try {
                        mExecutor.execute(() -> {
                            mSlot = slot;
                            callback.onStarted();
                            }));
                        });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }

                @Override
                public void onStopped() {
                    Binder.withCleanCallingIdentity(() ->
                    final long token = Binder.clearCallingIdentity();
                    try {
                        mExecutor.execute(() -> {
                            mSlot = null;
                            callback.onStopped();
                            }));
                        });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                    mExecutor.shutdown();
                }

                @Override
                public void onError(int error) {
                    Binder.withCleanCallingIdentity(() ->
                    final long token = Binder.clearCallingIdentity();
                    try {
                        mExecutor.execute(() -> {
                            mSlot = null;
                            callback.onError(error);
                            }));
                        });
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                    mExecutor.shutdown();
                }

+36 −20
Original line number Diff line number Diff line
@@ -187,38 +187,54 @@ public abstract class SocketKeepalive implements AutoCloseable {
        mCallback = new ISocketKeepaliveCallback.Stub() {
            @Override
            public void onStarted(int slot) {
                Binder.withCleanCallingIdentity(() ->
                final long token = Binder.clearCallingIdentity();
                try {
                    mExecutor.execute(() -> {
                        mSlot = slot;
                        callback.onStarted();
                        }));
                    });
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }

            @Override
            public void onStopped() {
                Binder.withCleanCallingIdentity(() ->
                final long token = Binder.clearCallingIdentity();
                try {
                    executor.execute(() -> {
                        mSlot = null;
                        callback.onStopped();
                        }));
                    });
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }

            @Override
            public void onError(int error) {
                Binder.withCleanCallingIdentity(() ->
                final long token = Binder.clearCallingIdentity();
                try {
                    executor.execute(() -> {
                        mSlot = null;
                        callback.onError(error);
                        }));
                    });
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }

            @Override
            public void onDataReceived() {
                Binder.withCleanCallingIdentity(() ->
                final long token = Binder.clearCallingIdentity();
                try {
                    executor.execute(() -> {
                        mSlot = null;
                        callback.onDataReceived();
                        }));
                    });
                } finally {
                    Binder.restoreCallingIdentity(token);
                }
            }
        };
    }