diff options
author | Raman Tenneti <rtenneti@google.com> | 2019-08-02 22:55:11 +0000 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2019-08-02 22:55:11 +0000 |
commit | 319278fe601ee4ff52772af121a33e045a8afba2 (patch) | |
tree | e3d5984aa159f1ae9c4abe767578a942c9430945 | |
parent | 20e45d84f9dc906034fb535ac35fb2a2ba9dc995 (diff) | |
download | UnifiedEmail-319278fe601ee4ff52772af121a33e045a8afba2.tar.gz |
Revert "Revert "AOSP/UnifiedEmail - Bumped the targetSdkVersion to 28 (maximum version). Used JobIntentservice API calls to replace context.startService.""
This reverts commit 20e45d84f9dc906034fb535ac35fb2a2ba9dc995.
Reason for revert: Email app needs to target API level 28+
Bug: 138276176
Bug: 119499886
Change-Id: I17abf17744dcd59948b40b1137c06e8e429e5adc
-rw-r--r-- | AndroidManifest.xml | 6 | ||||
-rw-r--r-- | src/com/android/mail/MailIntentService.java | 15 | ||||
-rw-r--r-- | src/com/android/mail/browse/EmlMessageLoader.java | 2 | ||||
-rw-r--r-- | src/com/android/mail/browse/EmlTempFileDeletionService.java | 18 |
4 files changed, 27 insertions, 14 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 721ba1b68..e34a4fc1d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -27,7 +27,7 @@ <uses-permission android:name="android.permission.NFC" /> <!-- This needs to be present when we are doing unbundled releases. --> - <uses-sdk android:targetSdkVersion="24" android:minSdkVersion="14" /> + <uses-sdk android:targetSdkVersion="28" android:minSdkVersion="14" /> <application android:icon="@mipmap/ic_launcher_mail" @@ -175,7 +175,9 @@ android:permission="android.permission.BIND_REMOTEVIEWS" android:exported="false" /> <service android:name=".MailLogService"/> - <service android:name=".browse.EmlTempFileDeletionService" /> + <service android:name=".browse.EmlTempFileDeletionService" + android:permission="android.permission.BIND_JOB_SERVICE" + android:exported="true" /> </application> diff --git a/src/com/android/mail/MailIntentService.java b/src/com/android/mail/MailIntentService.java index 8151dfc28..db7b99b04 100644 --- a/src/com/android/mail/MailIntentService.java +++ b/src/com/android/mail/MailIntentService.java @@ -15,11 +15,12 @@ */ package com.android.mail; -import android.app.IntentService; import android.content.Context; import android.content.Intent; import android.net.Uri; +import androidx.core.app.JobIntentService; + import com.android.mail.analytics.Analytics; import com.android.mail.photo.ContactFetcher; import com.android.mail.providers.Account; @@ -34,7 +35,7 @@ import com.android.mail.utils.Utils; /** * A service to handle various intents asynchronously. */ -public class MailIntentService extends IntentService { +public class MailIntentService extends JobIntentService { private static final String LOG_TAG = LogTag.getLogTag(); public static final String ACTION_RESEND_NOTIFICATIONS = @@ -56,16 +57,18 @@ public class MailIntentService extends IntentService { public static final String CONVERSATION_EXTRA = "conversation"; + public static final int JOB_ID = 100; + public MailIntentService() { - super("MailIntentService"); + super(); } - protected MailIntentService(final String name) { - super(name); + public static void enqueueWork(Context context, Intent work) { + enqueueWork(context, MailIntentService.class, JOB_ID, work); } @Override - protected void onHandleIntent(final Intent intent) { + protected void onHandleWork(final Intent intent) { // UnifiedEmail does not handle all Intents LogUtils.v(LOG_TAG, "Handling intent %s", intent); diff --git a/src/com/android/mail/browse/EmlMessageLoader.java b/src/com/android/mail/browse/EmlMessageLoader.java index 82fa98f81..acf7716e4 100644 --- a/src/com/android/mail/browse/EmlMessageLoader.java +++ b/src/com/android/mail/browse/EmlMessageLoader.java @@ -105,7 +105,7 @@ public class EmlMessageLoader extends MailAsyncTaskLoader<ConversationMessage> { intent.setClass(getContext(), EmlTempFileDeletionService.class); intent.setData(message.attachmentListUri); - getContext().startService(intent); + EmlTempFileDeletionService.enqueueWork(getContext(), intent); } } } diff --git a/src/com/android/mail/browse/EmlTempFileDeletionService.java b/src/com/android/mail/browse/EmlTempFileDeletionService.java index 71a915c51..8a772c3aa 100644 --- a/src/com/android/mail/browse/EmlTempFileDeletionService.java +++ b/src/com/android/mail/browse/EmlTempFileDeletionService.java @@ -17,25 +17,33 @@ package com.android.mail.browse; -import android.app.IntentService; +import android.content.Context; import android.content.Intent; import android.net.Uri; +import androidx.core.app.JobIntentService; + /** * {@link IntentService} that cleans up temporary files in the cache for the eml viewer. */ -public class EmlTempFileDeletionService extends IntentService { +public class EmlTempFileDeletionService extends JobIntentService { + + public static final int JOB_ID = 101; public EmlTempFileDeletionService() { - super("EmlTempFileDeletionService"); + super(); } public EmlTempFileDeletionService(String name) { - super(name); + super(); + } + + public static void enqueueWork(Context context, Intent work) { + enqueueWork(context, EmlTempFileDeletionService.class, JOB_ID, work); } @Override - protected void onHandleIntent(Intent intent) { + protected void onHandleWork(Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_DELETE.equals(action)) { final Uri uri = intent.getData(); |