Skip to content

Commit

Permalink
Fingerprint V6: update stable fingerprint
Browse files Browse the repository at this point in the history
Based on the report
#115 and also on
our internal data, BatteryFullCapacitySignal could fluctuate occasionally on
some devices. Although this signal provided some additional uniqueness to the
stable fingerprint, the decision was made to move it to the "Optimal" stability
tier to prioritise stability.

Implementation note: current code organization does not allow to make such
changes easily, so I had to duplicate the original signal and assign it another
stability level.
  • Loading branch information
Sergey-Makarov committed Dec 9, 2024
1 parent be8ffa2 commit feb5011
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ val FingerprintingSignal<*>.humanName: String
is ApplicationsListSignal -> "Applications List"
is AvailableLocalesSignal -> "Available Locales"
is BatteryFullCapacitySignal -> "Battery Full Capacity"
is BatteryFullCapacityV2Signal -> "Battery Full Capacity V2"
is BatteryHealthSignal -> "Battery Health"
is CameraListSignal -> "Camera List"
is CodecListSignal -> "Codec List"
Expand Down Expand Up @@ -70,6 +71,7 @@ val FingerprintingSignal<*>.jsonifiableValue: Any
is ApplicationsListSignal -> this.value.map { it.packageName }
is AvailableLocalesSignal -> this.value
is BatteryFullCapacitySignal -> this.value
is BatteryFullCapacityV2Signal -> this.value
is BatteryHealthSignal -> this.value
is CameraListSignal -> this.value.map {
CameraListSignalItemVo(
Expand Down Expand Up @@ -154,6 +156,7 @@ val FingerprintingSignal<*>.humanValue: String
is ApplicationsListSignal -> valueAsSimpleListString { appendLine(it) }
is AvailableLocalesSignal -> valueAsSimpleListString { appendLine(it) }
is BatteryFullCapacitySignal -> valueAsSimpleString()
is BatteryFullCapacityV2Signal -> valueAsSimpleString()
is BatteryHealthSignal -> valueAsSimpleString()
is CameraListSignal -> valueAsSeparatedListString {
appendLine(it.cameraName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public class Fingerprinter internal constructor(
V_2(intValue = 2),
V_3(intValue = 3),
V_4(intValue = 4),
V_5(intValue = 5);
V_5(intValue = 5),
V_6(intValue = 6);

public companion object {
@get:Discouraged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,34 @@ public class BatteryFullCapacitySignal(
public companion object {
public val info: Info = Info(
addedInVersion = Fingerprinter.Version.V_2,
removedInVersion = null,
removedInVersion = Fingerprinter.Version.V_6,
stabilityLevel = StabilityLevel.STABLE,
)
}
}

/**
* Same as [BatteryFullCapacitySignal], but [StabilityLevel] is downgraded to [StabilityLevel.OPTIMAL]
*/
public class BatteryFullCapacityV2Signal(
override val value: String,
) : FingerprintingSignal<String>() {
override val info: Info
get() = Companion.info

override fun getHashableString(): String {
return value
}

public companion object {
public val info: Info = Info(
addedInVersion = Fingerprinter.Version.V_6,
removedInVersion = null,
stabilityLevel = StabilityLevel.OPTIMAL,
)
}
}

public class CameraListSignal(
override val value: List<CameraInfo>,
) : FingerprintingSignal<List<CameraInfo>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class FingerprintingSignalsProvider internal constructor(
InputDevicesV2Signal.info to { inputDevicesV2Signal },
BatteryHealthSignal.info to { batteryHealthSignal },
BatteryFullCapacitySignal.info to { batteryFullCapacitySignal },
BatteryFullCapacityV2Signal.info to { batteryFullCapacityV2Signal },
CameraListSignal.info to { cameraListSignal },
GlesVersionSignal.info to { glesVersionSignal },
AbiTypeSignal.info to { abiTypeSignal },
Expand Down Expand Up @@ -204,6 +205,11 @@ public class FingerprintingSignalsProvider internal constructor(
BatteryFullCapacitySignal(batteryInfoProvider.batteryTotalCapacity())
}

@get:WorkerThread
public val batteryFullCapacityV2Signal: BatteryFullCapacityV2Signal by lazy {
BatteryFullCapacityV2Signal(batteryInfoProvider.batteryTotalCapacity())
}

@get:WorkerThread
public val cameraListSignal: CameraListSignal by lazy {
CameraListSignal(cameraInfoProvider.getCameraInfo())
Expand Down

0 comments on commit feb5011

Please sign in to comment.