Merge "Add Game settings support." into sc-dev am: d32d11248e am: 4e4a7f0dbd

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14553339

Change-Id: I9eb8f13aaf68f586ac1068af26459e9db08f1a65
This commit is contained in:
Peiyong Lin
2021-05-20 01:55:47 +00:00
committed by Automerger Merge Worker
10 changed files with 240 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/*
* 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;
import android.content.Context;
/**
* Provider for Game Settings related feature.
*/
public interface GameSettingsFeatureProvider {
/**
* Returns true if the feature is supported.
*/
boolean isSupported(Context context);
/**
* Launch GameSettings
*/
void launchGameSettings(Context context);
}

View File

@@ -0,0 +1,35 @@
/*
* 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;
import android.content.Context;
/**
* Provider implementation for Game Settings related features.
*/
public class GameSettingsFeatureProviderImpl implements
GameSettingsFeatureProvider {
@Override
public boolean isSupported(Context context) {
return false;
}
@Override
public void launchGameSettings(Context context) {
return;
}
}

View File

@@ -0,0 +1,60 @@
/*
* 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;
import android.content.Context;
import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.overlay.FeatureFactory;
/** Contains logic that deals with showing Game Settings in app settings. */
public class GameSettingsPreferenceController extends BasePreferenceController {
@VisibleForTesting
final GameSettingsFeatureProvider mGameSettingsFeatureProvider;
public GameSettingsPreferenceController(Context context, String key) {
super(context, key);
mGameSettingsFeatureProvider =
FeatureFactory.getFactory(context).getGameSettingsFeatureProvider();
}
GameSettingsPreferenceController(Context context, String key,
GameSettingsFeatureProvider gameSettingsFeatureProvider) {
super(context, key);
mGameSettingsFeatureProvider = gameSettingsFeatureProvider;
}
@Override
public int getAvailabilityStatus() {
return mGameSettingsFeatureProvider.isSupported(mContext)
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (TextUtils.equals(getPreferenceKey(), preference.getKey())) {
mGameSettingsFeatureProvider.launchGameSettings(mContext);
return true;
}
return super.handlePreferenceTreeClick(preference);
}
}

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.GameSettingsFeatureProvider;
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
import com.android.settings.aware.AwareFeatureProvider;
import com.android.settings.biometrics.face.FaceFeatureProvider;
@@ -168,6 +169,11 @@ public abstract class FeatureFactory {
*/
public abstract SecuritySettingsFeatureProvider getSecuritySettingsFeatureProvider();
/**
* Retrieve implementation for Game Settings feature.
*/
public abstract GameSettingsFeatureProvider getGameSettingsFeatureProvider();
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.GameSettingsFeatureProvider;
import com.android.settings.applications.GameSettingsFeatureProviderImpl;
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProvider;
import com.android.settings.applications.appinfo.ExtraAppInfoFeatureProviderImpl;
import com.android.settings.aware.AwareFeatureProvider;
@@ -103,6 +105,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
private WifiTrackerLibProvider mWifiTrackerLibProvider;
private ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider;
private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
private GameSettingsFeatureProvider mGameSettingsFeatureProvider;
@Override
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
@@ -324,4 +327,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
}
return mSecuritySettingsFeatureProvider;
}
@Override
public GameSettingsFeatureProvider getGameSettingsFeatureProvider() {
if (mGameSettingsFeatureProvider == null) {
mGameSettingsFeatureProvider = new GameSettingsFeatureProviderImpl();
}
return mGameSettingsFeatureProvider;
}
}