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

Commit c584d277 authored by Eric Schwarzenbach's avatar Eric Schwarzenbach Committed by Gerrit Code Review
Browse files

Merge "Add PhysicalChannelConfig."

parents 1f568c14 5c6b3a35
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -251,6 +251,14 @@ public class PhoneStateListener {
     */
    public static final int LISTEN_USER_MOBILE_DATA_STATE                  = 0x00080000;

    /**
     *  Listen for changes to the physical channel configuration.
     *
     *  @see #onPhysicalChannelConfigurationChanged
     *  @hide
     */
    public static final int LISTEN_PHYSICAL_CHANNEL_CONFIGURATION          = 0x00100000;

    /*
     * Subscription used to listen to the phone state changes
     * @hide
@@ -362,7 +370,10 @@ public class PhoneStateListener {
                    case LISTEN_CARRIER_NETWORK_CHANGE:
                        PhoneStateListener.this.onCarrierNetworkChange((boolean)msg.obj);
                        break;

                    case LISTEN_PHYSICAL_CHANNEL_CONFIGURATION:
                        PhoneStateListener.this.onPhysicalChannelConfigurationChanged(
                            (List<PhysicalChannelConfig>)msg.obj);
                        break;
                }
            }
        };
@@ -560,6 +571,16 @@ public class PhoneStateListener {
        // default implementation empty
    }

    /**
     * Callback invoked when the current physical channel configuration has changed
     *
     * @param configs List of the current {@link PhysicalChannelConfig}s
     * @hide
     */
    public void onPhysicalChannelConfigurationChanged(List<PhysicalChannelConfig> configs) {
        // default implementation empty
    }

    /**
     * Callback invoked when telephony has received notice from a carrier
     * app that a network action that could result in connectivity loss
+20 −0
Original line number Diff line number Diff line
/*
**
** Copyright 2018, 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 android.telephony;

parcelable PhysicalChannelConfig;
 No newline at end of file
+127 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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 android.telephony;

import android.os.Parcel;
import android.os.Parcelable;
import android.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * @hide
 */
public final class PhysicalChannelConfig implements Parcelable {

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({CONNECTION_PRIMARY_SERVING, CONNECTION_SECONDARY_SERVING})
    public @interface ConnectionStatus {}

    /**
     * UE has connection to cell for signalling and possibly data (3GPP 36.331, 25.331).
     */
    public static final int CONNECTION_PRIMARY_SERVING = 1;

    /**
     * UE has connection to cell for data (3GPP 36.331, 25.331).
     */
    public static final int CONNECTION_SECONDARY_SERVING = 2;

    /**
     * Connection status of the cell.
     *
     * <p>One of {@link #CONNECTION_PRIMARY_SERVING}, {@link #CONNECTION_SECONDARY_SERVING}.
     */
    private int mCellConnectionStatus;

    /**
     * Cell bandwidth, in kHz.
     */
    private int mCellBandwidthDownlinkKhz;

    public PhysicalChannelConfig(int status, int bandwidth) {
        mCellConnectionStatus = status;
        mCellBandwidthDownlinkKhz = bandwidth;
    }

    public PhysicalChannelConfig(Parcel in) {
        mCellConnectionStatus = in.readInt();
        mCellBandwidthDownlinkKhz = in.readInt();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mCellConnectionStatus);
        dest.writeInt(mCellBandwidthDownlinkKhz);
    }

    /**
     * @return Cell bandwidth, in kHz
     */
    public int getCellBandwidthDownlink() {
        return mCellBandwidthDownlinkKhz;
    }

    /**
     * Gets the connection status of the cell.
     *
     * @see #CONNECTION_PRIMARY_SERVING
     * @see #CONNECTION_SECONDARY_SERVING
     *
     * @return Connection status of the cell
     */
    @ConnectionStatus
    public int getConnectionStatus() {
        return mCellConnectionStatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (!(o instanceof PhysicalChannelConfig)) {
            return false;
        }

        PhysicalChannelConfig config = (PhysicalChannelConfig) o;
        return mCellConnectionStatus == config.mCellConnectionStatus
                && mCellBandwidthDownlinkKhz == config.mCellBandwidthDownlinkKhz;
    }

    @Override
    public int hashCode() {
        return (mCellBandwidthDownlinkKhz * 29) + (mCellConnectionStatus * 31);
    }

    public static final Parcelable.Creator<PhysicalChannelConfig> CREATOR =
        new Parcelable.Creator<PhysicalChannelConfig>() {
            public PhysicalChannelConfig createFromParcel(Parcel in) {
                return new PhysicalChannelConfig(in);
            }

            public PhysicalChannelConfig[] newArray(int size) {
                return new PhysicalChannelConfig[size];
            }
        };
}