android 源码修改记录

xiaoxiao2021-02-28  142

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);
转载请注明原文地址: https://www.6miu.com/read-39665.html

最新回复(0)