修改开机logo有两种方法,一种直接去改c语言代码,第二种替换图片用python生成splash。第一种方法我没试过,感觉挺麻烦的,还有分辨率限制,超过多少分辨率就不能用第一种方法。
注:图片分辨率很重要!很重要!很重要!
生成splash.img 步骤
The steps to generate a splash.img:
1 sudo apt-get install python-imaging
2 python ./logo_gen.py boot_001.png (*.bmp)
为了减少编译时间可以直接将生成好的splash.img将刷机包中的文件替换掉。
Android 4.1在拔插耳机时,状态栏没有提示图标。最近做了这个新的需求,步骤如下:
1、在frameworks/base/packages/SystemUI/res/drawable-Xdpi下增加一个耳机图片stat_sys_headset.png。drawable-Xdpi中的X根据手机的分辨率来确定,我的手机用的是drawable-hdpi;
2、在frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java中增加下面的代码:
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_ALARM_CHANGED)) {
updateAlarm(intent);
}
else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) {
updateSyncState(intent);
}
else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
updateBluetooth(intent);
}
/*add code for adding headset icon in statusbar.*/
else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
updateHeadsetState(intent);
}
//end
else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {
updateVolume();
}
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
updateSimState(intent);
}
else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) {
updateTTY(intent);
} else if (action.equals(Intent.ACTION_LOCALE_CHANGED)) {
// when acceptting the locale change event,reload USB connection notification.
boolean isUsbConnected = mStorageManager.isUsbMassStorageConnected();
mStorageNotification.onUsbMassStorageConnectionChanged(isUsbConnected);
}
}
};
public PhoneStatusBarPolicy(Context context) {
mContext = context;
// init StorageNotification object
mStorageNotification = new StorageNotification(mContext);
mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE);
// listen for broadcasts
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_ALARM_CHANGED);
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
/*add code for adding headset icon in statusbar.*/
filter.addAction(Intent.ACTION_HEADSET_PLUG);
//end
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
// add locale change event filter
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
int numPhones = MSimTelephonyManager.getDefault().getPhoneCount();
mSimState = new IccCard.State[numPhones];
for (int i=0; i < numPhones; i++) {
mSimState[i] = IccCard.State.READY;
}
// storage
mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
mStorageManager.registerListener(mStorageNotification);
// TTY status
mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null);
mService.setIconVisibility("tty", false);
// Cdma Roaming Indicator, ERI
mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0, null);
mService.setIconVisibility("cdma_eri", false);
// bluetooth status
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
int bluetoothIcon = R.drawable.stat_sys_data_bluetooth;
if (adapter != null) {
mBluetoothEnabled = (adapter.getState() == BluetoothAdapter.STATE_ON);
if (adapter.getConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
}
}
mService.setIcon("bluetooth", bluetoothIcon, 0, null);
mService.setIconVisibility("bluetooth", mBluetoothEnabled);
/*add code for adding headset icon in statusbar.*/
mService.setIcon("headset", R.drawable.stat_sys_headset, 0, null);
mService.setIconVisibility("headset", false);
//end
// Alarm clock
mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null);
mService.setIconVisibility("alarm_clock", false);
// Sync state
mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
mService.setIcon("sync_failing", R.drawable.stat_sys_sync_error, 0, null);
mService.setIconVisibility("sync_active", false);
mService.setIconVisibility("sync_failing", false);
// volume
mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
mService.setIconVisibility("volume", false);
updateVolume();
}
/*add code for adding headset icon in statusbar.*/
private final void updateHeadsetState(Intent intent) {
boolean mIsHeadsetOn = (intent.getIntExtra("state", 0) == 1);
Slog.v(TAG, "updateHeadsetState: HeadsetState: " + mIsHeadsetOn);
mService.setIconVisibility("headset", mIsHeadsetOn);
}
在\frameworks\base\core\res\res\values\config.xml中加入耳机图标控制字段(headset):
ime
sync_failing
sync_active
gps
bluetooth
nfc
tty
speakerphone
mute
volume
wifi
cdma_eri
phone_signal_second_sub
data_connection
phone_evdo_signal
phone_signal
battery
alarm_clock
secure
clock
headset
因为所加代码中的 mService.setIcon和mService.setIconVisibility最终会调用到StatusBarManagerService,它的构造函数有mIcons.defineSlots(res.getStringArray(com.android.internal.R.array.config_statusBarIcons));语句,找到config_statusBarIcons所在的配置文件为config.xml。如果没加,会再seticon(StatusBarManagerService类里)函数里
目前状态栏图标有通知图标和系统图标
通知图标主要是指各应用发过来的通知,比如未接电话,截图,后台播放音乐等,系统图标主要有蓝牙,耳机,wifi,数据流量,时间和电池...
1,不显示通知图标,
在frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java中
public void updateNotificationIcons {
for (int i = 0; i < N; i++) {
NotificationData.Entry ent = activeNotifications.get(i);
+ final String pkg = ent.notification.getPackageName();
+ android.util.Log.d("StatusBarIconController","pkg========"+pkg);
//比如如果包名不是收音机的,就不显示图标
+ if (!pkg.contains("com.android.fmradio")) {
+ continue;
}
if (notificationData.isAmbient(ent.key)
&& !NotificationData.showNotificationEvenIfUnprovisioned(ent.notification)) {
continue;
}
}
2.不显示系统图标,系统图标的显示是在以下文件,比如蓝牙,wifi,耳机等
/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/
PhoneStatusBarPolicy.java
将不要显示图标,将setIconVisibility()改为false即可,比如,如果不要闹钟图标
public void updateNotificationIcons {
for (int i = 0; i < N; i++) {
NotificationData.Entry ent = activeNotifications.get(i);
+ final String pkg = ent.notification.getPackageName();
+ android.util.Log.d("StatusBarIconController","pkg========"+pkg);
//比如如果包名不是收音机的,就不显示图标
+ if (!pkg.contains("com.android.fmradio")) {
+ continue;
}
if (notificationData.isAmbient(ent.key)
&& !NotificationData.showNotificationEvenIfUnprovisioned(ent.notification)) {
continue;
}
}
2.不显示系统图标,系统图标的显示是在以下文件,比如蓝牙,wifi,耳机等
/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/
PhoneStatusBarPolicy.java
将不要显示图标,将setIconVisibility()改为false即可,比如,如果不要闹钟图标
private void updateAlarm() {
....
- - - mService.setIconVisibility(SLOT_ALARM_CLOCK, mCurrentUserSetup && hasAlarm);
+++ mService.setIconVisibility(SLOT_ALARM_CLOCK, false);
}
3,系统图标中比较特殊的时间和电池在
/frameworks/base/packages/SystemUI/res/layout/status_bar.xml