Android5.1-7.1系统(framework)定制、修改、移植、总结-上篇Android 5.1 - 7.1 系统(framework)定制、修改、移植、总结 - 上篇
⽬录
1:修改开机logo
修改开机logo有两种⽅法,⼀种直接去改c语⾔代码,第⼆种替换图⽚⽤python⽣成splash。第⼀种⽅法我没试过,感觉挺⿇烦的,还有分辨率限制,超过多少分辨率就不能⽤第⼀种⽅法。
1. 修改的⽂件路径LINUX/android/bootable/bootloader/lk/splash
2. 准备好logo图⽚(png、bmp格式)
3. 查看中原图⽚的分辨率,修改logo图⽚保证分辨率⼀致
4. ⽣成splash.img镜像⽂件
注:图⽚分辨率很重要!很重要!很重要!
⽣成splash.img 步骤
1.
The steps to generate a splash.img:
2.
3.
1 sudo apt-get install python-imaging
4.
5.
2 python ./logo_gen.py boot_001.png (*.bmp)
为了减少编译时间可以直接将⽣成好的splash.img将刷机包中的⽂件替换掉。
2:Framework(SysteimUI) Android在状态栏增加⽿机拔插图标
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中增加下⾯的代码:
1.
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
2.
@Override
3.
public void onReceive(Context context, Intent intent) {
4.
String action = Action();
5.
if (action.equals(Intent.ACTION_ALARM_CHANGED)) {
6.
updateAlarm(intent);
7.
}
8.
else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) {
9.
updateSyncState(intent);
10.
}
11.
else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
12.
action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
13.
updateBluetooth(intent);
14.
}
15.
/*add code for adding headset icon in statusbar.*/
16.
else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
17.
updateHeadsetState(intent);
18.
}
19.
//end
android软件else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
21.
action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {
22.
updateVolume();
23.
}
24.
else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
25.
updateSimState(intent);
26.
}
27.
else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) {
28.
updateTTY(intent);
29.
} else if (action.equals(Intent.ACTION_LOCALE_CHANGED)) {
30.
31.
// when acceptting the locale change event,reload USB connection notification.
32.
boolean isUsbConnected = mStorageManager.isUsbMassStorageConnected();
33.
34.
}
35.
}
36.
};
37.
38.
public PhoneStatusBarPolicy(Context context) {
39.
mContext = context;
40.
41.
// init StorageNotification object
42.
mStorageNotification = new StorageNotification(mContext);
43.
mService = (SystemService(Context.STATUS_BAR_SERVICE);
44.
45.
// listen for broadcasts
46.
IntentFilter filter = new IntentFilter();
47.
filter.addAction(Intent.ACTION_ALARM_CHANGED);
48.
filter.addAction(Intent.ACTION_SYNC_STATE_CHANGED);
49.
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
50.
filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
51.
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
52.
filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
53.
/*add code for adding headset icon in statusbar.*/
54.
filter.addAction(Intent.ACTION_HEADSET_PLUG);
55.
//end
56.
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
57.
filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
58.
59.
// add locale change event filter
60.
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
61.
62.
63.
int numPhones = Default().getPhoneCount();
64.
mSimState = new IccCard.State[numPhones];
65.
for (int i=0; i < numPhones; i++) {
66.
mSimState[i] = IccCard.State.READY;
67.
}
68.
// storage
69.
mStorageManager = (StorageManager) SystemService(Context.STORAGE_SERVICE);
70.
71.
72.
// TTY status
73.
mService.setIcon("tty", R.drawable.stat_sys_tty_mode, 0, null);
74.
mService.setIconVisibility("tty", false);
75.
76.
// Cdma Roaming Indicator, ERI
77.
mService.setIcon("cdma_eri", R.drawable.stat_sys_roaming_cdma_0, 0, null);
78.
mService.setIconVisibility("cdma_eri", false);
79.
80.
/
/ bluetooth status
81.
BluetoothAdapter adapter = DefaultAdapter();
82.
int bluetoothIcon = R.drawable.stat_sys_data_bluetooth;
83.
if (adapter != null) {
84.
mBluetoothEnabled = (State() == BluetoothAdapter.STATE_ON);
85.
if (ConnectionState() == BluetoothAdapter.STATE_CONNECTED) {
86.
bluetoothIcon = R.drawable.stat_sys_data_bluetooth_connected;
87.
}
88.
}
89.
mService.setIcon("bluetooth", bluetoothIcon, 0, null);
90.
mService.setIconVisibility("bluetooth", mBluetoothEnabled);
91.
92.
/*add code for adding headset icon in statusbar.*/
93.
mService.setIcon("headset", R.drawable.stat_sys_headset, 0, null);
94.
mService.setIconVisibility("headset", false);
95.
//end
96.
97.
// Alarm clock
98.
mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null);
99.
mService.setIconVisibility("alarm_clock", false);
100.
101.
// Sync state
102.
mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
103.
mService.setIcon("sync_failing", R.drawable.stat_sys_sync_error, 0, null);
104.
mService.setIconVisibility("sync_active", false);
105.
mService.setIconVisibility("sync_failing", false);
106.
107.
// volume
108.
mService.setIcon("volume", R.drawable.stat_sys_ringer_silent, 0, null);
109.
mService.setIconVisibility("volume", false);
110.
updateVolume();
111.
}
112.
113.
114.
/*add code for adding headset icon in statusbar.*/
115.
private final void updateHeadsetState(Intent intent) {
116.
boolean mIsHeadsetOn = (IntExtra("state", 0) == 1);
117.
Slog.v(TAG, "updateHeadsetState: HeadsetState: " + mIsHeadsetOn);
118.
119.
mService.setIconVisibility("headset", mIsHeadsetOn);
120.
}
在\frameworks\base\core\res\res\l中加⼊⽿机图标控制字段(headset):
1.
<string-array name="config_statusBarIcons">
2.
<item><xliff:g id="id">ime</xliff:g></item>
3.
<item><xliff:g id="id">sync_failing</xliff:g></item>
4.
<item><xliff:g id="id">sync_active</xliff:g></item>
5.
<item><xliff:g id="id">gps</xliff:g></item>
6.
<item><xliff:g id="id">bluetooth</xliff:g></item>
7.
<item><xliff:g id="id">nfc</xliff:g></item>
8.
<item><xliff:g id="id">tty</xliff:g></item>
9.
<item><xliff:g id="id">speakerphone</xliff:g></item>
10.
<item><xliff:g id="id">mute</xliff:g></item>
11.
<item><xliff:g id="id">volume</xliff:g></item>
12.
<item><xliff:g id="id">wifi</xliff:g></item>
13.
<item><xliff:g id="id">cdma_eri</xliff:g></item>
14.
<item><xliff:g id="id">phone_signal_second_sub</xliff:g></item>
15.
<item><xliff:g id="id">data_connection</xliff:g></item>
16.
<item><xliff:g id="id">phone_evdo_signal</xliff:g></item>
17.
<item><xliff:g id="id">phone_signal</xliff:g></item>
18.
<item><xliff:g id="id">battery</xliff:g></item>
19.
<item><xliff:g id="id">alarm_clock</xliff:g></item>
20.
<item><xliff:g id="id">secure</xliff:g></item>
21.
<item><xliff:g id="id">clock</xliff:g></item>
22.
<item><xliff:g id="id">headset</xliff:g></item>
23.
24.
</string-array>
因为所加代码中的 mService.setIcon和mService.setIconVisibility最终会调⽤到StatusBarManagerService,它的构造函数有
mIcons.StringArray(com.android.internal.fig_statusBarIcons));语句,到config_statusBarIcons所在的配置⽂件为l。如果没加,会再
seticon(StatusBarManagerService类⾥)函数⾥
3:Android--隐藏状态栏图标
⽬前状态栏图标有通知图标和系统图标
通知图标主要是指各应⽤发过来的通知,⽐如未接电话,截图,后台播放⾳乐等,系统图标主要有蓝⽛,⽿机,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 = (i);
+          final String pkg = PackageName();
+          android.util.Log.d("StatusBarIconController","pkg========"+pkg);
//⽐如如果包名不是收⾳机的,就不显⽰图标
+        if (!ains("com.android.fmradio")) {
+              continue;
}
if (notificationData.isAmbient(ent.key)
&& !NotificationData.ification)) {
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/l
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:paddingStart="7dp"
android:gravity="center_vertical|start"
+++            android:visibility="gone"  //时间
/
>
/frameworks/base/packages/SystemUI/res/layout/l
<com.android.systemui.BatteryMeterView android:id="@+id/battery"
android:layout_height="14.5dp"
android:layout_width="9.5dp"
+++    android:visibility="gone"      电池
android:layout_marginBottom="@dimen/battery_margin_bottom"/>
4:android 5.1 usb调试默认关闭设置⽅法
packages/apps/Provision/src/com/android/provision/DefaultActivity.java
在该⽂件中加⼊下⾯的代码:
1.
if (!android.Boolean("ro.inet.adb_enabled",true)) {
2.
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
3.
}
同时在system.prop中添加:
ro.inet.adb_enabled=false
5:【Audio】【⾳量曲线】【响度】如何修改⾳量曲线?
对应场景可能是:
当把媒体⾳量调到最⼩⼀级时,喇叭/⽿机⾳量仍然很⼤,如何解决?

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。