Skip to content

Commit

Permalink
Build 178
Browse files Browse the repository at this point in the history
  - Fixed various crashes
  • Loading branch information
Hamza417 committed Nov 23, 2023
1 parent 9ad0013 commit f6e5ebc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
-keep class app.simple.positional.activities.alias.IconSevenAlias
-keep class app.simple.positional.activities.alias.IconEightAlias
-keep class app.simple.positional.activities.alias.IconNineAlias
-keep class app.simple.positional.activities.alias.IconTenAlias
-keep class app.simple.positional.activities.alias.IconElevenAlias
-keep class app.simple.positional.activities.alias.IconLegacyAlias
-keep class kotlin.KotlinNullPointerException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,31 @@ abstract class ClockWidgetService : Service(), OnSharedPreferenceChangeListener

broadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
Intent.ACTION_SCREEN_ON -> {
isScreenOn = true
postCallbacks()
widgetNotification()
Log.d("ClockWidgetService", "Screen is on")
}
try {
when (intent.action) {
Intent.ACTION_SCREEN_ON -> {
isScreenOn = true
postCallbacks()
widgetNotification()
Log.d("ClockWidgetService", "Screen is on")
}

Intent.ACTION_SCREEN_OFF -> {
isScreenOn = false
// Leave the service running in the foreground
// because Android 14 is killing the service when
// the screen is off
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Log.d("ClockWidgetService", "Screen is off, we're on Android 14+")
} else {
stopForeground(STOP_FOREGROUND_REMOVE)
Intent.ACTION_SCREEN_OFF -> {
isScreenOn = false
// Leave the service running in the foreground
// because Android 14 is killing the service when
// the screen is off
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Log.d("ClockWidgetService", "Screen is off, we're on Android 14+")
} else {
stopForeground(STOP_FOREGROUND_REMOVE)
}
removeCallbacks()
Log.d("ClockWidgetService", "Screen is off")
}
removeCallbacks()
Log.d("ClockWidgetService", "Screen is off")
}
} catch (e: NullPointerException) {
e.printStackTrace()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import android.location.Location
import android.location.LocationManager
import android.os.HandlerThread
import android.os.IBinder
import androidx.core.content.ContextCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import app.simple.positional.util.ConditionUtils.isNotNull
import app.simple.positional.util.PermissionUtils
import com.google.android.gms.location.*
import com.google.android.gms.location.FusedLocationProviderClient
import com.google.android.gms.location.LocationCallback
import com.google.android.gms.location.LocationRequest
import com.google.android.gms.location.LocationResult
import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority

/**
* Service class to use [FusedLocationProviderClient] as location
Expand Down Expand Up @@ -69,7 +75,7 @@ class FusedLocationService : Service() {
}
}

registerReceiver(broadcastReceiver, intentFilter)
ContextCompat.registerReceiver(applicationContext, broadcastReceiver, intentFilter, ContextCompat.RECEIVER_NOT_EXPORTED)
}

override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Expand Down

0 comments on commit f6e5ebc

Please sign in to comment.