我正在尝试更改Settings.apk中的默认值。
首先,我将“android:默认值”(0 =右,1 =居中)添加到status_bar_clock_style.xml,但没有成功。
<ListPreference android:entries="@array/clock_style_entries" android:title="@string/clock_title_enable" android:key="clock_style" android:dependency="status_bar_show_clock" android:entryValues="@array/clock_style_values" android:defaultValue="1" />
然后将smali转换为java并在那里进行更改也没有用,因为我无法再次编译代码。这本来要容易得多......
所以我在StatusBarClockStyle.smali的相关方法中进行了实验并更改了序言。现在默认选择该值,但仍未实现。
.method private createCustomView()Landroid/preference/PreferenceScreen;
.locals 15
.prologue
const/4 v14, -0x2
const/4 v11, 0x0
const/4 v9, 0x1
const/4 v10, 0x1 // used to be 0x0.
.line 89
iput-boolean v10, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mCheckPreferences:Z
.line 90
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v6
.line 91
.local v6, prefSet:Landroid/preference/PreferenceScreen;
if-eqz v6, :cond_0
.line 92
invoke-virtual {v6}, Landroid/preference/PreferenceScreen;->removeAll()V
.line 95
:cond_0
const v8, 0x7f050057
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->addPreferencesFromResource(I)V
.line 96
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v6
.line 98
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getPackageManager()Landroid/content/pm/PackageManager;
move-result-object v5
.line 101
.local v5, pm:Landroid/content/pm/PackageManager;
:try_start_0
const-string v8, "com.android.systemui"
invoke-virtual {v5, v8}, Landroid/content/pm/PackageManager;->getResourcesForApplication(Ljava/lang/String;)Landroid/content/res/Resources;
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
move-result-object v7
.line 107
.local v7, systemUiResources:Landroid/content/res/Resources;
const-string v8, "clock_style"
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/ListPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockStyle:Landroid/preference/ListPreference;
.line 108
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockStyle:Landroid/preference/ListPreference;
invoke-virtual {v8, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 109
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockStyle:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v12
invoke-virtual {v12}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v12
const-string v13, "statusbar_clock_style"
invoke-static {v12, v13, v10}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v12
invoke-static {v12}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v12
invoke-virtual {v8, v12}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
.line 112
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockStyle:Landroid/preference/ListPreference;
iget-object v12, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockStyle:Landroid/preference/ListPreference;
invoke-virtual {v12}, Landroid/preference/ListPreference;->getEntry()Ljava/lang/CharSequence;
move-result-object v12
invoke-virtual {v8, v12}, Landroid/preference/ListPreference;->setSummary(Ljava/lang/CharSequence;)V
.line 114
const-string v8, "status_bar_am_pm"
invoke-virtual {v6, v8}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/ListPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
.line 115
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
invoke-virtual {v8, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 116
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v12
invoke-virtual {v12}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v12
const-string v13, "statusbar_clock_am_pm_style"
invoke-static {v12, v13, v10}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v12
invoke-static {v12}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v12
invoke-virtual {v8, v12}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
.line 119
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v8
invoke-static {v8}, Landroid/text/format/DateFormat;->is24HourFormat(Landroid/content/Context;)Z
move-result v3
.line 120
.local v3, is24hour:Z
if-eqz v3, :cond_3
.line 121
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
const v12, 0x7f0800ca
invoke-virtual {v8, v12}, Landroid/preference/ListPreference;->setSummary(I)V
.line 125
:goto_0
iget-object v12, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
if-nez v3, :cond_4
move v8, v9
:goto_1
invoke-virtual {v12, v8}, Landroid/preference/ListPreference;->setEnabled(Z)V
.line 127
const-string v8, "clock_color"
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mColorPicker:Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
.line 128
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mColorPicker:Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
invoke-virtual {v8, p0}, Lnet/margaritov/preference/colorpicker/ColorPickerPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 129
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v8
invoke-virtual {v8}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v8
const-string v12, "statusbar_clock_color"
invoke-static {v8, v12, v14}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v2
.line 131
.local v2, intColor:I
if-ne v2, v14, :cond_5
.line 132
const-string v8, "com.android.systemui:color/status_bar_clock_color"
invoke-virtual {v7, v8, v11, v11}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
move-result v8
invoke-virtual {v7, v8}, Landroid/content/res/Resources;->getColor(I)I
move-result v2
.line 134
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mColorPicker:Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getResources()Landroid/content/res/Resources;
move-result-object v11
const v12, 0x7f080067
invoke-virtual {v11, v12}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;
move-result-object v11
invoke-virtual {v8, v11}, Lnet/margaritov/preference/colorpicker/ColorPickerPreference;->setSummary(Ljava/lang/CharSequence;)V
.line 139
:goto_2
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mColorPicker:Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
invoke-virtual {v8, v2}, Lnet/margaritov/preference/colorpicker/ColorPickerPreference;->setNewPreviewColor(I)V
.line 141
const-string v8, "clock_date_display"
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/ListPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateDisplay:Landroid/preference/ListPreference;
.line 142
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateDisplay:Landroid/preference/ListPreference;
invoke-virtual {v8, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 143
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateDisplay:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v11
invoke-virtual {v11}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v11
const-string v12, "statusbar_clock_date_display"
invoke-static {v11, v12, v10}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v11
invoke-static {v11}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v11
invoke-virtual {v8, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
.line 146
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateDisplay:Landroid/preference/ListPreference;
iget-object v11, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateDisplay:Landroid/preference/ListPreference;
invoke-virtual {v11}, Landroid/preference/ListPreference;->getEntry()Ljava/lang/CharSequence;
move-result-object v11
invoke-virtual {v8, v11}, Landroid/preference/ListPreference;->setSummary(Ljava/lang/CharSequence;)V
.line 148
const-string v8, "clock_date_style"
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/ListPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
.line 149
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
invoke-virtual {v8, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 150
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v11
invoke-virtual {v11}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v11
const-string v12, "statusbar_clock_date_style"
const/4 v13, 0x2
invoke-static {v11, v12, v13}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v11
invoke-static {v11}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;
move-result-object v11
invoke-virtual {v8, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
.line 153
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
iget-object v11, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
invoke-virtual {v11}, Landroid/preference/ListPreference;->getEntry()Ljava/lang/CharSequence;
move-result-object v11
invoke-virtual {v8, v11}, Landroid/preference/ListPreference;->setSummary(Ljava/lang/CharSequence;)V
.line 155
const-string v8, "clock_date_format"
invoke-virtual {p0, v8}, Lcom/android/settings/slim/StatusBarClockStyle;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/ListPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateFormat:Landroid/preference/ListPreference;
.line 156
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateFormat:Landroid/preference/ListPreference;
invoke-virtual {v8, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 157
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateFormat:Landroid/preference/ListPreference;
invoke-virtual {v8}, Landroid/preference/ListPreference;->getValue()Ljava/lang/String;
move-result-object v8
if-nez v8, :cond_1
.line 158
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateFormat:Landroid/preference/ListPreference;
const-string v11, "EEE"
invoke-virtual {v8, v11}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V
.line 161
:cond_1
invoke-direct {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->parseClockDateFormats()V
.line 163
const-string v8, "status_bar_show_clock"
invoke-virtual {v6, v8}, Landroid/preference/PreferenceScreen;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v8
check-cast v8, Landroid/preference/CheckBoxPreference;
iput-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mStatusBarClock:Landroid/preference/CheckBoxPreference;
.line 164
iget-object v11, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mStatusBarClock:Landroid/preference/CheckBoxPreference;
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v8
invoke-virtual {v8}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;
move-result-object v8
invoke-virtual {v8}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v8
const-string v12, "status_bar_clock"
invoke-static {v8, v12, v9}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v8
if-ne v8, v9, :cond_6
move v8, v9
:goto_3
invoke-virtual {v11, v8}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
.line 167
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mStatusBarClock:Landroid/preference/CheckBoxPreference;
invoke-virtual {v8, p0}, Landroid/preference/CheckBoxPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V
.line 169
invoke-virtual {p0}, Lcom/android/settings/slim/StatusBarClockStyle;->getActivity()Landroid/app/Activity;
move-result-object v8
invoke-virtual {v8}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v8
const-string v11, "statusbar_clock_date_display"
invoke-static {v8, v11, v10}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v8
if-eqz v8, :cond_7
move v4, v9
.line 171
.local v4, mClockDateToggle:Z
:goto_4
if-nez v4, :cond_2
.line 172
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateStyle:Landroid/preference/ListPreference;
invoke-virtual {v8, v10}, Landroid/preference/ListPreference;->setEnabled(Z)V
.line 173
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockDateFormat:Landroid/preference/ListPreference;
invoke-virtual {v8, v10}, Landroid/preference/ListPreference;->setEnabled(Z)V
.line 176
:cond_2
invoke-virtual {p0, v9}, Lcom/android/settings/slim/StatusBarClockStyle;->setHasOptionsMenu(Z)V
.line 177
iput-boolean v9, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mCheckPreferences:Z
.line 178
.end local v2 #intColor:I
.end local v3 #is24hour:Z
.end local v4 #mClockDateToggle:Z
.end local v6 #prefSet:Landroid/preference/PreferenceScreen;
.end local v7 #systemUiResources:Landroid/content/res/Resources;
:goto_5
return-object v6
.line 102
.restart local v6 #prefSet:Landroid/preference/PreferenceScreen;
:catch_0
move-exception v0
.line 103
.local v0, e:Ljava/lang/Exception;
const-string v8, "StatusBarClockStyle"
const-string v9, "can\'t access systemui resources"
invoke-static {v8, v9, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
move-object v6, v11
.line 104
goto :goto_5
.line 123
.end local v0 #e:Ljava/lang/Exception;
.restart local v3 #is24hour:Z
.restart local v7 #systemUiResources:Landroid/content/res/Resources;
:cond_3
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
iget-object v12, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mClockAmPmStyle:Landroid/preference/ListPreference;
invoke-virtual {v12}, Landroid/preference/ListPreference;->getEntry()Ljava/lang/CharSequence;
move-result-object v12
invoke-virtual {v8, v12}, Landroid/preference/ListPreference;->setSummary(Ljava/lang/CharSequence;)V
goto/16 :goto_0
:cond_4
move v8, v10
.line 125
goto/16 :goto_1
.line 136
.restart local v2 #intColor:I
:cond_5
const-string v8, "#%08x"
new-array v11, v9, [Ljava/lang/Object;
and-int/lit8 v12, v2, -0x1
invoke-static {v12}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v12
aput-object v12, v11, v10
invoke-static {v8, v11}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v1
.line 137
.local v1, hexColor:Ljava/lang/String;
iget-object v8, p0, Lcom/android/settings/slim/StatusBarClockStyle;->mColorPicker:Lnet/margaritov/preference/colorpicker/ColorPickerPreference;
invoke-virtual {v8, v1}, Lnet/margaritov/preference/colorpicker/ColorPickerPreference;->setSummary(Ljava/lang/CharSequence;)V
goto/16 :goto_2
.end local v1 #hexColor:Ljava/lang/String;
:cond_6
move v8, v10
.line 164
goto :goto_3
:cond_7
move v4, v10
.line 169
goto :goto_4
.end method
有人能指出我正确的方向看什么或告诉我如何实现另一种方式?谢谢=)
(编辑:我知道我可以在status_bar.xml中执行此操作,这通常是关于更改默认值。)