Merge rvc-qpr-dev-plus-aosp-without-vendor@6881855

Bug: 172690556
Merged-In: Iafcefc2aa64cf3c50b1d139ec0204a315be29da7
Change-Id: I5d4e70fe723d890b5694c3490d6ec841b1ac596e
This commit is contained in:
Xin Li
2020-12-02 00:29:15 -08:00
393 changed files with 32291 additions and 47011 deletions

View File

@@ -16,6 +16,8 @@
package com.android.settings.development;
import static android.service.quicksettings.TileService.ACTION_QS_TILE_PREFERENCES;
import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothA2dp;
@@ -23,12 +25,14 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothCodecStatus;
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.UserManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -41,6 +45,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.development.autofill.AutofillLoggingLevelPreferenceController;
import com.android.settings.development.autofill.AutofillResetOptionsPreferenceController;
@@ -52,6 +57,7 @@ import com.android.settings.development.bluetooth.BluetoothCodecDialogPreference
import com.android.settings.development.bluetooth.BluetoothHDAudioPreferenceController;
import com.android.settings.development.bluetooth.BluetoothQualityDialogPreferenceController;
import com.android.settings.development.bluetooth.BluetoothSampleRateDialogPreferenceController;
import com.android.settings.development.qstile.DevelopmentTiles;
import com.android.settings.development.storage.SharedDataPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
@@ -199,11 +205,42 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
// Restore UI state based on whether developer options is enabled
if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
enableDeveloperOptions();
handleQsTileLongPressActionIfAny();
} else {
disableDeveloperOptions();
}
}
/**
* Long-pressing a developer options quick settings tile will by default (see
* QS_TILE_PREFERENCES in the manifest) take you to the developer options page.
* Some tiles may want to go into their own page within the developer options.
*/
private void handleQsTileLongPressActionIfAny() {
Intent intent = getActivity().getIntent();
if (intent == null || !TextUtils.equals(ACTION_QS_TILE_PREFERENCES, intent.getAction())) {
return;
}
Log.d(TAG, "Developer options started from qstile long-press");
final ComponentName componentName = (ComponentName) intent.getParcelableExtra(
Intent.EXTRA_COMPONENT_NAME);
if (componentName == null) {
return;
}
if (DevelopmentTiles.WirelessDebugging.class.getName().equals(
componentName.getClassName()) && getDevelopmentOptionsController(
WirelessDebuggingPreferenceController.class).isAvailable()) {
Log.d(TAG, "Long press from wireless debugging qstile");
new SubSettingLauncher(getContext())
.setDestination(WirelessDebuggingFragment.class.getName())
.setSourceMetricsCategory(SettingsEnums.SETTINGS_ADB_WIRELESS)
.launch();
}
// Add other qstiles here
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -16,8 +16,8 @@
package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_OFF;
import android.content.ContentResolver;
import android.content.Context;
@@ -62,7 +62,7 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
private final ContentResolver mContentResolver;
private final String mPreferenceTitle;
private final String mPreferenceDefault;
private final String mPreferenceGameDriver;
private final String mPreferenceProductionDriver;
private final String mPreferencePrereleaseDriver;
private final String mPreferenceSystem;
@VisibleForTesting
@@ -88,8 +88,8 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
final Resources resources = context.getResources();
mPreferenceTitle = resources.getString(R.string.graphics_driver_app_preference_title);
mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferenceProductionDriver =
resources.getString(R.string.graphics_driver_app_preference_production_driver);
mPreferencePrereleaseDriver =
resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
mPreferenceSystem = resources.getString(R.string.graphics_driver_app_preference_system);
@@ -101,19 +101,21 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
mAppInfos = getAppInfos(context);
mDevOptInApps =
getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS);
getGlobalSettingsString(mContentResolver,
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS);
mDevPrereleaseOptInApps = getGlobalSettingsString(
mContentResolver, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS);
mDevOptOutApps =
getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS);
getGlobalSettingsString(mContentResolver,
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS);
}
@Override
public int getAvailabilityStatus() {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
&& (Settings.Global.getInt(mContentResolver,
Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF)
Settings.Global.UPDATABLE_DRIVER_ALL_APPS, UPDATABLE_DRIVER_DEFAULT)
!= UPDATABLE_DRIVER_OFF)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -157,7 +159,7 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
mDevOptInApps.remove(packageName);
mDevPrereleaseOptInApps.remove(packageName);
mDevOptOutApps.add(packageName);
} else if (value.equals(mPreferenceGameDriver)) {
} else if (value.equals(mPreferenceProductionDriver)) {
mDevOptInApps.add(packageName);
mDevPrereleaseOptInApps.remove(packageName);
mDevOptOutApps.remove(packageName);
@@ -174,13 +176,15 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
listPref.setSummary(value);
// Push the updated Sets for stable/prerelease opt-in and opt-out apps to
// corresponding Settings.Global.GAME_DRIVER(_PRERELEASE)?_OPT_(IN|OUT)_APPS
Settings.Global.putString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS,
// corresponding Settings.Global.UPDATABLE_DRIVER_[PRODUCTION|PRERELEASE]_OPT_(IN|OUT)_APPS
Settings.Global.putString(mContentResolver,
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS,
String.join(",", mDevOptInApps));
Settings.Global.putString(mContentResolver,
Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS,
Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS,
String.join(",", mDevPrereleaseOptInApps));
Settings.Global.putString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS,
Settings.Global.putString(mContentResolver,
Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS,
String.join(",", mDevOptOutApps));
return true;
@@ -251,7 +255,7 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
listPreference.setEntryValues(mEntryList);
// Initialize preference default and summary with the opt in/out choices
// from Settings.Global.GAME_DRIVER(_PRERELEASE)?_OPT_(IN|OUT)_APPS
// from Settings.Global.UPDATABLE_DRIVER_[PRODUCTION|PRERELEASE]_OPT_[IN|OUT]_APPS
if (mDevOptOutApps.contains(packageName)) {
listPreference.setValue(mPreferenceSystem);
listPreference.setSummary(mPreferenceSystem);
@@ -259,8 +263,8 @@ public class GraphicsDriverAppPreferenceController extends BasePreferenceControl
listPreference.setValue(mPreferencePrereleaseDriver);
listPreference.setSummary(mPreferencePrereleaseDriver);
} else if (mDevOptInApps.contains(packageName)) {
listPreference.setValue(mPreferenceGameDriver);
listPreference.setSummary(mPreferenceGameDriver);
listPreference.setValue(mPreferenceProductionDriver);
listPreference.setSummary(mPreferenceProductionDriver);
} else {
listPreference.setValue(mPreferenceDefault);
listPreference.setSummary(mPreferenceDefault);

View File

@@ -52,7 +52,7 @@ public class GraphicsDriverContentObserver extends ContentObserver {
*/
public void register(ContentResolver contentResolver) {
contentResolver.registerContentObserver(
Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false, this);
Settings.Global.getUriFor(Settings.Global.UPDATABLE_DRIVER_ALL_APPS), false, this);
}
/**

View File

@@ -30,7 +30,7 @@ import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.search.SearchIndexable;
/**
* Dashboard for Game Driver preferences.
* Dashboard for Graphics Driver preferences.
*/
@SearchIndexable
public class GraphicsDriverDashboard extends DashboardFragment {
@@ -39,7 +39,7 @@ public class GraphicsDriverDashboard extends DashboardFragment {
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD;
return SettingsEnums.SETTINGS_GRAPHICS_DRIVER_DASHBOARD;
}
@Override

View File

@@ -46,24 +46,24 @@ import java.util.ArrayList;
import java.util.List;
/**
* Controller of global switch to enable Game Driver for all Apps.
* Controller of global switch to enable updatable driver for all Apps.
*/
public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePreferenceController
implements Preference.OnPreferenceChangeListener,
GraphicsDriverContentObserver.OnGraphicsDriverContentChangedListener,
LifecycleObserver, OnStart, OnStop {
public static final int GAME_DRIVER_DEFAULT = 0;
public static final int GAME_DRIVER_ALL_APPS = 1;
public static final int GAME_DRIVER_PRERELEASE_ALL_APPS = 2;
public static final int GAME_DRIVER_OFF = 3;
public static final String PROPERTY_GFX_DRIVER_GAME = "ro.gfx.driver.0";
public static final int UPDATABLE_DRIVER_DEFAULT = 0;
public static final int UPDATABLE_DRIVER_PRODUCTION_ALL_APPS = 1;
public static final int UPDATABLE_DRIVER_PRERELEASE_ALL_APPS = 2;
public static final int UPDATABLE_DRIVER_OFF = 3;
public static final String PROPERTY_GFX_DRIVER_PRODUCTION = "ro.gfx.driver.0";
public static final String PROPERTY_GFX_DRIVER_PRERELEASE = "ro.gfx.driver.1";
private final Context mContext;
private final ContentResolver mContentResolver;
private final String mPreferenceDefault;
private final String mPreferenceGameDriver;
private final String mPreferenceProductionDriver;
private final String mPreferencePrereleaseDriver;
@VisibleForTesting
CharSequence[] mEntryList;
@@ -79,8 +79,8 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
final Resources resources = context.getResources();
mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferenceProductionDriver =
resources.getString(R.string.graphics_driver_app_preference_production_driver);
mPreferencePrereleaseDriver =
resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
mEntryList = constructEntryList(mContext, false);
@@ -92,8 +92,9 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
public int getAvailabilityStatus() {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
&& (Settings.Global.getInt(mContentResolver,
Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF)
Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT)
!= UPDATABLE_DRIVER_OFF)
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -122,11 +123,12 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
final ListPreference listPref = (ListPreference) preference;
listPref.setVisible(isAvailable());
final int currentChoice = Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
if (currentChoice == GAME_DRIVER_ALL_APPS) {
listPref.setValue(mPreferenceGameDriver);
listPref.setSummary(mPreferenceGameDriver);
} else if (currentChoice == GAME_DRIVER_PRERELEASE_ALL_APPS) {
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT);
if (currentChoice == UPDATABLE_DRIVER_PRODUCTION_ALL_APPS) {
listPref.setValue(mPreferenceProductionDriver);
listPref.setSummary(mPreferenceProductionDriver);
} else if (currentChoice == UPDATABLE_DRIVER_PRERELEASE_ALL_APPS) {
listPref.setValue(mPreferencePrereleaseDriver);
listPref.setSummary(mPreferencePrereleaseDriver);
} else {
@@ -140,21 +142,22 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
final ListPreference listPref = (ListPreference) preference;
final String value = newValue.toString();
final int currentChoice = Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT);
final int userChoice;
if (value.equals(mPreferenceGameDriver)) {
userChoice = GAME_DRIVER_ALL_APPS;
if (value.equals(mPreferenceProductionDriver)) {
userChoice = UPDATABLE_DRIVER_PRODUCTION_ALL_APPS;
} else if (value.equals(mPreferencePrereleaseDriver)) {
userChoice = GAME_DRIVER_PRERELEASE_ALL_APPS;
userChoice = UPDATABLE_DRIVER_PRERELEASE_ALL_APPS;
} else {
userChoice = GAME_DRIVER_DEFAULT;
userChoice = UPDATABLE_DRIVER_DEFAULT;
}
listPref.setValue(value);
listPref.setSummary(value);
if (userChoice != currentChoice) {
Settings.Global.putInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, userChoice);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS, userChoice);
}
return true;
@@ -172,7 +175,8 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
final Resources resources = context.getResources();
final String prereleaseDriverPackageName =
SystemProperties.get(PROPERTY_GFX_DRIVER_PRERELEASE);
final String gameDriverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER_GAME);
final String productionDriverPackageName =
SystemProperties.get(PROPERTY_GFX_DRIVER_PRODUCTION);
List<CharSequence> entryList = new ArrayList<>();
entryList.add(resources.getString(R.string.graphics_driver_app_preference_default));
@@ -182,9 +186,10 @@ public class GraphicsDriverEnableForAllAppsPreferenceController extends BasePref
entryList.add(resources.getString(
R.string.graphics_driver_app_preference_prerelease_driver));
}
if (!TextUtils.isEmpty(gameDriverPackageName)
&& hasDriverPackage(pm, gameDriverPackageName)) {
entryList.add(resources.getString(R.string.graphics_driver_app_preference_game_driver));
if (!TextUtils.isEmpty(productionDriverPackageName)
&& hasDriverPackage(pm, productionDriverPackageName)) {
entryList.add(resources.getString(
R.string.graphics_driver_app_preference_production_driver));
}
if (withSystem) {
entryList.add(resources.getString(R.string.graphics_driver_app_preference_system));

View File

@@ -16,8 +16,8 @@
package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_OFF;
import android.content.ContentResolver;
import android.content.Context;
@@ -58,8 +58,9 @@ public class GraphicsDriverFooterPreferenceController extends BasePreferenceCont
@Override
public int getAvailabilityStatus() {
return Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
== GAME_DRIVER_OFF
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT)
== UPDATABLE_DRIVER_OFF
? AVAILABLE_UNSEARCHABLE
: CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -16,10 +16,10 @@
package com.android.settings.development.graphicsdriver;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.GAME_DRIVER_PRERELEASE_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_DEFAULT;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_OFF;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_PRERELEASE_ALL_APPS;
import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableForAllAppsPreferenceController.UPDATABLE_DRIVER_PRODUCTION_ALL_APPS;
import android.content.ContentResolver;
import android.content.Context;
@@ -36,7 +36,7 @@ import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
/**
* Controller of global switch bar used to fully turn off Game Driver.
* Controller of global switch bar used to fully turn off updatable driver.
*/
public class GraphicsDriverGlobalSwitchBarController
implements SwitchWidgetController.OnSwitchChangeListener,
@@ -61,8 +61,9 @@ public class GraphicsDriverGlobalSwitchBarController
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context));
mSwitchWidgetController.setChecked(
Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT)
!= UPDATABLE_DRIVER_OFF);
mSwitchWidgetController.setListener(this);
}
@@ -81,21 +82,22 @@ public class GraphicsDriverGlobalSwitchBarController
@Override
public boolean onSwitchToggled(boolean isChecked) {
final int graphicsDriverGlobalOption = Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT);
if (isChecked
&& (graphicsDriverGlobalOption == GAME_DRIVER_DEFAULT
|| graphicsDriverGlobalOption == GAME_DRIVER_ALL_APPS
|| graphicsDriverGlobalOption == GAME_DRIVER_PRERELEASE_ALL_APPS)) {
&& (graphicsDriverGlobalOption == UPDATABLE_DRIVER_DEFAULT
|| graphicsDriverGlobalOption == UPDATABLE_DRIVER_PRODUCTION_ALL_APPS
|| graphicsDriverGlobalOption == UPDATABLE_DRIVER_PRERELEASE_ALL_APPS)) {
return true;
}
if (!isChecked && graphicsDriverGlobalOption == GAME_DRIVER_OFF) {
if (!isChecked && graphicsDriverGlobalOption == UPDATABLE_DRIVER_OFF) {
return true;
}
Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
isChecked ? GAME_DRIVER_DEFAULT : GAME_DRIVER_OFF);
Settings.Global.putInt(mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
isChecked ? UPDATABLE_DRIVER_DEFAULT : UPDATABLE_DRIVER_OFF);
return true;
}
@@ -104,7 +106,8 @@ public class GraphicsDriverGlobalSwitchBarController
public void onGraphicsDriverContentChanged() {
mSwitchWidgetController.setChecked(
Settings.Global.getInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF);
mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS,
UPDATABLE_DRIVER_DEFAULT)
!= UPDATABLE_DRIVER_OFF);
}
}