然后看了android的源码,得到音量这个方法用的是本地的native 方法。但是我又不会C++,也没有源码不能分析,然后反编了微信的apk,看到他们的录音好你用的是自己写的native方法。如下:
package com.tencent.mm.compatible.audio;import android.media.MediaRecorder;
import com.tencent.mm.compatible.f.k;
import com.tencent.mm.pointers.PByteArray;
import com.tencent.mm.sdk.platformtools.by;
import com.tencent.mm.sdk.platformtools.y;public class SimpleMediaRecorder
{
  public static final int[] bnp = { 13, 14, 16, 18, 20, 21, 27, 32 };
  private static long bnw = 0L;
  private static Object bnx = new Object();
  private n bnA = null;
  private b bnB;
  private aa bnC;
  private int bnD = 8000;
  private int bnE = 0;
  private k bnF = new k();
  private p bnG = new u(???);
  private z bnq;
  private int bnr = 0;
  private String bns = null;
  private v bnt = null;
  private long bnu = 0L;
  private long bnv = 0L;
  private MediaRecorder bny;
  private int bnz;  public SimpleMediaRecorder(b paramb)
  {
    this.bnB = paramb;
    if (paramb == b.bmv)
    {
      this.bnz = 7;
      this.bny = new MediaRecorder();
      return;
    }
    this.bnD = 8000;
    int i = by.a((Integer)com.tencent.mm.compatible.c.n.gJ().get(102401), 0);
    y.aC("MicroMsg.SimpleMediaRecorder", "dk16k sr:" + this.bnD + " notsu:" + i);
    if (i == 1)
      this.bnD = 8000;
    this.bnr = 0;
    this.bns = null;
    this.bnt = null;
    try
    {
      y.aC("MicroMsg.SimpleMediaRecorder", "!!out mutex :" + bnx.hashCode());
      synchronized (bnx)
      {
        this.bnA = new n(this.bnD, 120, true, 0);
        this.bnA.a(this.bnG);
        this.bnC = aa.bnV;
        this.bnz = 1;
        return;
      }
    }
    catch (Exception localException)
    {
      while (localException.getMessage() != null)
      {
        y.az("MicroMsg.SimpleMediaRecorder", localException.getMessage());
        this.bnC = aa.bnY;
      }
      y.az("MicroMsg.SimpleMediaRecorder", "Unknown error occured while initializing recording");
    }
  }  private static native boolean native_init();  private static native boolean native_pcm2amr(int paramInt1, byte[] paramArrayOfByte, int paramInt2, PByteArray paramPByteArray, int paramInt3);  private static native boolean native_pcmresamp(byte[] paramArrayOfByte, int paramInt, PByteArray paramPByteArray);  private static native boolean native_release();  public final void a(z paramz)
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bnq = paramz;
      this.bny.setOnErrorListener(new t(this));
      this.bnC = aa.bnY;
      return;
    }
    try
    {
      if (this.bnC != aa.bnV);
      this.bnq = paramz;
      return;
    }
    catch (Exception localException)
    {
      if (localException.getMessage() != null)
      {
        y.az("MicroMsg.SimpleMediaRecorder", localException.getMessage());
        this.bnC = aa.bnY;
        return;
      }
      y.az("MicroMsg.SimpleMediaRecorder", "Unknown error occured while setting output path");
    }
  }  public final int getMaxAmplitude()
  {
    if (this.bnB == b.bmv)
      if (this.bny == null);
    do
    {
      return 0;
      return this.bny.getMaxAmplitude();
    }
    while (this.bnC != aa.bnX);
    int i = this.bnr;
    this.bnr = 0;
    return i;
  }  public final void gq()
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bny.setMaxDuration(3600010);
      return;
    }
    this.bnu = 3600010L;
  }  public final void gr()
  {
    if ((this.bnB != b.bmv) || (this.bny == null))
      return;
    this.bny.setAudioEncoder(1);
  }  public final void gs()
  {
    if ((this.bnB != b.bmv) || (this.bny == null))
      return;
    this.bny.setAudioSource(1);
  }  public final void gt()
  {
    if ((this.bnB != b.bmv) || (this.bny == null))
      return;
    this.bny.setOutputFormat(3);
  }  public final boolean gu()
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny != null)
      {
        this.bny.stop();
        this.bny.release();
        this.bny = null;
      }
      return true;
    }
    k localk = new k();
    y.aC("MicroMsg.SimpleMediaRecorder", "Stop now  state:" + this.bnC);
    if (this.bnC != aa.bnX)
    {
      y.az("MicroMsg.SimpleMediaRecorder", "stop() called on illegal state");
      this.bnC = aa.bnY;
      return true;
    }
    synchronized (bnx)
    {
      if (this.bnA != null)
      {
        this.bnA.gk();
        this.bnA.a(null);
      }
      long l1 = localk.hk();
      this.bnC = aa.bnZ;
      long l2 = localk.hk();
      this.bnt.gy();
      long l3 = by.L(this.bnv);
      y.az("MicroMsg.SimpleMediaRecorder", "toNow " + l3 + " sStartTS " + this.bnv + " bufferLen " + bnw);
      if ((l3 <= 2000L) || (bnw != 0L))
        break label250;
      com.tencent.mm.compatible.c.n.gJ().set(102401, Integer.valueOf(1));
      y.az("MicroMsg.SimpleMediaRecorder", "16k not suppourt");
      label250: y.aC("MicroMsg.SimpleMediaRecorder", "Wait Stop Time Media:" + l1 + " Read:" + l2 + " Thr:" + localk.hk());
      return false;
    }
  }  public final void prepare()
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bny.prepare();
      return;
    }
    if ((this.bnC != aa.bnV) || (this.bns == null))
    {
      this.bnC = aa.bnY;
      release();
      return;
    }
    this.bnC = aa.bnW;
  }  public final void release()
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bny.release();
      return;
    }
    if (this.bnC == aa.bnX)
      gu();
    while (true)
      synchronized (bnx)
      {
        if (this.bnA != null)
        {
          this.bnA.gk();
          this.bnA = null;
        }
        return;
      }
  }  public final void setOutputFile(String paramString)
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bny.setOutputFile(paramString);
      this.bns = paramString;
      return;
    }
    if (this.bnC == aa.bnV)
    {
      this.bns = paramString;
      return;
    }
    this.bnC = aa.bnY;
  }  public final void start()
  {
    if (this.bnB == b.bmv)
    {
      if (this.bny == null)
        return;
      this.bny.start();
      return;
    }
    y.aC("MicroMsg.SimpleMediaRecorder", "Start now  state:" + this.bnC);
    if (this.bnC == aa.bnW)
    {
      this.bnv = System.currentTimeMillis();
      bnw = 0L;
      this.bnC = aa.bnX;
      synchronized (bnx)
      {
        if (this.bnt == null)
        {
          this.bnt = new v();
          v.a(this.bnt, this.bnz, this.bns);
        }
        this.bnA.gj();
        return;
      }
    }
    com.tencent.mm.compatible.c.n.gJ().set(102401, Integer.valueOf(1));
    y.az("MicroMsg.SimpleMediaRecorder", "start() called on illegal state");
    this.bnC = aa.bnY;
  }
}