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

Commit 5e3d677b authored by Matthew Sedam's avatar Matthew Sedam
Browse files

Add hashCode() methods to ContextHub classes

Bug: 340880058
Change-Id: I2b598630919b13ba64c190568fac381ee843efa9
Flag: android.chre.flags.fix_api_check
Test: Presubmits
parent ee9db8e9
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;

import java.util.Arrays;
import java.util.Objects;

/**
 * @hide
@@ -370,6 +371,20 @@ public class ContextHubInfo implements Parcelable {
        return isEqual;
    }

    @Override
    public int hashCode() {
        if (!Flags.fixApiCheck()) {
            return super.hashCode();
        }

        return Objects.hash(mId, mName, mVendor, mToolchain, mToolchainVersion,
                getStaticSwVersion(), mChrePlatformId, mPeakMips,
                mStoppedPowerDrawMw, mSleepPowerDrawMw, mPeakPowerDrawMw,
                mMaxPacketLengthBytes, mSupportsReliableMessages,
                Arrays.hashCode(mSupportedSensors),
                Arrays.hashCode(mMemoryRegions));
    }

    private ContextHubInfo(Parcel in) {
        mId = in.readInt();
        mName = in.readString();
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.chre.flags.Flags;
import android.content.Intent;

import java.util.Objects;
@@ -275,6 +276,16 @@ public class ContextHubIntentEvent {
        return isEqual;
    }

    @Override
    public int hashCode() {
        if (!Flags.fixApiCheck()) {
            return super.hashCode();
        }

        return Objects.hash(mEventType, mContextHubInfo, mNanoAppId,
                mNanoAppMessage, mNanoAppAbortCode, mClientAuthorizationState);
    }

    private static void hasExtraOrThrow(Intent intent, String extra) {
        if (!intent.hasExtra(extra)) {
            throw new IllegalArgumentException("Intent did not have extra: " + extra);
+13 −0
Original line number Diff line number Diff line
@@ -19,9 +19,12 @@ package android.hardware.location;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.chre.flags.Flags;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * @hide
 */
@@ -127,6 +130,16 @@ public class MemoryRegion implements Parcelable{
        return isEqual;
    }

    @Override
    public int hashCode() {
        if (!Flags.fixApiCheck()) {
            return super.hashCode();
        }

        return Objects.hash(mSizeBytes, mSizeBytesFree, mIsReadable,
                mIsWritable, mIsExecutable);
    }

    @Override
    public int describeContents() {
        return 0;
+12 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Parcelable;
import libcore.util.HexEncoding;

import java.util.Arrays;
import java.util.Objects;

/**
 * A class describing messages send to or from nanoapps through the Context Hub Service.
@@ -273,4 +274,15 @@ public final class NanoAppMessage implements Parcelable {

        return isEqual;
    }

    @Override
    public int hashCode() {
        if (!Flags.fixApiCheck()) {
            return super.hashCode();
        }

        return Objects.hash(mNanoAppId, mMessageType, mIsBroadcasted,
                Arrays.hashCode(mMessageBody), mIsReliable,
                mMessageSequenceNumber);
    }
}