/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wifi;

import android.net.wifi.WifiInfo;
import android.net.wifi.WifiUsabilityStatsEntry;

/**
 * Base class for connection scoring
 */
public abstract class ConnectedScorer {

    /** Maximum NetworkAgent score that should be generated by wifi */
    public static final int WIFI_MAX_SCORE = 60;

    /** Initial Wifi score when starting up NetworkAgent. */
    public static final int WIFI_INITIAL_SCORE = WIFI_MAX_SCORE;

    /** Wifi score of secondary network compared to primary network. */
    public static final int WIFI_SECONDARY_DELTA_SCORE = 8;
    /** Maximum NetworkAgent score for secondary network that should be generated by wifi */
    public static final int WIFI_SECONDARY_MAX_SCORE = WIFI_MAX_SCORE - WIFI_SECONDARY_DELTA_SCORE;
    /** Initial Wifi score of secondary network when starting up NetworkAgent. */
    public static final int WIFI_SECONDARY_INITIAL_SCORE = WIFI_INITIAL_SCORE
            - WIFI_SECONDARY_DELTA_SCORE;

    /** Score at which wifi is considered poor enough to give up ant try something else */
    public static final int WIFI_TRANSITION_SCORE = WIFI_MAX_SCORE - 10;

    public static final int WIFI_SECONDARY_TRANSITION_SCORE = WIFI_TRANSITION_SCORE
            - WIFI_SECONDARY_DELTA_SCORE;

    public static final int WIFI_MIN_SCORE = 0;

    /** This is a typical STD for the connected RSSI for a phone sitting still */
    public double mDefaultRssiStandardDeviation = 2.0;

    /**
     * Generate a {@link ConnectedScoreResult} based on the current state.
     *
     * @return network score - on NetworkAgent scale.
     */
    public abstract ConnectedScoreResult generateScoreResult(WifiInfo wifiInfo,
            WifiUsabilityStatsEntry stats, long millis, boolean isPrimary);

    /**
     * Clears out state associated with the connection
     */
    public abstract void reset();
}
