title: modifying .smali files
body: <p>I reverse engineered some android apks to add some instrumentation for functional testing.
  I want to know given an smali as following how can I add something like </p>
  
  <pre><code>Log.e(TAG, "some descritpion", e);
  </code></pre>
  
  <p>to each method in the .smali files.</p>
  
  <pre><code>.class public Ld;
  .super Landroid/view/View;
  .source "SourceFile"
  
  
  # instance fields
  .field a:Z
  
  .field b:Lcom/rovio/ka3d/App;
  
  
  # direct methods
  .method public constructor &lt;init&gt;(Lcom/rovio/ka3d/App;)V
      .locals 2
      .parameter
  
      .prologue
      const/4 v1, 0x1
  
      .line 317
      invoke-direct {p0, p1}, Landroid/view/View;-&gt;&lt;init&gt;(Landroid/content/Context;)V
  
      .line 313
      const/4 v0, 0x0
  
      iput-boolean v0, p0, Ld;-&gt;a:Z
  
      .line 314
      const/4 v0, 0x0
  
      iput-object v0, p0, Ld;-&gt;b:Lcom/rovio/ka3d/App;
  
      .line 318
      iput-object p1, p0, Ld;-&gt;b:Lcom/rovio/ka3d/App;
  
      .line 319
      invoke-virtual {p0, v1}, Ld;-&gt;setFocusable(Z)V
  
      .line 320
      invoke-virtual {p0, v1}, Ld;-&gt;setFocusableInTouchMode(Z)V
  
      .line 321
      return-void
  .end method
  
  
  # virtual methods
  .method public a(Z)V
      .locals 4
      .parameter
  
      .prologue
      const/4 v3, 0x0
  
      .line 325
      invoke-virtual {p0}, Ld;-&gt;getContext()Landroid/content/Context;
  
      move-result-object v0
  
      const-string v1, "input_method"
  
      invoke-virtual {v0, v1}, Landroid/content/Context;-&gt;getSystemService(Ljava/lang/String;)Ljava/lang/Object;
  
      move-result-object v0
  
      check-cast v0, Landroid/view/inputmethod/InputMethodManager;
  
      .line 326
      invoke-virtual {p0}, Ld;-&gt;getWindowToken()Landroid/os/IBinder;
  
      move-result-object v1
  
      invoke-virtual {v0, v1, v3}, Landroid/view/inputmethod/InputMethodManager;-&gt;hideSoftInputFromWindow(Landroid/os/IBinder;I)Z
  
      .line 327
      if-eqz p1, :cond_0
  
      .line 329
      invoke-virtual {p0}, Ld;-&gt;getWindowToken()Landroid/os/IBinder;
  
      move-result-object v1
  
      const/4 v2, 0x2
  
      invoke-virtual {v0, v1, v2, v3}, Landroid/view/inputmethod/InputMethodManager;-&gt;toggleSoftInputFromWindow(Landroid/os/IBinder;II)V
  
      .line 330
      invoke-virtual {p0}, Ld;-&gt;requestFocus()Z
  
      .line 333
      :cond_0
      iput-boolean p1, p0, Ld;-&gt;a:Z
  
      .line 334
      return-void
  .end method
  
  .method public onCreateInputConnection(Landroid/view/inputmethod/EditorInfo;)Landroid/view/inputmethod/InputConnection;
      .locals 3
      .parameter
  
      .prologue
      .line 343
      new-instance v0, La;
  
      iget-object v1, p0, Ld;-&gt;b:Lcom/rovio/ka3d/App;
  
      const/4 v2, 0x0
  
      invoke-direct {v0, v1, p0, v2}, La;-&gt;&lt;init&gt;(Lcom/rovio/ka3d/App;Landroid/view/View;Z)V
  
      .line 345
      const/4 v1, 0x0
  
      iput-object v1, p1, Landroid/view/inputmethod/EditorInfo;-&gt;actionLabel:Ljava/lang/CharSequence;
  
      .line 350
      const v1, 0x80090
  
      iput v1, p1, Landroid/view/inputmethod/EditorInfo;-&gt;inputType:I
  
      .line 351
      const/high16 v1, 0x1000
  
      iput v1, p1, Landroid/view/inputmethod/EditorInfo;-&gt;imeOptions:I
  
      .line 352
      return-object v0
  .end method
  </code></pre>