Add Extra App Info into Settings App UI.
Bug: b/174956516 Test: Settings -> Apps -> APP -> Extra App Info Change-Id: Id978fb3569579f54b8399156d52c2ddeceb9bb91
This commit is contained in:
@@ -12805,4 +12805,7 @@
|
||||
<string name="enable_2g_title">Allow 2G</string>
|
||||
<!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=NONE] -->
|
||||
<string name="enable_2g_summary">Use 2G cellular connections. For emergency calls, 2G is always turned on.</string>
|
||||
|
||||
<!-- Label for extra app info settings for a specific app [CHAR LIMIT=40] -->
|
||||
<string name="extra_app_info_label" translatable="false"></string>
|
||||
</resources>
|
||||
|
@@ -80,6 +80,11 @@
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.applications.appinfo.AppDataUsagePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="extra_app_info_settings"
|
||||
android:title="@string/extra_app_info_label"
|
||||
settings:controller="com.android.settings.applications.appinfo.ExtraAppInfoPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="time_spent_in_app"
|
||||
android:title="@string/time_spent_in_app_pref_title"
|
||||
|
@@ -166,6 +166,9 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
use(AppStoragePreferenceController.class).setParentFragment(this);
|
||||
use(AppVersionPreferenceController.class).setParentFragment(this);
|
||||
use(InstantAppDomainsPreferenceController.class).setParentFragment(this);
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME)) {
|
||||
use(ExtraAppInfoPreferenceController.class).setPackageName(packageName);
|
||||
}
|
||||
|
||||
final WriteSystemSettingsPreferenceController writeSystemSettings =
|
||||
use(WriteSystemSettingsPreferenceController.class);
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.applications.appinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Provider for Extra App Info related feature
|
||||
*/
|
||||
public interface ExtraAppInfoFeatureProvider {
|
||||
/** Returns true if the feature is supported. */
|
||||
boolean isSupported(Context context);
|
||||
|
||||
/**
|
||||
* Launch ExtraAppInfoSettings
|
||||
*/
|
||||
void launchExtraAppInfoSettings(Context context);
|
||||
|
||||
/**
|
||||
* Sets the package name
|
||||
*/
|
||||
void setPackageName(String packageName);
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.applications.appinfo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Provider for Extra App Info related feature
|
||||
*/
|
||||
public class ExtraAppInfoFeatureProviderImpl implements
|
||||
ExtraAppInfoFeatureProvider {
|
||||
@Override
|
||||
public boolean isSupported(Context context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchExtraAppInfoSettings(Context context) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackageName(String packageName) {
|
||||
return;
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.applications.appinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
/** Contains logic that deals with showing extra app info in app settings. */
|
||||
public class ExtraAppInfoPreferenceController extends BasePreferenceController {
|
||||
|
||||
private final ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider;
|
||||
|
||||
public ExtraAppInfoPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mExtraAppInfoFeatureProvider =
|
||||
FeatureFactory.getFactory(context).getExtraAppInfoFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mExtraAppInfoFeatureProvider.isSupported(mContext)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (TextUtils.equals(getPreferenceKey(), preference.getKey())) {
|
||||
mExtraAppInfoFeatureProvider.launchExtraAppInfoSettings(mContext);
|
||||
return true;
|
||||
}
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the local package name
|
||||
*/
|
||||
public void setPackageName(String packageName) {
|
||||
if (mExtraAppInfoFeatureProvider != null) {
|
||||
mExtraAppInfoFeatureProvider.setPackageName(packageName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -25,6 +25,7 @@ import androidx.annotation.Nullable;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -149,6 +150,11 @@ public abstract class FeatureFactory {
|
||||
*/
|
||||
public abstract WifiTrackerLibProvider getWifiTrackerLibProvider();
|
||||
|
||||
/**
|
||||
* Retrieve implementation for Extra App Info feature.
|
||||
*/
|
||||
public abstract ExtraAppInfoFeatureProvider getExtraAppInfoFeatureProvider();
|
||||
|
||||
public static final class FactoryNotFoundException extends RuntimeException {
|
||||
public FactoryNotFoundException(Throwable throwable) {
|
||||
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
||||
|
@@ -29,6 +29,8 @@ import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
|
||||
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProviderImpl;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProviderImpl;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
@@ -94,6 +96,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private AwareFeatureProvider mAwareFeatureProvider;
|
||||
private FaceFeatureProvider mFaceFeatureProvider;
|
||||
private WifiTrackerLibProvider mWifiTrackerLibProvider;
|
||||
private ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider;
|
||||
|
||||
@Override
|
||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||
@@ -291,4 +294,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
}
|
||||
return mWifiTrackerLibProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraAppInfoFeatureProvider getExtraAppInfoFeatureProvider() {
|
||||
if (mExtraAppInfoFeatureProvider == null) {
|
||||
mExtraAppInfoFeatureProvider = new ExtraAppInfoFeatureProviderImpl();
|
||||
}
|
||||
return mExtraAppInfoFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.applications.appinfo;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ExtraAppInfoPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private ExtraAppInfoPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new ExtraAppInfoPreferenceController(mContext, "test_key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_unavailableByDefault() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
}
|
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -79,6 +80,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||
|
||||
public WifiTrackerLibProvider wifiTrackerLibProvider;
|
||||
public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -124,6 +126,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mAwareFeatureProvider = mock(AwareFeatureProvider.class);
|
||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||
extraAppInfoFeatureProvider = mock(ExtraAppInfoFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -240,4 +243,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public WifiTrackerLibProvider getWifiTrackerLibProvider() {
|
||||
return wifiTrackerLibProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraAppInfoFeatureProvider getExtraAppInfoFeatureProvider() {
|
||||
return extraAppInfoFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
@@ -74,6 +75,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||
|
||||
public WifiTrackerLibProvider wifiTrackerLibProvider;
|
||||
public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider;
|
||||
|
||||
/**
|
||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||
@@ -110,6 +112,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
mAwareFeatureProvider = mock(AwareFeatureProvider.class);
|
||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
|
||||
extraAppInfoFeatureProvider = mock(ExtraAppInfoFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -226,4 +229,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public WifiTrackerLibProvider getWifiTrackerLibProvider() {
|
||||
return wifiTrackerLibProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtraAppInfoFeatureProvider getExtraAppInfoFeatureProvider() {
|
||||
return extraAppInfoFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user