From 35152d3b3eda324ed451d8b35b4e716756c552fb Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Mon, 9 Apr 2018 16:33:15 -0700 Subject: Migrate Email to androidx. Bug: 76692459 Test: make Email, and manually started email from launcher on emulator Change-Id: I3ccef0b4aefaae2ebb874ca7d23ace4422447337 --- Android.mk | 18 +++++++++--------- emailcommon/Android.mk | 4 ++-- .../com/android/emailcommon/provider/MessageMove.java | 2 +- .../emailcommon/provider/MessageStateChange.java | 2 +- .../com/android/email/service/EmailServiceUtils.java | 2 +- res/layout-w600dp/account_setup_options_fragment.xml | 4 ++-- src/com/android/email/EmailNotificationController.java | 4 ++-- .../email/activity/setup/AccountSettingsFragment.java | 2 +- .../email/activity/setup/AccountSetupFinal.java | 2 +- .../email/activity/setup/EmailPreferenceActivity.java | 2 +- .../android/email/activity/setup/MailboxSettings.java | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Android.mk b/Android.mk index cfc205b89..78df40d53 100644 --- a/Android.mk +++ b/Android.mk @@ -45,17 +45,17 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \ libphotoviewer_appcompat \ android-opt-bitmap \ android-opt-datetimepicker \ - android-support-compat \ - android-support-media-compat \ - android-support-core-utils \ - android-support-core-ui \ - android-support-fragment \ - android-support-v7-appcompat \ - android-support-v7-gridlayout \ - android-support-v13 + androidx.core_core \ + androidx.media_media \ + androidx.legacy_legacy-support-core-utils \ + androidx.legacy_legacy-support-core-ui \ + androidx.fragment_fragment \ + androidx.appcompat_appcompat \ + androidx.gridlayout_gridlayout \ + androidx.legacy_legacy-support-v13 LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-annotations \ + androidx.annotation_annotation \ android-common \ guava \ owasp-html-sanitizer diff --git a/emailcommon/Android.mk b/emailcommon/Android.mk index fc47652ef..165f30222 100644 --- a/emailcommon/Android.mk +++ b/emailcommon/Android.mk @@ -34,12 +34,12 @@ LOCAL_MODULE := com.android.emailcommon LOCAL_STATIC_JAVA_LIBRARIES := \ guava \ android-common \ - android-support-annotations + androidx.annotation_annotation LOCAL_JAVA_LIBRARIES := \ org.apache.http.legacy -LOCAL_STATIC_ANDROID_LIBRARIES += android-support-compat +LOCAL_STATIC_ANDROID_LIBRARIES += androidx.core_core LOCAL_SRC_FILES := $(call all-java-files-under, src/com/android/emailcommon) LOCAL_SRC_FILES += \ diff --git a/emailcommon/src/com/android/emailcommon/provider/MessageMove.java b/emailcommon/src/com/android/emailcommon/provider/MessageMove.java index 9d0cae16a..2b6754472 100644 --- a/emailcommon/src/com/android/emailcommon/provider/MessageMove.java +++ b/emailcommon/src/com/android/emailcommon/provider/MessageMove.java @@ -5,7 +5,7 @@ import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.support.v4.util.LongSparseArray; +import androidx.collection.LongSparseArray; import com.android.mail.utils.LogUtils; diff --git a/emailcommon/src/com/android/emailcommon/provider/MessageStateChange.java b/emailcommon/src/com/android/emailcommon/provider/MessageStateChange.java index 78b84cc45..2feea0d2e 100644 --- a/emailcommon/src/com/android/emailcommon/provider/MessageStateChange.java +++ b/emailcommon/src/com/android/emailcommon/provider/MessageStateChange.java @@ -4,7 +4,7 @@ import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.support.v4.util.LongSparseArray; +import androidx.collection.LongSparseArray; import com.android.mail.utils.LogUtils; diff --git a/provider_src/com/android/email/service/EmailServiceUtils.java b/provider_src/com/android/email/service/EmailServiceUtils.java index 3532689c4..183c0cdd7 100644 --- a/provider_src/com/android/email/service/EmailServiceUtils.java +++ b/provider_src/com/android/email/service/EmailServiceUtils.java @@ -46,7 +46,7 @@ import android.provider.CalendarContract.SyncState; import android.provider.ContactsContract; import android.provider.ContactsContract.RawContacts; import android.provider.SyncStateContract; -import android.support.annotation.Nullable; +import androidx.annotation.Nullable; import android.text.TextUtils; import com.android.email.R; diff --git a/res/layout-w600dp/account_setup_options_fragment.xml b/res/layout-w600dp/account_setup_options_fragment.xml index e92b2eb8c..140d07808 100644 --- a/res/layout-w600dp/account_setup_options_fragment.xml +++ b/res/layout-w600dp/account_setup_options_fragment.xml @@ -24,7 +24,7 @@ android:orientation="vertical" > - @@ -56,7 +56,7 @@ app:layout_gravity="center_vertical|fill_horizontal" android:visibility="gone" /> - + Date: Thu, 13 Dec 2018 19:06:38 -0800 Subject: Migrate packages/apps/Email to androidx.test See go/jetpack-test-android-migration Test: make checkbuild Change-Id: Id4f25bf324a564afbaf9c726ea97fa33074d8660 --- tests/Android.mk | 2 +- tests/AndroidManifest.xml | 4 ++-- tests/src/com/android/email/DummyFlakyTest.java | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/Android.mk b/tests/Android.mk index 5598c2ef9..d5e9d9616 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -24,7 +24,7 @@ include $(CLEAR_VARS) # We only want this apk build for tests. LOCAL_MODULE_TAGS := tests -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test +LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules # For LOCAL_JAVA_LANGUAGE_VERSION >= 1.7, OpenJDK 9 javac generates synthetic calls to # Objects.requireNonNull() which was only added in Android API level 19. Thus, this must diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 8169f688c..b5e087c37 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -28,9 +28,9 @@ - diff --git a/tests/src/com/android/email/DummyFlakyTest.java b/tests/src/com/android/email/DummyFlakyTest.java index a7278b66a..99e37b4e9 100644 --- a/tests/src/com/android/email/DummyFlakyTest.java +++ b/tests/src/com/android/email/DummyFlakyTest.java @@ -16,7 +16,8 @@ package com.android.email; -import android.support.test.filters.FlakyTest; +import androidx.test.filters.FlakyTest; + import org.junit.Test; /** -- cgit v1.2.3 From e81f6f92bbdd43f34aa25fc2b7605aeb887af2cc Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 13 May 2019 13:29:40 -0700 Subject: AOSP/Email - bug fix: do not allow composing message with hidden private data attachments. Ported/merged thefollowing from CL https://critique.corp.google.com/#review/247540041 original file: java/com/google/android/apps/gmail/unifiedgmail/src/com/google/android/gm/ComposeActivityGmailExternal.java aosp's version: src/com/android/email/activity/ComposeActivityEmailExternal.java Change description from the above CL: "Switch intent filtering to be whitelist based rather than blacklist based. ComposeActivityGmailExternal should whitelist what extras we allow in. This is a very belated follow up to cl/235253805 where I wrote a quick fix as a blacklist based solution." Bug: 127320867 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 -rw-r--r-- 1 rtenneti primarygroup 6375626 May 5 19:49 out/target/product/marlin/system/product/app/Email/Email.apk $ make UnifiedEmailTests -j -rw-r--r-- 1 rtenneti primarygroup 311703 May 5 20:04 out/target/product/marlin/testcases/UnifiedEmailTests/arm64/UnifiedEmailTests.apk $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 365023 May 13 14:39 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r out/target/product/marlin/system/product/app/Email/Email.apk $ adb install -r out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r out/target/product/marlin/testcases/UnifiedEmailTests/arm64/UnifiedEmailTests.apk $ adb shell am instrument -w com.android.mail.emailtests Time: 3.519 OK (157 tests) Change-Id: I5f6541ceb79a1a1c598d0c8207e3cab98d1a8ac5 Merged-In: I5f6541ceb79a1a1c598d0c8207e3cab98d1a8ac5 --- .../activity/ComposeActivityEmailExternal.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/com/android/email/activity/ComposeActivityEmailExternal.java b/src/com/android/email/activity/ComposeActivityEmailExternal.java index 455193bea..a5cbe9d3a 100644 --- a/src/com/android/email/activity/ComposeActivityEmailExternal.java +++ b/src/com/android/email/activity/ComposeActivityEmailExternal.java @@ -16,11 +16,21 @@ package com.android.email.activity; +import android.content.Intent; +import android.os.Bundle; +import com.android.mail.compose.ComposeActivity; + /** * A subclass of {@link ComposeActivityEmail} which is exported for other Android packages to open. */ public class ComposeActivityEmailExternal extends ComposeActivityEmail { + @Override + protected void onCreate(Bundle savedInstanceState) { + sanitizeIntent(); + super.onCreate(savedInstanceState); + } + /** * Only relevant when WebView Compose is enabled. Change this when WebView * Compose is enabled for Email. @@ -29,4 +39,30 @@ public class ComposeActivityEmailExternal extends ComposeActivityEmail { public boolean isExternal() { return false; } + + /** + * Overrides the value of {@code #getIntent()} so any future callers will get a sanitized version + * of the intent. + */ + // See b/114493057 for context. + private void sanitizeIntent() { + Intent sanitizedIntent = getIntent(); + if (sanitizedIntent != null) { + Bundle originalExtras = sanitizedIntent.getExtras(); + sanitizedIntent.replaceExtras(new Bundle()); + copyStringExtraIfExists(ComposeActivity.EXTRA_SUBJECT, originalExtras, sanitizedIntent); + copyStringExtraIfExists(ComposeActivity.EXTRA_TO, originalExtras, sanitizedIntent); + copyStringExtraIfExists(ComposeActivity.EXTRA_CC, originalExtras, sanitizedIntent); + copyStringExtraIfExists(ComposeActivity.EXTRA_BCC, originalExtras, sanitizedIntent); + copyStringExtraIfExists(ComposeActivity.EXTRA_BODY, originalExtras, sanitizedIntent); + setIntent(sanitizedIntent); + } + } + + private void copyStringExtraIfExists( + String extraKey, Bundle originalExtras, Intent sanitizedIntent) { + if (originalExtras.containsKey(extraKey)) { + sanitizedIntent.putExtra(extraKey, originalExtras.getString(extraKey)); + } + } } -- cgit v1.2.3 From c504e21a118f30955ff0df81ead92313767bc0ab Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 25 Jun 2019 18:04:39 -0700 Subject: AOSP/Email - Create an empty Bundle if originalExtras doesn't exit. Backporting the fix to fix NullPointerException. + Added "originalExtras = new Bundle();" change from cl/247540041 Bug: 135889250 Bug: 127320867 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 -rw-r--r-- 1 rtenneti primarygroup 6371530 Jun 25 17:23 out/target/product/marlin/system/product/app/Email/Email.apk $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 365023 Jun 25 17:49 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r out/target/product/marlin/system/product/app/Email/Email.apk $ adb install -r out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 2.986 OK (157 tests) Change-Id: Ica9eb7ad3ddd11c752a526c2b1d5f086c74da283 Merged-In: Ica9eb7ad3ddd11c752a526c2b1d5f086c74da283 --- src/com/android/email/activity/ComposeActivityEmailExternal.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/email/activity/ComposeActivityEmailExternal.java b/src/com/android/email/activity/ComposeActivityEmailExternal.java index a5cbe9d3a..a94313a86 100644 --- a/src/com/android/email/activity/ComposeActivityEmailExternal.java +++ b/src/com/android/email/activity/ComposeActivityEmailExternal.java @@ -49,6 +49,9 @@ public class ComposeActivityEmailExternal extends ComposeActivityEmail { Intent sanitizedIntent = getIntent(); if (sanitizedIntent != null) { Bundle originalExtras = sanitizedIntent.getExtras(); + if (originalExtras == null) { + originalExtras = new Bundle(); + } sanitizedIntent.replaceExtras(new Bundle()); copyStringExtraIfExists(ComposeActivity.EXTRA_SUBJECT, originalExtras, sanitizedIntent); copyStringExtraIfExists(ComposeActivity.EXTRA_TO, originalExtras, sanitizedIntent); -- cgit v1.2.3 From 3150b66305bea67a83ce289c42c85efc669088d3 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 25 Jun 2019 18:04:39 -0700 Subject: AOSP/Email - Create an empty Bundle if originalExtras doesn't exit. Backporting the fix to fix NullPointerException. + Added "originalExtras = new Bundle();" change from cl/247540041 Bug: 135889250 Bug: 127320867 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 -rw-r--r-- 1 rtenneti primarygroup 6371530 Jun 25 17:23 out/target/product/marlin/system/product/app/Email/Email.apk $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 365023 Jun 25 17:49 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r out/target/product/marlin/system/product/app/Email/Email.apk $ adb install -r out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 2.986 OK (157 tests) Change-Id: Ica9eb7ad3ddd11c752a526c2b1d5f086c74da283 Merged-In: Ica9eb7ad3ddd11c752a526c2b1d5f086c74da283 --- src/com/android/email/activity/ComposeActivityEmailExternal.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/android/email/activity/ComposeActivityEmailExternal.java b/src/com/android/email/activity/ComposeActivityEmailExternal.java index a5cbe9d3a..a94313a86 100644 --- a/src/com/android/email/activity/ComposeActivityEmailExternal.java +++ b/src/com/android/email/activity/ComposeActivityEmailExternal.java @@ -49,6 +49,9 @@ public class ComposeActivityEmailExternal extends ComposeActivityEmail { Intent sanitizedIntent = getIntent(); if (sanitizedIntent != null) { Bundle originalExtras = sanitizedIntent.getExtras(); + if (originalExtras == null) { + originalExtras = new Bundle(); + } sanitizedIntent.replaceExtras(new Bundle()); copyStringExtraIfExists(ComposeActivity.EXTRA_SUBJECT, originalExtras, sanitizedIntent); copyStringExtraIfExists(ComposeActivity.EXTRA_TO, originalExtras, sanitizedIntent); -- cgit v1.2.3 From 0e52fa5ed409cec374f28545f6420edde6fcb8db Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 25 Jun 2019 21:44:07 +0000 Subject: Revert "AOSP/Email - Bump targetSdkVersion to 28." This reverts commit 62359082b83b870195f7899bd33d3d86d1830988. Reason for revert: No notification when new email arrived. Bug: 132923014 Cherry-picking https://android-review.googlesource.com/c/platform/packages/apps/Email/+/992814 Test: manual - Ran the following tests on Pixel phone. Tested the email UI for notifications. $ make -j 40 $ make EmailTests -j $ adb install -r out/target/product/marlin/system/product/app/Email/Email.apk $ adb install -r out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 2.986 OK (157 tests) Change-Id: I66beb67a7bb74bd272c65777adbcd1f8d0d12835 Merged-In: I66beb67a7bb74bd272c65777adbcd1f8d0d12835 --- AndroidManifest.xml | 1 - .../com/android/email/provider/EmailProvider.java | 12 +++--- .../android/email/service/AttachmentService.java | 50 +--------------------- res/values/strings.xml | 3 -- .../android/email/EmailNotificationController.java | 29 ------------- 5 files changed, 7 insertions(+), 88 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4fc82cb9d..9dd32c260 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -508,7 +508,6 @@ diff --git a/provider_src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java index 1f0956b2e..00d608f30 100644 --- a/provider_src/com/android/email/provider/EmailProvider.java +++ b/provider_src/com/android/email/provider/EmailProvider.java @@ -6357,7 +6357,7 @@ public class EmailProvider extends ContentProvider // Start/stop the various services depending on whether there are any accounts // TODO: Make sure that the AttachmentService responds to this request as it // expects a particular set of data in the intents that it receives or it ignores. - startOrStopService(enabled, context); + startOrStopService(enabled, context, new Intent(context, AttachmentService.class)); final NotificationController controller = NotificationControllerCreatorHolder.getInstance(context); @@ -6367,16 +6367,16 @@ public class EmailProvider extends ContentProvider } /** - * Starts or stops the attachment service as necessary. - * + * Starts or stops the service as necessary. * @param enabled If {@code true}, the service will be started. Otherwise, it will be stopped. * @param context The context to manage the service with. + * @param intent The intent of the service to be managed. */ - private static void startOrStopService(boolean enabled, Context context) { + private static void startOrStopService(boolean enabled, Context context, Intent intent) { if (enabled) { - AttachmentService.startWithoutSpecificAttachmentChange(context); + context.startService(intent); } else { - AttachmentService.stop(context); + context.stopService(intent); } } diff --git a/provider_src/com/android/email/service/AttachmentService.java b/provider_src/com/android/email/service/AttachmentService.java index 50ee42969..632104931 100644 --- a/provider_src/com/android/email/service/AttachmentService.java +++ b/provider_src/com/android/email/service/AttachmentService.java @@ -27,20 +27,15 @@ import android.content.Intent; import android.database.Cursor; import android.net.ConnectivityManager; import android.net.Uri; -import android.os.Build.VERSION_CODES; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.text.format.DateUtils; -import androidx.core.os.BuildCompat; - import com.android.email.AttachmentInfo; import com.android.email.EmailConnectivityManager; -import com.android.email.EmailNotificationController; import com.android.email.NotificationControllerCreatorHolder; import com.android.email.NotificationController; -import com.android.email.R; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.EmailContent.Attachment; @@ -126,10 +121,6 @@ public class AttachmentService extends Service implements Runnable { // Signify that we are being shut down & destroyed. private volatile boolean mStop = false; - // Indicates whether this service is currently running. Currently, only used for Android O+ to - // decide whether to call startForegroundService or startService in start method. - private static volatile boolean isRunning = false; - EmailConnectivityManager mConnectivityManager; // Helper class that keeps track of in progress downloads to make sure that they @@ -595,35 +586,7 @@ public class AttachmentService extends Service implements Runnable { debugTrace("Calling startService with extras %d & %d", id, flags); intent.putExtra(EXTRA_ATTACHMENT_ID, id); intent.putExtra(EXTRA_ATTACHMENT_FLAGS, flags); - start(context, intent); - } - - public static void startWithoutSpecificAttachmentChange(Context context) { - LogUtils.d(LOG_TAG, "Going to start AttachmentService without specifying an attachment."); - - Intent intent = new Intent(context, AttachmentService.class); - start(context, intent); - } - - /** - * Starts running attachment service. - * - * @param intent an intent set to run AttachmentService class - */ - public static void start(Context context, Intent intent) { - if (context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O && - !isRunning) { - LogUtils.i(LOG_TAG, "startForegroundService"); - context.startForegroundService(intent); - } else { - LogUtils.i(LOG_TAG, "startService"); - context.startService(intent); - } - } - - public static void stop(Context context) { - Intent intent = new Intent(context, AttachmentService.class); - context.stopService(intent); + context.startService(intent); } /** @@ -659,16 +622,6 @@ public class AttachmentService extends Service implements Runnable { */ @Override public void onCreate() { - isRunning = true; - if (getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O) { - LogUtils.i(LOG_TAG, "startForeground"); - startForeground( - EmailNotificationController.NOTIFICATION_ID_ONGOING_ATTACHMENT, - EmailNotificationController.getOngoingDownloadNotification( - getApplicationContext(), - getApplicationContext().getString( - R.string.notification_downloading_attachments_title))); - } // Start up our service thread. new Thread(this, "AttachmentService").start(); } @@ -696,7 +649,6 @@ public class AttachmentService extends Service implements Runnable { mConnectivityManager.stopWait(); mConnectivityManager = null; } - isRunning = false; } /** diff --git a/res/values/strings.xml b/res/values/strings.xml index dd1d5c158..2f39425a4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -110,9 +110,6 @@ Attachment not forwarded - - Syncing mail… - %s signin unsuccessful. diff --git a/src/com/android/email/EmailNotificationController.java b/src/com/android/email/EmailNotificationController.java index c9254adc4..6773f1bee 100644 --- a/src/com/android/email/EmailNotificationController.java +++ b/src/com/android/email/EmailNotificationController.java @@ -68,10 +68,6 @@ public class EmailNotificationController implements NotificationController { private static final int NOTIFICATION_ID_ATTACHMENT_WARNING = 3; private static final int NOTIFICATION_ID_PASSWORD_EXPIRING = 4; private static final int NOTIFICATION_ID_PASSWORD_EXPIRED = 5; - private static final int NOTIFICATION_ID_PERMISSIONS_NEEDED = 6; - public static final int NOTIFICATION_ID_ONGOING_ATTACHMENT = 7; - - public static final String NOTIFICATION_CHANNEL_ID_ATTACHMENTS = "^nc_~_z_attachments"; private static final int NOTIFICATION_ID_BASE_MASK = 0xF0000000; private static final int NOTIFICATION_ID_BASE_LOGIN_WARNING = 0x20000000; @@ -404,31 +400,6 @@ public class EmailNotificationController implements NotificationController { NOTIFICATION_ID_ATTACHMENT_WARNING); } - /** - * Creates a notification to be used with {@link com.android.email.service.AttachmentService}, - * which should be launched as a foreground service on Android O+. - * - *

