mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	UploadWorker: add foreground service type
This commit is contained in:
		
							parent
							
								
									d9494abf24
								
							
						
					
					
						commit
						03b5b278fb
					
				
					 2 changed files with 18 additions and 4 deletions
				
			
		|  | @ -25,6 +25,7 @@ | ||||||
|   <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/> |   <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/> | ||||||
|   <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" |   <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" | ||||||
|     android:minSdkVersion="34"/> |     android:minSdkVersion="34"/> | ||||||
|  |   <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> | ||||||
| 
 | 
 | ||||||
|   <queries> |   <queries> | ||||||
|     <!-- Browser --> |     <!-- Browser --> | ||||||
|  | @ -201,6 +202,10 @@ | ||||||
|       android:name="org.acra.sender.SenderService" |       android:name="org.acra.sender.SenderService" | ||||||
|       android:exported="false" |       android:exported="false" | ||||||
|       android:process=":acra" /> |       android:process=":acra" /> | ||||||
|  |      | ||||||
|  |     <service | ||||||
|  |       android:name="androidx.work.impl.foreground.SystemForegroundService" | ||||||
|  |       android:foregroundServiceType="dataSync" /> | ||||||
| 
 | 
 | ||||||
|     <provider |     <provider | ||||||
|       android:name=".filepicker.ExtendedFileProvider" |       android:name=".filepicker.ExtendedFileProvider" | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import android.app.PendingIntent | ||||||
| import android.app.TaskStackBuilder | import android.app.TaskStackBuilder | ||||||
| import android.content.Context | import android.content.Context | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
|  | import android.content.pm.ServiceInfo | ||||||
| import android.graphics.BitmapFactory | import android.graphics.BitmapFactory | ||||||
| import android.os.Build | import android.os.Build | ||||||
| import androidx.core.app.NotificationCompat | import androidx.core.app.NotificationCompat | ||||||
|  | @ -271,10 +272,18 @@ class UploadWorker( | ||||||
|      * Create new notification for foreground service |      * Create new notification for foreground service | ||||||
|      */ |      */ | ||||||
|     private fun createForegroundInfo(): ForegroundInfo { |     private fun createForegroundInfo(): ForegroundInfo { | ||||||
|         return ForegroundInfo( |         return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { | ||||||
|             1, |             ForegroundInfo( | ||||||
|             createNotificationForForegroundService() |                 1, | ||||||
|         ) |                 createNotificationForForegroundService(), | ||||||
|  |                 ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC | ||||||
|  |             ) | ||||||
|  |         } else { | ||||||
|  |             ForegroundInfo( | ||||||
|  |                 1, | ||||||
|  |                 createNotificationForForegroundService() | ||||||
|  |             ) | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     override suspend fun getForegroundInfo(): ForegroundInfo { |     override suspend fun getForegroundInfo(): ForegroundInfo { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rohit Verma
						Rohit Verma