diff options
author | Felipe Leme <felipeal@google.com> | 2018-01-22 15:33:40 -0800 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-03-22 20:42:03 +0000 |
commit | ee65a393854cdfcfec54333c6a06bc6c3429b3fc (patch) | |
tree | c33e7c4df08e787eac392bed8b37be82c6c56363 | |
parent | 173d37569997fdf7eaf7b05912c760352e724893 (diff) | |
download | base-ee65a393854cdfcfec54333c6a06bc6c3429b3fc.tar.gz |
DO NOT MERGE - fix AFM.getComponentNameFromContext()
This method broke on O-MR1 when I3abf999eb6056c1df7982780bae43b58337c0668
was chery-picked from master.
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases \
-t android.autofillservice.cts.AttachedContextActivityTest#testAutofill
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases
Also individually ran tests that failed (due to flakiness) when ran in a suite:
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases \
-t android.autofillservice.cts.OptionalSaveActivityTest#testDontShowSaveUiWhenUserManuallyFilled_oneDatasetAllRequiredFields
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases -t android.autofillservice.cts.PreSimpleSaveActivityTest #testTapLink_tapBack_thenStartOverBySayingYesAndManualRequest
Fixes: 71960322
Change-Id: Ia093dcefe6699dc9493c46d671e48c2000214b31
Merged-In: I3abf999eb6056c1df7982780bae43b58337c0668
(cherry picked from commit b25b4736db2ea05dce6b9f03e8a9920ab338dd5a)
-rw-r--r-- | core/java/android/app/Activity.java | 10 | ||||
-rw-r--r-- | core/java/android/view/autofill/AutofillManager.java | 23 |
2 files changed, 23 insertions, 10 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 2c04f8ff9548..8dc558ccf755 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5872,6 +5872,16 @@ public class Activity extends ContextThemeWrapper } /** + * Temporary method on O-MR1 only. + * + * @hide + */ + @Override + public ComponentName getComponentNameForAutofill() { + return mComponent; + } + + /** * Retrieve a {@link SharedPreferences} object for accessing preferences * that are private to this activity. This simply calls the underlying * {@link #getSharedPreferences(String, int)} method by passing in this activity's diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index ba738b6dfcea..fb9534b2e52e 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -24,7 +24,6 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemService; -import android.app.Activity; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -387,6 +386,13 @@ public final class AutofillManager { * Runs the specified action on the UI thread. */ void runOnUiThread(Runnable action); + + /** + * Gets the complete component name of this client. + * + * <p>Temporary method on O-MR1 only. + */ + ComponentName getComponentNameForAutofill(); } /** @@ -943,11 +949,8 @@ public final class AutofillManager { return mContext.getAutofillClient(); } - private ComponentName getComponentNameFromContext() { - if (mContext instanceof Activity) { - return ((Activity) mContext).getComponentName(); - } - return null; + private ComponentName getComponentNameFromContext(AutofillClient client) { + return client == null ? null : client.getComponentNameForAutofill(); } /** @hide */ @@ -1000,7 +1003,8 @@ public final class AutofillManager { return; } try { - final ComponentName componentName = getComponentNameFromContext(); + final AutofillClient client = getClientLocked(); + final ComponentName componentName = getComponentNameFromContext(client); if (componentName == null) { Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext); return; @@ -1011,7 +1015,6 @@ public final class AutofillManager { if (mSessionId != NO_SESSION) { mState = STATE_ACTIVE; } - final AutofillClient client = getClientLocked(); if (client != null) { client.autofillCallbackResetableStateAvailable(); } @@ -1065,7 +1068,8 @@ public final class AutofillManager { try { if (restartIfNecessary) { - final ComponentName componentName = getComponentNameFromContext(); + final AutofillClient client = getClientLocked(); + final ComponentName componentName = getComponentNameFromContext(client); if (componentName == null) { Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext); return; @@ -1077,7 +1081,6 @@ public final class AutofillManager { if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId); mSessionId = newId; mState = (mSessionId == NO_SESSION) ? STATE_UNKNOWN : STATE_ACTIVE; - final AutofillClient client = getClientLocked(); if (client != null) { client.autofillCallbackResetableStateAvailable(); } |