作为中国人,比较多的情况下会用到农历,虽然android系统的日历支持农历,但锁屏情况下只显示了阳历的日期,以下是CM7系列添加锁屏显示农历功能的方法(其他ROM是否可行请自行测试)。
需要修改的文件包括framework-res.apk,android.policy.jar,framework.jar三个文件,均位于system/framework/文件夹下。
1.修改framework-res.apk,添加所需要的资源。
1.1反编译framework-res.apk,得到framework-res文件夹。
1.2修改framework-res\res\values\arrays.xml文件,在该文件末尾的"</resources>"前加入下列代码:
Xml代码
1.<string-array name="chinese_month">
2. <item>正月</item>
3. <item>二月</item>
4. <item>三月</item>
5. <item>四月</item>
6. <item>五月</item>
7. <item>六月</item>
8. <item>七月</item>
9. <item>八月</item>
10. <item>九月</item>
11. <item>十月</item>
12. <item>冬月</item>
13. <item>腊月</item>
14. </string-array>
15. <string-array name="chinese_month1">
16. <item>一</item>
17. <item>二</item>
18. <item>三</item>
19. <item>四</item>
20. <item>五</item>
21. <item>六</item>
22. <item>七</item>
23. <item>八</item>
24. <item>九</item>
25. <item>十</item>
26. <item>十一</item>
27. <item>十二</item>
28. </string-array>
29. <string-array name="chinese_ten">
30. <item>初</item>
31. <item>十</item>
32. <item>廿</item>
33. <item>卅</item>
34. </string-array>
35. <string-array name="chinese_gan">
36. <item>甲</item>
37. <item>乙</item>
38. <item>丙</item>
39. <item>丁</item>
40. <item>戊</item>
41. <item>己</item>
42. <item>庚</item>
43. <item>辛</item>
44. <item>壬</item>
45. <item>癸</item>
46. </string-array>
47. <string-array name="chinese_zhi">
48. <item>子(鼠</item>
49. <item>丑(牛</item>
50. <item>寅(虎</item>
51. <item>卯(兔</item>
52. <item>辰(龙</item>
53. <item>巳(蛇</item>
54. <item>午(马</item>
55. <item>未(羊</item>
56. <item>申(猴</item>
57. <item>酉(鸡</item>
58. <item>戌(狗</item>
59. <item>亥(猪</item>
60. </string-array>
61. <string-array name="lunar_animals">
62. <item>鼠</item>
63. <item>牛</item>
64. <item>虎</item>
65. <item>兔</item>
66. <item>龙</item>
67. <item>蛇</item>
68. <item>马</item>
69. <item>羊</item>
70. <item>猴</item>
71. <item>鸡</item>
72. <item>狗</item>
73. <item>猪</item>
74. </string-array>
75. <string-array name="lunar_gans">
76. <item>甲</item>
77. <item>乙</item>
78. <item>丙</item>
79. <item>丁</item>
80. <item>戊</item>
81. <item>己</item>
82. <item>庚</item>
83. <item>辛</item>
84. <item>壬</item>
85. <item>癸</item>
86. </string-array>
87. <string-array name="lunar_zhis">
88. <item>子</item>
89. <item>丑</item>
90. <item>寅</item>
91. <item>卯</item>
92. <item>辰</item>
93. <item>巳</item>
94. <item>午</item>
95. <item>未</item>
96. <item>申</item>
97. <item>酉</item>
98. <item>戌</item>
99. <item>亥</item>
100. </string-array>
101. <string-array name="lunar_chinese_tens">
102. <item>初</item>
103. <item>十</item>
104. <item>廿</item>
105. <item>三</item>
106. </string-array>
107. <string-array name="lunar_chinese_month">
108. <item>正</item>
109. <item>二</item>
110. <item>三</item>
111. <item>四</item>
112. <item>五</item>
113. <item>六</item>
114. <item>七</item>
115. <item>八</item>
116. <item>九</item>
117. <item>十</item>
118. <item>冬</item>
119. <item>腊</item>
120. </string-array>
<string-array name="chinese_month">
<item>正月</item>
<item>二月</item>
<item>三月</item>
<item>四月</item>
<item>五月</item>
<item>六月</item>
<item>七月</item>
<item>八月</item>
<item>九月</item>
<item>十月</item>
<item>冬月</item>
<item>腊月</item>
</string-array>
<string-array name="chinese_month1">
<item>一</item>
<item>二</item>
<item>三</item>
<item>四</item>
<item>五</item>
<item>六</item>
<item>七</item>
<item>八</item>
<item>九</item>
<item>十</item>
<item>十一</item>
<item>十二</item>
</string-array>
<string-array name="chinese_ten">
<item>初</item>
<item>十</item>
<item>廿</item>
<item>卅</item>
</string-array>
<string-array name="chinese_gan">
<item>甲</item>
<item>乙</item>
<item>丙</item>
<item>丁</item>
<item>戊</item>
<item>己</item>
<item>庚</item>
<item>辛</item>
<item>壬</item>
<item>癸</item>
</string-array>
<string-array name="chinese_zhi">
<item>子(鼠</item>
<item>丑(牛</item>
<item>寅(虎</item>
<item>卯(兔</item>
<item>辰(龙</item>
<item>巳(蛇</item>
<item>午(马</item>
<item>未(羊</item>
<item>申(猴</item>
<item>酉(鸡</item>
<item>戌(狗</item>
<item>亥(猪</item>
</string-array>
<string-array name="lunar_animals">
<item>鼠</item>
<item>牛</item>
<item>虎</item>
<item>兔</item>
<item>龙</item>
<item>蛇</item>
<item>马</item>
<item>羊</item>
<item>猴</item>
<item>鸡</item>
<item>狗</item>
<item>猪</item>
</string-array>
<string-array name="lunar_gans">
<item>甲</item>
<item>乙</item>
<item>丙</item>
<item>丁</item>
<item>戊</item>
<item>己</item>
<item>庚</item>
<item>辛</item>
<item>壬</item>
<item>癸</item>
</string-array>
<string-array name="lunar_zhis">
<item>子</item>
<item>丑</item>
<item>寅</item>
<item>卯</item>
<item>辰</item>
<item>巳</item>
<item>午</item>
<item>未</item>
<item>申</item>
<item>酉</item>
<item>戌</item>
<item>亥</item>
</string-array>
<string-array name="lunar_chinese_tens">
<item>初</item>
<item>十</item>
<item>廿</item>
<item>三</item>
</string-array>
<string-array name="lunar_chinese_month">
<item>正</item>
<item>二</item>
<item>三</item>
<item>四</item>
<item>五</item>
<item>六</item>
<item>七</item>
<item>八</item>
<item>九</item>
<item>十</item>
<item>冬</item>
<item>腊</item>
</string-array> 1.3 修改framework-res\res\values\strings.xml,在该文件末尾的"</resources>"前加入下列代码:
Xml代码
1.<string name="chn_ten">初十</string>
2.<string name="chn_double">闰</string>
3.<string name="chn_year">年)-</string>
4.<string name="lunar_date_template">1900年1月31日</string>
5.<string name="lunar_date_chushi">初十</string>
6.<string name="lunar_name">农历</string>
7.<string name="lunar_run_month">闰</string>
8.<string name="lunar_month">月</string>
9.<string name="lunar_year">年</string>
10.<string name="lunar_date_format">yyyy年MM月dd日</string>
11.<string name="lockscreen_unread_sms">未读短信:%s</string>
12.<string name="lockscreen_unread_mms">未读彩信:%s</string>
13.<string name="lockscreen_missed_call">未接电话:%s</string>
<string name="chn_ten">初十</string>
<string name="chn_double">闰</string>
<string name="chn_year">年)-</string>
<string name="lunar_date_template">1900年1月31日</string>
<string name="lunar_date_chushi">初十</string>
<string name="lunar_name">农历</string>
<string name="lunar_run_month">闰</string>
<string name="lunar_month">月</string>
<string name="lunar_year">年</string>
<string name="lunar_date_format">yyyy年MM月dd日</string>
<string name="lockscreen_unread_sms">未读短信:%s</string>
<string name="lockscreen_unread_mms">未读彩信:%s</string>
<string name="lockscreen_missed_call">未接电话:%s</string> 1.4 修改framework-res\res\values\public.xml,在该文件中加入1.3中添加的字符串资源的id定义:
Xml代码
1.<public type="string" name="chn_ten" id="0x010403c4" />
2. <public type="string" name="chn_double" id="0x010403c5" />
3. <public type="string" name="chn_year" id="0x010403b9" />
4. <public type="string" name="lunar_date_template" id="0x010403ba" />
5. <public type="string" name="lunar_date_chushi" id="0x010403bb" />
6. <public type="string" name="lunar_name" id="0x010403bc" />
7. <public type="string" name="lunar_run_month" id="0x010403bd" />
8. <public type="string" name="lunar_month" id="0x010403be" />
9. <public type="string" name="lunar_year" id="0x010403bf" />
10. <public type="string" name="lunar_date_format" id="0x010403c0" />
11. <public type="string" name="lockscreen_unread_sms" id="0x010403c1" />
12. <public type="string" name="lockscreen_unread_mms" id="0x010403c2" />
13. <public type="string" name="lockscreen_missed_call" id="0x010403c3" />
<public type="string" name="chn_ten" id="0x010403c4" />
<public type="string" name="chn_double" id="0x010403c5" />
<public type="string" name="chn_year" id="0x010403b9" />
<public type="string" name="lunar_date_template" id="0x010403ba" />
<public type="string" name="lunar_date_chushi" id="0x010403bb" />
<public type="string" name="lunar_name" id="0x010403bc" />
<public type="string" name="lunar_run_month" id="0x010403bd" />
<public type="string" name="lunar_month" id="0x010403be" />
<public type="string" name="lunar_year" id="0x010403bf" />
<public type="string" name="lunar_date_format" id="0x010403c0" />
<public type="string" name="lockscreen_unread_sms" id="0x010403c1" />
<public type="string" name="lockscreen_unread_mms" id="0x010403c2" />
<public type="string" name="lockscreen_missed_call" id="0x010403c3" /> 注意:这里所用到的id编号根据文件中最后一个string的id号顺序排下来,另外,这里的id号码要记住,下面修改其他文件要用;虽然删除该public.xml后apktool在编译时会自动添加,但是所有资源的id号码将不一样,而系统framework中的jar调用资源的方式是通过id调用的,id乱了之后将无限重启。
这里,framework-res文件夹相关文件修改完成,回编译该文件夹得到apk文件,用winrar打开该apk文件,将其中的
resources.arsc文件拖到最初的framework-res.apk文件中。
2.修改framework.jar文件
2.1 用baksmali将framework.jar反编译得到包含一堆smali文件的文件夹(反编译时可选择反编译后的文件夹名称,本文中使用framework/)。
2.2 将本文的附件Lunar.rar解压得到Lunar.smali文件,将该文件放在framework\android\util中。
2.3 用smali将framework文件夹回编译为classes.dex,将classes.dex拖入framework.jar替换原有文件(用winrar打开framework.jar)。
3.修改android.policy.jar文件
该文件的修改比较麻烦,因为不是文件的替换而是修改其中某个文件中的一个函数,而smali文件看起来比较累,不过没办法,谁让咱懒得弄源代码呢。
3.1 用baksmali将 android.policy.jar反编译得到包含一堆smali文件的文件夹(反编译时可选择反编译后的文件夹名称,本文中使用 android.policy/)。
3.2 用notepad++打开android.policy\com\android\internal\policy\impl\LockScreen.smali,使用正则表达式将其中的.line行全部删除,不然添加代码比较麻烦。具体操作为查找(.line [0-9]+),替换所有为空即可。
然后查找".method private refreshTimeAndDateDisplay()V"不包括双引号,将该行与下一个“.end method”之间的内容替换为如下代码:
Java代码
1..method private refreshTimeAndDateDisplay()V
2. .registers 6
3.
4. .prologue
5.
6. iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mRotarySelector:Lcom/android/internal/widget/RotarySelector;
7.
8. invoke-virtual {v1}, Lcom/android/internal/widget/RotarySelector;->invalidate()V
9.
10.
11. new-instance v0, Landroid/util/Lunar;
12.
13. invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;
14.
15. move-result-object v1
16.
17. invoke-direct {v0, v1}, Landroid/util/Lunar;-><init>(Ljava/util/Calendar;)V
18.
19.
20. .local v0, lunar:Landroid/util/Lunar;
21. iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mDate:Landroid/widget/TextView;
22.
23. new-instance v2, Ljava/lang/StringBuilder;
24.
25. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
26.
27. iget-object v3, p0, Lcom/android/internal/policy/impl/LockScreen;->mDateFormatString:Ljava/lang/String;
28.
29. new-instance v4, Ljava/util/Date;
30.
31. invoke-direct {v4}, Ljava/util/Date;-><init>()V
32.
33. invoke-static {v3, v4}, Landroid/text/format/DateFormat;->format(Ljava/lang/CharSequence;Ljava/util/Date;)Ljava/lang/CharSequence;
34.
35. move-result-object v3
36.
37. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
38.
39. move-result-object v2
40.
41. invoke-virtual {v0}, Landroid/util/Lunar;->isZhRegion()Z
42.
43. move-result v3
44.
45. if-eqz v3, :cond_49
46.
47. new-instance v3, Ljava/lang/StringBuilder;
48.
49. invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
50.
51. const-string v4, "\n"
52.
53. invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
54.
55. move-result-object v3
56.
57. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
58.
59. move-result-object v3
60.
61. invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
62.
63. move-result-object v3
64.
65. :goto_3d
66. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
67.
68. move-result-object v2
69.
70. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
71.
72. move-result-object v2
73.
74. invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
75.
76.
77. return-void
78.
79.
80. :cond_49
81. const-string v3, ""
82.
83. goto :goto_3d
84..end method
.method private refreshTimeAndDateDisplay()V
.registers 6
.prologue
iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mRotarySelector:Lcom/android/internal/widget/RotarySelector;
invoke-virtual {v1}, Lcom/android/internal/widget/RotarySelector;->invalidate()V
new-instance v0, Landroid/util/Lunar;
invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;
move-result-object v1
invoke-direct {v0, v1}, Landroid/util/Lunar;-><init>(Ljava/util/Calendar;)V
.local v0, lunar:Landroid/util/Lunar;
iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mDate:Landroid/widget/TextView;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
iget-object v3, p0, Lcom/android/internal/policy/impl/LockScreen;->mDateFormatString:Ljava/lang/String;
new-instance v4, Ljava/util/Date;
invoke-direct {v4}, Ljava/util/Date;-><init>()V
invoke-static {v3, v4}, Landroid/text/format/DateFormat;->format(Ljava/lang/CharSequence;Ljava/util/Date;)Ljava/lang/CharSequence;
move-result-object v3
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v0}, Landroid/util/Lunar;->isZhRegion()Z
move-result v3
if-eqz v3, :cond_49
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "\n"
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
:goto_3d
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
return-void
:cond_49
const-string v3, ""
goto :goto_3d
.end method
修改完成后保存。
3.3 使用3.2中相同方法修改android.policy\com\android\internal\policy\impl\PatternUnlockScreen.smali文件。
3.4 用smali将 android.policy文件夹回编译为classes.dex,将classes.dex拖入 android.policy.jar替换原有文件(用winrar打开 android.policy.jar)。
本文并非原创
需要修改的文件包括framework-res.apk,android.policy.jar,framework.jar三个文件,均位于system/framework/文件夹下。
1.修改framework-res.apk,添加所需要的资源。
1.1反编译framework-res.apk,得到framework-res文件夹。
1.2修改framework-res\res\values\arrays.xml文件,在该文件末尾的"</resources>"前加入下列代码:
Xml代码
1.<string-array name="chinese_month">
2. <item>正月</item>
3. <item>二月</item>
4. <item>三月</item>
5. <item>四月</item>
6. <item>五月</item>
7. <item>六月</item>
8. <item>七月</item>
9. <item>八月</item>
10. <item>九月</item>
11. <item>十月</item>
12. <item>冬月</item>
13. <item>腊月</item>
14. </string-array>
15. <string-array name="chinese_month1">
16. <item>一</item>
17. <item>二</item>
18. <item>三</item>
19. <item>四</item>
20. <item>五</item>
21. <item>六</item>
22. <item>七</item>
23. <item>八</item>
24. <item>九</item>
25. <item>十</item>
26. <item>十一</item>
27. <item>十二</item>
28. </string-array>
29. <string-array name="chinese_ten">
30. <item>初</item>
31. <item>十</item>
32. <item>廿</item>
33. <item>卅</item>
34. </string-array>
35. <string-array name="chinese_gan">
36. <item>甲</item>
37. <item>乙</item>
38. <item>丙</item>
39. <item>丁</item>
40. <item>戊</item>
41. <item>己</item>
42. <item>庚</item>
43. <item>辛</item>
44. <item>壬</item>
45. <item>癸</item>
46. </string-array>
47. <string-array name="chinese_zhi">
48. <item>子(鼠</item>
49. <item>丑(牛</item>
50. <item>寅(虎</item>
51. <item>卯(兔</item>
52. <item>辰(龙</item>
53. <item>巳(蛇</item>
54. <item>午(马</item>
55. <item>未(羊</item>
56. <item>申(猴</item>
57. <item>酉(鸡</item>
58. <item>戌(狗</item>
59. <item>亥(猪</item>
60. </string-array>
61. <string-array name="lunar_animals">
62. <item>鼠</item>
63. <item>牛</item>
64. <item>虎</item>
65. <item>兔</item>
66. <item>龙</item>
67. <item>蛇</item>
68. <item>马</item>
69. <item>羊</item>
70. <item>猴</item>
71. <item>鸡</item>
72. <item>狗</item>
73. <item>猪</item>
74. </string-array>
75. <string-array name="lunar_gans">
76. <item>甲</item>
77. <item>乙</item>
78. <item>丙</item>
79. <item>丁</item>
80. <item>戊</item>
81. <item>己</item>
82. <item>庚</item>
83. <item>辛</item>
84. <item>壬</item>
85. <item>癸</item>
86. </string-array>
87. <string-array name="lunar_zhis">
88. <item>子</item>
89. <item>丑</item>
90. <item>寅</item>
91. <item>卯</item>
92. <item>辰</item>
93. <item>巳</item>
94. <item>午</item>
95. <item>未</item>
96. <item>申</item>
97. <item>酉</item>
98. <item>戌</item>
99. <item>亥</item>
100. </string-array>
101. <string-array name="lunar_chinese_tens">
102. <item>初</item>
103. <item>十</item>
104. <item>廿</item>
105. <item>三</item>
106. </string-array>
107. <string-array name="lunar_chinese_month">
108. <item>正</item>
109. <item>二</item>
110. <item>三</item>
111. <item>四</item>
112. <item>五</item>
113. <item>六</item>
114. <item>七</item>
115. <item>八</item>
116. <item>九</item>
117. <item>十</item>
118. <item>冬</item>
119. <item>腊</item>
120. </string-array>
<string-array name="chinese_month">
<item>正月</item>
<item>二月</item>
<item>三月</item>
<item>四月</item>
<item>五月</item>
<item>六月</item>
<item>七月</item>
<item>八月</item>
<item>九月</item>
<item>十月</item>
<item>冬月</item>
<item>腊月</item>
</string-array>
<string-array name="chinese_month1">
<item>一</item>
<item>二</item>
<item>三</item>
<item>四</item>
<item>五</item>
<item>六</item>
<item>七</item>
<item>八</item>
<item>九</item>
<item>十</item>
<item>十一</item>
<item>十二</item>
</string-array>
<string-array name="chinese_ten">
<item>初</item>
<item>十</item>
<item>廿</item>
<item>卅</item>
</string-array>
<string-array name="chinese_gan">
<item>甲</item>
<item>乙</item>
<item>丙</item>
<item>丁</item>
<item>戊</item>
<item>己</item>
<item>庚</item>
<item>辛</item>
<item>壬</item>
<item>癸</item>
</string-array>
<string-array name="chinese_zhi">
<item>子(鼠</item>
<item>丑(牛</item>
<item>寅(虎</item>
<item>卯(兔</item>
<item>辰(龙</item>
<item>巳(蛇</item>
<item>午(马</item>
<item>未(羊</item>
<item>申(猴</item>
<item>酉(鸡</item>
<item>戌(狗</item>
<item>亥(猪</item>
</string-array>
<string-array name="lunar_animals">
<item>鼠</item>
<item>牛</item>
<item>虎</item>
<item>兔</item>
<item>龙</item>
<item>蛇</item>
<item>马</item>
<item>羊</item>
<item>猴</item>
<item>鸡</item>
<item>狗</item>
<item>猪</item>
</string-array>
<string-array name="lunar_gans">
<item>甲</item>
<item>乙</item>
<item>丙</item>
<item>丁</item>
<item>戊</item>
<item>己</item>
<item>庚</item>
<item>辛</item>
<item>壬</item>
<item>癸</item>
</string-array>
<string-array name="lunar_zhis">
<item>子</item>
<item>丑</item>
<item>寅</item>
<item>卯</item>
<item>辰</item>
<item>巳</item>
<item>午</item>
<item>未</item>
<item>申</item>
<item>酉</item>
<item>戌</item>
<item>亥</item>
</string-array>
<string-array name="lunar_chinese_tens">
<item>初</item>
<item>十</item>
<item>廿</item>
<item>三</item>
</string-array>
<string-array name="lunar_chinese_month">
<item>正</item>
<item>二</item>
<item>三</item>
<item>四</item>
<item>五</item>
<item>六</item>
<item>七</item>
<item>八</item>
<item>九</item>
<item>十</item>
<item>冬</item>
<item>腊</item>
</string-array> 1.3 修改framework-res\res\values\strings.xml,在该文件末尾的"</resources>"前加入下列代码:
Xml代码
1.<string name="chn_ten">初十</string>
2.<string name="chn_double">闰</string>
3.<string name="chn_year">年)-</string>
4.<string name="lunar_date_template">1900年1月31日</string>
5.<string name="lunar_date_chushi">初十</string>
6.<string name="lunar_name">农历</string>
7.<string name="lunar_run_month">闰</string>
8.<string name="lunar_month">月</string>
9.<string name="lunar_year">年</string>
10.<string name="lunar_date_format">yyyy年MM月dd日</string>
11.<string name="lockscreen_unread_sms">未读短信:%s</string>
12.<string name="lockscreen_unread_mms">未读彩信:%s</string>
13.<string name="lockscreen_missed_call">未接电话:%s</string>
<string name="chn_ten">初十</string>
<string name="chn_double">闰</string>
<string name="chn_year">年)-</string>
<string name="lunar_date_template">1900年1月31日</string>
<string name="lunar_date_chushi">初十</string>
<string name="lunar_name">农历</string>
<string name="lunar_run_month">闰</string>
<string name="lunar_month">月</string>
<string name="lunar_year">年</string>
<string name="lunar_date_format">yyyy年MM月dd日</string>
<string name="lockscreen_unread_sms">未读短信:%s</string>
<string name="lockscreen_unread_mms">未读彩信:%s</string>
<string name="lockscreen_missed_call">未接电话:%s</string> 1.4 修改framework-res\res\values\public.xml,在该文件中加入1.3中添加的字符串资源的id定义:
Xml代码
1.<public type="string" name="chn_ten" id="0x010403c4" />
2. <public type="string" name="chn_double" id="0x010403c5" />
3. <public type="string" name="chn_year" id="0x010403b9" />
4. <public type="string" name="lunar_date_template" id="0x010403ba" />
5. <public type="string" name="lunar_date_chushi" id="0x010403bb" />
6. <public type="string" name="lunar_name" id="0x010403bc" />
7. <public type="string" name="lunar_run_month" id="0x010403bd" />
8. <public type="string" name="lunar_month" id="0x010403be" />
9. <public type="string" name="lunar_year" id="0x010403bf" />
10. <public type="string" name="lunar_date_format" id="0x010403c0" />
11. <public type="string" name="lockscreen_unread_sms" id="0x010403c1" />
12. <public type="string" name="lockscreen_unread_mms" id="0x010403c2" />
13. <public type="string" name="lockscreen_missed_call" id="0x010403c3" />
<public type="string" name="chn_ten" id="0x010403c4" />
<public type="string" name="chn_double" id="0x010403c5" />
<public type="string" name="chn_year" id="0x010403b9" />
<public type="string" name="lunar_date_template" id="0x010403ba" />
<public type="string" name="lunar_date_chushi" id="0x010403bb" />
<public type="string" name="lunar_name" id="0x010403bc" />
<public type="string" name="lunar_run_month" id="0x010403bd" />
<public type="string" name="lunar_month" id="0x010403be" />
<public type="string" name="lunar_year" id="0x010403bf" />
<public type="string" name="lunar_date_format" id="0x010403c0" />
<public type="string" name="lockscreen_unread_sms" id="0x010403c1" />
<public type="string" name="lockscreen_unread_mms" id="0x010403c2" />
<public type="string" name="lockscreen_missed_call" id="0x010403c3" /> 注意:这里所用到的id编号根据文件中最后一个string的id号顺序排下来,另外,这里的id号码要记住,下面修改其他文件要用;虽然删除该public.xml后apktool在编译时会自动添加,但是所有资源的id号码将不一样,而系统framework中的jar调用资源的方式是通过id调用的,id乱了之后将无限重启。
这里,framework-res文件夹相关文件修改完成,回编译该文件夹得到apk文件,用winrar打开该apk文件,将其中的
resources.arsc文件拖到最初的framework-res.apk文件中。
2.修改framework.jar文件
2.1 用baksmali将framework.jar反编译得到包含一堆smali文件的文件夹(反编译时可选择反编译后的文件夹名称,本文中使用framework/)。
2.2 将本文的附件Lunar.rar解压得到Lunar.smali文件,将该文件放在framework\android\util中。
2.3 用smali将framework文件夹回编译为classes.dex,将classes.dex拖入framework.jar替换原有文件(用winrar打开framework.jar)。
3.修改android.policy.jar文件
该文件的修改比较麻烦,因为不是文件的替换而是修改其中某个文件中的一个函数,而smali文件看起来比较累,不过没办法,谁让咱懒得弄源代码呢。
3.1 用baksmali将 android.policy.jar反编译得到包含一堆smali文件的文件夹(反编译时可选择反编译后的文件夹名称,本文中使用 android.policy/)。
3.2 用notepad++打开android.policy\com\android\internal\policy\impl\LockScreen.smali,使用正则表达式将其中的.line行全部删除,不然添加代码比较麻烦。具体操作为查找(.line [0-9]+),替换所有为空即可。
然后查找".method private refreshTimeAndDateDisplay()V"不包括双引号,将该行与下一个“.end method”之间的内容替换为如下代码:
Java代码
1..method private refreshTimeAndDateDisplay()V
2. .registers 6
3.
4. .prologue
5.
6. iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mRotarySelector:Lcom/android/internal/widget/RotarySelector;
7.
8. invoke-virtual {v1}, Lcom/android/internal/widget/RotarySelector;->invalidate()V
9.
10.
11. new-instance v0, Landroid/util/Lunar;
12.
13. invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;
14.
15. move-result-object v1
16.
17. invoke-direct {v0, v1}, Landroid/util/Lunar;-><init>(Ljava/util/Calendar;)V
18.
19.
20. .local v0, lunar:Landroid/util/Lunar;
21. iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mDate:Landroid/widget/TextView;
22.
23. new-instance v2, Ljava/lang/StringBuilder;
24.
25. invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
26.
27. iget-object v3, p0, Lcom/android/internal/policy/impl/LockScreen;->mDateFormatString:Ljava/lang/String;
28.
29. new-instance v4, Ljava/util/Date;
30.
31. invoke-direct {v4}, Ljava/util/Date;-><init>()V
32.
33. invoke-static {v3, v4}, Landroid/text/format/DateFormat;->format(Ljava/lang/CharSequence;Ljava/util/Date;)Ljava/lang/CharSequence;
34.
35. move-result-object v3
36.
37. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
38.
39. move-result-object v2
40.
41. invoke-virtual {v0}, Landroid/util/Lunar;->isZhRegion()Z
42.
43. move-result v3
44.
45. if-eqz v3, :cond_49
46.
47. new-instance v3, Ljava/lang/StringBuilder;
48.
49. invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
50.
51. const-string v4, "\n"
52.
53. invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
54.
55. move-result-object v3
56.
57. invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
58.
59. move-result-object v3
60.
61. invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
62.
63. move-result-object v3
64.
65. :goto_3d
66. invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
67.
68. move-result-object v2
69.
70. invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
71.
72. move-result-object v2
73.
74. invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
75.
76.
77. return-void
78.
79.
80. :cond_49
81. const-string v3, ""
82.
83. goto :goto_3d
84..end method
.method private refreshTimeAndDateDisplay()V
.registers 6
.prologue
iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mRotarySelector:Lcom/android/internal/widget/RotarySelector;
invoke-virtual {v1}, Lcom/android/internal/widget/RotarySelector;->invalidate()V
new-instance v0, Landroid/util/Lunar;
invoke-static {}, Ljava/util/Calendar;->getInstance()Ljava/util/Calendar;
move-result-object v1
invoke-direct {v0, v1}, Landroid/util/Lunar;-><init>(Ljava/util/Calendar;)V
.local v0, lunar:Landroid/util/Lunar;
iget-object v1, p0, Lcom/android/internal/policy/impl/LockScreen;->mDate:Landroid/widget/TextView;
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
iget-object v3, p0, Lcom/android/internal/policy/impl/LockScreen;->mDateFormatString:Ljava/lang/String;
new-instance v4, Ljava/util/Date;
invoke-direct {v4}, Ljava/util/Date;-><init>()V
invoke-static {v3, v4}, Landroid/text/format/DateFormat;->format(Ljava/lang/CharSequence;Ljava/util/Date;)Ljava/lang/CharSequence;
move-result-object v3
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v0}, Landroid/util/Lunar;->isZhRegion()Z
move-result v3
if-eqz v3, :cond_49
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "\n"
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
:goto_3d
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V
return-void
:cond_49
const-string v3, ""
goto :goto_3d
.end method
修改完成后保存。
3.3 使用3.2中相同方法修改android.policy\com\android\internal\policy\impl\PatternUnlockScreen.smali文件。
3.4 用smali将 android.policy文件夹回编译为classes.dex,将classes.dex拖入 android.policy.jar替换原有文件(用winrar打开 android.policy.jar)。
本文并非原创