Merge "Add Extra App Info into Settings App UI." into sc-dev

This commit is contained in:
Trevor Black
2021-03-08 07:04:42 +00:00
committed by Android (Google) Code Review
11 changed files with 228 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -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;
}
}