1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.telephony;
18
19/**
20 * Link Bandwidth Information from the Radio
21 */
22public class LinkCapacityEstimate {
23    /** Any field that is not reported shall be set to INVALID */
24    public static final int INVALID = -1;
25
26    /** LCE is active; Deprecated in HAL 1.2 */
27    public static final int STATUS_ACTIVE = 0;
28
29    /** LCE is suspended; Deprecated in HAL 1.2 */
30    public static final int STATUS_SUSPENDED = 1;
31
32    /** Downlink radio link capacity in kbps */
33    public final int downlinkCapacityKbps;
34
35    /** Uplink radio link capacity; added in HAL 1.2 */
36    public final int uplinkCapacityKbps;
37
38    /** Confidence of the downlink estimate as a percentage [1, 100]; deprecated in HAL 1.2 */
39    public final int confidence;
40
41    /** Status of the LCE; deprecated in HAL 1.2 */
42    public final int status; // either STATUS_ACTIVE, STATUS_SUSPENDED, or INVALID
43
44    /** Constructor matching the estimate in Radio HAL v1.0 */
45    public LinkCapacityEstimate(int downlinkCapacityKbps, int confidence, int status) {
46        this.downlinkCapacityKbps = downlinkCapacityKbps;
47        this.confidence = confidence;
48        this.status = status;
49        this.uplinkCapacityKbps = INVALID;
50    }
51
52    /** Constructor matching the estimate in Radio HAL v1.2 */
53    public LinkCapacityEstimate(int downlinkCapacityKbps, int uplinkCapacityKbps) {
54        this.downlinkCapacityKbps = downlinkCapacityKbps;
55        this.uplinkCapacityKbps = uplinkCapacityKbps;
56        this.confidence = INVALID;
57        this.status = INVALID;
58    }
59
60    @Override
61    public String toString() {
62        return new StringBuilder()
63                .append("{downlinkCapacityKbps=")
64                .append(downlinkCapacityKbps)
65                .append(", uplinkCapacityKbps=")
66                .append(uplinkCapacityKbps)
67                .append(", confidence=")
68                .append(confidence)
69                .append(", status=")
70                .append(status)
71                .toString();
72    }
73}
74