1.frameworks/base/core/java/android/provider/Settings.java中添加
/**
*Control whether to enable led indicator mod.
*@hide
*/
public static final String LED_INDICATOR_MODE=”led_indicator_mode”;
/**
*LED_INDICATOR_MODE value for off mode.
*@hide
*/
public static final int LED_INDICATOR_MODE=0;
/**
*LED_INDICATOR_MODE value for on mode.
*@hide
*/
public static final int LED_INDICATOR_MODE=1;
2.frameworks/base/packages/SettingsProvider/res/values/defaults.xml中添加
1
3.frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java中添加使led指示的键和键值存入数据库的操作
loadintegerSettings(stmt,Settings.System.LED_INDICATOR_MODE,
R.integer.def_led_indicator_mode);
4.packages/apps/Settings/res/values/string.xml中添加
Led indicator
5.packages/apps/Settings/res/xml/display_settings.xml中添加
6.在packages/apps/Settings/src/com/android/settings/display/中添加一个新文件LedIndicatorPreferenceController.java
package com.android.settings.display;
import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support..v14.preference.SwitchPreference;
import com.android.settings.core.PreferenceController;
import static android.provider.Settings.System.LED_INDICATOR_MODE;
import static android.provider.Settings.System.LED_INDICAATOR_MODE_OFF;
import static android.provider.Settings.System.LED_INDICAATOR_MODE_ON;
/**
* Created by songyan on 2017/12/28.
*/
public class LedIndecatorPreferenceController extends PreferenceController implements
Preference.OnPreferenceChangeListener{
private static final String KEY_LED_INDICATOR="led_indicator";
public LedIndecatorPreferenceController(Context context){
super(context);
}
@Override
public String getPreferenceKey(){
return KEY_LED_INDICATOR;
}
@Override
public void updateState(Preference preference){
int ledMode=Settings.System.getInt(mContext.getContentResolver(),
LED_INDICATOR_MODE,LED_INDICATOR_MODE_ON);
((SwitchPreference)preference).setChecked(ledMode==LED_INDICATOR_MODE_ON);
}
@Override
public boolean isAvailable(){
return true;
}
@Override
public boolean onPreferenceChange(Preference preference,Object newValue){
boolean isOn=(Boolean)newValue;
Settings.System.putInt(mContext.getContentResolver(),LED_INDICATOR_MODE,
isOn ? LED_INDICATOR_MODE_ON : LED_INDICATOR_MODE_OFF);
return true;
}
}
7.packages/apps/Settings/src/com/android/settings/DisplaySettings.java中添加
import com.android.settings.display.LedIndicatorPreferenceController;
private static final String KEY_LED_INDICATOR=”led_indicator”;
在buildPreferenceController方法中添加
controllers.add(new LedIndicatorPreferenceController(context));
8.frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java中添加
import static android.provider.Settings.System.LED_INDICATOR_MODE;
import static android.provider.Settings.System.LED_INDICATOR_MODE_OFF;
import static android.provider.Settings.System.LED_INDICATOR_MODE_ON
在updateLightsLocked()方法中添加
int ledMode=Settings.System.getInt(getContext().getContentResolver(),
LED_INDICATOR_MODE,LED_INDICATOR_MODE_ON);
if(ledNotification==null || mInCall || mScreenOn || ledMode==LED_INDICATOR_MODE_OFF){