Vous êtes sur la page 1sur 7

package com.redmangoanalytics.

voicerecorder;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

android.content.Context;
android.content.Intent;
android.location.Location;
android.location.LocationListener;
android.location.LocationManager;
android.media.AudioManager;
android.net.Uri;
android.os.Binder;
android.os.Bundle;
android.os.CountDownTimer;
android.os.Environment;
android.os.IBinder;
android.support.v4.app.NotificationCompat.WearableExtender;
android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
android.support.v4.widget.DrawerLayout;
android.support.v7.app.ActionBarActivity;
android.telephony.CellInfo;
android.telephony.CellLocation;
android.telephony.PhoneStateListener;
android.telephony.ServiceState;
android.telephony.SignalStrength;
android.telephony.TelephonyManager;
android.telephony.gsm.GsmCellLocation;
android.util.Log;
android.view.Menu;
android.view.MenuItem;
android.view.View;
android.widget.EditText;
android.widget.TextView;
android.widget.Toast;
dalvik.system.DexFile;
java.io.File;
java.io.FileOutputStream;
java.io.IOException;
java.lang.reflect.Method;
java.util.ArrayList;
java.util.Enumeration;
java.util.List;

public class MainActivity extends ActionBarActivity {


protected float accuracy;
protected AudioManager am;
protected int callCount;
protected long callDuration;
protected long callPause;
protected boolean callPlaced;
protected int cellid;
protected CountDownTimer countdown;
protected Context ctx;
protected int currentServiceState;
protected int ecio;
protected long endTime;
protected int errorBitRate;
protected EditText etDuration;
protected EditText etIteration;
protected EditText etNumber;
FileOutputStream fileOutputStream;
protected GsmCellLocation gsmCellLocation;

protected String imei;


protected int lac;
protected double lat;
protected double lng;
protected LocationManager locationManager;
protected int maxCount;
protected int maxDuration;
protected int mcc;
protected int mnc;
protected int networkType;
protected float signal;
protected int snr;
protected float speed;
private ServiceState ss;
protected long startTime;
protected TelephonyManager tm;
private TextView tvRSSI;
private TextView tvSignal;
private TextView txtStatus;
/* renamed from: com.redmangoanalytics.voicerecorder.MainActivity.1 */
class C01421 implements LocationListener {
C01421() {
}
public void onLocationChanged(Location location) {
MainActivity.this.lat = location.getLatitude();
MainActivity.this.lng = location.getLongitude();
MainActivity.this.speed = location.getSpeed();
MainActivity.this.accuracy = location.getAccuracy();
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
}
private class CallStateListener extends PhoneStateListener {
/* renamed from: com.redmangoanalytics.voicerecorder.MainActivity.CallSt
ateListener.1 */
class C01431 extends CountDownTimer {
C01431(long x0, long x1) {
super(x0, x1);
}
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
MainActivity mainActivity = MainActivity.this;
mainActivity.callCount++;
MainActivity.this.callEnd();
}

}
private CallStateListener() {
}
public void onCellLocationChanged(CellLocation location) {
super.onCellLocationChanged(location);
if (MainActivity.this.currentServiceState == 0) {
if (location != null) {
MainActivity.this.cellid = ((GsmCellLocation) location).getC
id();
MainActivity.this.lac = ((GsmCellLocation) location).getLac(
);
MainActivity.this.networkType = MainActivity.this.tm.getNetw
orkType();
}
String networkOperator = MainActivity.this.tm.getNetworkOperator
();
if (networkOperator != null) {
MainActivity.this.mcc = Integer.parseInt(networkOperator.sub
string(0, 3));
MainActivity.this.mnc = Integer.parseInt(networkOperator.sub
string(3));
return;
}
return;
}
MainActivity.this.cellid = -1;
MainActivity.this.lac = -1;
MainActivity.this.networkType = -1;
MainActivity.this.mcc = -1;
MainActivity.this.mnc = -1;
}
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
switch (MainActivity.this.tm.getNetworkType()) {
case WearableExtender.SIZE_FULL_SCREEN /*5*/:
case FragmentManagerImpl.ANIM_STYLE_FADE_EXIT /*6*/:
case C0144R.styleable.Toolbar_titleMarginStart /*12*/:
MainActivity.this.signal = (float) signalStrength.getEvdoDbm
();
break;
default:
MainActivity.this.signal = (float) ((signalStrength.getGsmSi
gnalStrength() * 2) - 113);
break;
}
MainActivity.this.ecio = signalStrength.getEvdoEcio();
MainActivity.this.snr = signalStrength.getEvdoSnr();
MainActivity.this.errorBitRate = signalStrength.getGsmBitErrorRate()
;
MainActivity.this.networkType = MainActivity.this.tm.getNetworkType(
);
}
public void onCellInfoChanged(List<CellInfo> cellInfo) {
super.onCellInfoChanged(cellInfo);
}

public void onServiceStateChanged(ServiceState serviceState) {


super.onServiceStateChanged(serviceState);
MainActivity.this.currentServiceState = serviceState.getState();
}
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case SpinnerCompat.MODE_DIALOG /*0*/:
if (MainActivity.this.callPlaced) {
MainActivity.this.endTime = System.currentTimeMillis();
MainActivity.this.callPlaced = false;
MainActivity.this.callDuration = MainActivity.this.endTi
me - MainActivity.this.startTime;
MainActivity.this.writeLog();
if (MainActivity.this.maxDuration == -1 || MainActivity.
this.maxCount == -1 || MainActivity.this.callCount < MainActivity.this.maxCount)
{
try {
Thread.sleep(15000);
} catch (Exception e) {
}
MainActivity.this.startCalling();
}
}
case DrawerLayout.STATE_SETTLING /*2*/:
MainActivity.this.startTime = System.currentTimeMillis();
MainActivity.this.writeLog();
if (MainActivity.this.maxDuration != -1) {
MainActivity.this.countdown = new C01431((long) (MainAct
ivity.this.maxDuration * 1000), 100).start();
}
default:
}
}
}
public MainActivity() {
this.maxCount = 0;
this.maxDuration = 0;
this.callCount = 0;
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.callPlaced = false;
setContentView((int) C0144R.layout.activity_main);
this.ctx = getBaseContext();
this.etDuration = (EditText) findViewById(C0144R.id.etDuration);
this.etIteration = (EditText) findViewById(C0144R.id.etIteration);
this.etNumber = (EditText) findViewById(C0144R.id.etNumber);
this.txtStatus = (TextView) findViewById(C0144R.id.txtStatus);
this.tvRSSI = (TextView) findViewById(C0144R.id.tvRSSI);
this.tvSignal = (TextView) findViewById(C0144R.id.tvSignal);
String filename = "call_test_log.csv";
String path = this.ctx.getFilesDir().getAbsolutePath();
if (Environment.getExternalStorageDirectory().canWrite()) {
path = Environment.getExternalStoragePublicDirectory(Environment.DIR
ECTORY_DOWNLOADS).getAbsolutePath();
}
File file = new File(path, filename);

try {
if (!file.exists()) {
file.createNewFile();
}
this.fileOutputStream = new FileOutputStream(file, true);
} catch (Exception e) {
}
System.currentTimeMillis();
this.tm = (TelephonyManager) this.ctx.getSystemService("phone");
this.am = (AudioManager) this.ctx.getSystemService("audio");
this.imei = this.tm.getDeviceId();
this.locationManager = (LocationManager) this.ctx.getSystemService("loca
tion");
registerListener();
this.txtStatus.setText(Environment.getExternalStoragePublicDirectory(Env
ironment.DIRECTORY_DOCUMENTS).getAbsolutePath());
}
protected void registerListener() {
this.tm.listen(new CallStateListener(), 32);
this.tm.listen(new CallStateListener(), 16);
this.tm.listen(new CallStateListener(), AccessibilityNodeInfoCompat.ACTI
ON_NEXT_AT_MOVEMENT_GRANULARITY);
this.tm.listen(new CallStateListener(), 1);
LocationListener listener = new C01421();
this.locationManager.requestLocationUpdates("gps", 0, 0.0f, listener);
this.locationManager.requestLocationUpdates("network", 0, 0.0f, listener
);
}
protected void onDestroy() {
try {
this.fileOutputStream.close();
} catch (Exception e) {
}
super.onDestroy();
}
protected void writeLog() {
if (this.callPlaced) {
this.endTime = 0;
}
try {
this.fileOutputStream.write((this.startTime + "," + this.endTime + "
," + this.callDuration + "," + 0 + "," + this.lat + "," + this.lng + "," + this.
speed + "," + this.accuracy + "," + this.signal + "," + this.mcc + "," + this.mn
c + "," + this.lac + "," + this.currentServiceState + "," + this.cellid + "," +
this.imei + "," + this.networkType + "," + this.ecio + "," + this.snr + "," + th
is.errorBitRate + "\n").getBytes());
} catch (Exception ex) {
Log.e("File Error", ex.getMessage());
}
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(C0144R.menu.menu_main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {

if (item.getItemId() == C0144R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void callNumber(View v) {
if (this.etIteration.getText().length() <= 0 || this.etNumber.getText().
length() <= 2 || this.etDuration.getText().length() <= 0) {
Toast.makeText(this, "Some fields are missing", 1).show();
return;
}
this.maxCount = Integer.parseInt(this.etIteration.getText().toString());
this.maxDuration = Integer.parseInt(this.etDuration.getText().toString()
);
this.callCount = 0;
startCalling();
}
public void startCalling() {
if (this.tm.getCallState() == 0) {
this.callPlaced = true;
Intent dial = new Intent("android.intent.action.CALL", Uri.parse("te
l:" + this.etNumber.getText()));
this.am.setBluetoothScoOn(false);
this.am.setSpeakerphoneOn(true);
this.am.setMicrophoneMute(true);
startActivity(dial);
}
}
public void disconnect(View v) {
if (this.countdown != null) {
this.countdown.cancel();
this.maxDuration = 0;
this.maxCount = 0;
callEnd();
return;
}
this.maxDuration = 0;
this.maxCount = 0;
callEnd();
}
public void callEnd() {
try {
Class<?> telephonyClass = Class.forName("com.android.internal.teleph
ony.ITelephony");
Class<?> telephonyStubClass = telephonyClass.getClasses()[0];
Class<?> serviceManagerClass = Class.forName("android.os.ServiceMana
ger");
Class<?> serviceManagerNativeClass = Class.forName("android.os.Servi
ceManagerNative");
String str = "getService";
Method getService = serviceManagerClass.getMethod(r17, new Class[]{S
tring.class});
str = "asInterface";
Method tempInterfaceMethod = serviceManagerNativeClass.getMethod(r17
, new Class[]{IBinder.class});
new Binder().attachInterface(null, "fake");

IBinder retbinder = (IBinder) getService.invoke(tempInterfaceMethod.


invoke(null, new Object[]{tmpBinder}), new Object[]{"phone"});
str = "asInterface";
str = "endCall";
Object[] objArr = new Object[0];
telephonyClass.getMethod(r17, new Class[0]).invoke(telephonyStubClas
s.getMethod(r17, new Class[]{IBinder.class}).invoke(null, new Object[]{retbinder
}), objArr);
} catch (Exception e) {
}
}
private String[] getClassesOfPackage(String packageName) {
ArrayList<String> classes = new ArrayList();
try {
Enumeration<String> iter = new DexFile(getPackageCodePath()).entries
();
while (iter.hasMoreElements()) {
String className = (String) iter.nextElement();
if (className.contains(packageName)) {
classes.add(className.substring(className.lastIndexOf(".") +
1, className.length()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
return toStringArray(classes);
}
private String[] toStringArray(ArrayList<String> classes) {
String[] array = new String[classes.size()];
for (int i = 0; i < classes.size(); i++) {
array[i] = (String) classes.get(i);
}
return array;
}
}

Vous aimerez peut-être aussi