Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ concurrency:
env:
# The version of Flutter to use should use the minimum Dart SDK version supported by the package.
# Current minimum (N-1 logic)
FLUTTER_VERSION_MINIMUM_DEFAULT: "3.41.9"
FLUTTER_VERSION_MINIMUM_DEFAULT: "3.44.7"
# Latest 3.x stable
FLUTTER_VERSION_LATEST_STABLE_CHANNEL_DEFAULT: "3.x"
# Beta channel support
Expand Down
5 changes: 4 additions & 1 deletion wakelock_plus/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ pubspec.lock
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/example/ios/Podfile
!/example/ios/Podfile

# AI Agent exclusions
.artifacts
6 changes: 6 additions & 0 deletions wakelock_plus/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ analyzer:
- "build/**" # Exclude generated files in the build directory
- ".dart_tool/**" # Exclude Dart tool-generated files
- "pigeons/**" # Exclude pigeons
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**

linter:
rules:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Autogenerated from Pigeon (v26.2.3), do not edit directly.
// Autogenerated from Pigeon (v28.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")

package dev.fluttercommunity.plus.wakelock


import android.util.Log
import io.flutter.plugin.common.BasicMessageChannel
import io.flutter.plugin.common.BinaryMessenger
Expand Down Expand Up @@ -35,36 +34,150 @@ private object WakelockPlusMessagesPigeonUtils {
)
}
}
fun doubleEquals(a: Double, b: Double): Boolean {
// Normalize -0.0 to 0.0 and handle NaN equality.
return (if (a == 0.0) 0.0 else a) == (if (b == 0.0) 0.0 else b) || (a.isNaN() && b.isNaN())
}

fun floatEquals(a: Float, b: Float): Boolean {
// Normalize -0.0 to 0.0 and handle NaN equality.
return (if (a == 0.0f) 0.0f else a) == (if (b == 0.0f) 0.0f else b) || (a.isNaN() && b.isNaN())
}

fun doubleHash(d: Double): Int {
// Normalize -0.0 to 0.0 and handle NaN to ensure consistent hash codes.
val normalized = if (d == 0.0) 0.0 else d
val bits = java.lang.Double.doubleToLongBits(normalized)
return (bits xor (bits ushr 32)).toInt()
}

fun floatHash(f: Float): Int {
// Normalize -0.0 to 0.0 and handle NaN to ensure consistent hash codes.
val normalized = if (f == 0.0f) 0.0f else f
return java.lang.Float.floatToIntBits(normalized)
}

fun deepEquals(a: Any?, b: Any?): Boolean {
if (a === b) {
return true
}
if (a == null || b == null) {
return false
}
if (a is ByteArray && b is ByteArray) {
return a.contentEquals(b)
return a.contentEquals(b)
}
if (a is IntArray && b is IntArray) {
return a.contentEquals(b)
return a.contentEquals(b)
}
if (a is LongArray && b is LongArray) {
return a.contentEquals(b)
return a.contentEquals(b)
}
if (a is DoubleArray && b is DoubleArray) {
return a.contentEquals(b)
if (a.size != b.size) return false
for (i in a.indices) {
if (!doubleEquals(a[i], b[i])) return false
}
return true
}
if (a is FloatArray && b is FloatArray) {
if (a.size != b.size) return false
for (i in a.indices) {
if (!floatEquals(a[i], b[i])) return false
}
return true
}
if (a is Array<*> && b is Array<*>) {
return a.size == b.size &&
a.indices.all{ deepEquals(a[it], b[it]) }
if (a.size != b.size) return false
for (i in a.indices) {
if (!deepEquals(a[i], b[i])) return false
}
return true
}
if (a is List<*> && b is List<*>) {
return a.size == b.size &&
a.indices.all{ deepEquals(a[it], b[it]) }
if (a.size != b.size) return false
val iterA = a.iterator()
val iterB = b.iterator()
while (iterA.hasNext() && iterB.hasNext()) {
if (!deepEquals(iterA.next(), iterB.next())) return false
}
return true
}
if (a is Map<*, *> && b is Map<*, *>) {
return a.size == b.size && a.all {
(b as Map<Any?, Any?>).contains(it.key) &&
deepEquals(it.value, b[it.key])
if (a.size != b.size) return false
for (entry in a) {
val key = entry.key
var found = false
for (bEntry in b) {
if (deepEquals(key, bEntry.key)) {
if (deepEquals(entry.value, bEntry.value)) {
found = true
break
} else {
return false
}
}
}
if (!found) return false
}
return true
}
if (a is Double && b is Double) {
return doubleEquals(a, b)
}
if (a is Float && b is Float) {
return floatEquals(a, b)
}
return a == b
}


fun deepHash(value: Any?): Int {
return when (value) {
null -> 0
is ByteArray -> value.contentHashCode()
is IntArray -> value.contentHashCode()
is LongArray -> value.contentHashCode()
is DoubleArray -> {
var result = 1
for (item in value) {
result = 31 * result + doubleHash(item)
}
result
}
is FloatArray -> {
var result = 1
for (item in value) {
result = 31 * result + floatHash(item)
}
result
}
is Array<*> -> {
var result = 1
for (item in value) {
result = 31 * result + deepHash(item)
}
result
}
is List<*> -> {
var result = 1
for (item in value) {
result = 31 * result + deepHash(item)
}
result
}
is Map<*, *> -> {
var result = 0
for (entry in value) {
result += ((deepHash(entry.key) * 31) xor deepHash(entry.value))
}
result
}
is Double -> doubleHash(value)
is Float -> floatHash(value)
else -> value.hashCode()
}
}

}

