Skip to content

Commit

Permalink
Use receiver exported for all sensor receiver intents (#4661)
Browse files Browse the repository at this point in the history
* Use reciever exported for all intents received outside the app

* Revert change to widget and complication

* Revert null receiver battery intents
  • Loading branch information
dshokouhi authored Sep 30, 2024
1 parent 77cc7dd commit f4c3e9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ open class HomeAssistantApplication : Application() {
addAction(Intent.ACTION_POWER_CONNECTED)
addAction(Intent.ACTION_POWER_DISCONNECTED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// This will cause interactive and power save to update upon a state change
Expand All @@ -106,7 +106,7 @@ open class HomeAssistantApplication : Application() {
addAction(Intent.ACTION_SCREEN_ON)
addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Update Quest only sensors when the device is a Quest
Expand All @@ -129,7 +129,7 @@ open class HomeAssistantApplication : Application() {
IntentFilter().apply {
addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -152,23 +152,23 @@ open class HomeAssistantApplication : Application() {
IntentFilter().apply {
addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen for bluetooth state changes
ContextCompat.registerReceiver(
this,
sensorReceiver,
IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen for NFC state changes
ContextCompat.registerReceiver(
this,
sensorReceiver,
IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen to changes to the audio input/output on the device
Expand All @@ -190,7 +190,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -200,7 +200,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(AudioManager.ACTION_SPEAKERPHONE_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -210,7 +210,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -226,7 +226,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(Intent.ACTION_SHUTDOWN),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Register for all saved user intents
Expand Down Expand Up @@ -259,7 +259,7 @@ open class HomeAssistantApplication : Application() {
addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE)
addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -270,7 +270,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(Intent.ACTION_TIME_TICK),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class NfcSetupActivity : BaseActivity() {
this,
nfcStateChangedReceiver,
IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ open class HomeAssistantApplication : Application() {
addAction(Intent.ACTION_POWER_CONNECTED)
addAction(Intent.ACTION_POWER_DISCONNECTED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// This will trigger an update any time the wifi state has changed
Expand All @@ -71,7 +71,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen to changes to the audio input/output on the device
Expand All @@ -93,7 +93,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(AudioManager.ACTION_MICROPHONE_MUTE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -103,7 +103,7 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(AudioManager.ACTION_SPEAKERPHONE_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)
}

Expand All @@ -116,7 +116,7 @@ open class HomeAssistantApplication : Application() {
addAction(Intent.ACTION_SCREEN_ON)
addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

ContextCompat.registerReceiver(
Expand All @@ -125,7 +125,7 @@ open class HomeAssistantApplication : Application() {
IntentFilter().apply {
addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED)
},
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen to changes to Wet Mode State
Expand All @@ -144,15 +144,15 @@ open class HomeAssistantApplication : Application() {
this,
sensorReceiver,
IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Listen for NFC state changes
ContextCompat.registerReceiver(
this,
sensorReceiver,
IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED),
ContextCompat.RECEIVER_NOT_EXPORTED
ContextCompat.RECEIVER_EXPORTED
)

// Update complications when the screen is on
Expand Down

0 comments on commit f4c3e9f

Please sign in to comment.