[XDA-University] remuntada78:
hi all, i'm workink on old jellybean BatteryController.smali, i got the following error

E/AndroidRuntime( 1268): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference

E/AndroidRuntime( 1268):	at com.android.systemui.statusbar.policy.BatteryController.addIconView(BatteryController.java:103)

E/AndroidRuntime( 1268):	at com.android.systemui.statusbar.phone.PhoneStatusBar.makeStatusBarView(PhoneStatusBar.java:1346)

E/AndroidRuntime( 1268):	at com.android.systemui.statusbar.phone.PhoneStatusBar.addStatusBarWindow(PhoneStatusBar.java:4204)

E/AndroidRuntime( 1268):	at com.android.systemui.statusbar.phone.PhoneStatusBar.createAndAddWindows(PhoneStatusBar.java:4200)

E/AndroidRuntime( 1268):	at com.android.systemui.statusbar.BaseStatusBar.start(BaseStatusBar.java:1110)

the error is refered to the following code

.method public addIconView(Landroid/widget/ImageView;)V
.locals 1
.parameter "v"

.prologue
.line 103
iget-object v0, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mIconViews:Ljava/util/ArrayList;

invoke-virtual {v0, p1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

.line 104
return-void
.end method

i don't understand why

for more information i have

.line 48
new-instance v0, Ljava/util/ArrayList;

invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

iput-object v0, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mIconViews:Ljava/util/ArrayList;

.local v4, icon:I
:goto_0
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mIconViews:Ljava/util/ArrayList;

invoke-virtual {v7}, Ljava/util/ArrayList;->size()I

move-result v0

.line 140
.local v0, N:I
const/4 v3, 0x0

.local v3, i:I
:goto_1
if-ge v3, v0, :cond_1

.line 141
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mIconViews:Ljava/util/ArrayList;

invoke-virtual {v7, v3}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

move-result-object v6

check-cast v6, Landroid/widget/ImageView;

.line 142
.local v6, v:Landroid/widget/ImageView;
invoke-virtual {v6, v4}, Landroid/widget/ImageView;->setImageResource(I)V

.line 143
invoke-virtual {v6, p1}, Landroid/widget/ImageView;->setImageLevel(I)V

.line 144
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mContext:Landroid/content/Context;

const v8, 0x7f0a006c #accessibility_battery_level

const/4 v9, 0x1

new-array v9, v9, [Ljava/lang/Object;

const/4 v10, 0x0

invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

move-result-object v11

aput-object v11, v9, v10

invoke-virtual {v7, v8, v9}, Landroid/content/Context;->getString(I[Ljava/lang/Object;)Ljava/lang/String;

move-result-object v7

invoke-virtual {v6, v7}, Landroid/widget/ImageView;->setContentDescription(Ljava/lang/CharSequence;)V

.line 140
add-int/lit8 v3, v3, 0x1

goto :goto_1

.line 133
.end local v0 #N:I
.end local v3 #i:I
.end local v4 #icon:I
.end local v6 #v:Landroid/widget/ImageView;
:cond_0
goto/16 :goto_5

.line 136
.line 147
.restart local v4 #icon:I
.end local v4 #icon:I
.restart local v0 #N:I
.restart local v3 #i:I
.restart local v4 #icon:I
:cond_1
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mLabelViews:Ljava/util/ArrayList;

invoke-virtual {v7}, Ljava/util/ArrayList;->size()I

move-result v0

.line 148
const/4 v3, 0x0

:goto_2
if-ge v3, v0, :cond_2

.line 149
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mLabelViews:Ljava/util/ArrayList;

invoke-virtual {v7, v3}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

move-result-object v6

check-cast v6, Landroid/widget/TextView;

.line 150
.local v6, v:Landroid/widget/TextView;
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mContext:Landroid/content/Context;

const v8, 0x7f0a001c #status_bar_settings_battery_meter_format

const/4 v9, 0x1

new-array v9, v9, [Ljava/lang/Object;

const/4 v10, 0x0

invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

move-result-object v11

aput-object v11, v9, v10

invoke-virtual {v7, v8, v9}, Landroid/content/Context;->getString(I[Ljava/lang/Object;)Ljava/lang/String;

move-result-object v7

invoke-virtual {v6, v7}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 148
add-int/lit8 v3, v3, 0x1

goto :goto_2

.line 155
.end local v6 #v:Landroid/widget/TextView;
:cond_2
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryGroup:Landroid/view/ViewGroup;

if-eqz v7, :cond_3

.line 156
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryText:Landroid/widget/TextView;

invoke-static {p1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;

move-result-object v8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 157
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryCenterText:Landroid/widget/TextView;

invoke-static {p1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;

move-result-object v8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 158
new-instance v2, Landroid/text/SpannableStringBuilder;

new-instance v7, Ljava/lang/StringBuilder;

invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

invoke-static {p1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;

move-result-object v8

invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v7

const-string v8, "%"

invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v7

invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v7

invoke-direct {v2, v7}, Landroid/text/SpannableStringBuilder;-><init>(Ljava/lang/CharSequence;)V

.line 160
.local v2, formatted:Landroid/text/SpannableStringBuilder;
new-instance v5, Landroid/text/style/RelativeSizeSpan;

const v7, 0x3f333333

invoke-direct {v5, v7}, Landroid/text/style/RelativeSizeSpan;-><init>(F)V

.line 162
.local v5, style:Landroid/text/style/CharacterStyle;
const/16 v7, 0xa

if-ge p1, v7, :cond_4

.line 163
const/4 v7, 0x1

const/4 v8, 0x2

const/16 v9, 0x22

invoke-virtual {v2, v5, v7, v8, v9}, Landroid/text/SpannableStringBuilder;->setSpan(Ljava/lang/Object;III)V

.line 172
:goto_3
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly:Landroid/widget/TextView;

invoke-virtual {v7, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 173
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Low:Landroid/widget/TextView;

invoke-virtual {v7, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 174
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Plugged:Landroid/widget/TextView;

invoke-virtual {v7, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

.line 175
sget v7, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryStyle:I

const/4 v8, 0x1

if-ne v7, v8, :cond_8

.line 176
if-eqz p2, :cond_6

.line 177
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 178
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Plugged:Landroid/widget/TextView;

const/4 v8, 0x0

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 179
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Low:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 195
.end local v2 #formatted:Landroid/text/SpannableStringBuilder;
.end local v5 #style:Landroid/text/style/CharacterStyle;
:cond_3
:goto_4
return-void

.line 165
.restart local v2 #formatted:Landroid/text/SpannableStringBuilder;
.restart local v5 #style:Landroid/text/style/CharacterStyle;
:cond_4
const/16 v7, 0x64

if-ge p1, v7, :cond_5

.line 166
const/4 v7, 0x2

const/4 v8, 0x3

const/16 v9, 0x22

invoke-virtual {v2, v5, v7, v8, v9}, Landroid/text/SpannableStringBuilder;->setSpan(Ljava/lang/Object;III)V

goto :goto_3

.line 169
:cond_5
const/4 v7, 0x3

const/4 v8, 0x4

const/16 v9, 0x22

invoke-virtual {v2, v5, v7, v8, v9}, Landroid/text/SpannableStringBuilder;->setSpan(Ljava/lang/Object;III)V

goto :goto_3

.line 180
:cond_6
const/16 v7, 0x10

if-ge p1, v7, :cond_7

.line 181
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 182
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Plugged:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 183
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Low:Landroid/widget/TextView;

const/4 v8, 0x0

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

goto :goto_4

.line 185
:cond_7
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly:Landroid/widget/TextView;

const/4 v8, 0x0

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 186
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Plugged:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 187
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Low:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

goto :goto_4

.line 190
:cond_8
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 191
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Plugged:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

.line 192
iget-object v7, p0, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryTextOnly_Low:Landroid/widget/TextView;

const/16 v8, 0x8

invoke-virtual {v7, v8}, Landroid/widget/TextView;->setVisibility(I)V

goto :goto_4

:goto_5
sget v7, Lcom/android/systemui/statusbar/policy/BatteryController;->mBatteryStyle:I

const/4 v4, 0x4

if-ne v4, v7, :cond_a

if-eqz p2, :cond_9

const v4, 0x7f02033c #stat_sys_battery_c_charge

goto/16 :goto_0

:cond_9
const v4, 0x7f0202d6 #stat_sys_battery_c

goto/16 :goto_0

:cond_a
const/16 v4, 0xb

if-ne v4, v7, :cond_c

if-eqz p2, :cond_b

const v4, 0x7f020410 #stat_sys_battery_android_charge

goto/16 :goto_0

:cond_b
const v4, 0x7f0203aa #stat_sys_battery_android

goto/16 :goto_0

:cond_c
const/4 v4, 0x6

if-ne v4, v7, :cond_e

if-eqz p2, :cond_d

const v4, 0x7f0204de #stat_sys_battery_blueglass_charge

goto/16 :goto_0

:cond_d
const v4, 0x7f020478 #stat_sys_battery_blueglass

goto/16 :goto_0

:cond_e
const/4 v4, 0x7

if-ne v4, v7, :cond_10

if-eqz p2, :cond_f

const v4, 0x7f02067a #stat_sys_battery_castaway_charge

goto/16 :goto_0

:cond_f
const v4, 0x7f020614 #stat_sys_battery_castaway

goto/16 :goto_0

:cond_10
const/16 v4, 0x8

if-ne v4, v7, :cond_12

if-eqz p2, :cond_11

const v4, 0x7f020749 #stat_sys_battery_chrysis_charge

goto/16 :goto_0

:cond_11
const v4, 0x7f0206e3 #stat_sys_battery_chrysis

goto/16 :goto_0

:cond_12
const/16 v4, 0x9

if-ne v4, v7, :cond_14

if-eqz p2, :cond_13

const v4, 0x7f020817 #stat_sys_battery_drkbluehc_charge

goto/16 :goto_0

:cond_13
const v4, 0x7f0207b1 #stat_sys_battery_drkbluehc

goto/16 :goto_0

:cond_14
const/16 v4, 0xa

if-ne v4, v7, :cond_16

if-eqz p2, :cond_15

const v4, 0x7f0208e4 #stat_sys_battery_drkbluestock_charge

goto/16 :goto_0

:cond_15
const v4, 0x7f02087e #stat_sys_battery_drkbluestock

goto/16 :goto_0

:cond_16
const/4 v4, -0x1

if-ne v4, v7, :cond_18

if-eqz p2, :cond_17

const v4, 0x7f0209b2 #stat_sys_battery_greenglass_charge

goto/16 :goto_0

:cond_17
const v4, 0x7f02094c #stat_sys_battery_greenglass

goto/16 :goto_0

:cond_18
const/4 v4, -0x2

if-ne v4, v7, :cond_1a

if-eqz p2, :cond_19

const v4, 0x7f020a81 #stat_sys_battery_greenhc_charge

goto/16 :goto_0

:cond_19
const v4, 0x7f020a1b #stat_sys_battery_greenhc

goto/16 :goto_0

:cond_1a
const/4 v4, -0x3

if-ne v4, v7, :cond_1c

if-eqz p2, :cond_1b

const v4, 0x7f020b4e #stat_sys_battery_greenstock_charge

goto/16 :goto_0

:cond_1b
const v4, 0x7f020ae8 #stat_sys_battery_greenstock

goto/16 :goto_0

:cond_1c
const/4 v4, -0x4

if-ne v4, v7, :cond_1e

if-eqz p2, :cond_1d

const v4, 0x7f020c1c #stat_sys_battery_icsbluehc_charge

goto/16 :goto_0

:cond_1d
const v4, 0x7f020bb6 #stat_sys_battery_icsbluehc

goto/16 :goto_0

:cond_1e
const/4 v4, -0x5

if-ne v4, v7, :cond_20

if-eqz p2, :cond_1f

const v4, 0x7f020cea #stat_sys_battery_icsbluestock_charge

goto/16 :goto_0

:cond_1f
const v4, 0x7f020c84 #stat_sys_battery_icsbluestock

goto/16 :goto_0

:cond_20
const/4 v4, -0x6

if-ne v4, v7, :cond_22

if-eqz p2, :cond_21

const v4, 0x7f020db8 #stat_sys_battery_littleandroid_charge

goto/16 :goto_0

:cond_21
const v4, 0x7f020d52 #stat_sys_battery_littleandroid

goto/16 :goto_0

:cond_22
const/4 v4, -0x7

if-ne v4, v7, :cond_24

if-eqz p2, :cond_23

const v4, 0x7f020e86 #stat_sys_battery_naddict_charge

goto/16 :goto_0

:cond_23
const v4, 0x7f020e20 #stat_sys_battery_naddict

goto/16 :goto_0

:cond_24
const/16 v4, -0x8

if-ne v4, v7, :cond_26

if-eqz p2, :cond_25

const v4, 0x7f021022 #stat_sys_battery_sense_charge

goto/16 :goto_0

:cond_25
const v4, 0x7f020fbc #stat_sys_battery_sense

goto/16 :goto_0

:cond_26
const/16 v4, -0x9

if-ne v4, v7, :cond_28

if-eqz p2, :cond_27

const v4, 0x7f020f54 #stat_sys_battery_remove_charge

goto/16 :goto_0

:cond_27
const v4, 0x7f020eee #stat_sys_battery_remove

goto/16 :goto_0

:cond_28
if-eqz p2, :cond_29

const v4, 0x7f020083 #stat_sys_battery_charge

goto/16 :goto_0

:cond_29
const v4, 0x7f02007a #stat_sys_battery

goto/16 :goto_0
.end method