1.各手机检查是否开启自动录音代码如下:
/**
* 检查小米手机自动录音功能是否开启,true已开启 false未开启
*
* @return
*/
private boolean checkXiaomiRecord() {
try {
int key = Settings.System.getInt(RecordApp.context.getContentResolver(), "button_auto_record_call");
XLog.d(TAG, "Xiaomi key:" + key);
//0是未开启,1是开启
return key != 0;
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return true;
}
/**
* 检查OPPO手机自动录音功能是否开启,true已开启 false未开启
*
* @return
*/
private boolean checkOppoRecord() {
try {
int key = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ? Settings.Global.getInt(RecordApp.context.getContentResolver(), "oppo_all_call_audio_record") : 0;
XLog.d(TAG, "Oppo key:" + key);
//0代表OPPO自动录音未开启,1代表OPPO自动录音已开启
return key != 0;
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return true;
}
/**
* 检查VIVO自动录音功能是否开启,true已开启 false未开启
*
* @return
*/
private boolean checkVivoRecord() {
try {
int key = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 ? Settings.Global.getInt(RecordApp.context.getContentResolver(), "call_record_state_global") : 0;
XLog.d(TAG, "Vivo key:" + key);
//0代表VIVO自动录音未开启,1代表VIVO所有通话自动录音已开启,2代表指定号码自动录音
return key == 1;
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return true;
}
/**
* 检查华为手机自动录音功能是否开启,true已开启 false未开启
*
* @return
*/
private boolean checkHuaweiRecord() {
try {
int key = Settings.Secure.getInt(RecordApp.context.getContentResolver(), "enable_record_auto_key");
XLog.d(TAG, "Huawei key:" + key);
//0代表华为自动录音未开启,1代表华为自动录音已开启
return key != 0;
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
return true;
}
2.各手机跳转到开启自动录音页面如下:
/**
* 跳转到VIVO开启通话自动录音功能页面
*/
private void startVivoRecord() {
ComponentName componentName = new ComponentName("com.android.incallui", "com.android.incallui.record.CallRecordSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
RecordApp.context.startActivity(intent);
ToastUtil.getInstance().showToast("请打开VIVO通话自动录音功能");
}
/**
* 跳转到小米开启通话自动录音功能页面
*/
private void startXiaomiRecord() {
ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.settings.CallRecordSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
RecordApp.context.startActivity(intent);
ToastUtil.getInstance().showToast("请打开小米通话自动录音功能");
}
/**
* 跳转到华为开启通话自动录音功能页面
*/
private void startHuaweiRecord() {
ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.MSimCallFeaturesSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
RecordApp.context.startActivity(intent);
ToastUtil.getInstance().showToast("请打开华为通话自动录音功能");
}
/**
* 跳转到OPPO开启通话自动录音功能页面
*/
private void startOppoRecord() {
ComponentName componentName = new ComponentName("com.android.phone", "com.android.phone.OppoCallFeaturesSetting");
Intent intent = new Intent();
intent.setComponent(componentName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
RecordApp.context.startActivity(intent);
ToastUtil.getInstance().showToast("请打开OPPO通话自动录音功能");
}
3.查找对应的key值如下:
//Settings下的 System 、Secure 、Global下的key和value遍历打印查看:
//1.Secure
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Cursor cursor = RecordApp.context.getContentResolver().query(Settings.Secure.CONTENT_URI, null, null, null);
String[] columnNames = cursor.getColumnNames();
StringBuilder builder = new StringBuilder();
while (cursor.moveToNext()) {
for (String columnName : columnNames) {
String string = cursor.getString(cursor.getColumnIndex(columnName));
builder.append(columnName).append(":").append(string).append("\n");
}
}
Log.e(TAG, builder.toString());
}
//2.Global
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Cursor cursor = RecordApp.context.getContentResolver().query(Settings.Global.CONTENT_URI, null, null, null);
String[] columnNames = cursor.getColumnNames();
StringBuilder builder = new StringBuilder();
while (cursor.moveToNext()) {
for (String columnName : columnNames) {
String string = cursor.getString(cursor.getColumnIndex(columnName));
builder.append(columnName).append(":").append(string).append("\n");
}
}
Log.e(TAG, builder.toString());
}
//3.System
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Cursor cursor = RecordApp.context.getContentResolver().query(Settings.System.CONTENT_URI, null, null, null);
String[] columnNames = cursor.getColumnNames();
StringBuilder builder = new StringBuilder();
while (cursor.moveToNext()) {
for (String columnName : columnNames) {
String string = cursor.getString(cursor.getColumnIndex(columnName));
builder.append(columnName).append(":").append(string).append("\n");
}
}
Log.e(TAG, builder.toString());
}
//有时候数据太多 打印不全 使用以下方式打印:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Cursor cursor = RecordApp.context.getContentResolver().query(Settings.System.CONTENT_URI, null, null, null);
String[] columnNames = cursor.getColumnNames();
while (cursor.moveToNext()) {
for (String columnName : columnNames) {
String string = cursor.getString(cursor.getColumnIndex(columnName));
Log.e(TAG, columnName+":"+string);
}
}
}
//---------------------------------------有时间用到魅族手机再更新魅族-------------------------------------------
//----------------------------------------------------------END-------------------------------------------------------------