Android定制之常见问题解决

此修改基于MTK|SPRD平台,Android O/Android GO

状态栏默认显示电量百分比

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
这样修改不知道是不是不规范, 因为注释IMPORTANT: Do not add any more upgrade steps here as the global

@@ -2338,7 +2338,12 @@ class DatabaseHelper extends SQLiteOpenHelper {
             // set default button light timeout.
             loadIntegerSetting(stmt, Settings.System.BUTTON_LIGHT_OFF_TIMEOUT,
                     R.integer.def_button_light_off_timeout);
-
+            //add for default show battery percent @2018-08-09 {
+            if (SystemProperties.getBoolean("ro.bdfun.show_battery_perecnt", true)){
+                loadSetting(stmt, Settings.System.SHOW_BATTERY_PERCENT, 1);
+            }
+            /// @}
/*
              * IMPORTANT: Do not add any more upgrade steps here as the global,
              * secure, and system settings are no longer stored in a database

关闭未知来源, 包括所有系统软件

设置-应用和通知-高级-特殊应用权限-安装未知应用
frameworks/base//core/java/android/app/AppOpsManager.java

@@ -957,7 +957,7 @@ public class AppOpsManager {
             AppOpsManager.MODE_ALLOWED,  // OP_RUN_IN_BACKGROUND
             AppOpsManager.MODE_ALLOWED,  // OP_AUDIO_ACCESSIBILITY_VOLUME
             AppOpsManager.MODE_ALLOWED,
-            AppOpsManager.MODE_DEFAULT,  // OP_REQUEST_INSTALL_PACKAGES
+            AppOpsManager.MODE_ERRORED,  // OP_REQUEST_INSTALL_PACKAGES // modified  for turn off unknown source default
             AppOpsManager.MODE_ALLOWED,  // OP_PICTURE_IN_PICTURE
             AppOpsManager.MODE_DEFAULT,  // OP_INSTANT_APP_START_FOREGROUND
             AppOpsManager.MODE_ALLOWED, // ANSWER_PHONE_CALLS

//Android O已经默认移除了总开关未知来源选项框, 随之添加的是对有安装应用权限的应用的未知来源选项, 但是发现这样修改后是默认关闭了所以应用的未知来源选项, 却发现所有应用的显示出来了(没有安装应用权限的应用是没有必要显示的), 这样修改貌似不是很科学

不开移动数据不能发送彩信

vendor/mediatek/proprietary/frameworks/opt/telephony

@@ -52,6 +52,7 @@ import com.mediatek.internal.telephony.MtkGsmCdmaPhone;
 import com.mediatek.internal.telephony.MtkPhoneConstants;

 import java.util.ArrayList;
+import android.os.SystemProperties; // add

 /** DataConnectionExt is default implementation for Data Plugin. */
 public class DataConnectionExt implements IDataConnectionExt {
@@ -82,7 +83,7 @@ public class DataConnectionExt implements IDataConnectionExt {
     @Override
     public boolean isDataAllowedAsOff(String apnType) {
         if (TextUtils.equals(apnType, PhoneConstants.APN_TYPE_DEFAULT) ||
-                TextUtils.equals(apnType, PhoneConstants.APN_TYPE_MMS) ||
+                (!SystemProperties.getBoolean("ro.func.open_nodata_send_mms", false) && TextUtils.equals(apnType, PhoneConstants.APN_TYPE_MMS)) ||  // add for no internet connect to send mm
                 TextUtils.equals(apnType, PhoneConstants.APN_TYPE_DUN)) {
             return false;
         }

图标图标字体显示不全,修改为显示两行

这里对于图标字体显示不全当然还可以改为跑马灯效果
// 如需修改Luncher3文件夹的两行显示, 也在DeviceProfile.java文件中, 方法类似
packages/apps/Launcher3/src/com/android/launcher3/BubbleTextView.java

public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver {
+       setSingleLine(false);
+       setMaxlines(2);
+       setTextSize(TypedValue.COMPLEX_UNIT_SP, 13); // 字体大小视情况决定

packages/apps/Launcher3/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java

public class DeviceProfile {
         iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale);

         cellHeightPx = iconSizePx + iconDrawablePaddingPx
-                + Utilities.calculateTextHeight(iconTextSizePx);
+                + Utilities.calculateTextHeight(iconTextSizePx) * 2;
         int cellYPadding = (getCellSize().y - cellHeightPx) / 2;
         if (iconDrawablePaddingPx > cellYPadding && !isVerticalBarLayout()
                 && !inMultiWindowMode()) {
public class DeviceProfile {
         allAppsIconTextSizePx = iconTextSizePx;
         allAppsIconSizePx = iconSizePx;
         allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
-        allAppsCellHeightPx = getCellSize().y;
+        allAppsCellHeightPx = getCellSize().y + Utilities.calculateTextHeight(iconTextSizePx);
         if (isVerticalBarLayout()) {
        // Always hide the Workspace text with vertical bar layout.

客户要求,将CARD改为SIM

vendor/mediatek/proprietary/packages/apps/SystemUI/
src/com/mediatek/keyguard/Telephony/KeyguardSimPinPukMeView.java

public class KeyguardSimPinPukMeView extends KeyguardPinBasedInputView {
             ///   fetch the latest/updated active sub list.
             SubscriptionInfo info = mUpdateMonitor.getSubscriptionInfoForSubId(subId, forceReload);
             CharSequence displayName = info != null ? info.getDisplayName() : ""; // don't crash
+            displayName = ((String) displayName).replace("CARD 1","SIM 1").replace("CARD 2","SIM 2");
             // M: add for ALPS02475558
             if (info == null) {
-                displayName = "CARD " + Integer.toString(mPhoneId + 1);
+                displayName = "SIM " + Integer.toString(mPhoneId + 1);
                 Log.d(TAG, "we set a displayname");
             }
             Log.d(TAG, "resetState() - subId = " + subId + ", displayName = " + displayName) ;

vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/sim/SimDialogActivity.java

public class SimDialogActivity extends Activity {
        mSimManagementExt.setCurrNetworkIcon(holder.icon, mDialogId, position);
        holder.icon.setAlpha(OPACITY);
} else {
-       holder.title.setText(sir.getDisplayName());
+       holder.title.setText((sir.getDisplayName().toString()).replace("CARD", "SIM"));
        holder.summary.setText(sir.getNumber());
        holder.icon.setImageBitmap(sir.createIconBitmap(mContext));

添加133紧急拨号

vendor/mediatek/proprietary/external/EccList/ecc_list.xml

     <EccEntry Ecc="911" Category="0" Condition="1" />
     <EccEntry Ecc="112" Category="0" Condition="1" />
     <EccEntry Ecc="113" Category="0" Condition="1" />
+    <EccEntry Ecc="133" Category="0" Condition="1" />
 EccTable>

vendor/mediatek/proprietary/external/EccList/cdma_ecc_list.xml

     <EccEntry Ecc="911" Category="0" Condition="1" />
     <EccEntry Ecc="112" Category="0" Condition="1" />
     <EccEntry Ecc="113" Category="0" Condition="1" />
+    <EccEntry Ecc="133" Category="0" Condition="1" />
 EccTable>

vendor/mediatek/proprietary/external/EccList/cdma_ecc_list_ss.xml

     <EccEntry Ecc="911" Category="0" Condition="1" />
     <EccEntry Ecc="112" Category="0" Condition="1" />
     <EccEntry Ecc="113" Category="0" Condition="1" />
+    <EccEntry Ecc="133" Category="0" Condition="1" />
 EccTable>

移除分屏模式

frameworks/base/core/res/res/values/config.xml

     
-    <bool name="config_supportsMultiWindow">truebool>
+    <bool name="config_supportsMultiWindow">falsebool>
     
     <bool name="config_supportsSplitScreenMultiWindow">truebool>

默认APN按顺序显示

device/mediatek/common
apns-conf.xml
将需要的接入点设置的放在最上面
vendor/mediatek/proprietary/packages/apps/MtkSettings/ext/src/com/mediatek/settings/ext/DefaultApnSettingsExt.java

  public class DefaultApnSettingsExt implements IApnSettingsExt {
      */
     @Override
     public String getApnSortOrder(String order) {
-        return order;
+        return null;
     }
     /*

指令添加修改,使用Google Dialer

需要在AndroidManifest中添加android_secret_code
并在src/com/agenew/peakli/phoneinfo/SecretCodeActivity.java添加对应操作
vendor/mediatek/proprietary/packages/apps/PhoneInfo

声音-勿扰自定义规则不随语言改变切换

frameworks/base/services/core/java/com/android/server/notification/ZenModeHelper.java

    @@ -918,7 +918,8 @@ public class ZenModeHelper {
             weeknights.endHour = 7;
             final ZenRule rule1 = new ZenRule();
             rule1.enabled = false;
    -        rule1.name = mDefaultRuleWeeknightsName;
    +        rule1.name = mContext.getResources()
    +                .getString(R.string.zen_mode_default_weeknights_name);
             rule1.conditionId = ZenModeConfig.toScheduleConditionId(weeknights);
             rule1.zenMode = Global.ZEN_MODE_ALARMS;
             rule1.component = ScheduleConditionProvider.COMPONENT;
    @@ -933,7 +934,8 @@ public class ZenModeHelper {
             weekends.endHour = 10;
             final ZenRule rule2 = new ZenRule();
             rule2.enabled = false;
    -        rule2.name = mDefaultRuleWeekendsName;
    +        rule2.name = mContext.getResources()
    +                .getString(R.string.zen_mode_default_weekends_name);
             rule2.conditionId = ZenModeConfig.toScheduleConditionId(weekends);
             rule2.zenMode = Global.ZEN_MODE_ALARMS;
             rule2.component = ScheduleConditionProvider.COMPONENT;
    @@ -950,7 +952,8 @@ public class ZenModeHelper {
             events.reply = EventInfo.REPLY_YES_OR_MAYBE;
             final ZenRule rule = new ZenRule();
             rule.enabled = false;
    -        rule.name = mDefaultRuleEventsName;
    +        rule.name = mContext.getResources()
    +                .getString(R.string.zen_mode_default_events_name);
             rule.conditionId = ZenModeConfig.toEventConditionId(events);
             rule.zenMode = Global.ZEN_MODE_ALARMS;
             rule.component = EventConditionProvider.COMPONENT;

重启字串显示关机

frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java

@@ -348,7 +348,13 @@ public class ShutdownThread extends Thread {
                             com.android.internal.R.string.reboot_to_reset_message));
                 pd.setIndeterminate(true);
             }
+        } else if (mReboot){
+                pd.setTitle(context.getText(com.android.internal.R.string.sim_restart_button));
+                pd.setMessage(context.getText(com.android.internal.R.string.reboot_to_reset_message));
+                pd.setIndeterminate(true);
         } else {
             if(!sInstance.isCustomizedShutdown()) {
                 if (showSysuiReboot()) {
                     return null;

添加充电提示音

充电提示默认是无线充电时才会有提示, 若需要有线充电提示音则按以下方法添加
frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java

@@ -212,6 +212,10 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;

+import android.media.Ringtone;
+import android.media.RingtoneManager;

 /** {@hide} */
 public class NotificationManagerService extends SystemService {
     static final String TAG = "NotificationService";
@@ -1018,7 +1022,25 @@ public class NotificationManagerService extends SystemService {
                 mListeners.onUserUnlocked(user);
                 mAssistants.onUserUnlocked(user);
                 mZenModeHelper.onUserUnlocked(user);
-            }
+            } else if (action.equals(Intent.ACTION_POWER_CONNECTED)){
+                final boolean enabled = Settings.Global.getInt(getContext().getContentResolver(),  
+                                Settings.Global.CHARGING_SOUNDS_ENABLED, 1) != 0 && SystemProperties.getBoolean("ro.bdfun.sound_power_connected", false);  
+                final String soundPath = Settings.Global.getString(getContext().getContentResolver(),  
+                                Settings.Global.WIRELESS_CHARGING_STARTED_SOUND); 
+
+                 if (enabled && soundPath != null) {  
+                     final Uri soundUri = Uri.parse("file://" + soundPath);  
+                     if (soundUri != null) {  
+                         final Ringtone sfx = RingtoneManager.getRingtone(getContext(), soundUri);  
+                         if (sfx != null) {  
+                             sfx.setStreamType(AudioManager.STREAM_SYSTEM);  
+                             sfx.play();  
+                         }  
+                     }  
+                }               
+            }
             /// M: Privacy protected lock support
             if (mMtkPplManager.filterPplAction(action)) {
                 mNotificationLight.turnOff();
@@ -1370,6 +1392,7 @@ public class NotificationManagerService extends SystemService {
         filter.addAction(Intent.ACTION_USER_PRESENT);
         filter.addAction(Intent.ACTION_USER_STOPPED);
         filter.addAction(Intent.ACTION_USER_SWITCHED);
+        filter.addAction(Intent.ACTION_POWER_CONNECTED); // add by fanjinhao
         filter.addAction(Intent.ACTION_USER_ADDED);
         filter.addAction(Intent.ACTION_USER_REMOVED);
         filter.addAction(Intent.ACTION_USER_UNLOCKED);

默认音量修改

修改在 frameworks/base/media/java/android/media/AudioSystem.java中
默认值定义在DEFAULT_STREAM_VOLUME这个数组中
这里的数值是按比值的大小, 在frameworks/base/services/core/java/com/android/server/audio/AudioService.java定义了其最大值
所以修改音量需要对照修改

长按power键添加静音调节模式(SPRD, MTK类似)

vendor/sprd/platform/frameworks/base/core/res/res/values/config.xml

@@ -74,6 +74,8 @@
         users
         
         airplane
+        
+        silent
     

如需要进行宏控, 则做如下修改
frameworks/base/services/core/java/com/android/server/policy/LegacyGlobalActions.java

@@ -301,9 +301,11 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn
                     mItems.add(new BugReportAction());
                 }
             } else if (GLOBAL_ACTION_KEY_SILENT.equals(actionKey)) {
-                if (mShowSilentToggle) {
+                // for show silent mode in long press power button @2018-08-11 {
+                if (mShowSilentToggle && SystemProperties.getBoolean("ro.func.show_silent_power", false)) {
                     mItems.add(mSilentModeAction);
                 }
+                /// @}
             } else if (GLOBAL_ACTION_KEY_USERS.equals(actionKey)) {
                 if (SystemProperties.getBoolean("fw.power_user_switcher", false)) {
                     addUsersToMenu(mItems);

你可能感兴趣的:(Android)