1.android/frameworks/base/core/res/res/values/config.xml
<bool name="config_brightness">falsebool>
//新添加的config属性必须要在symbols.xml文件里添加对应符号,否则在R.java文件里生成不了
2.android/frameworks/base/core/res/res/values/symbols.xml
"bool" name="config_brightness" />
3.//使用已添加的config
if(getResources().getBoolean(com.android.internal.R.bool.config_brightness) == false)
{
do something.
}
默认屏保时间def_screen_off_timeout
android/frameworks/base/packages/SettingsProvider/DatabaseHelper.java
//默认设置值
android/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
"def_screen_off_timeout">60000
//Settings.System.SCREEN_OFF_TIMEOUT 定义
android/frameworks/base/core/java/android/provider/Settings.java
public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";
private void loadSystemSettings(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
R.bool.def_dim_screen);
//读取默认值
loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
R.integer.def_screen_off_timeout);
// Set default cdma DTMF type
loadSetting(stmt, Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, 0);
// Set default hearing aid
loadSetting(stmt, Settings.System.HEARING_AID, 0);
// Set default tty mode
loadSetting(stmt, Settings.System.TTY_MODE, 0);
loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
R.integer.def_screen_brightness);
loadBooleanSetting(stmt, Settings.System.SCREEN_BRIGHTNESS_MODE,
R.bool.def_screen_brightness_automatic_mode);
loadDefaultAnimationSettings(stmt);
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
R.bool.def_accelerometer_rotation);
loadDefaultHapticSettings(stmt);
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
R.bool.def_notification_pulse);
loadUISoundEffectsSettings(stmt);
loadIntegerSetting(stmt, Settings.System.POINTER_SPEED,
R.integer.def_pointer_speed);
/*
* IMPORTANT: Do not add any more upgrade steps here as the global,
* secure, and system settings are no longer stored in a database
* but are kept in memory and persisted to XML.
*
* See: SettingsProvider.UpgradeController#onUpgradeLocked
*/
} finally {
if (stmt != null) stmt.close();
}
}
移除Daydreams
android/frameworks/base/core/res/res/values/config.xml
<bool name="config_dreamsSupported">truebool>
@Override
public List getNonIndexableKeys(Context context) {
ArrayList result = new ArrayList();
if (!context.getResources().getBoolean(
com.android.internal.R.bool.config_dreamsSupported)) {
result.add(KEY_SCREEN_SAVER);
}
}
android/packages/apps/Settings/res/xml/display_settings.xml
"screensaver"
android:title="@string/screensaver_settings_title"
android:fragment="com.android.settings.DreamSettings" />
android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java
private static final String KEY_SCREEN_SAVER = "screensaver";
private Preference mScreenSaverPreference;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
final ContentResolver resolver = activity.getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null
&& getResources().getBoolean(
com.android.internal.R.bool.config_dreamsSupported) == false) {
getPreferenceScreen().removePreference(mScreenSaverPreference);
}
....
}
<bool name="config_cameraDoubleTapPowerGestureEnabled">falsebool>
删除/system/app/PhotoTable/PhotoTable.apk即可
源码路径:android/packages/screensavers/PhotoTable
android7.1 Settings代码分析:
android7.1\packages\apps\Settings\src\com\android\settings\Settings.java
/**
* Top-level Settings activity
*/
public class Settings extends SettingsActivity {
/*
* Settings subclasses for launching independently.
*/
public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
public static class WirelessSettingsActivity extends SettingsActivity { /* empty */ }
public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
public static class StorageSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
public static class PrivateVolumeSettingsActivity extends SettingsActivity { /* empty */ }
public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
public static class PhysicalKeyboardActivity extends SettingsActivity { /* empty */ }
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
public static class HomeSettingsActivity extends SettingsActivity { /* empty */ }
public static class DisplaySettingsActivity extends SettingsActivity { /* empty */ }
public static class NightDisplaySettingsActivity extends SettingsActivity { /* empty */ }
public static class DeviceInfoSettingsActivity extends SettingsActivity { /* empty */ }
public static class ApplicationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageApplicationsActivity extends SettingsActivity { /* empty */ }
public static class ManageAssistActivity extends SettingsActivity { /* empty */ }
public static class AllApplicationsActivity extends SettingsActivity { /* empty */ }
public static class HighPowerApplicationsActivity extends SettingsActivity { /* empty */ }
public static class AppOpsSummaryActivity extends SettingsActivity {
@Override
public boolean isValidFragment(String className) {
if (AppOpsSummary.class.getName().equals(className)) {
return true;
}
return super.isValidFragment(className);
}
}
public static class BackgroundCheckSummaryActivity extends SettingsActivity { /* empty */ }
public static class StorageUseActivity extends SettingsActivity { /* empty */ }
public static class DevelopmentSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
public static class SecuritySettingsActivity extends SettingsActivity { /* empty */ }
public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
public static class FactoryResetActivity extends SettingsActivity { /* empty */ }
public static class RunningServicesActivity extends SettingsActivity { /* empty */ }
public static class ManageAccountsSettingsActivity extends SettingsActivity { /* empty */ }
public static class PowerUsageSummaryActivity extends SettingsActivity { /* empty */ }
public static class BatterySaverSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccountSyncSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccountSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
public static class GestureSettingsActivity extends SettingsActivity { /* empty */ }
public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
public static class AdvancedWifiSettingsActivity extends SettingsActivity { /* empty */ }
public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
public static class TextToSpeechSettingsActivity extends SettingsActivity { /* empty */ }
public static class AndroidBeamSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiDisplaySettingsActivity extends SettingsActivity { /* empty */ }
public static class DreamSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationStationActivity extends SettingsActivity { /* empty */ }
public static class UserSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class VrListenersSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class ConditionProviderSettingsActivity extends SettingsActivity { /* empty */ }
public static class UsbSettingsActivity extends SettingsActivity { /* empty */ }
public static class TrustedCredentialsSettingsActivity extends SettingsActivity { /* empty */ }
public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeScheduleRuleSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeEventRuleSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeExternalRuleSettingsActivity extends SettingsActivity { /* empty */ }
public static class ZenModeVisualInterruptionSettingsActivity extends SettingsActivity { /* empty */}
public static class SoundSettingsActivity extends SettingsActivity { /* empty */ }
public static class ConfigureNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class OtherSoundSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
public static class TopLevelSettings extends SettingsActivity { /* empty */ }
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
public static class MemorySettingsActivity extends SettingsActivity { /* empty */ }
public static class AppMemoryUsageActivity extends SettingsActivity { /* empty */ }
public static class OverlaySettingsActivity extends SettingsActivity { /* empty */ }
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class AdvancedAppsActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingSuggestionActivity extends SettingsActivity { /* empty */ }
public static class ZenModeAutomationSuggestionActivity extends SettingsActivity { /* empty */ }
public static class FingerprintSuggestionActivity extends FingerprintSettings { /* empty */ }
public static class FingerprintEnrollSuggestionActivity extends FingerprintEnrollIntroduction {
/* empty */
}
public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ }
public static class WallpaperSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeletionHelperActivity extends SettingsActivity { /* empty */ }
public static class ApnEditorActivity extends SettingsActivity { /* empty */ }
public static class ChooseAccountActivity extends SettingsActivity { /* empty */ }
public static class IccLockSettingsActivity extends SettingsActivity { /* empty */ }
public static class ImeiInformationActivity extends SettingsActivity { /* empty */ }
public static class SimStatusActivity extends SettingsActivity { /* empty */ }
public static class StatusActivity extends SettingsActivity { /* empty */ }
public static class TestingSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiAPITestActivity extends SettingsActivity { /* empty */ }
public static class WifiInfoActivity extends SettingsActivity { /* empty */ }
// Categories.
public static class WirelessSettings extends SettingsActivity { /* empty */ }
public static class DeviceSettings extends SettingsActivity { /* empty */ }
public static class PersonalSettings extends SettingsActivity { /* empty */ }
public static class SystemSettings extends SettingsActivity { /* empty */ }
}
android7.1\packages\apps\Settings\src\com\android\settings\SettingsActivity.java
private void doUpdateTilesList() {
PackageManager pm = getPackageManager();
final UserManager um = UserManager.get(this);
final boolean isAdmin = um.isAdminUser();
String packageName = getPackageName();
setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm);
/**pm.hasSystemFeature(PackageManager.FEATURE_WIFI)通过判断是否有FEATURE_WIFI来确认是否使用WIFI设置项,定义在PackageManger.java public static final String FEATURE_WIFI = "android.hardware.wifi";**/
setTileEnabled(new ComponentName(packageName,
Settings.BluetoothSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.DataUsageSummaryActivity.class.getName()),
Utils.isBandwidthControlEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.SimSettingsActivity.class.getName()),
Utils.showSimCardTile(this), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.PowerUsageSummaryActivity.class.getName()),
mBatteryPresent, isAdmin, pm); //Battery设置项
setTileEnabled(new ComponentName(packageName,
Settings.UserSettingsActivity.class.getName()),
UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers()
&& !Utils.isMonkeyRunning(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.WirelessSettingsActivity.class.getName()),
!UserManager.isDeviceInDemoMode(this), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.DateTimeSettingsActivity.class.getName()),
!UserManager.isDeviceInDemoMode(this), isAdmin, pm);
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
setTileEnabled(new ComponentName(packageName,
Settings.PaymentSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_NFC)
&& pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
&& adapter != null && adapter.isEnabled(), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
Settings.PrintSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm);
final boolean showDev = mDevelopmentPreferences.getBoolean(
DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng"))
&& !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
setTileEnabled(new ComponentName(packageName,
Settings.DevelopmentSettingsActivity.class.getName()),
showDev, isAdmin, pm);
// Reveal development-only quick settings tiles
DevelopmentTiles.setTilesEnabled(this, showDev);
if (UserHandle.MU_ENABLED && !isAdmin) {
// When on restricted users, disable all extra categories (but only the settings ones).
List categories = getDashboardCategories();
for (DashboardCategory category : categories) {
for (Tile tile : category.tiles) {
ComponentName component = tile.intent.getComponent();
if (packageName.equals(component.getPackageName()) && !ArrayUtils.contains(
SETTINGS_FOR_RESTRICTED, component.getClassName())) {
setTileEnabled(component, false, isAdmin, pm);
}
}
}
}
String backupIntent = getResources().getString(R.string.config_backup_settings_intent);
boolean useDefaultBackup = TextUtils.isEmpty(backupIntent);
setTileEnabled(new ComponentName(packageName,
Settings.PrivacySettingsActivity.class.getName()), useDefaultBackup, isAdmin, pm);
boolean hasBackupActivity = false;
if (!useDefaultBackup) {
try {
Intent intent = Intent.parseUri(backupIntent, 0);
hasBackupActivity = !getPackageManager().queryIntentActivities(intent, 0).isEmpty();
} catch (URISyntaxException e) {
Log.e(LOG_TAG, "Invalid backup intent URI!", e);
}
}
setTileEnabled(new ComponentName(packageName,
BackupSettingsActivity.class.getName()), hasBackupActivity,
isAdmin || Utils.isCarrierDemoUser(this), pm);
}
android7.1\packages\apps\Settings\src\com\android\settings\SettingsActivity.java
private boolean mBatteryPresent = false; //default true ,by song to false;
if(mBatteryPresent) {
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
if ( mBatteryPresent ) {
unregisterReceiver(mBatteryInfoReceiver);
}
Android7.1
PackageManager pm = getPackageManager();
final UserManager um = UserManager.get(this);
final boolean isAdmin = um.isAdminUser();
String packageName = getPackageName();
setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()),
pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm);
if (!getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
getPreferenceScreen().removePreference(mUpgradeBluetoothRemote); //add by song
}