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

Commit 4c7a3d12 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding a little more verbose logging."

parents 3023320d 4ad7ca05
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
package android.net;

import android.annotation.SystemApi;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -20,6 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
@SystemApi
public abstract class NetworkRecommendationProvider {
    private static final String TAG = "NetworkRecProvider";
    private static final boolean VERBOSE = Build.IS_DEBUGGABLE && Log.isLoggable(TAG, Log.VERBOSE);
    /** The key into the callback Bundle where the RecommendationResult will be found. */
    public static final String EXTRA_RECOMMENDATION_RESULT =
            "android.net.extra.RECOMMENDATION_RESULT";
@@ -91,8 +93,10 @@ public abstract class NetworkRecommendationProvider {
         * @param result a {@link RecommendationResult} instance.
         */
        public void onResult(RecommendationResult result) {
            if (VERBOSE) Log.v(TAG, "onResult(seq=" + mSequence + ")");
            if (!mCallbackRun.compareAndSet(false, true)) {
                throw new IllegalStateException("The callback cannot be run more than once.");
                throw new IllegalStateException("The callback cannot be run more than once. "
                        + "seq=" + mSequence);
            }
            final Bundle data = new Bundle();
            data.putInt(EXTRA_SEQUENCE, mSequence);
@@ -102,6 +106,7 @@ public abstract class NetworkRecommendationProvider {
            } catch (RemoteException e) {
                Log.w(TAG, "Callback failed for seq: " + mSequence, e);
            }
            if (VERBOSE) Log.v(TAG, "onResult() complete. seq=" + mSequence);
        }

        @Override
@@ -134,9 +139,13 @@ public abstract class NetworkRecommendationProvider {
        @Override
        public void requestRecommendation(final RecommendationRequest request,
                final IRemoteCallback callback, final int sequence) throws RemoteException {
            if (VERBOSE) Log.v(TAG, "requestRecommendation(seq=" + sequence + ")");
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (VERBOSE) {
                        Log.v(TAG, "requestRecommendation(seq=" + sequence + ") running...");
                    }
                    ResultCallback resultCallback = new ResultCallback(callback, sequence);
                    onRequestRecommendation(request, resultCallback);
                }
+3 −0
Original line number Diff line number Diff line
@@ -917,6 +917,7 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
                return;
            }
            writer.println("Current scorer: " + currentScorer);
            writer.println("RecommendationRequestTimeoutMs: " + mRecommendationRequestTimeoutMs);

            sendCacheUpdateCallback(new BiConsumer<INetworkScoreCache, Object>() {
                @Override
@@ -1086,6 +1087,7 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
                    final RecommendationResult result =
                            data.getParcelable(EXTRA_RECOMMENDATION_RESULT);
                    final int sequence = data.getInt(EXTRA_SEQUENCE, -1);
                    if (VERBOSE) Log.v(TAG, "callback received for sequence " + sequence);
                    onRemoteMethodResult(result, sequence);
                }
            };
@@ -1105,6 +1107,7 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
        RecommendationResult getRecommendationResult(INetworkRecommendationProvider target,
                RecommendationRequest request) throws RemoteException, TimeoutException {
            final int sequence = onBeforeRemoteCall();
            if (VERBOSE) Log.v(TAG, "getRecommendationResult() seq=" + sequence);
            target.requestRecommendation(request, mCallback, sequence);
            return getResultTimed(sequence);
        }