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

Commit c6dd53b3 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Allow null TransmitPowerRange ctor argument for ModemActivityInfo

There are existing usages in other Android code that pass null here,
causing a crash. Instead of fixing these other places (ctor is already
annotated as NonNull), let's just be graceful here as there is already
logic to handle empty input.

Bug: 143565652
Test: it builds
Change-Id: I86544bc47ff05f19a86e211fb1af87585ea68bd5
parent 153f66fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8246,7 +8246,7 @@ package android.telephony {
  }
  public final class ModemActivityInfo implements android.os.Parcelable {
    ctor public ModemActivityInfo(long, int, int, @NonNull int[], int);
    ctor public ModemActivityInfo(long, int, int, @Nullable int[], int);
    method public int describeContents();
    method public int getIdleTimeMillis();
    method public int getReceiveTimeMillis();
+10 −6
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.telephony;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -59,7 +60,7 @@ public final class ModemActivityInfo implements Parcelable {
    private int mRxTimeMs;

    public ModemActivityInfo(long timestamp, int sleepTimeMs, int idleTimeMs,
                        @NonNull int[] txTimeMs, int rxTimeMs) {
                        @Nullable int[] txTimeMs, int rxTimeMs) {
        mTimestamp = timestamp;
        mSleepTimeMs = sleepTimeMs;
        mIdleTimeMs = idleTimeMs;
@@ -68,10 +69,13 @@ public final class ModemActivityInfo implements Parcelable {
    }

    /** helper API to populate tx power range for each bucket **/
    private void populateTransmitPowerRange(@NonNull int[] transmitPowerMs) {
    private void populateTransmitPowerRange(@Nullable int[] transmitPowerMs) {
        int i = 0;
        if (transmitPowerMs != null) {
            for ( ; i < Math.min(transmitPowerMs.length, TX_POWER_LEVELS); i++) {
            mTransmitPowerInfo.add(i, new TransmitPower(TX_POWER_RANGES[i], transmitPowerMs[i]));
                mTransmitPowerInfo.add(i,
                        new TransmitPower(TX_POWER_RANGES[i], transmitPowerMs[i]));
            }
        }
        // Make sure that mTransmitPowerInfo is fully initialized.
        for ( ; i < TX_POWER_LEVELS; i++) {
@@ -94,7 +98,7 @@ public final class ModemActivityInfo implements Parcelable {
        return 0;
    }

    public static final @android.annotation.NonNull Parcelable.Creator<ModemActivityInfo> CREATOR =
    public static final @NonNull Parcelable.Creator<ModemActivityInfo> CREATOR =
            new Parcelable.Creator<ModemActivityInfo>() {
        public ModemActivityInfo createFromParcel(Parcel in) {
            long timestamp = in.readLong();
@@ -149,7 +153,7 @@ public final class ModemActivityInfo implements Parcelable {
    }

    /** @hide */
    public void setTransmitTimeMillis(int[] txTimeMs) {
    public void setTransmitTimeMillis(@Nullable int[] txTimeMs) {
        populateTransmitPowerRange(txTimeMs);
    }