Android 源码热门改动速查(持续更新.....)

1、8.1 默认音量调整

frameworks\base\media\java\android\media\AudioSystem.java
修改 DEFAULT_STREAM_VOLUME 数组,最大值和最小值修改对应文件

frameworks\base\services\core\java\com\android\server\audio\AudioService.java

MIN_STREAM_VOLUME MAX_STREAM_VOLUME

媒体音量在 AudioService 中被初始化修改了,可以强制赋值

AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_MUSIC] = defaultMusicVolume;

或可以通过配置 ro.config.media_vol_default 修改

device\mediateksample\xxxx\system.prop

2、USB 连接图标修改

frameworks\base\core\res\res\drawable-nodpi\stat_sys_adb.xml

6.0 以前都一直使用小机器人图标,8.1 是 奥利奥图标,9.0 是 P图标,如果怀旧可以从 6.0 复制并覆盖

3、系统触摸提示音开启和关闭

vendor\mediatek\proprietary\packages\apps\SettingsProvider\res\values\defaults.xml

<!-- Default for UI touch sounds enabled -->
<bool name="def_sound_effects_enabled">true</bool>

java 代码中可通过

 private void handleSoundEffects(boolean isOpen){
        Settings.System.putInt(getContentResolver(),
                Settings.System.SOUND_EFFECTS_ENABLED, isOpen ? 1 : 0);
        final AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        if (isOpen) {
            am.loadSoundEffects();
        } else {
            am.unloadSoundEffects();
        }
    }

如要替换触摸提示音可至路径 frameworks\base\data\sounds\effects\Effect_Tick.ogg

4、修改系统默认字体大小

查看系统支持的字体大小范围
vendor\mediatek\proprietary\packages\apps\MtkSettings\res\values\arrays.xml

    <string-array name="entryvalues_font_size" translatable="false">
        <item>0.85</item>
        <item>1.0</item>
        <item>1.15</item>
        <item>1.30</item>
    </string-array>

以下三处地方的改动,请根据实际生效情况而定

