android 源碼修改記錄

1.長按power彈出三個選項,其中新增重啓和飛行模式。
 GlobalActions.java:
 
if(SystemProperties.getInt("ro.cenon_f27", 0)==1){// add by csc
		  mItems.add(new RebootAction());
            	}
	     }else if (GLOBAL_ACTION_KEY_AIRPLANE.equals(actionKey)) {       
	     if(SystemProperties.getInt("ro.cenon_f27", 0)==1){// add by csc
                mItems.add(mAirplaneModeOn);
				//mItems.add(new AirplaneAction());
	     	}


2.狀態欄左右全屏
SystemUI裏面的dimens.xml:
<dimen name="notification_side_padding">0dp</dimen><!-- mod by csc from 8dp -->

3.在主界面點擊拍照按鍵跳到相機
PhoneWindowManager.java:

if (keyCode == KeyEvent.KEYCODE_CAMERA && SystemProperties.getInt("ro.cenon_f27", 0)==1) {// add by csc 
		if(isHome(mContext)){// isHome(mContext) 判斷是否在主界面
		  	       Intent intent = new Intent(); 
				intent.setAction("android.media.action.STILL_IMAGE_CAMERA"); 
				startActivityAsUser(intent, UserHandle.CURRENT);
		  	}else{ 
				
			}


	  }

4.home和power鍵一起按截屏
PhoneWindowManager.java:
 case KeyEvent.KEYCODE_HOME:// add by csc
            	if(SystemProperties.getInt("ro.cenon_f27", 0)==1){// add by csc
            		
            	}else{
            		break;
            	}

5.整個launcher換掉將文件夾名字改爲F27_Launcher3 修改相應的Android.mk文件

/alps/device/mediatek/mt6755/device.mk:


# mod by csc from Launcher3 to F27_Launcher3
# add by csc
ifeq ($(strip $(CENON_F27)), yes)
	PRODUCT_PACKAGES += F27_Launcher3 
else 
	PRODUCT_PACKAGES += Launcher3 
endif

# add by csc
ifeq ($(strip $(CENON_F27)), yes)
	PRODUCT_PROPERTY_OVERRIDES += ro.cenon_f27=1
endif




/alps/cenon/make/F27.mk
#add by csc
CENON_F27 = yes




6.[FAQ11476]Launcher3如何設置桌面的行數和列數?(MediaTek On-Line)

Launcher3桌面的行數和列數都是在InvariantDeviceProfile.java和DeviceProfile.java中動態計算的,xml中無法配置。
Note:L版本無InvariantDeviceProfile.java,是DynamicGrid.java,但是計算方法都是一樣的。
InvariantDeviceProfile中用InvariantDeviceProfile來配置各種屏幕的手機桌面。如下:


 
 ArrayList<InvariantDeviceProfile> getPredefinedDeviceProfiles() {
        ArrayList<InvariantDeviceProfile> predefinedDeviceProfiles = new ArrayList<>();
        // width, height, #rows, #columns, #folder rows, #folder columns,
        // iconSize, iconTextSize, #hotseat, #hotseatIconSize, defaultLayoutId.
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Super Short Stubby",
                255, 300,     2, 3, 2, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Shorter Stubby",
                255, 400,     3, 3, 3, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Short Stubby",
                275, 420,     3, 4, 3, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Stubby",
                255, 450,     3, 4, 3, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus S",
                296, 491.33f, 4, 4, 4, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 4",
                335, 567,     4, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 5",
                359, 567,     4, 4, 4, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Large Phone",
                406, 694,     5, 5, 4, 4, 4, 64, 14.4f,  5, 56, R.xml.default_workspace_5x5));
        // The tablet profile is odd in that the landscape orientation
        // also includes the nav bar on the side
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 7",
                575, 904,     5, 6, 4, 5, 4, 72, 14.4f,  7, 60, R.xml.default_workspace_5x6));
        // Larger tablet profiles always have system bars on the top & bottom
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("Nexus 10",
                727, 1207,    5, 6, 4, 5, 4, 76, 14.4f,  7, 64, R.xml.default_workspace_5x6));
        predefinedDeviceProfiles.add(new InvariantDeviceProfile("20-inch Tablet",
                1527, 2527,   7, 7, 6, 6, 4, 100, 20,  7, 72, R.xml.default_workspace_4x4));
        return predefinedDeviceProfiles;
    }



