工作空间 v3.6.5.2版本的 MD5 值为:58e65af156c65a63bf64ed2e64960853
以下内容为反编译后的 NativeModule.java 源代码,内容仅作参考
package com.uusafe.jsbridge.module;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.database.Cursor;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog;
import android.provider.ContactsContract;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.widget.Toast;
import com.uusafe.commbase.env.CrashHandler;
import com.uusafe.commbase.global.BaseGlobal;
import com.uusafe.emm.policy.DevicePolicyWrapper;
import com.uusafe.emm.policy.PolicyProtocol;
import com.uusafe.h5app.library.utils.ToastUtil;
import com.uusafe.jsbridge.base.JavascriptMethod;
import com.uusafe.jsbridge.bean.JsCallback;
import com.uusafe.jsbridge.bean.WritableJsMap;
import com.uusafe.net.model.Progress;
import com.uusafe.permission.util.PermissionsUtils;
import com.uusafe.sandbox.controller.utility.AppEnv;
import com.uusafe.sandboxsdk.publish.UUSandboxSdk;
import com.uusafe.util.H5AppUtils;
import com.uusafe.util.PackageUtils;
import com.uusafe.utils.common.ContactUtils;
import com.uusafe.utils.common.DateUtil;
import com.uusafe.utils.common.NativeUtil;
import com.uusafe.utils.common.StringUtils;
import com.zhizhangyi.platform.log.ZLog;
import com.zhizhangyi.platform.mdm.api.common.ResultConst;
import com.zhizhangyi.platform.performance.internal.ApmProvider;
import com.zzy.engine.app.sdk.module.ZModuleWatermark;
import java.io.File;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import net.sqlcipher.database.SQLiteDatabase;
import org.json.JSONObject;
public class NativeModule extends JsModule {
LocationListener locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
NativeModule.this.showLocation(location);
}
@Override
public void onProviderDisabled(String str) {
}
@Override
public void onProviderEnabled(String str) {
}
@Override
public void onStatusChanged(String str, int i, Bundle bundle) {
}
};
@SuppressLint({"MissingPermission"})
private void addCallLOg(Context context) {
ContentValues contentValues = new ContentValues();
contentValues.clear();
contentValues.put("name", "lum");
contentValues.put("number", (Integer) 123456789);
contentValues.put("type", "1");
contentValues.put("new", DevicePolicyWrapper.DEFAULT_ID);
context.getContentResolver().insert(CallLog.Calls.CONTENT_URI, contentValues);
}
public static String getContact(Context context) {
StringBuffer stringBuffer = new StringBuffer();
Cursor query = context.getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, new String[]{"_id", "display_name"}, null, null, null);
String[] strArr = new String[query.getCount()];
if (query != null && query.moveToFirst()) {
do {
try {
Long valueOf = Long.valueOf(query.getLong(0));
String string = query.getString(1);
stringBuffer.append("name=" + string + ";");
ContentResolver contentResolver = context.getContentResolver();
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
Cursor query2 = contentResolver.query(uri, new String[]{"data1"}, "contact_id=" + valueOf, null, null);
if (query2 != null && query2.moveToFirst()) {
do {
String replaceAll = query2.getString(0).replaceAll("[^0-9]", "");
stringBuffer.append("number=" + replaceAll + ";");
} while (query2.moveToNext());
}
} catch (Exception unused) {
}
} while (query.moveToNext());
return stringBuffer.toString();
}
return stringBuffer.toString();
}
private String getContentCallLog(Context context) {
Cursor query = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, new String[]{"name", "number", Progress.DATE, ApmProvider.F_DURATION, "type"}, null, null, "date DESC");
StringBuffer stringBuffer = new StringBuffer();
while (query.moveToNext()) {
String string = query.getString(query.getColumnIndex("name"));
String string2 = query.getString(query.getColumnIndex("number"));
long j = query.getLong(query.getColumnIndex(Progress.DATE));
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(j));
new SimpleDateFormat(DateUtil.HHMM).format(new Date(j));
query.getInt(query.getColumnIndex(ApmProvider.F_DURATION));
query.getInt(query.getColumnIndex("type"));
new SimpleDateFormat("dd").format(new Date());
new SimpleDateFormat("dd").format(new Date(j));
stringBuffer.append("name==" + string + "&phone" + string2);
}
return stringBuffer.toString();
}
private String getSMS(Context context) {
Cursor query = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[]{"_id", "address", "person", "body", Progress.DATE, "type"}, "read = ?", new String[]{DevicePolicyWrapper.DEFAULT_ID}, "date desc");
StringBuilder sb = new StringBuilder();
if (query.moveToFirst()) {
int columnIndex = query.getColumnIndex("address");
int columnIndex2 = query.getColumnIndex("person");
int columnIndex3 = query.getColumnIndex("body");
int columnIndex4 = query.getColumnIndex(Progress.DATE);
int columnIndex5 = query.getColumnIndex("type");
do {
String string = query.getString(columnIndex);
int i = query.getInt(columnIndex2);
String string2 = query.getString(columnIndex3);
long j = query.getLong(columnIndex4);
int i2 = query.getInt(columnIndex5);
String format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date(j));
String str = i2 == 1 ? "接收" : i2 == 2 ? "发送" : i2 == 3 ? "草稿" : i2 == 4 ? "发件箱" : i2 == 5 ? "发送失败" : i2 == 6 ? "待发送列表" : i2 == 0 ? "所以短信" : "null";
sb.append("[ ");
sb.append(string + ", ");
sb.append(i + ", ");
sb.append(string2 + ", ");
sb.append(format + ", ");
sb.append(str);
sb.append(" ]\n\n");
} while (query.moveToNext());
if (!query.isClosed()) {
query.close();
}
} else {
sb.append("no result!");
}
sb.append("getSmsInPhone has executed!");
return sb.toString();
}
public void showLocation(Location location) {
ToastUtil.show(getContext(), "location------>经度为:" + location.getLatitude() + "\n纬度为" + location.getLongitude());
}
@Override
public String getModuleName() {
return "native";
}
@JavascriptMethod
public void openAppInfo(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
Intent launchIntent;
String stringArg = JsModule.getStringArg(hashMap, "notice", "应用未安装");
WritableJsMap jsonArg = JsModule.getJsonArg(hashMap, "android");
if (jsonArg != null) {
String string = jsonArg.getString("packageName");
if (!PackageUtils.isPkgInstalled(string, -1, -1)) {
Toast.makeText(AppEnv.getContext(), stringArg, 1).show();
return;
}
String string2 = jsonArg.getString("pageUrl");
String string3 = jsonArg.getString("extend");
if (StringUtils.areNotEmpty(string2)) {
launchIntent = PackageUtils.getLaunchIntent(getContext(), string, string2);
} else {
launchIntent = PackageUtils.getLaunchIntent(getContext(), string, null);
}
if (launchIntent != null) {
if (StringUtils.areNotEmpty(string2) && !TextUtils.isEmpty(string2)) {
launchIntent.putExtra("pageUrl", string2);
}
if (StringUtils.areNotEmpty(string3) && !TextUtils.isEmpty(string3)) {
launchIntent.putExtra("extend", string3);
}
getContext().startActivity(launchIntent);
return;
}
getFragment().showToast(stringArg);
ZLog.f("NativeModule", String.format("LaunchIntent of %s is null", string));
}
}
@JavascriptMethod
public void openFile(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
try {
UUSandboxSdk.Sandbox.viewDoc(new File(H5AppUtils.getFileFullPath(getFragment(), JsModule.getStringArg(hashMap, CrashHandler.EXTRA_PATH, ""))));
} catch (Throwable th) {
th.printStackTrace();
}
}
@JavascriptMethod
public void openNativeApp(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
Intent launchIntentForPackage;
String stringArg = JsModule.getStringArg(hashMap, PolicyProtocol.APP_APP_ID, "");
String stringArg2 = JsModule.getStringArg(hashMap, "activity", "");
WritableJsMap jsonArg = JsModule.getJsonArg(hashMap, "params");
if (StringUtils.areNotEmpty(stringArg2)) {
launchIntentForPackage = new Intent();
launchIntentForPackage.setComponent(new ComponentName(stringArg, stringArg2));
} else {
launchIntentForPackage = this.mContext.getPackageManager().getLaunchIntentForPackage(stringArg);
}
launchIntentForPackage.setFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
if (jsonArg != null) {
launchIntentForPackage.putExtra("params", jsonArg.toString());
}
if (launchIntentForPackage != null) {
this.mContext.startActivity(launchIntentForPackage);
JsModule.callBackSuccess(hashMap2);
return;
}
JsModule.callBackFail(hashMap2);
}
@JavascriptMethod
public void shareFile(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
String stringArg = JsModule.getStringArg(hashMap, "title", "");
String fileFullPath = H5AppUtils.getFileFullPath(getFragment(), JsModule.getStringArg(hashMap, Progress.FILE_PATH, ""));
if (TextUtils.isEmpty(fileFullPath)) {
return;
}
NativeUtil.shareFile(this.mContext, stringArg, fileFullPath, BaseGlobal.getInstance().getFileProvider());
}
@JavascriptMethod
public void shareImage(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
String stringArg = JsModule.getStringArg(hashMap, "title", "");
String stringArg2 = JsModule.getStringArg(hashMap, "imagePath", "");
if (TextUtils.isEmpty(stringArg2)) {
return;
}
NativeUtil.shareImage(this.mContext, stringArg, stringArg2, BaseGlobal.getInstance().getFileProvider());
}
@JavascriptMethod
public void shareText(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
NativeUtil.shareText(this.mContext, JsModule.getStringArg(hashMap, "title", ""), JsModule.getStringArg(hashMap, ZModuleWatermark.sSdkType_WatermarkText, ""));
}
@JavascriptMethod
public void startEmail(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
String str = "";
String str2 = "";
for (PackageInfo packageInfo : this.mContext.getPackageManager().getInstalledPackages(8192)) {
if (packageInfo.packageName.endsWith(".android.email") || packageInfo.packageName.endsWith(".android.mail") || packageInfo.packageName.endsWith(".android.gm")) {
str = str + packageInfo.packageName + ";";
}
if (packageInfo.packageName.contains(".android.email") || packageInfo.packageName.contains(".android.mail") || packageInfo.packageName.contains(".android.gm")) {
str2 = str2 + packageInfo.packageName + ";";
}
}
if (str.length() >= 1 || str2.length() >= 1) {
if (str.length() > 1) {
for (String str3 : Arrays.asList(str.split(";"))) {
try {
this.mContext.startActivity(this.mContext.getPackageManager().getLaunchIntentForPackage(str3));
JSONObject jSONObject = new JSONObject();
jSONObject.put(ResultConst.Key.sErrMessage, "startEmail:ok");
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
}
}
}
if (str2.length() > 1) {
for (String str4 : Arrays.asList(str2.split(";"))) {
try {
this.mContext.startActivity(this.mContext.getPackageManager().getLaunchIntentForPackage(str4));
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put(ResultConst.Key.sErrMessage, "startEmail:ok");
JsModule.callBackSuccess(hashMap2, jSONObject2);
return;
} catch (Exception unused2) {
}
}
}
}
JsModule.callBackFail(hashMap2, "open fail");
}
@JavascriptMethod
public void testAddContact(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.CONTACTS)) {
try {
JSONObject jSONObject = new JSONObject();
ContactUtils.insertContact(getContext(), "testname", "15861805745");
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testAddContact fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.CONTACTS);
}
@JavascriptMethod
@SuppressLint({"MissingPermission"})
public void testDeleteCall(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
String[] strArr = {"android.permission.READ_CALL_LOG", "android.permission.WRITE_CALL_LOG"};
if (PermissionsUtils.hasPermission(getFragment(), strArr)) {
try {
String stringArg = JsModule.getStringArg(hashMap, "phone", "15861805745");
getContext().getContentResolver().delete(CallLog.Calls.CONTENT_URI, "NUMBER=" + stringArg, null);
JsModule.callBackSuccess(hashMap2, new JSONObject());
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testDeleteCall fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, strArr);
}
@JavascriptMethod
public void testDeleteContact(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.CONTACTS)) {
try {
JSONObject jSONObject = new JSONObject();
ContentResolver contentResolver = getContext().getContentResolver();
Cursor query = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while (query.moveToNext()) {
try {
Uri withAppendedPath = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, query.getString(query.getColumnIndex("lookup")));
PrintStream printStream = System.out;
printStream.println("The uri is " + withAppendedPath.toString());
contentResolver.delete(withAppendedPath, null, null);
} catch (Exception e2) {
System.out.println(e2.getStackTrace());
}
}
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testAddContact fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.CONTACTS);
}
@JavascriptMethod
public void testGetCall(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
String[] strArr = {"android.permission.READ_CALL_LOG", "android.permission.WRITE_CALL_LOG"};
if (PermissionsUtils.hasPermission(getFragment(), strArr)) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("result", getContentCallLog(getContext()));
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetCall fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, strArr);
}
@JavascriptMethod
public void testGetContact(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.CONTACTS)) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("result", getContact(getContext()));
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetContact fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.CONTACTS);
}
@JavascriptMethod
@SuppressLint({"MissingPermission"})
public void testGetLocation(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.LOCATION)) {
try {
Context context = getContext();
getContext();
LocationManager locationManager = (LocationManager) context.getSystemService("location");
Criteria criteria = new Criteria();
criteria.setAccuracy(2);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(false);
criteria.setPowerRequirement(1);
String bestProvider = locationManager.getBestProvider(criteria, true);
Location lastKnownLocation = locationManager.getLastKnownLocation(bestProvider);
if (lastKnownLocation != null) {
showLocation(lastKnownLocation);
}
locationManager.requestLocationUpdates(bestProvider, 0L, 0.0f, this.locationListener);
JsModule.callBackSuccess(hashMap2, new JSONObject());
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetContact fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.LOCATION);
}
@JavascriptMethod
public void testGetPhone(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.PHONE_STATE)) {
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("result", ((TelephonyManager) getContext().getSystemService("phone")).getLine1Number());
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetContact fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.PHONE_STATE);
}
@JavascriptMethod
public void testGetSMS(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.SMS)) {
try {
String sms = getSMS(getFragment().getContext());
JSONObject jSONObject = new JSONObject();
jSONObject.put("result", sms);
JsModule.callBackSuccess(hashMap2, jSONObject);
return;
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetSMS fail");
return;
}
}
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.SMS);
}
@JavascriptMethod
public void testSendSMS(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.hasPermission(getFragment(), PermissionsUtils.SMS)) {
SmsManager.getDefault().sendTextMessage(JsModule.getStringArg(hashMap, "phone", "15861805745"), null, "this is a test message.", null, null);
} else {
PermissionsUtils.requestPermission(getFragment(), 138, PermissionsUtils.SMS);
}
}
@JavascriptMethod
@SuppressLint({"MissingPermission"})
public void testStartBluetooth(HashMap<String, Object> hashMap, HashMap<String, JsCallback> hashMap2) {
if (PermissionsUtils.requestPermission(getFragment(), 138, new String[]{"android.permission.BLUETOOTH", "android.permission.BLUETOOTH_ADMIN"})) {
try {
JSONObject jSONObject = new JSONObject();
BluetoothAdapter.getDefaultAdapter().enable();
JsModule.callBackSuccess(hashMap2, jSONObject);
} catch (Exception unused) {
JsModule.callBackFail(hashMap2, "testGetContact fail");
}
}
}
}