Skip to content

Commit

Permalink
[Feature] Target Android 14.
Browse files Browse the repository at this point in the history
Add foreground service types and specify exported flag when register
receivers.
  • Loading branch information
zhanghai committed Sep 10, 2023
1 parent bf5e720 commit 9dbab7d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
minSdk 21
// Not supporting notification runtime permission yet.
//noinspection OldTargetApi
targetSdk 33
targetSdk 34
versionCode 33
versionName '1.6.1'
resValue 'string', 'app_version', versionName + ' (' + versionCode + ')'
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
Expand Down Expand Up @@ -314,9 +315,12 @@
</intent-filter>
</activity>

<service android:name="me.zhanghai.android.files.filejob.FileJobService" />
<service
android:name="me.zhanghai.android.files.filejob.FileJobService"
android:foregroundServiceType="dataSync" />

<service android:name="me.zhanghai.android.files.ftpserver.FtpServerService" />
<service android:name="me.zhanghai.android.files.ftpserver.FtpServerService"
android:foregroundServiceType="dataSync" />

<service
android:name="me.zhanghai.android.files.ftpserver.FtpServerTileService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.storage.StorageVolume
import androidx.core.content.ContextCompat
import androidx.lifecycle.LiveData
import me.zhanghai.android.files.app.application
import me.zhanghai.android.files.app.storageManager
import me.zhanghai.android.files.compat.registerReceiverCompat
import me.zhanghai.android.files.compat.storageVolumesCompat

object StorageVolumeListLiveData : LiveData<List<StorageVolume>>() {
init {
loadValue()
application.registerReceiver(
application.registerReceiverCompat(
object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
loadValue()
Expand All @@ -36,7 +38,7 @@ object StorageVolumeListLiveData : LiveData<List<StorageVolume>>() {
// The "file" data scheme is required to receive these broadcasts.
// @see https://stackoverflow.com/a/7143298
addDataScheme(ContentResolver.SCHEME_FILE)
}
}, ContextCompat.RECEIVER_NOT_EXPORTED
)
}

Expand Down

0 comments on commit 9dbab7d

Please sign in to comment.