Add a new About Phone page.

This adds the "Me Card" page. The current functionality is to show
information based upon the first account added to the system. The page
shows the user's avatar, name, primary account, and phone number.

Bug: 63819909
Test: Robotest

Change-Id: I64bfae922e828994b2b87009d0647e67dab0da42
This commit is contained in:
Daniel Nishi
2017-12-19 10:15:14 -08:00
parent 663b2d9bd3
commit 1e620957b8
16 changed files with 461 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.deviceinfo;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import android.accounts.Account;
import android.content.Context;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class BrandedAccountPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
private BrandedAccountPreferenceController mController;
private FakeFeatureFactory fakeFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
fakeFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new BrandedAccountPreferenceController(mContext);
}
@Test
public void isAvailable_defaultOff() {
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_onWhenAccountIsAvailable() {
when(fakeFeatureFactory.mAccountFeatureProvider.getAccounts(any(Context.class))).thenReturn(
new Account[]
{new Account("fake@account.foo", "fake.reallyfake")});
mController = new BrandedAccountPreferenceController(mContext);
assertThat(mController.isAvailable()).isTrue();
}
}

View File

@@ -21,6 +21,7 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
@@ -65,6 +66,7 @@ public class FakeFeatureFactory extends FeatureFactory {
public final SmsMirroringFeatureProvider smsMirroringFeatureProvider;
public final SlicesFeatureProvider slicesFeatureProvider;
public SearchFeatureProvider searchFeatureProvider;
public final AccountFeatureProvider mAccountFeatureProvider;
/**
* Call this in {@code @Before} method of the test class to use fake factory.
@@ -104,6 +106,7 @@ public class FakeFeatureFactory extends FeatureFactory {
dataPlanFeatureProvider = mock(DataPlanFeatureProvider.class);
smsMirroringFeatureProvider = mock(SmsMirroringFeatureProvider.class);
slicesFeatureProvider = mock(SlicesFeatureProvider.class);
mAccountFeatureProvider = mock(AccountFeatureProvider.class);
}
@Override
@@ -190,4 +193,9 @@ public class FakeFeatureFactory extends FeatureFactory {
public SlicesFeatureProvider getSlicesFeatureProvider() {
return slicesFeatureProvider;
}
@Override
public AccountFeatureProvider getAccountFeatureProvider() {
return mAccountFeatureProvider;
}
}