Android framwork一些常见的修改

Android framwork一些常见的修改

  1. 默认中文

    /build/target/product/core_base.mk
    PRODUCT_PROPERTY_OVERRIDES := \
        ro.config.notification_sound=OnTheHunt.ogg \
        ro.config.alarm_alert=Alarm_Classic.ogg \
    +    persist.sys.language=zh \
    +    persist.sys.country=CN
    
  2. 添加默认中文输入法(Google拼音)

    将下载的google拼音输入法放在\vendor\rockchip\common\apps\GooglePinyin\GooglePinyin.apk目录下,
    新建\vendor\rockchip\common\apps\GooglePinyin\Android.mk

    ###############################################################################
    # GooglePinyin
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE := GooglePinyin
    LOCAL_MODULE_CLASS := APPS
    LOCAL_MODULE_TAGS := optional
    LOCAL_BUILT_MODULE_STEM := package.apk
    LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
    #LOCAL_PRIVILEGED_MODULE :=
    LOCAL_CERTIFICATE := PRESIGNED
    #LOCAL_OVERRIDES_PACKAGES :=
    LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
    #LOCAL_REQUIRED_MODULES :=
    #LOCAL_PREBUILT_JNI_LIBS :=
    include $(BUILD_PREBUILT)
    
    # vendor/rockchip/common
    
    diff --git a/apps/apps.mk b/apps/apps.mk
    index 258e65f..3e58184 100755
    --- a/apps/apps.mk
    +++ b/apps/apps.mk
    @@ -1,7 +1,8 @@
    
    PRODUCT_PACKAGES += \
    -    RKUpdateService
    +    RKUpdateService \
    +       GooglePinyin
    
    ifeq ($(strip $(TARGET_BOARD_HARDWARE)), rk30board)
    ifeq ($(strip $(TARGET_ARCH)), arm)
    
    # frameworks/base
    
    packages/SettingsProvider/res/values/defaults.xml
    diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
    index 94758c3..218a38a 100755
    --- a/packages/SettingsProvider/res/values/defaults.xml
    +++ b/packages/SettingsProvider/res/values/defaults.xml
    @@ -225,4 +225,6 @@
        <integer name="def_screenshot_button_show">1</integer>
        <!-- the store location of screen capture by default-->
        <string name="def_screenshot_location">internal_storage</string>
    +
    +    <string name="config_default_input_method" translatable="false">com.android.inputmethod.pinyin/.PinyinIME</string>
    </resources>
    
    # frameworks/base
    
    packages/SettingsProvider/src/com/android/providers/settings//DatabaseHelper.java
    diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    old mode 100644
    new mode 100755
    index 5e2114d..740ce6a
    --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    @@ -2526,6 +2526,10 @@ class DatabaseHelper extends SQLiteOpenHelper {
    
                loadStringSetting(stmt, Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS,
                            R.string.def_immersive_mode_confirmations);
    +
    +            //add default input methods
    +            loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
    +                        R.string.config_default_input_method);
                loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
                        R.bool.def_install_non_market_apps);
    
  3. 默认不休眠,不锁屏(将休眠时间设置为无限大[2^31-1])

    
    # framwork/base
    
    diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
    index f4cefc2..43ef213 100644
    --- a/packages/SettingsProvider/res/values/defaults.xml
    +++ b/packages/SettingsProvider/res/values/defaults.xml
    @@ -18,7 +18,7 @@
    -->
    <resources>
        <bool name="def_dim_screen">true</bool>
    -    <integer name="def_screen_off_timeout">60000</integer>
    +    <integer name="def_screen_off_timeout">2147483647</integer>
        <integer name="def_sleep_timeout">-1</integer>
        <bool name="def_airplane_mode_on">false</bool>
        <bool name="def_theater_mode_on">false</bool>
    @@ -80,7 +80,7 @@
        <string name="def_trusted_sound" translatable="false">/system/media/audio/ui/Trusted.ogg</string>
        <string name="def_wireless_charging_started_sound" translatable="false">/system/media/audio/ui/WirelessChargingStarted.ogg</string>
    
    -    <bool name="def_lockscreen_disabled">false</bool>
    +    <bool name="def_lockscreen_disabled">true</bool>
        <bool name="def_device_provisioned">false</bool>
        <integer name="def_dock_audio_media_enabled">1</integer>
    
    
  4. 屏幕物理方向修改

    修改device/rockchip/rk3399/(所选lunch目录)/system.prop

    # 0 90 180 270
    ro.sf.hwrotation=90
    
  5. 屏幕密度修改

    修改device/rockchip/rk3399/(所选lunch目录)/system.prop

    ro.sf.lcd_density=160
    
  6. 去除StatusBar或者NavigatorBar

    # frameworks/base/packages/SystemUI
    
    diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
    old mode 100644
    new mode 100755
    diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
    old mode 100644
    new mode 100755
    diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
    index f55d1f7..3682cb0 100755
    --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
    +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
    @@ -41,6 +41,7 @@ import android.app.IActivityManager;
    import android.app.Notification;
    import android.app.PendingIntent;
    import android.app.StatusBarManager;
    +import android.app.AlarmManager;
    import android.content.BroadcastReceiver;
    import android.content.ComponentCallbacks2;
    import android.content.ComponentName;
    @@ -285,6 +286,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        */
        private static final int REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY = 200;
    
    +    private static final String ACTION_NAVIGATION_BAR = "com.android.NavigationBarReceiver";
        /**
        * Never let the alpha become zero for surfaces that draw with SRC - otherwise the RenderNode
        * won't draw anything and uninitialized memory will show through*/
    @@ -1013,6 +1016,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            filter.addAction(Intent.ACTION_SCREEN_ON);
            filter.addAction(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG);
    +        filter.addAction(ACTION_NAVIGATION_BAR);
            context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
    
            IntentFilter demoFilter = new IntentFilter();
    @@ -3667,6 +3672,20 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                }
                else if (DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG.equals(action)) {
                    mQSPanel.showDeviceMonitoringDialog();
    +            }else if (ACTION_NAVIGATION_BAR.equals(action)){
    +                try {
    +                    boolean show = intent.getBooleanExtra("show", true);
    +                    if (show) {
    +                        displaySystemUI();
    +                    } else {
    +                        hideSystemUI();
    +                    }
    +                } catch (Exception e) {
    +                    e.printStackTrace();
    +                }
                }
            }
        };
    @@ -5296,4 +5315,31 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                }
            }
        }
    +
    +    public void hideSystemUI() {
    +        if (mNavigationBarView != null && mNavigationBarView.isAttachedToWindow()) {
    +            mWindowManager.removeViewImmediate(mNavigationBarView);
    +            mNavigationBarView = null;
    +        }
    +
    +         if (mStatusBarWindow != null && mStatusBarWindow.isAttachedToWindow()) {
    +             getBouncerContainer().setVisibility(View.GONE);
    +         }
    +    }
    +
    +    public void displaySystemUI() {
    +        if (mNavigationBarView == null) {
    +            mHandler.post(new Runnable() {
    +                @Override
    +                public void run() {
    +                    final Context context = mContext;
    +                    createNavigationBarView(context);
    +                    addNavigationBar();
    +                }
    +            });
    +        }
    +
    +        if (mStatusBarWindow != null && mStatusBarWindow.isAttachedToWindow()) {
    +            getBouncerContainer().setVisibility(View.VISIBLE);
    +        }
    +    }
    }
    
  7. 系统默认时间修改(一般默认为1970年)

    # frameworks/base
    
    diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
    old mode 100644
    new mode 100755
    index 393f062..0d16f48
    --- a/services/java/com/android/server/SystemServer.java
    +++ b/services/java/com/android/server/SystemServer.java
    @@ -123,11 +123,13 @@ public final class SystemServer {
    
        // The earliest supported time.  We pick one day into 1970, to
        // give any timezone code room without going into negative time.
    -    private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
    +    // private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
    +    // The earliest supported time change to 2018/09/01 1358473528234
    +    private static final long EARLIEST_SUPPORTED_TIME = 1535760000000L;
    
        /*
    -     * Implementation class names. TODO: Move them to a codegen class or load
    -     * them from the build system somehow.
    +     * Implementation class names. TODO: Move them to a codegen class or load them
    +     * from the build system somehow.
        */
        private static final String BACKUP_MANAGER_SERVICE_CLASS =
                "com.android.server.backup.BackupManagerService$Lifecycle";
    @@ -235,14 +237,7 @@ public final class SystemServer {
        private void run() {
            try {
                Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "InitBeforeStartServices");
    -            // If a device's clock is before 1970 (before 0), a lot of
    -            // APIs crash dealing with negative numbers, notably
    -            // java.io.File#setLastModified, so instead we fake it and
    -            // hope that time from cell towers or NTP fixes it shortly.
    -            if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
    -                Slog.w(TAG, "System clock is before 1970; setting to 1970.");
    -                SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
    -            }
    +
    
                // If the system has "persist.sys.language" and friends set, replace them with
                // "persist.sys.locale". Note that the default locale at this point is calculated
    @@ -341,6 +336,20 @@ public final class SystemServer {
                startBootstrapServices();
                startCoreServices();
                startOtherServices();
    +
    +            // If a device's clock is before 1970 (before 0), a lot of
    +            // APIs crash dealing with negative numbers, notably
    +            // java.io.File#setLastModified, so instead we fake it and
    +            // hope that time from cell towers or NTP fixes it shortly.
    +            Slog.w(TAG, "System.currentTimeMillis(): " + System.currentTimeMillis() + " EARLIEST_SUPPORTED_TIME: "
    +                    + EARLIEST_SUPPORTED_TIME);
    +            if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
    +                Slog.w(TAG, "System clock is before 2018; setting to 2018.");
    +                SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
    +            }
    +
    +            Slog.w(TAG, "System.currentTimeMillis(): " + System.currentTimeMillis() + " EARLIEST_SUPPORTED_TIME: "
    +                    + EARLIEST_SUPPORTED_TIME);
            } catch (Throwable ex) {
                Slog.e("System", "******************************************");
                Slog.e("System", "************ Failure starting system services", ex);
    
  8. 修改开机Launcher为自己的app

    # /frameworks/base/services
    
    diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
    index 9fbd87d..621db11 100755
    --- a/services/core/java/com/android/server/am/ActivityManagerService.java
    +++ b/services/core/java/com/android/server/am/ActivityManagerService.java
    @@ -4082,6 +4082,25 @@ public final class ActivityManagerService extends ActivityManagerNative
            Intent intent = getHomeIntent();
            ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
            if (aInfo != null) {
    +
    +            //add eyesdetector launcher start
    +            PackageManager pm = mContext.getPackageManager();
    +            Intent newintent = new Intent(Intent.ACTION_MAIN);
    +            newintent.addCategory(Intent.CATEGORY_HOME);
    +
    +            List<ResolveInfo> resolveInfoList = pm.queryIntentActivities(newintent, 0);
    +            //判断带有Intent.CATEGORY_HOME标签的所有activity中如果有你指定的activity则替换
    +            if(resolveInfoList != null){
    +                int size = resolveInfoList.size();
    +                for(int i = 0; i < size; i++){
    +                    ResolveInfo rInfo = resolveInfoList.get(i);
    +                    if(rInfo.activityInfo.name.equals("com.qytech.eyesdetector.home.MainActivity")){
    +                        aInfo = rInfo.activityInfo;
    +                        break;
    +                    }
    +                }
    +            }
    +            //add eyesdetector launcher stop
    +
                intent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));
                // Don't do this if the home app is currently being
                // instrumented.
    
  9. 取消usb授权弹窗

    # frameworks/base/packages/SystemUI
    
    diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java
    old mode 100644
    new mode 100755
    index 1e69fc5..ec61b66
    --- a/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java
    +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java
    @@ -110,8 +110,9 @@ public class UsbPermissionActivity extends AlertActivity
                                                        com.android.internal.R.id.clearDefaultHint);
            mClearDefaultHint.setVisibility(View.GONE);
    
    -        setupAlert();
    -
    +        //setupAlert();
    +        mPermissionGranted = true;
    +        finish();
        }
    
  10. 默认允许安装不是从应用市场下载的apk

    # frameworks/base
    
    diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
    index 43ef213..3667b36 100755
    --- a/packages/SettingsProvider/res/values/defaults.xml
    +++ b/packages/SettingsProvider/res/values/defaults.xml
    @@ -38,7 +38,7 @@
    
        <bool name="def_bluetooth_on">false</bool>
        <bool name="def_wifi_display_on">false</bool>
    -    <bool name="def_install_non_market_apps">false</bool>
    +    <bool name="def_install_non_market_apps">true</bool>
        <bool name="def_package_verifier_enable">true</bool>
        <!-- Comma-separated list of location providers.
            Network location is off by default because it requires
    
  11. 禁止状态栏下拉

    # frameworks/base/packages/SystemUI
    
    diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
    old mode 100644
    new mode 100755
    index 47ea59e..bf06f6a
    --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
    +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
    @@ -59,6 +59,7 @@ import com.android.systemui.statusbar.DragDownHelper;
    import com.android.systemui.statusbar.StatusBarState;
    import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
    
    +import android.os.SystemProperties;
    
    public class StatusBarWindowView extends FrameLayout {
        public static final String TAG = "StatusBarWindowView";
    @@ -243,6 +244,10 @@ public class StatusBarWindowView extends FrameLayout {
    
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
    +        if (SystemProperties.getBoolean("persist.sys.disdropstatusbar", true)) {
    +            return true;
    +        }
    +
            boolean intercept = false;
            if (mNotificationPanel.isFullyExpanded()
                    && mStackScrollLayout.getVisibility() == View.VISIBLE
    
  12. 待续

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,013评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,205评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,370评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,168评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,153评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,954评论 1 283
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,271评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,916评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,382评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,877评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,989评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,624评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,209评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,199评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,418评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,401评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,700评论 2 345

推荐阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,689评论 0 3
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 171,498评论 25 707
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,399评论 2 45
  • 1.更改设置中的平板加密为不加密的: 修改\device\intel\cherrytrail\cht_cr_rvp...
    cc小表弟阅读 9,044评论 2 20
  • 对方给予我们何等的压力,我们也应该用同样的方式还回去。若对方带着善意,那么我们也应该心存善意,但若对方心存恶...
    李向姿阅读 142评论 0 0