Skip to content
Snippets Groups Projects
Commit 86992fe5 authored by Matt Walliser's avatar Matt Walliser
Browse files

Move IsBatteryCharging from extras bundle to API.

Bug: 273947205
Test: atest -c android.net.wifi.sharedconnectivity.cts
Change-Id: I1d6e50e07eeca9d3b681b6a359355d23e90d93b0
parent 42a82a15
No related branches found
No related tags found
No related merge requests found
......@@ -10112,6 +10112,7 @@ package android.net.wifi.sharedconnectivity.app {
method public int getDeviceType();
method @NonNull public android.os.Bundle getExtras();
method @NonNull public String getModelName();
method public boolean isBatteryCharging();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.sharedconnectivity.app.NetworkProviderInfo> CREATOR;
field public static final int DEVICE_TYPE_AUTO = 5; // 0x5
......@@ -10125,6 +10126,7 @@ package android.net.wifi.sharedconnectivity.app {
public static final class NetworkProviderInfo.Builder {
ctor public NetworkProviderInfo.Builder(@NonNull String, @NonNull String);
method @NonNull public android.net.wifi.sharedconnectivity.app.NetworkProviderInfo build();
method @NonNull public android.net.wifi.sharedconnectivity.app.NetworkProviderInfo.Builder setBatteryCharging(boolean);
method @NonNull public android.net.wifi.sharedconnectivity.app.NetworkProviderInfo.Builder setBatteryPercentage(@IntRange(from=0, to=100) int);
method @NonNull public android.net.wifi.sharedconnectivity.app.NetworkProviderInfo.Builder setConnectionStrength(@IntRange(from=0, to=4) int);
method @NonNull public android.net.wifi.sharedconnectivity.app.NetworkProviderInfo.Builder setDeviceName(@NonNull String);
......@@ -84,17 +84,12 @@ public final class NetworkProviderInfo implements Parcelable {
public @interface DeviceType {
}
/**
* Key in extras bundle indicating that the device battery is charging.
* @hide
*/
public static final String EXTRA_KEY_IS_BATTERY_CHARGING = "is_battery_charging";
@DeviceType
private final int mDeviceType;
private final String mDeviceName;
private final String mModelName;
private final int mBatteryPercentage;
private final boolean mIsBatteryCharging;
private final int mConnectionStrength;
private final Bundle mExtras;
......@@ -106,6 +101,7 @@ public final class NetworkProviderInfo implements Parcelable {
private String mDeviceName;
private String mModelName;
private int mBatteryPercentage;
private boolean mIsBatteryCharging;
private int mConnectionStrength;
private Bundle mExtras = Bundle.EMPTY;
......@@ -166,6 +162,18 @@ public final class NetworkProviderInfo implements Parcelable {
return this;
}
/**
* Sets if the battery of the remote device is charging.
*
* @param isBatteryCharging True if battery is charging.
* @return Returns the Builder object.
*/
@NonNull
public Builder setBatteryCharging(boolean isBatteryCharging) {
mIsBatteryCharging = isBatteryCharging;
return this;
}
/**
* Sets the displayed connection strength of the remote device to the internet.
*
......@@ -197,7 +205,7 @@ public final class NetworkProviderInfo implements Parcelable {
@NonNull
public NetworkProviderInfo build() {
return new NetworkProviderInfo(mDeviceType, mDeviceName, mModelName, mBatteryPercentage,
mConnectionStrength, mExtras);
mIsBatteryCharging, mConnectionStrength, mExtras);
}
}
......@@ -217,13 +225,14 @@ public final class NetworkProviderInfo implements Parcelable {
}
private NetworkProviderInfo(@DeviceType int deviceType, @NonNull String deviceName,
@NonNull String modelName, int batteryPercentage, int connectionStrength,
@NonNull Bundle extras) {
@NonNull String modelName, int batteryPercentage, boolean isBatteryCharging,
int connectionStrength, @NonNull Bundle extras) {
validate(deviceType, deviceName, modelName, batteryPercentage, connectionStrength);
mDeviceType = deviceType;
mDeviceName = deviceName;
mModelName = modelName;
mBatteryPercentage = batteryPercentage;
mIsBatteryCharging = isBatteryCharging;
mConnectionStrength = connectionStrength;
mExtras = extras;
}
......@@ -268,6 +277,15 @@ public final class NetworkProviderInfo implements Parcelable {
return mBatteryPercentage;
}
/**
* Gets the charging state of the battery on the remote device.
*
* @return Returns true if the battery of the remote device is charging.
*/
public boolean isBatteryCharging() {
return mIsBatteryCharging;
}
/**
* Gets the displayed connection strength of the remote device to the internet.
*
......@@ -296,13 +314,14 @@ public final class NetworkProviderInfo implements Parcelable {
&& Objects.equals(mDeviceName, other.mDeviceName)
&& Objects.equals(mModelName, other.mModelName)
&& mBatteryPercentage == other.mBatteryPercentage
&& mIsBatteryCharging == other.mIsBatteryCharging
&& mConnectionStrength == other.mConnectionStrength;
}
@Override
public int hashCode() {
return Objects.hash(mDeviceType, mDeviceName, mModelName, mBatteryPercentage,
mConnectionStrength);
mIsBatteryCharging, mConnectionStrength);
}
@Override
......@@ -311,6 +330,7 @@ public final class NetworkProviderInfo implements Parcelable {
dest.writeString(mDeviceName);
dest.writeString(mModelName);
dest.writeInt(mBatteryPercentage);
dest.writeBoolean(mIsBatteryCharging);
dest.writeInt(mConnectionStrength);
dest.writeBundle(mExtras);
}
......@@ -328,7 +348,7 @@ public final class NetworkProviderInfo implements Parcelable {
@NonNull
public static NetworkProviderInfo readFromParcel(@NonNull Parcel in) {
return new NetworkProviderInfo(in.readInt(), in.readString(), in.readString(), in.readInt(),
in.readInt(), in.readBundle());
in.readBoolean(), in.readInt(), in.readBundle());
}
@NonNull
......@@ -351,6 +371,7 @@ public final class NetworkProviderInfo implements Parcelable {
.append(", deviceName=").append(mDeviceName)
.append(", modelName=").append(mModelName)
.append(", batteryPercentage=").append(mBatteryPercentage)
.append(", isBatteryCharging=").append(mIsBatteryCharging)
.append(", connectionStrength=").append(mConnectionStrength)
.append(", extras=").append(mExtras.toString())
.append("]").toString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment