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

Commit 6ec0d5df authored by Neil Fuller's avatar Neil Fuller Committed by Android (Google) Code Review
Browse files

Merge "Renames / tidy ups"

parents 59ce935e 3e93c016
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.database.ContentObserver;
import android.os.Binder;
import android.os.Handler;
import android.provider.Settings;
import android.util.IndentingPrintWriter;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DumpUtils;
@@ -139,7 +140,9 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub {
            @Nullable String[] args) {
        if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

        mTimeDetectorStrategy.dump(pw, args);
        IndentingPrintWriter ipw = new IndentingPrintWriter(pw);
        mTimeDetectorStrategy.dump(ipw, args);
        ipw.flush();
    }

    private void enforceSuggestTelephonyTimePermission() {
+5 −8
Original line number Diff line number Diff line
@@ -17,25 +17,25 @@
package com.android.server.timedetector;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.timedetector.ManualTimeSuggestion;
import android.app.timedetector.NetworkTimeSuggestion;
import android.app.timedetector.TelephonyTimeSuggestion;
import android.os.TimestampedValue;
import android.util.IndentingPrintWriter;

import java.io.PrintWriter;
import com.android.server.timezonedetector.Dumpable;

/**
 * The interface for the class that implements the time detection algorithm used by the
 * {@link TimeDetectorService}.
 *
 * <p>Most calls will be handled by a single thread but that is not true for all calls. For example
 * {@link #dump(PrintWriter, String[])}) may be called on a different thread so implementations must
 * handle thread safety.
 * {@link #dump(IndentingPrintWriter, String[])}) may be called on a different thread so
 * implementations must handle thread safety.
 *
 * @hide
 */
public interface TimeDetectorStrategy {
public interface TimeDetectorStrategy extends Dumpable {

    /**
     * The interface used by the strategy to interact with the surrounding service.
@@ -94,9 +94,6 @@ public interface TimeDetectorStrategy {
    /** Handle the auto-time setting being toggled on or off. */
    void handleAutoTimeDetectionChanged();

    /** Dump debug information. */
    void dump(@NonNull PrintWriter pw, @Nullable String[] args);

    // Utility methods below are to be moved to a better home when one becomes more obvious.

    /**
+2 −5
Original line number Diff line number Diff line
@@ -24,16 +24,15 @@ import android.app.timedetector.ManualTimeSuggestion;
import android.app.timedetector.NetworkTimeSuggestion;
import android.app.timedetector.TelephonyTimeSuggestion;
import android.os.TimestampedValue;
import android.util.IndentingPrintWriter;
import android.util.LocalLog;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.timezonedetector.ArrayMapWithHistory;
import com.android.server.timezonedetector.ReferenceWithHistory;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -203,8 +202,7 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
    }

    @Override
    public synchronized void dump(@NonNull PrintWriter pw, @Nullable String[] args) {
        IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
    public synchronized void dump(@NonNull IndentingPrintWriter ipw, @Nullable String[] args) {
        ipw.println("TimeDetectorStrategy:");
        ipw.increaseIndent(); // level 1

@@ -232,7 +230,6 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
        ipw.decreaseIndent(); // level 2

        ipw.decreaseIndent(); // level 1
        ipw.flush();
    }

    @GuardedBy("this")
+1 −1
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@ import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.ArrayMap;
import android.util.IndentingPrintWriter;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;

/**
 * A partial decorator for {@link ArrayMap} that records historic values for each mapping for
+8 −5
Original line number Diff line number Diff line
@@ -15,24 +15,27 @@
 */
package com.android.server.timezonedetector;

import java.io.PrintWriter;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.IndentingPrintWriter;

/** An interface for components that can write their internal state to dumpsys logs. */
public interface Dumpable {

    /** Dump internal state. */
    void dump(PrintWriter pw, String[] args);
    void dump(@NonNull IndentingPrintWriter pw, @Nullable String[] args);

    /**
     * An interface that can be used expose when one component allows another to be registered so
     * that it is dumped at the same time.
     */
    interface Dumpee {
    interface Container {

        /**
         * Registers the supplied {@link Dumpable}. When the implementation is dumped
         * {@link Dumpable#dump(PrintWriter, String[])} should be called on the {@code dumpable}.
         * {@link Dumpable#dump(IndentingPrintWriter, String[])} should be called on the
         * {@code dumpable}.
         */
        void addDumpable(Dumpable dumpable);
        void addDumpable(@NonNull Dumpable dumpable);
    }
}
Loading