The notification is sent with the lowest priority and contains an indefinite loading bar, - * hence "ongoing". - * - * @param title The text that will be displayed on the ongoing notification. - */ - public static Notification getOngoingDownloadNotification(Context context, String title) { - NotificationCompat.Builder builder = - new NotificationCompat.Builder(context) - .setContentTitle(title) - .setVisibility(Notification.VISIBILITY_SECRET) - .setProgress(0, 0, true) - .setSmallIcon(R.drawable.ic_notification_mail_24dp) - .setOngoing(true); - - if (context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.O) { - builder.setChannelId(NOTIFICATION_CHANNEL_ID_ATTACHMENTS); - } - - return builder.build(); - } - /** * Returns a notification ID for login failed notifications for the given account account. */ -- cgit v1.2.3 From 883f025edc30febb9e439fd1430758f5eab4cf2f Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 25 Jun 2019 21:44:53 +0000 Subject: Revert "AOSP/Email - Changes for code to work with UnifiedEmail's version bump to the targetSdkVersion to 28 (maximum version). Used JobIntentservice API calls to replace context.startService for EmailBroadcastProcessorService." This reverts commit 1189cb8b2b2e1cc1fae89112351e6a0b9a8f7c33. Reason for revert: No notification when new email arrived Bug: 132923014 Cherry picking: https://android-review.googlesource.com/c/platform/packages/apps/Email/+/991656 Test: manual - Ran the following tests on Pixel phone. Tested the email UI for notifications. $ make -j 40 $ make EmailTests -j $ adb install -r out/target/product/marlin/system/product/app/Email/Email.apk $ adb install -r out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 2.986 OK (157 tests) Change-Id: If97049cb5238a8a56caddb39827b177882c3c74d Merged-In: If97049cb5238a8a56caddb39827b177882c3c74d --- AndroidManifest.xml | 5 +---- .../com/android/email/EmailIntentService.java | 6 +++--- .../service/EmailBroadcastProcessorService.java | 23 ++++++++++------------ 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4fc82cb9d..8d6167609 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -486,9 +486,7 @@ + android:name=".service.EmailBroadcastProcessorService" /> diff --git a/provider_src/com/android/email/EmailIntentService.java b/provider_src/com/android/email/EmailIntentService.java index 5924c90ce..0c6d76178 100644 --- a/provider_src/com/android/email/EmailIntentService.java +++ b/provider_src/com/android/email/EmailIntentService.java @@ -29,12 +29,12 @@ public class EmailIntentService extends MailIntentService { private static final String LOG_TAG = LogTag.getLogTag(); public EmailIntentService() { - super(); + super("EmailIntentService"); } @Override - protected void onHandleWork(final Intent intent) { - super.onHandleWork(intent); + protected void onHandleIntent(final Intent intent) { + super.onHandleIntent(intent); if (UIProvider.ACTION_UPDATE_NOTIFICATION.equals(intent.getAction())) { final NotificationController nc = diff --git a/provider_src/com/android/email/service/EmailBroadcastProcessorService.java b/provider_src/com/android/email/service/EmailBroadcastProcessorService.java index 5d264f007..7aa54673e 100644 --- a/provider_src/com/android/email/service/EmailBroadcastProcessorService.java +++ b/provider_src/com/android/email/service/EmailBroadcastProcessorService.java @@ -17,6 +17,7 @@ package com.android.email.service; import android.accounts.AccountManager; +import android.app.IntentService; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; @@ -33,8 +34,6 @@ import android.provider.ContactsContract; import android.text.TextUtils; import android.text.format.DateUtils; -import androidx.core.app.JobIntentService; - import com.android.email.EmailIntentService; import com.android.email.Preferences; import com.android.email.R; @@ -70,9 +69,7 @@ import java.util.Set; * This also handles the DeviceAdminReceiver in SecurityPolicy, because it is also * a BroadcastReceiver and requires the same processing semantics. */ -public class EmailBroadcastProcessorService extends JobIntentService { - public static final int JOB_ID = 200; - +public class EmailBroadcastProcessorService extends IntentService { // Action used for BroadcastReceiver entry point private static final String ACTION_BROADCAST = "broadcast_receiver"; @@ -84,11 +81,11 @@ public class EmailBroadcastProcessorService extends JobIntentService { private static final String ACTION_UPGRADE_BROADCAST = "upgrade_broadcast_receiver"; public EmailBroadcastProcessorService() { - super(); - } + // Class name will be the thread name. + super(EmailBroadcastProcessorService.class.getName()); - public static void enqueueWork(Context context, Intent work) { - enqueueWork(context, EmailBroadcastProcessorService.class, JOB_ID, work); + // Intent should be redelivered if the process gets killed before completing the job. + setIntentRedelivery(true); } /** @@ -98,13 +95,13 @@ public class EmailBroadcastProcessorService extends JobIntentService { Intent i = new Intent(context, EmailBroadcastProcessorService.class); i.setAction(ACTION_BROADCAST); i.putExtra(Intent.EXTRA_INTENT, broadcastIntent); - EmailBroadcastProcessorService.enqueueWork(context, i); + context.startService(i); } public static void processUpgradeBroadcastIntent(final Context context) { final Intent i = new Intent(context, EmailBroadcastProcessorService.class); i.setAction(ACTION_UPGRADE_BROADCAST); - EmailBroadcastProcessorService.enqueueWork(context, i); + context.startService(i); } /** @@ -116,11 +113,11 @@ public class EmailBroadcastProcessorService extends JobIntentService { Intent i = new Intent(context, EmailBroadcastProcessorService.class); i.setAction(ACTION_DEVICE_POLICY_ADMIN); i.putExtra(EXTRA_DEVICE_POLICY_ADMIN, message); - EmailBroadcastProcessorService.enqueueWork(context, i); + context.startService(i); } @Override - protected void onHandleWork(Intent intent) { + protected void onHandleIntent(Intent intent) { // This method is called on a worker thread. // Dispatch from entry point -- cgit v1.2.3 From 37275ba2833057630de85bfa95c141ec55c6d304 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 16 Sep 2019 10:45:52 -0700 Subject: Deleted "" in "com.android.email.activity.ComposeActivityEmailExternal" activity of the AndroidManifest.xml as part of cleanup. Bug: 139259734 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 $ make Email -j $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 6356400 Sep 16 10:59 out/target/product/marlin/testcases/Email/arm64/Email.apk -rw-r--r-- 1 rtenneti primarygroup 389599 Sep 16 10:57 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r -d -g out/target/product/marlin/testcases/Email/arm64/Email.apk $ adb install -r -d -g out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 10.338 OK (157 tests) $ atest EmailTests Summary ------- EmailTests: Passed: 157, Failed: 0, Ignored: 0, Assumption Failed: 0 All tests passed! Change-Id: Iff7a42a3248a8b45cf128d2335624fc298c8888c --- AndroidManifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b4450fcc8..603ad0adb 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -116,15 +116,6 @@ - - - - - -- cgit v1.2.3 From 1c4b9bca1fbf1e791bd1c6aa567cde71fd9ef325 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 16 Sep 2019 15:22:08 -0700 Subject: AOSP/Email - Secure UPDATE_WIDGET receiver with a new permission The update methods sends a broadcast with the account name, the folder, etc. This implicitly bypasses the GET_ACCOUNT permission if a third-party applications listens to this broadcast. - Introduce a new app permission - com.android.email.permission.GET_WIDGET_UPDATE - Now the com.android.email.permission.GET_WIDGET_UPDATE is required to - receive the emitted broadcast - Add this permission to our existing widgets. Ported changes from cr/106302205 - added uses-permission GET_WIDGET_UPDATE, so Gmail app has the permission to receive the intent Bug: 139803872 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 $ make Email -j $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 6356400 Sep 16 14:10 out/target/product/marlin/testcases/Email/arm64/Email.apk -rw-r--r-- 1 rtenneti primarygroup 389599 Sep 16 14:18 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r -d -g out/target/product/marlin/testcases/Email/arm64/Email.apk $ adb install -r -d -g out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 34.746 OK (157 tests) $ atest EmailTests Summary ------- EmailTests: Passed: 157, Failed: 0, Ignored: 0, Assumption Failed: 0 All tests passed! $ adb install ../security_attack/bug_139803872/poc.apk Captured the logcat output at rtenneti's x20web logcat.out.0916.1503 while reproducting the steps in b/139803872#comment3 Change-Id: I6eea128c20b555b38d325e3706473bb18080bedd --- AndroidManifest.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b4450fcc8..8c58f9879 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -68,6 +68,14 @@ + + + Date: Wed, 18 Sep 2019 16:02:57 -0700 Subject: Deleted "" in "com.android.email.activity.ComposeActivityEmailExternal" activity of the AndroidManifest.xml as part of cleanup. Bug: 139259734 Test: manual - Ran the following tests on Pixel phone. Tested the email UI. $ make -j 40 $ make Email -j $ make EmailTests -j -rw-r--r-- 1 rtenneti primarygroup 6356400 Sep 18 15:32 out/target/product/marlin/testcases/Email/arm64/Email.apk -rw-r--r-- 1 rtenneti primarygroup 389599 Sep 18 15:32 out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb install -r -d -g out/target/product/marlin/testcases/Email/arm64/Email.apk $ adb install -r -d -g out/target/product/marlin/testcases/EmailTests/arm64/EmailTests.apk $ adb shell am instrument -w com.android.email.tests Time: 3.38 OK (157 tests) $ atest EmailTests com.android.email.tests (157 Tests) [1/157] com.android.email.DummyFlakyTest#imNotReallyFlaky: PASSED (2ms) ... [157/157] com.android.emailcommon.utility.UtilityTest#testParseEmailDateTime: PASSED (0ms) EmailTests: Passed: 157, Failed: 0, Ignored: 0, Assumption Failed: 0 All tests passed! Change-Id: Ia397eee0d9b966d7052dea5b9791ad6f351e9bb9 --- AndroidManifest.xml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index aee70c907..54235cf7e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -115,29 +115,10 @@ - - - - - - - - - - -- cgit v1.2.3