|
|
|
@ -1,11 +1,14 @@
|
|
|
|
|
package com.idormy.sms.forwarder;
|
|
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
@ -22,15 +25,14 @@ import androidx.core.app.ActivityCompat;
|
|
|
|
|
|
|
|
|
|
import com.idormy.sms.forwarder.BroadCastReceiver.SmsForwarderBroadcastReceiver;
|
|
|
|
|
import com.idormy.sms.forwarder.adapter.LogAdapter;
|
|
|
|
|
import com.idormy.sms.forwarder.model.LogModel;
|
|
|
|
|
import com.idormy.sms.forwarder.model.vo.LogVo;
|
|
|
|
|
import com.idormy.sms.forwarder.utils.LogUtil;
|
|
|
|
|
import com.umeng.analytics.MobclickAgent;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements ReFlashListView.IReflashListener {
|
|
|
|
|
|
|
|
|
@ -41,6 +43,8 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
|
|
|
|
private List<LogVo> logVos = new ArrayList<>();
|
|
|
|
|
private LogAdapter adapter;
|
|
|
|
|
private ReFlashListView listView;
|
|
|
|
|
//SIM卡信息
|
|
|
|
|
//private Map<String, Map> SimInfo = new HashMap();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -65,12 +69,15 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
|
|
|
|
//检查权限是否获取
|
|
|
|
|
checkPermission();
|
|
|
|
|
|
|
|
|
|
//获取本机号码
|
|
|
|
|
//获取本机号码(注意:这里获取的不一定是卡槽1的)
|
|
|
|
|
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
String Line1Number = mTelephonyMgr.getLine1Number();
|
|
|
|
|
Log.d(TAG, "Line1Number: " + Line1Number);
|
|
|
|
|
MyApplication appContext = ((MyApplication) getApplicationContext());
|
|
|
|
|
appContext.setLine1Number(Line1Number);
|
|
|
|
|
|
|
|
|
|
//获取SIM卡信息
|
|
|
|
|
getSimInfo(Line1Number);
|
|
|
|
|
//MyApplication appContext = ((MyApplication) getApplicationContext());
|
|
|
|
|
//appContext.setSimInfo(SimInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化数据
|
|
|
|
@ -121,7 +128,12 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
|
|
|
|
public void logDetail(LogVo logVo) {
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
|
builder.setTitle("详情");
|
|
|
|
|
builder.setMessage(logVo.getFrom() + "\n\n" + logVo.getContent() + "\n\n" + logVo.getRule() + "\n\n" + logVo.getTime());
|
|
|
|
|
String simInfo = logVo.getSimInfo();
|
|
|
|
|
if (simInfo != null) {
|
|
|
|
|
builder.setMessage(logVo.getFrom() + "\n\n" + logVo.getContent() + "\n\n" + logVo.getSimInfo() + "\n\n" + logVo.getRule() + "\n\n" + logVo.getTime());
|
|
|
|
|
} else {
|
|
|
|
|
builder.setMessage(logVo.getFrom() + "\n\n" + logVo.getContent() + "\n\n" + logVo.getRule() + "\n\n" + logVo.getTime());
|
|
|
|
|
}
|
|
|
|
|
builder.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -158,14 +170,6 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addLog(View view) {
|
|
|
|
|
Log.d(TAG, "refreshLog");
|
|
|
|
|
LogModel newModel = new LogModel("199999", "content" + (new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").format(new Date())), 1l);
|
|
|
|
|
LogUtil.addLog(newModel);
|
|
|
|
|
// initTLogs();
|
|
|
|
|
// adapter.add(logVos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//按返回键不退出回到桌面
|
|
|
|
|
@Override
|
|
|
|
|
public void onBackPressed() {
|
|
|
|
@ -225,4 +229,33 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
|
|
|
|
MobclickAgent.onPause(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取SIM卡信息
|
|
|
|
|
private void getSimInfo(String Line1Number) {
|
|
|
|
|
Uri uri = Uri.parse("content://telephony/siminfo"); //访问raw_contacts表
|
|
|
|
|
MyApplication appContext = ((MyApplication) getApplicationContext());
|
|
|
|
|
ContentResolver resolver = appContext.getContentResolver();
|
|
|
|
|
Cursor cursor = resolver.query(uri, new String[]{"_id", "icc_id", "sim_id", "display_name", "carrier_name", "name_source", "color", "number", "display_number_format", "data_roaming", "mcc", "mnc"}, "sim_id >= 0", null, "_id");
|
|
|
|
|
if (cursor != null) {
|
|
|
|
|
while (cursor.moveToNext()) {
|
|
|
|
|
Log.d(TAG, "_id: " + cursor.getString(cursor.getColumnIndex("_id")));
|
|
|
|
|
Log.d(TAG, "sim_id: " + cursor.getString(cursor.getColumnIndex("sim_id")));
|
|
|
|
|
Log.d(TAG, "carrier_name: " + cursor.getString(cursor.getColumnIndex("carrier_name")));
|
|
|
|
|
Log.d(TAG, "display_name: " + cursor.getString(cursor.getColumnIndex("display_name")));
|
|
|
|
|
Map<String, String> sim = new HashMap();
|
|
|
|
|
String id = cursor.getString(cursor.getColumnIndex("_id"));
|
|
|
|
|
sim.put("_id", id);
|
|
|
|
|
sim.put("sim_id", cursor.getString(cursor.getColumnIndex("sim_id")));
|
|
|
|
|
sim.put("carrier_name", cursor.getString(cursor.getColumnIndex("carrier_name")));
|
|
|
|
|
sim.put("display_name", cursor.getString(cursor.getColumnIndex("display_name")));
|
|
|
|
|
sim.put("phone_number", Line1Number);
|
|
|
|
|
if (Line1Number != "Unknown") {
|
|
|
|
|
Line1Number = "Unknown";
|
|
|
|
|
}
|
|
|
|
|
MyApplication.SimInfo.put(id, sim);
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
Log.d(TAG, String.valueOf(MyApplication.SimInfo.get("2").get("sim_id")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|