1、frameworks\base\core\java\android\provider\Settings.java

 public static final class System extends NameValueTable {
	private static final float DEFAULT_FONT_SCALE = 1.0f;

2、frameworks\base\core\java\android\content\res\Configuration.java

    public void setToDefaults() {
        fontScale = 1;
        mcc = mnc = 0;

3、vendor\mediatek\proprietary\packages\apps\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java

private void loadSystemSettings(SQLiteDatabase db) {
		....
loadSetting(stmt, Settings.System.FONT_SCALE, 0.85f);

5、休眠时间增加永不息屏选项

vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/arrays.xml

+++ b/alps/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/arrays.xml
@@ -37,6 +37,7 @@
     <item msgid="7489864775127957179">"5分钟"</item>
     <item msgid="2314124409517439288">"10分钟"</item>
     <item msgid="6864027152847611413">"30分钟"</item>
+    <item msgid="7149253832238213885">"永不息屏"</item>
   </string-array>
   <string-array name="dream_timeout_entries">
     <item msgid="3149294732238283185">"永不"</item>

vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/arrays.xml

+++ b/alps/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/arrays.xml
@@ -48,6 +48,7 @@
         <item>5 minutes</item>
         <item>10 minutes</item>
         <item>30 minutes</item>
+        <item>never</item>
     </string-array>
 
     <!-- Do not translate. -->
@@ -66,6 +67,8 @@
         <item>600000</item>
         <!-- Do not translate. -->
         <item>1800000</item>
+        <!-- MAX. -->
+        <item>2147483647</item>
     </string-array>

Android 8.1
vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/TimeoutPreferenceController.java

+++ b/alps/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/display/TimeoutPreferenceController.java
@@ -111,7 +111,11 @@ public class TimeoutPreferenceController extends AbstractPreferenceController im
         } else {
             final CharSequence timeoutDescription = getTimeoutDescription(
                     currentTimeout, entries, values);
-            summary = timeoutDescription == null
+            //cczheng add for show never sleep
+            if (currentTimeout == Integer.MAX_VALUE)
+                summary = entries[entries.length-1].toString();
+            else
+                summary = timeoutDescription == null
                     ? ""
                     : mContext.getString(R.string.screen_timeout_summary, timeoutDescription);
         }

Android6.0
packages\apps\Settings\src\com\android\settings\DisplaySettings.java

private void updateTimeoutPreferenceDescription(long currentTimeout) {
        ListPreference preference = mScreenTimeoutPreference;
        String summary;
        if (currentTimeout < 0) {
            // Unsupported value
            summary = "";
        } else {
            final CharSequence[] entries = preference.getEntries();
            final CharSequence[] values = preference.getEntryValues();
            if (entries == null || entries.length == 0) {
                summary = "";
            } else {
                int best = 0;
                for (int i = 0; i < values.length; i++) {
                    long timeout = Long.parseLong(values[i].toString());
                    if (currentTimeout >= timeout) {
                        best = i;
                    }
                }
                //cczheng add for show never sleep
                if (currentTimeout == Integer.MAX_VALUE)
                    summary = entries[best].toString();
                else
                    summary = preference.getContext().getString(R.string.screen_timeout_summary,
                        entries[best]);
            }
        }
        preference.setSummary(summary);
    }

6、Launcher的 hotseat 自动上下跳动

vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\Launcher.java
注释onResume() 中的如下方法

 @Override
    protected void onResume() {
        long startTime = 0;
        	....
		/*if (shouldShowDiscoveryBounce()) {
            mAllAppsController.showDiscoveryBounce();
        }*/

7、非系统拨号应用呼叫紧急号码直接呼出,不跳转至Dialer

vendor\mediatek\proprietary\packages\services\Telecomm\src\com\android\server\telecom\NewOutgoingCallIntentBroadcaster.java

去除 mIsDefaultOrSystemPhoneApp 判断

    @VisibleForTesting
    public int processIntent() {
        Log.v(this, "Processing call intent in OutgoingCallIntentBroadcaster.");

		....

		if (Intent.ACTION_CALL.equals(action)) {
            if (isPotentialEmergencyNumber) {
                //cczheng remove the default Dialer islaunched when call an EmergencyNumber
                /*if (!mIsDefaultOrSystemPhoneApp) {
                    Log.w(this, "Cannot call potential emergency number %s with CALL Intent %s "
                            + "unless caller is system or default dialer.", number, intent);
                    launchSystemDialer(intent.getData());
                    return DisconnectCause.OUTGOING_CANCELED;
                } else {*/
                    callImmediately = true;
                //}
            }
        } else if (Intent.ACTION_CALL_EMERGENCY.equals(action)) {
		......

8、vlote电话自动转语音电话通知

vendor\mediatek\proprietary\packages\apps\Dialer\java\com\android\incallui\InCallActivity.java

private String lastUIScreenShow;
  private String currentUIScreen;
  private void showMainInCallFragment() {
    // If the activity's onStart method hasn't been called yet then defer doing any work.
    if (!isVisible) {
      LogUtil.i("InCallActivity.showMainInCallFragment", "not visible yet/anymore");
      return;
    }

    // Don't let this be reentrant.
    if (isInShowMainInCallFragment) {
      LogUtil.i("InCallActivity.showMainInCallFragment", "already in method, bailing");
      return;
    }

    isInShowMainInCallFragment = true;
    ShouldShowUiResult shouldShowAnswerUi = getShouldShowAnswerUi();
    ShouldShowUiResult shouldShowVideoUi = getShouldShowVideoUi();
    LogUtil.d(
        "InCallActivity.showMainInCallFragment",
        "shouldShowAnswerUi: %b, shouldShowVideoUi: %b, "
            + "didShowAnswerScreen: %b, didShowInCallScreen: %b, didShowVideoCallScreen: %b",
        shouldShowAnswerUi.shouldShow,
        shouldShowVideoUi.shouldShow,
        didShowAnswerScreen,
        didShowInCallScreen,
        didShowVideoCallScreen);
     android.util.Log.i(
        "InCallActivity.showMainInCallFragment",
        String.format("shouldShowAnswerUi: %b, shouldShowVideoUi: %b, "
            + "didShowAnswerScreen: %b, didShowInCallScreen: %b, didShowVideoCallScreen: %b",
        shouldShowAnswerUi.shouldShow,
        shouldShowVideoUi.shouldShow,
        didShowAnswerScreen,
        didShowInCallScreen,
        didShowVideoCallScreen));
    /// M:[ALPS03482828] modify allow orientation conditions.incallactivity and videocallpresenter
    ///have conflicts on allow orientation.keep incallactivity and videocallpresenter have same
    ///conditions. @{
    /// Google original code:@{
    // Only video call ui allows orientation change.
    //setAllowOrientationChange(shouldShowVideoUi.shouldShow);
    ///@}
    setAllowOrientationChange(isAllowOrientation(shouldShowAnswerUi,shouldShowVideoUi));
    ///@}
    /// M:ALPS03538860 clear rotation when disable incallOrientationEventListner.@{
    common.checkResetOrientation();
    ///@}
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    boolean didChangeInCall;
    boolean didChangeVideo;
    boolean didChangeAnswer;
    if (shouldShowAnswerUi.shouldShow) {
       currentUIScreen = "answercall";
      LogUtil.d("showMainInCallFragment", "showAnswerScreenFragment");
      didChangeInCall = hideInCallScreenFragment(transaction);
      didChangeVideo = hideVideoCallScreenFragment(transaction);
      didChangeAnswer = showAnswerScreenFragment(transaction, shouldShowAnswerUi.call);
    } else if (shouldShowVideoUi.shouldShow) {
       currentUIScreen = "videocall";
      LogUtil.d("showMainInCallFragment", "showVideoCallScreenFragment");
      didChangeInCall = hideInCallScreenFragment(transaction);
      didChangeVideo = showVideoCallScreenFragment(transaction, shouldShowVideoUi.call);
      didChangeAnswer = hideAnswerScreenFragment(transaction);
    /// M: Hide incall screen when exist waiting account call. @{
    } else if (CallList.getInstance().getWaitingForAccountCall() != null) {
       currentUIScreen = "nocall";
      LogUtil.d("showMainInCallFragment", "hide all");
      didChangeInCall = hideInCallScreenFragment(transaction);
      didChangeVideo = hideVideoCallScreenFragment(transaction);
      didChangeAnswer = hideAnswerScreenFragment(transaction);
    /// @}
    } else {
      currentUIScreen = "incall";
       LogUtil.d("showMainInCallFragment", "showInCallScreenFragment");
      didChangeInCall = showInCallScreenFragment(transaction);
      didChangeVideo = hideVideoCallScreenFragment(transaction);
      didChangeAnswer = hideAnswerScreenFragment(transaction);
    }

    //voltecall no support auto change voicecall
    if ("videocall".equals(lastUIScreenShow) && "incall".equals(currentUIScreen)) {
       LogUtil.i("showMainInCallFragment", "voltecall---->voicecall");
       sendBroadcast(new Intent("com.android.incall.volte2voice").addFlags(0x01000000));
    }

    if (didChangeInCall || didChangeVideo || didChangeAnswer) {
      transaction.commitNow();
      Logger.get(this).logScreenView(ScreenEvent.Type.INCALL, this);
    }
    isInShowMainInCallFragment = false;

    lastUIScreenShow = currentUIScreen;
  }

9、vlote电话刷机后第一次来电页面不显示预览权限问题

vendor/mediatek/proprietary/packages/apps/Dialer/java/com/android/incallui/videotech/utils/VideoUtils.java

@@ -50,7 +50,8 @@ public class VideoUtils {
     ///choose. so incallui will set camera is null to vtservice.VTservice will get stuck. @{
     return isTestSim() ? hasCameraPermission(context) :
     ///@}
-           (PermissionsUtil.hasCameraPrivacyToastShown(context) && hasCameraPermission(context));
+           (/*PermissionsUtil.hasCameraPrivacyToastShown(context) &&*/ hasCameraPermission(context));
+// annotaion for first don't show Video is off,don't toast tell have open camera permission
   }
 
   public static boolean hasCameraPermission(@NonNull Context context) {

10、Dialer 通话界面背景色随机切换问题,修改默认为蓝色

vendor/mediatek/proprietary/packages/apps/Dialer/java/com/android/incallui/ThemeColorManager.java

@@ -97,14 +97,17 @@ public class ThemeColorManager {
       backgroundColorMiddle = context.getColor(R.color.incall_background_gradient_middle);
       backgroundColorBottom = context.getColor(R.color.incall_background_gradient_bottom);
       backgroundColorSolid = context.getColor(R.color.incall_background_multiwindow);
-      if (highlightColor != PhoneAccount.NO_HIGHLIGHT_COLOR) {
+      android.util.Log.e("ccd","updateThemeColors() ="+ (highlightColor != PhoneAccount.NO_HIGHLIGHT_COLOR));
+      //annotation for incallbg show blue not green
+      //IncallActivity updateWindowBackgroundColor()
+      /*if (highlightColor != PhoneAccount.NO_HIGHLIGHT_COLOR) {
         // The default background gradient has a subtle alpha. We grab that alpha and apply it to
         // the phone account color.
         backgroundColorTop = applyAlpha(palette.mPrimaryColor, backgroundColorTop);
         backgroundColorMiddle = applyAlpha(palette.mPrimaryColor, backgroundColorMiddle);
         backgroundColorBottom = applyAlpha(palette.mPrimaryColor, backgroundColorBottom);
         backgroundColorSolid = applyAlpha(palette.mPrimaryColor, backgroundColorSolid);
-      }
+      }*/
     }
 
     primaryColor = palette.mPrimaryColor;

11、Volte 通话界面预览图像拉伸bug修改

设置预览宽高的方法在 VideoCallFragment 中

vendor\mediatek\proprietary\packages\apps\Dialer\java\com\android\incallui\video\impl\VideoCallFragment.java

private void updatePreviewVideoScaling() {
    if (previewTextureView.getWidth() == 0 || previewTextureView.getHeight() == 0) {
      LogUtil.i("VideoCallFragment.updatePreviewVideoScaling", "view layout hasn't finished yet");
      return;
    }
    VideoSurfaceTexture localVideoSurfaceTexture =
        videoCallScreenDelegate.getLocalVideoSurfaceTexture();
    Point cameraDimensions = localVideoSurfaceTexture.getSurfaceDimensions();

	....}

private void updateRemoteVideoScaling() {
    VideoSurfaceTexture remoteVideoSurfaceTexture =
        videoCallScreenDelegate.getRemoteVideoSurfaceTexture();
    Point videoSize = remoteVideoSurfaceTexture.getSourceVideoDimensions();
    if (videoSize == null) {
      LogUtil.i("VideoCallFragment.updateRemoteVideoScaling", "video size is null");
      return;
    }
    if (remoteTextureView.getWidth() == 0 || remoteTextureView.getHeight() == 0) {
      LogUtil.i("VideoCallFragment.updateRemoteVideoScaling", "view layout hasn't finished yet");
      return;
    }

    // If the video and display aspect ratio's are close then scale video to fill display
    float videoAspectRatio = ((float) videoSize.x) / videoSize.y;
    float displayAspectRatio =
        ((float) remoteTextureView.getWidth()) / remoteTextureView.getHeight();
    float delta = Math.abs(videoAspectRatio - displayAspectRatio);

最终实际是在 VideoScale 中,通过对调宽高来修改比例

vendor\mediatek\proprietary\packages\apps\Dialer\java\com\android\incallui\videosurface\impl\VideoScale.java

public class VideoScale {
  /**
   * Scales the video in the given view such that the video takes up the entire view. To maintain
   * aspect ratio the video will be scaled to be larger than the view.
   */
  public static void scaleVideoAndFillView(
      TextureView textureView, float videoWidth, float videoHeight, float rotationDegrees) {
    // add for localPreView smaller bug
    if (videoWidth > videoHeight) {
      float tmpVideoWidth = videoWidth;
      videoWidth = videoHeight;
      videoHeight = tmpVideoWidth;
      LogUtil.i("VideoScale.scaleVideoAndFillView","need change width and height");
    }//E
    float viewWidth = textureView.getWidth();
    float viewHeight = textureView.getHeight();
    float viewAspectRatio = viewWidth / viewHeight;
    float videoAspectRatio = videoWidth / videoHeight;
    float scaleWidth = 1.0f;
    float scaleHeight = 1.0f;

    if (viewAspectRatio > videoAspectRatio) {
      // Scale to exactly fit the width of the video. The top and bottom will be cropped.
      float scaleFactor = viewWidth / videoWidth;
      float desiredScaledHeight = videoHeight * scaleFactor;
      scaleHeight = desiredScaledHeight / viewHeight;
    } else {
      // Scale to exactly fit the height of the video. The sides will be cropped.
      float scaleFactor = viewHeight / videoHeight;
      float desiredScaledWidth = videoWidth * scaleFactor;
      scaleWidth = desiredScaledWidth / viewWidth;
    }

    if (rotationDegrees == 90.0f || rotationDegrees == 270.0f) {
      // We're in landscape mode but the camera feed is still drawing in portrait mode. Normally,
      // scale of 1.0 means that the video feed stretches to fit the view. In this case the X axis
      // is scaled to fit the height and the Y axis is scaled to fit the width.
      float scaleX = scaleWidth;
      float scaleY = scaleHeight;
      scaleWidth = viewHeight / viewWidth * scaleY;
      scaleHeight = viewWidth / viewHeight * scaleX;

      // This flips the view vertically. Without this the camera feed would be upside down.
      scaleWidth = scaleWidth * -1.0f;
      // This flips the view horizontally. Without this the camera feed would be mirrored (left
      // side would appear on right).
      scaleHeight = scaleHeight * -1.0f;
    }

    LogUtil.i(
        "VideoScale.scaleVideoAndFillView",
        "view: %f x %f, video: %f x %f scale: %f x %f, rotation: %f",
        viewWidth,
        viewHeight,
        videoWidth,
        videoHeight,
        scaleWidth,
        scaleHeight,
        rotationDegrees);

    Matrix transform = new Matrix();
    transform.setScale(
        scaleWidth,
        scaleHeight,
        // This performs the scaling from the horizontal middle of the view.
        viewWidth / 2.0f,
        // This perform the scaling from vertical middle of the view.
        viewHeight / 2.0f);
    if (rotationDegrees != 0) {
      transform.postRotate(rotationDegrees, viewWidth / 2.0f, viewHeight / 2.0f);
    }
    textureView.setTransform(transform);
  }


12、修改系统默认显示大小

packages\apps\Provision\src\com\android\provision\DefaultActivity.java


   setDefaultDisplaySmall(this);
  
    public void setDefaultDisplaySmall(Context mContext){
        final com.android.settingslib.display.DisplayDensityUtils density 
        = new com.android.settingslib.display.DisplayDensityUtils(mContext);
        int mDefaultDensity;
        int[] mValues;

        final int initialIndex = density.getCurrentIndex();
        android.util.Log.e("DefaultActivity", "initialIndex="+initialIndex);
        if (initialIndex < 0) {
            // Failed to obtain default density, which means we failed to
            // connect to the window manager service. Just use the current
            // density and don't let the user change anything.
            final int densityDpi = mContext.getResources().getDisplayMetrics().densityDpi;
            mValues = new int[] { densityDpi };
            mDefaultDensity = densityDpi;
        } else {
            mValues = density.getValues();
            mDefaultDensity = density.getDefaultDensity();
        }

        for (int i = 0; i < mValues.length; i++) {
           android.util.Log.e("DefaultActivity", "mValues[" + i + "] = " + mValues[i]);
        }
        android.util.Log.e("DefaultActivity", "mDefaultDensity =  " + mDefaultDensity);
        com.android.settingslib.display.DisplayDensityUtils
        .setForcedDisplayDensity(android.view.Display.DEFAULT_DISPLAY, mValues[0]);
    }

packages\apps\Provision\Android.mk

include vendor/mediatek/proprietary/packages/apps/SettingsLib/common.mk
include $(BUILD_PACKAGE)

13、默认显示电池电量百分比

packages\apps\Provision\src\com\android\provision\DefaultActivity.java

Settings.System.putInt(getContentResolver(), Settings.System.SHOW_BATTERY_PERCENT, 1);

14、启用屏保

adb shell settings put secure screensaver_enabled 0

Settings.Secure.SCREENSAVER_ENABLED

15、无障碍服务重启默认授权

在设置中监听开机广播,收到后执行如下代码
传递参数app 包名和无障碍服务类名

    private void checkAccessibilitySeviceGrant(Context mContext, String pkgName, String clsName){
        android.content.ComponentName mComponentName = new android.content.ComponentName(pkgName, clsName);
        final boolean isGranted 
        = com.android.settingslib.accessibility.AccessibilityUtils.getEnabledServicesFromSettings(mContext)
                .contains(mComponentName);
        if (isGranted) return;

        android.util.Log.e("acceGrant","PackageName="+mComponentName.getPackageName()+ " ClassName="+mComponentName.getClassName());
        com.android.settingslib.accessibility.AccessibilityUtils
        .setAccessibilityServiceState(mContext, mComponentName, true);
    }

16、MTK R 版本屏蔽插入 SIM 开机系统语言自动切换问题

问题原因,预制 GMS包,Google SetupWizard 引导页面会在识别到 SIM 卡后根据 sim 卡国家码将系统语言自动切换

有些客户不要这个功能,可以查看 adb shell getprop persist.sys.locale 修改后的语言

解决办法

frameworks\opt\telephony\src\java\com\android\internal\telephony\MccTable.java

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q,
            publicAlternatives = "There is no alternative for {@code MccTable.entryForMcc}, "
                    + "but it was included in hidden APIs due to a static analysis false positive "
                    + "and has been made greylist-max-q. Please file a bug if you still require "
                    + "this API.")
    public static MccEntry entryForMcc(int mcc) {
        MccEntry m = new MccEntry(mcc, "", 0);
        //cczheng add 
        //int index = Collections.binarySearch(sTable, m);
        int index = -1;//end
        if (index < 0) {
            return null;
        } else {
            return sTable.get(index);
        }
    }

插入中国sim卡 mcc 打印 460

详细流程可以参考

Android 根据SIM卡自动切换语言

Android L SIM卡自适应更新语言的问题

17、改横屏后通话界面二次拨号盘显示拥挤问题

二次拨号盘实际是 DialpadFragment, 在 InCallActivity 中调用 showDialpadFragment() 进行替换

用 id 为 incall_dialpad_container FrameLayout 进行替换,所以根源在这里

packages\apps\Dialer\java\com\android\incallui\incall\impl\res\layout\frag_incall_voice.xml

    <!-- remove this for incallui DialpadFragment DialpadView smaller bug 
        style="@style/DialpadContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" -->
    <FrameLayout
        android:id="@+id/incall_dialpad_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:clipChildren="false"
        android:clipToPadding="false"
        tools:background="@android:color/white"
        tools:visibility="gone"/>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cczhengv

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值