InvariantDeviceProfile的各個參數依次代表:
配置名字(任意定義)、最小寬度(單位是dp)、最小高度(單位是dp)、桌面行數、桌面列數、文件夾行數、文件夾列數、主菜單中predicted apps最小列數、桌面Icon的size(單位是dp)、桌面Icon的文字size(單位是dp)、Hotseat的Icon個數、Hotseat的Icon的size(單位是dp)、默認的桌面配置LayoutId。
 
PS:
如何由手機分辨率計算最小寬度、最小高度?
例如:手機分辨率爲720*1280,DPI=320。
豎屏時:X*Y=720*1230(1230=屏幕高度-狀態欄高度-NavigationBar高度)
橫屏時:Y*X=646*1280(646=屏幕寬度-狀態欄高度-NavigationBar高度)
最小寬度爲:323=Min(720,646)/(320/160)
最小高度爲:615=Min(1230,1280)/(320/160)
 
如果要配置自己手機桌面的行數、列數、Hotseat的Icon個數,需要計算"桌面Icon的size、桌面Icon的文字size、Hotseat的Icon的size",計算方式如下:
1、挑選三個和自己的手機配置最接近的DeviceProfile。最接近意味着dn 最小。
dn 的計算公式爲:


 2、由逆距離加權插值計算結果,計算公式如下:






計算結果爲:
 
 r1+r2+r3
 
 
例如:手機的最小寬度爲294dp,最小高度爲544dp。
1、挑選三個和自己的手機配置最接近的DeviceProfile:
▪Nexus S,distance is 52
▪Nexus 4,distance is 69
▪Stubby,distance is 102
2、由逆距離權重差值計算結果:




 
 
Hotseat的Icon的size爲:37.57+10.65+1.29 = 49dp
dp轉換爲px:如果手機DPI=240,那麼dp應該乘以1.5(240/160)轉換爲px,即49dp=73.5px。
桌面Icon的size、桌面Icon的文字size 計算與此類似。






7.當配置文件宏開關不好加的時候,將文件寫入/alps/cenon


如alps/cenon/frameworks/f27/base/packages/SystemUI/res/values 下面放入改過的文件
然後修改/alps/mkCenon,如下面的第4項就是新增的frameworks內容



filename1=cenon/vendor/$CENON_CUSTOM_DIR
filename2=cenon/kernel-3.18/$CENON_CUSTOM_DIR
filename3=cenon/device/$CENON_CUSTOM_DIR
filename4=cenon/frameworks/$CENON_CUSTOM_DIR
if [ ! -e $filename1 ]; 
then
echo $filename1 $filename2 $filename3 $filename4 not exist,pls check in the directory $filename1 $filename2 $filename3 $filename4
else
mkdir cenon_temp1 cenon_temp2 cenon_temp3 cenon_temp4
cp -rf $filename1/* cenon_temp1/
cp -rf $filename2/* cenon_temp2/
cp -rf $filename3/* cenon_temp3/
cp -rf $filename4/* cenon_temp4/
find cenon_temp1/ -name .svn | xargs rm -rf
find cenon_temp2/ -name .svn | xargs rm -rf
find cenon_temp3/ -name .svn | xargs rm -rf
find cenon_temp4/ -name .svn | xargs rm -rf
cp -rf cenon_temp1/* vendor
cp -rf cenon_temp2/* kernel-3.18
cp -rf cenon_temp3/* device/cenon/$PROJECT_NAME
cp -rf cenon_temp4/* frameworks
rm -r cenon_temp1 cenon_temp2 cenon_temp3 cenon_temp4
fi




8.來電去電默認打開揚聲器
src/com/android/incallui/CallButtonFragment.java
onResume()裏面加入:
 new Handler().postDelayed(new Runnable(){
            public void run() {
                AudioManager audioManager = (AudioManager) mContext.getSystemService  (Context.AUDIO_SERVICE);
                if(!audioManager.isSpeakerphoneOn()) {
                    getPresenter().toggleSpeakerphone();
                }
                updateAudioButtons(getPresenter().getSupportedAudio());
            }
        }, 500);




9.狀態欄下拉設置裏的藍牙和wifi界面下面的文字上移:
res/layout/qs_detail.xml


+    <!--add by csc android:layout_marginTop="-120dp"-->
     <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:paddingEnd="8dp"
+            android:layout_marginTop="-120dp"
             android:gravity="end">
 
         <TextView



10.設置裏面增加媒體音量控制


M       res_ext/xml/edit_profile_prefs.xml
M       src/com/mediatek/audioprofile/Editprofile.java


開放edit_profile_prefs.xml的佈局代碼
Editprofile.java的initVolume(PreferenceScreen parent)方法加initVolumePreference(KEY_MEDIA_VOLUME, AudioManager.STREAM_MUSIC);





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章