Specify exported status and PendingIntent mutability.

Also reduce shake sampling frequency, add coarse location permission.
Random things for targetSdk 32.
This commit is contained in:
Nicholas Tinsley
2022-09-20 10:13:58 -04:00
committed by Cody Henthorne
parent 2566d6f61f
commit b9f4dc3fe9
38 changed files with 126 additions and 63 deletions

View File

@@ -13,18 +13,31 @@ import android.os.Build
*/
object PendingIntentFlags {
@JvmStatic
fun updateCurrent(): Int {
return mutable() or PendingIntent.FLAG_UPDATE_CURRENT
}
@JvmStatic
fun cancelCurrent(): Int {
return mutable() or PendingIntent.FLAG_CANCEL_CURRENT
}
@JvmStatic
fun oneShot(): Int {
return mutable() or PendingIntent.FLAG_ONE_SHOT
}
/**
* The backwards compatible "default" value for pending intent flags.
*/
@JvmStatic
fun mutable(): Int {
return if (Build.VERSION.SDK_INT >= 31) PendingIntent.FLAG_MUTABLE else 0
}
@JvmStatic
fun immutable(): Int {
return if (Build.VERSION.SDK_INT >= 23) PendingIntent.FLAG_IMMUTABLE else 0
}
}

View File

@@ -50,7 +50,7 @@ public class ShakeDetector implements SensorEventListener {
if (accelerometer != null) {
this.sensorManager = sensorManager;
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_FASTEST);
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
return accelerometer != null;