OSDN Git Service

Set the mAccountName as null while device has no any account
authorSunny Shao <sunnyshao@google.com>
Tue, 4 Jun 2019 06:11:40 +0000 (14:11 +0800)
committerSunny Shao <sunnyshao@google.com>
Tue, 4 Jun 2019 07:56:18 +0000 (15:56 +0800)
It doesn't clean the mAccountName buffer while device has no any account. And it will be put into
the Intent and pass to MeCard when user click the ghost boy avatar. It does not make sense and
modify code to fixed it.

Fixes: 129265427
Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER=com.android.settings.accounts
      make RunSettingsRoboTests -j56 ROBOTEST_FILTER=com.android.settings.core
      make RunSettingsRoboTests -j56 ROBOTEST_FILTER=com.android.settings.dashboard

Change-Id: Ib8cfab2cb416515018f335b21ef49a95699a1597

src/com/android/settings/accounts/AvatarViewMixin.java
tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java

index 9e762c7..7eb8cab 100644 (file)
@@ -67,7 +67,8 @@ public class AvatarViewMixin implements LifecycleObserver {
     private final MutableLiveData<Bitmap> mAvatarImage;
     private final ActivityManager mActivityManager;
 
-    private String mAccountName;
+    @VisibleForTesting
+    String mAccountName;
 
     public AvatarViewMixin(SettingsHomepageActivity activity, ImageView avatarView) {
         mContext = activity.getApplicationContext();
@@ -127,6 +128,7 @@ public class AvatarViewMixin implements LifecycleObserver {
         if (hasAccount()) {
             loadAccount();
         } else {
+            mAccountName = null;
             mAvatarView.setImageResource(R.drawable.ic_account_circle_24dp);
         }
     }
index 8c75e33..8dbf2a8 100644 (file)
@@ -131,6 +131,17 @@ public class AvatarViewMixinTest {
     }
 
     @Test
+    @Config(qualifiers = "mcc999")
+    public void onStart_noAccount_mAccountNameShouldBeNull() {
+        final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);
+        avatarViewMixin.mAccountName = DUMMY_ACCOUNT;
+
+        avatarViewMixin.onStart();
+
+        assertThat(avatarViewMixin.mAccountName).isNull();
+    }
+
+    @Test
     public void queryProviderAuthority_useShadowPackagteManager_returnNull() {
         final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);