summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2019-08-03 02:09:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-08-03 02:09:48 +0000
commit516e349b34789a1668a801c21e3184c525aae0ef (patch)
tree4e162b1d4dfd51b3d85fcc3235b46a75b1a19a18
parentd6521bbe73087f848db430a6081ab8d8f74320cf (diff)
parent319278fe601ee4ff52772af121a33e045a8afba2 (diff)
downloadUnifiedEmail-516e349b34789a1668a801c21e3184c525aae0ef.tar.gz
Merge "Revert "Revert "AOSP/UnifiedEmail - Bumped the targetSdkVersion to 28 (maximum version). Used JobIntentservice API calls to replace context.startService."""
-rw-r--r--AndroidManifest.xml6
-rw-r--r--src/com/android/mail/MailIntentService.java15
-rw-r--r--src/com/android/mail/browse/EmlMessageLoader.java2
-rw-r--r--src/com/android/mail/browse/EmlTempFileDeletionService.java18
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();