use com.android.phone
This commit is contained in:
parent
135dd8305e
commit
2fa48187b9
@ -1,6 +1,6 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -36,5 +36,5 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
implementation files('libs/qcrilhook.jar')
|
||||
implementation files('libs/mirilhook.jar')
|
||||
implementation files('libs/qti-telephony-utils.jar')
|
||||
}
|
Binary file not shown.
@ -1,13 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:sharedUserId="android.uid.system"
|
||||
android:sharedUserId="android.uid.phone"
|
||||
>
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
<uses-permission android:name="com.qualcomm.permission.USE_QCRIL_MSG_TUNNEL"/>
|
||||
|
||||
<!-- <uses-permission-->
|
||||
<!-- android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"-->
|
||||
@ -21,20 +17,15 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.ModemTool"
|
||||
android:process="com.android.systemui"
|
||||
android:process="com.android.phone"
|
||||
tools:targetApi="31">
|
||||
|
||||
|
||||
<uses-library android:name="com.qualcomm.qcrilhook" android:exported="true" android:required="false"/>
|
||||
<uses-library android:name="com.qti.extphone.extphonelib" android:exported="true" android:required="false"/>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
|
@ -5,7 +5,6 @@ import android.os.Bundle;
|
||||
import android.telephony.CellIdentityNr;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.CellInfoNr;
|
||||
import android.telephony.CellSignalStrength;
|
||||
import android.telephony.CellSignalStrengthNr;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
@ -19,11 +18,8 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.qualcomm.qcrilhook.QcRilHook;
|
||||
import com.qualcomm.qcrilhook.QcRilHookCallback;
|
||||
import com.xiaomi.mirilhook.MiRilHook;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.List;
|
||||
@ -61,9 +57,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private boolean miRilHookReady = false;
|
||||
|
||||
private QcRilHook mQcRilHook = null;
|
||||
|
||||
private boolean mQcRilHookReady = false;
|
||||
|
||||
TelephonyManager.CellInfoCallback cellInfoCallback;
|
||||
|
||||
@ -163,20 +156,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mQcRilHook = new QcRilHook(getApplicationContext(), new QcRilHookCallback() {
|
||||
@Override
|
||||
public void onQcRilHookDisconnected() {
|
||||
Log.i(TAG, "onMiRilHookDisconnected");
|
||||
mQcRilHookReady = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQcRilHookReady() {
|
||||
Log.i(TAG, "onQcRilHookReady");
|
||||
mQcRilHookReady = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -186,23 +165,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
private void modemSSR() {
|
||||
try {
|
||||
if (miRilHookReady) {
|
||||
miRilHook.onHookCommonMsgSync(31, 4, -2147483647);
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "miRilHookReady = false", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshMbn() {
|
||||
try {
|
||||
if (mQcRilHookReady) {
|
||||
if (miRilHookReady) {
|
||||
int slotIndex = SubscriptionManager.getSlotIndex(getSub());
|
||||
mQcRilHook.qcRilRefreshMbn(slotIndex);
|
||||
miRilHook.qcRilRefreshMbn(slotIndex);
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "mQcRilHookReady = false", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@ -299,4 +267,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
238
app/src/main/java/run/evan/modemtool/MiRilHook.java
Normal file
238
app/src/main/java/run/evan/modemtool/MiRilHook.java
Normal file
@ -0,0 +1,238 @@
|
||||
package run.evan.modemtool;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.qualcomm.qcrilhook.QcRilHook;
|
||||
import com.qualcomm.qcrilhook.QcRilHookCallback;
|
||||
|
||||
import org.codeaurora.telephony.utils.CommandException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MiRilHook extends QcRilHook {
|
||||
|
||||
|
||||
private final int mHeaderSize;
|
||||
|
||||
private static final int HOOK_HEAD_SIZE = "QOEMHOOK".length() + 8;
|
||||
|
||||
|
||||
public MiRilHook(Context context) {
|
||||
super(context);
|
||||
this.mHeaderSize = "QOEMHOOK".length() + 8;
|
||||
|
||||
}
|
||||
|
||||
public MiRilHook(Context context, QcRilHookCallback qcRilHookCallback) {
|
||||
super(context, qcRilHookCallback);
|
||||
this.mHeaderSize = "QOEMHOOK".length() + 8;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ByteBuffer onHookBigEfsReadSync(int sub, String path, int responseSize) {
|
||||
return onHookSendSync(onPkHookEfsOpt(sub, path, 4), responseSize, 0);
|
||||
}
|
||||
|
||||
public ByteBuffer onHookBigEfsReadSync(int sub, String path) {
|
||||
return onHookSendSync(onPkHookEfsOpt(sub, path, 4), 102400, 0);
|
||||
}
|
||||
|
||||
private ByteBuffer onHookSendSync(byte[] requestBytes, int responseSize, int phoneId) {
|
||||
if (requestBytes == null) {
|
||||
return null;
|
||||
} else if (responseSize <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
return sendQcRilHookMsgSync(524970, requestBytes, responseSize, phoneId);
|
||||
}
|
||||
}
|
||||
public ByteBuffer sendQcRilHookMsgSync(int requestId, byte[] request, int responseSize, int phoneId) {
|
||||
org.codeaurora.telephony.utils.AsyncResult ar = sendQcRilHookMsg(requestId, request, responseSize, phoneId);
|
||||
if (ar == null) {
|
||||
return null;
|
||||
} else if (ar.exception != null) {
|
||||
return null;
|
||||
} else if (ar.result == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] response = (byte[]) ar.result;
|
||||
ByteBuffer byteBuf = ByteBuffer.wrap(response);
|
||||
byteBuf.order(ByteOrder.nativeOrder());
|
||||
return byteBuf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public org.codeaurora.telephony.utils.AsyncResult sendQcRilHookMsg(int requestId, byte[] request, int responseSize, int phoneId) {
|
||||
validateInternalState();
|
||||
int mHeaderSize = "QOEMHOOK".length() + 8;
|
||||
byte[] request_new = new byte[mHeaderSize + request.length];
|
||||
ByteBuffer reqBuffer = createBufferWithNativeByteOrder(request_new);
|
||||
addQcRilHookHeader(reqBuffer, requestId, request.length);
|
||||
reqBuffer.put(request);
|
||||
return sendRilOemHookMsg(requestId, request_new, responseSize, phoneId);
|
||||
}
|
||||
|
||||
public ByteBuffer onHookEfsWriteSync(int sub, String path, byte[] data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
return onHookEfsWriteSync(sub, path, data, data.length);
|
||||
}
|
||||
public ByteBuffer onHookEfsWriteSync(int sub, String path, byte[] data, int dataLen) {
|
||||
return onHookSendSync(onPkHookEfsWrite(sub, path, data, dataLen));
|
||||
}
|
||||
|
||||
public ByteBuffer sendQcRilHookMsgSync(int requestId, byte[] request, int phoneId) {
|
||||
org.codeaurora.telephony.utils.AsyncResult ar = sendQcRilHookMsg(requestId, request, phoneId);
|
||||
if (ar == null) {
|
||||
return null;
|
||||
} else if (ar.exception != null) {
|
||||
return null;
|
||||
} else if (ar.result == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte[] response = (byte[]) ar.result;
|
||||
ByteBuffer byteBuf = ByteBuffer.wrap(response);
|
||||
byteBuf.order(ByteOrder.nativeOrder());
|
||||
return byteBuf;
|
||||
}
|
||||
}
|
||||
public ByteBuffer onHookEfsOptSync(int sub, String path, int hook_id) {
|
||||
return onHookSendSync(onPkHookEfsOpt(sub, path, hook_id));
|
||||
}
|
||||
|
||||
|
||||
public static boolean putByteToBuffer(ByteBuffer buf, byte[] value, int len) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
} else if (buf == null) {
|
||||
return false;
|
||||
} else if (len <= 0) {
|
||||
return false;
|
||||
} else {
|
||||
for (int i = 0; i < len; i++) {
|
||||
buf.put(value[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private ByteBuffer onHookSendSync(byte[] requestBytes) {
|
||||
return onHookSendSync(requestBytes, 0);
|
||||
}
|
||||
|
||||
private ByteBuffer onHookSendSync(byte[] requestBytes, int phoneId) {
|
||||
if (requestBytes == null) {
|
||||
return null;
|
||||
} else {
|
||||
return sendQcRilHookMsgSync(524970, requestBytes, phoneId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void validateInternalState() {
|
||||
if (isDisposed()) {
|
||||
throw new IllegalStateException("QcRilHook is in disposed state");
|
||||
}
|
||||
}
|
||||
|
||||
private org.codeaurora.telephony.utils.AsyncResult sendRilOemHookMsg(int requestId, byte[] request, int responseSize, int phoneId) {
|
||||
if (responseSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
byte[] response = new byte[responseSize];
|
||||
try {
|
||||
int retVal = this.mService.sendOemRilRequestRaw(request, response, phoneId);
|
||||
if (retVal >= 0) {
|
||||
byte[] validResponseBytes = null;
|
||||
if (retVal > 0) {
|
||||
validResponseBytes = Arrays.copyOf(response, retVal);
|
||||
}
|
||||
org.codeaurora.telephony.utils.AsyncResult ar = new org.codeaurora.telephony.utils.AsyncResult(Integer.valueOf(retVal), validResponseBytes, (Throwable) null);
|
||||
return ar;
|
||||
}
|
||||
byte[] validResponseBytes2 = Arrays.copyOf(response, response.length);
|
||||
CommandException ex = CommandException.fromRilErrno(retVal * (-1));
|
||||
org.codeaurora.telephony.utils.AsyncResult ar2 = new org.codeaurora.telephony.utils.AsyncResult(request, validResponseBytes2, ex);
|
||||
return ar2;
|
||||
} catch (RemoteException e) {
|
||||
org.codeaurora.telephony.utils.AsyncResult ar3 = new org.codeaurora.telephony.utils.AsyncResult(Integer.valueOf(requestId), (Object) null, e);
|
||||
return ar3;
|
||||
} catch (NullPointerException e2) {
|
||||
org.codeaurora.telephony.utils.AsyncResult ar4 = new org.codeaurora.telephony.utils.AsyncResult(Integer.valueOf(requestId), (Object) null, e2);
|
||||
return ar4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private byte[] onPkHookEfsOpt(int sub, String path, int hook_id) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
} else if (4 != hook_id && 6 != hook_id && 110 != hook_id && 51 != hook_id) {;
|
||||
return null;
|
||||
} else {
|
||||
int msg_len = path.length() + 12;
|
||||
byte[] hookBytes = onGetHookMsgBytes(msg_len);
|
||||
ByteBuffer reqBuffer = onGetHookMsgBuffer(hookBytes);
|
||||
if (reqBuffer == null) {
|
||||
return null;
|
||||
}
|
||||
reqBuffer.putInt(hook_id);
|
||||
reqBuffer.putInt(sub);
|
||||
reqBuffer.putInt(path.length());
|
||||
reqBuffer.put(path.getBytes());
|
||||
return hookBytes;
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] onGetHookMsgBytes(int msg_len) {
|
||||
int i = HOOK_HEAD_SIZE;
|
||||
byte[] hookBytes = new byte[i + msg_len];
|
||||
return hookBytes;
|
||||
}
|
||||
|
||||
private ByteBuffer onGetHookMsgBuffer(byte[] hookBytes) {
|
||||
if (hookBytes == null) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer reqBuffer = createBufferWithNativeByteOrder(hookBytes);
|
||||
return reqBuffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private byte[] onPkHookEfsWrite(int sub, String path, byte[] data, int dataLen) {
|
||||
if (sub != 0 && 1 != sub) {
|
||||
return null;
|
||||
} else if (path == null) {
|
||||
return null;
|
||||
} else if (data == null) {
|
||||
return null;
|
||||
} else if (dataLen <= 0) {
|
||||
return null;
|
||||
} else {
|
||||
int msg_len = path.length() + 12 + 4 + dataLen;
|
||||
byte[] hookBytes = onGetHookMsgBytes(msg_len);
|
||||
ByteBuffer reqBuffer = onGetHookMsgBuffer(hookBytes);
|
||||
if (reqBuffer == null) {
|
||||
return null;
|
||||
}
|
||||
reqBuffer.putInt(5);
|
||||
reqBuffer.putInt(sub);
|
||||
reqBuffer.putInt(path.length());
|
||||
reqBuffer.put(path.getBytes());
|
||||
reqBuffer.putInt(dataLen);
|
||||
putByteToBuffer(reqBuffer, data, dataLen);
|
||||
return hookBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user