/**
Expand All @@ -77,7 +190,7 @@ class WakelockPlusFlutterError (
val code: String,
override val message: String? = null,
val details: Any? = null
) : Throwable()
) : RuntimeException()

/**
* Message for toggling the wakelock on the platform side.
Expand All @@ -100,15 +213,24 @@ data class ToggleMessage (
)
}
override fun equals(other: Any?): Boolean {
if (other !is ToggleMessage) {
if (other == null || other.javaClass != javaClass) {
return false
}
if (this === other) {
return true
}
return WakelockPlusMessagesPigeonUtils.deepEquals(toList(), other.toList()) }
val other = other as ToggleMessage
return WakelockPlusMessagesPigeonUtils.deepEquals(this.enable, other.enable)
}

override fun hashCode(): Int = toList().hashCode()
override fun hashCode(): Int {
var result = javaClass.hashCode()
result = 31 * result + WakelockPlusMessagesPigeonUtils.deepHash(this.enable)
return result
}
override fun toString(): String {
return "ToggleMessage(enable=$enable)"
}
}

/**
Expand All @@ -132,15 +254,24 @@ data class IsEnabledMessage (
)
}
override fun equals(other: Any?): Boolean {
if (other !is IsEnabledMessage) {
if (other == null || other.javaClass != javaClass) {
return false
}
if (this === other) {
return true
}
return WakelockPlusMessagesPigeonUtils.deepEquals(toList(), other.toList()) }
val other = other as IsEnabledMessage
return WakelockPlusMessagesPigeonUtils.deepEquals(this.enabled, other.enabled)
}

override fun hashCode(): Int = toList().hashCode()
override fun hashCode(): Int {
var result = javaClass.hashCode()
result = 31 * result + WakelockPlusMessagesPigeonUtils.deepHash(this.enabled)
return result
}
override fun toString(): String {
return "IsEnabledMessage(enabled=$enabled)"
}
}
private open class WakelockPlusMessagesPigeonCodec : StandardMessageCodec() {
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.fluttercommunity.plus.wakelock

import ToggleMessage
import android.app.Activity
import android.os.Build
import android.view.WindowManager
Expand Down
7 changes: 7 additions & 0 deletions wakelock_plus/example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ analyzer:
- '**.g.dart'
- '**.gr.dart'
- '**/generated_plugin_registrant.dart'
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**

linter:
# The lint rules applied to this project can be customized in the
Expand Down
4 changes: 2 additions & 2 deletions wakelock_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description: Demonstrates how to use the wakelock_plus plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

environment:
sdk: '>=3.10.0 <4.0.0'
flutter: ">=3.38.0"
sdk: '>=3.12.0 <4.0.0'
flutter: ">=3.44.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
15 changes: 12 additions & 3 deletions wakelock_plus/ios/wakelock_plus.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ Plugin that allows you to keep the device screen awake, i.e. prevent the screen
s.source_files = 'wakelock_plus/Sources/wakelock_plus/**/*.{h,m}'
s.public_header_files = 'wakelock_plus/Sources/wakelock_plus/include/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '13.0'
s.ios.deployment_target = '13.0'
s.tvos.deployment_target = '13.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.resource_bundles = {'wakelock_plus_privacy' => ['wakelock_plus/Sources/wakelock_plus/Resources/PrivacyInfo.xcprivacy']}
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
'EXCLUDED_ARCHS[sdk=appletvsimulator*]' => 'i386'
}
s.resource_bundles = {
'wakelock_plus_privacy' => [
'wakelock_plus/Sources/wakelock_plus/Resources/PrivacyInfo.xcprivacy'
]
}
end
3 changes: 2 additions & 1 deletion wakelock_plus/ios/wakelock_plus/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import PackageDescription
let package = Package(
name: "wakelock_plus",
platforms: [
.iOS("13.0")
.iOS("13.0"),
.tvOS("13.0")
],
products: [
.library(name: "wakelock-plus", targets: ["wakelock_plus"])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v26.2.3), do not edit directly.
// Autogenerated from Pigeon (v28.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

@import Foundation;
Expand Down
Loading
Loading