Merge "Use preference for about phone page instead of injection."
This commit is contained in:
@@ -922,14 +922,6 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.SHORTCUT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.order" android:value="20"/>
|
||||
<meta-data android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.homepage" />
|
||||
<meta-data android:name="com.android.settings.title"
|
||||
android:resource="@string/about_settings" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
|
@@ -124,6 +124,15 @@
|
||||
android:order="10"
|
||||
android:fragment="com.android.settings.system.SystemDashboardFragment"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_about_device"
|
||||
android:title="@string/about_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:icon="@drawable/ic_homepage_about"
|
||||
android:order="20"
|
||||
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
|
||||
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="top_level_support"
|
||||
android:summary="@string/support_summary"
|
||||
|
@@ -79,12 +79,7 @@ public class DeviceModelPreferenceController extends BasePreferenceController {
|
||||
}
|
||||
|
||||
public static String getDeviceModel() {
|
||||
FutureTask<String> msvSuffixTask = new FutureTask<String>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return DeviceInfoUtils.getMsvSuffix();
|
||||
}
|
||||
});
|
||||
FutureTask<String> msvSuffixTask = new FutureTask<>(() -> DeviceInfoUtils.getMsvSuffix());
|
||||
|
||||
msvSuffixTask.run();
|
||||
try {
|
||||
|
@@ -181,25 +181,6 @@ public class MyDeviceInfoFragment extends DashboardFragment
|
||||
controller.updateDeviceName(confirm);
|
||||
}
|
||||
|
||||
private static class SummaryProvider implements SummaryLoader.SummaryProvider {
|
||||
|
||||
private final SummaryLoader mSummaryLoader;
|
||||
|
||||
public SummaryProvider(SummaryLoader summaryLoader) {
|
||||
mSummaryLoader = summaryLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
if (listening) {
|
||||
mSummaryLoader.setSummary(this, DeviceModelPreferenceController.getDeviceModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
|
||||
= (activity, summaryLoader) -> new SummaryProvider(summaryLoader);
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
*/
|
||||
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.aboutphone;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.deviceinfo.DeviceModelPreferenceController;
|
||||
|
||||
public class TopLevelAboutDevicePreferenceController extends BasePreferenceController {
|
||||
|
||||
public TopLevelAboutDevicePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return DeviceModelPreferenceController.getDeviceModel();
|
||||
}
|
||||
}
|
@@ -1,4 +1,20 @@
|
||||
package com.android.settings.deviceinfo.deviceinfo;
|
||||
/*
|
||||
* 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.aboutphone;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -6,8 +22,6 @@ import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import com.android.settings.deviceinfo.aboutphone.DeviceNameWarningDialog;
|
||||
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Test;
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.deviceinfo;
|
||||
package com.android.settings.deviceinfo.aboutphone;
|
||||
|
||||
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
|
||||
|
||||
@@ -35,7 +35,7 @@ import android.util.ArrayMap;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
|
||||
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.aboutphone;
|
||||
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class TopLevelAboutDevicePreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private TopLevelAboutDevicePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new TopLevelAboutDevicePreferenceController(mContext, "test_key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityState_shouldBeAvailable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_shouldReturnDeviceModel() {
|
||||
assertThat(mController.getSummary().toString()).isEqualTo(Build.MODEL);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user