version:1.2.1

fix:
update:优化双卡拨号
This commit is contained in:
2024-09-06 09:25:26 +08:00
parent fe53356c3c
commit 5bb723bc48
17 changed files with 304 additions and 40 deletions

View File

@@ -220,6 +220,7 @@
<activity
android:name=".activity.selectnumber.SelectNumberActivity"
android:launchMode="singleTask"
android:theme="@style/activity_styles"
android:screenOrientation="portrait" />
<activity
android:name=".activity.screenlock.ScreenLockActivity"

View File

@@ -41,7 +41,6 @@ import com.jeremyliao.liveeventbus.LiveEventBus;
import com.tencent.mmkv.MMKV;
import com.xxpatx.os.BuildConfig;
import com.xxpatx.os.R;
import com.xxpatx.os.activity.activation.ActivationActivity;
import com.xxpatx.os.activity.dock.DockActivity;
import com.xxpatx.os.activity.phone.PhoneActivity;
import com.xxpatx.os.activity.update.UpdateActivity;
@@ -306,21 +305,21 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
}
});
// mViewModel.getAppList();
mViewModel.getActivationData().observe(this, new Observer<Integer>() {
@Override
public void onChanged(Integer integer) {
if (integer == 0) {
if (WiFiUtils.getInstance().isNetworkConnected()) {
Toaster.showLong("请先激活设备");
startActivity(new Intent(MainActivity.this, ActivationActivity.class));
}
} else {
Log.e("getActivationData", "onChanged: 已激活");
}
}
});
mViewModel.getSnIsActivation();
// mViewModel.getActivationData().observe(this, new Observer<Integer>() {
// @Override
// public void onChanged(Integer integer) {
// if (integer == 0) {
// if (WiFiUtils.getInstance().isNetworkConnected()) {
// Toaster.showLong("请先激活设备");
// startActivity(new Intent(MainActivity.this, ActivationActivity.class));
// }
// } else {
// Log.e("getActivationData", "onChanged: 已激活");
// }
// }
// });
//
// mViewModel.getSnIsActivation();
mViewModel.getAppInfoData().observe(this, new Observer<AppInfo>() {
@Override

View File

@@ -1,17 +1,24 @@
package com.xxpatx.os.activity.selectnumber;
import android.content.Context;
import android.content.Intent;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.xxpatx.os.R;
import com.xxpatx.os.adapter.PhoneAdapter;
import com.xxpatx.os.base.mvvm.BaseMvvmActivity;
import com.xxpatx.os.databinding.ActivitySelectNumberBinding;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -22,6 +29,7 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
private TelephonyManager mTelephonyManager;
private SubscriptionManager subscriptionManager;
private TelecomManager telecomManager;
private PhoneAdapter mPhoneAdapter;
@Override
public int getLayoutId() {
@@ -38,19 +46,50 @@ public class SelectNumberActivity extends BaseMvvmActivity<SelectNumberViewModel
@Override
public void initView() {
Intent intent =getIntent();
if (intent==null){
finish();
return;
}
String phone = intent.getStringExtra("phone_number");
if (TextUtils.isEmpty(phone)){
finish();
return;
}
mPhoneAdapter = new PhoneAdapter();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(SelectNumberActivity.this);
linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
mViewDataBinding.recyclerView.setLayoutManager(linearLayoutManager);
mViewDataBinding.recyclerView.setAdapter(mPhoneAdapter);
mPhoneAdapter.setPhone(phone);
mPhoneAdapter.setOutCallback(new PhoneAdapter.OutCallback() {
@Override
public void onCall() {
finish();
}
});
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
telecomManager = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
}
@Override
public void initData() {
List<SubscriptionInfo> subscriptionInfos = subscriptionManager.getActiveSubscriptionInfoList();
List<String> stringList =new ArrayList<>();
for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
Log.e(TAG, "initData: id = " + subscriptionInfo.getSubscriptionId());
// Log.e(TAG, "initData: mCardString = " + subscriptionInfo.getCardString());
// Log.e(TAG, "initData: phone = " + mTelephonyManager.getLine1Number(subscriptionInfo.getSubscriptionId()));
Log.e(TAG, "initData: mCardString = " + subscriptionInfo.getCardString());
Log.e(TAG, "initData: phone = " + mTelephonyManager.getLine1Number(subscriptionInfo.getSubscriptionId()));
stringList.add(mTelephonyManager.getLine1Number(subscriptionInfo.getSubscriptionId()));
}
mPhoneAdapter.setPhoneList(stringList);
List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
Map<String, PhoneAccountHandle> phoneAccountHandleMap = new HashMap<>();
for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandleList) {

View File

@@ -100,7 +100,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
}
private void setStatus() {
boolean showFloatWindow = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, true);
boolean showFloatWindow = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
Log.e(TAG, "initView: showFloatWindow = " + showFloatWindow);
mViewDataBinding.setFloatWindowEnable(showFloatWindow);
@@ -206,7 +206,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
public class BtnClick {
public void openFloat(View view) {
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, true);
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
if (floatWindowEnable) {
hideFloatingWindow();
} else {
@@ -267,7 +267,7 @@ public class SettingActivity extends BaseMvvmActivity<SettingViewModel, Activity
intent.putExtra("auto_answer", !autoAccept);
sendBroadcast(intent);
} else {
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, true);
boolean floatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
if (floatWindowEnable) {
Toaster.showLong("因为系统限制,请先关闭悬浮窗功能,开启自动接听后再打开悬浮窗");
} else {

View File

@@ -17,9 +17,11 @@ import androidx.recyclerview.widget.RecyclerView;
import com.shehuan.niv.NiceImageView;
import com.xxpatx.os.R;
import com.xxpatx.os.activity.selectnumber.SelectNumberActivity;
import com.xxpatx.os.bean.Contact;
import com.xxpatx.os.bean.RecordsInfo;
import com.xxpatx.os.utils.GlideLoadUtils;
import com.xxpatx.os.utils.Utils;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -85,10 +87,21 @@ public class CallRecordAdapter extends RecyclerView.Adapter<CallRecordAdapter.Ho
holder.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent dialIntent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phone);
dialIntent.setData(data);
mContext.startActivity(dialIntent);
if (Utils.isMultiSim(mContext)) {
Intent intent = new Intent(mContext, SelectNumberActivity.class);
intent.putExtra("phone_number", phone);
mContext.startActivity(intent);
} else {
try {
Intent dialIntent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phone);
dialIntent.setData(data);
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(dialIntent);
} catch (Exception e) {
Log.e(TAG, "callNumber: " + e.getMessage());
}
}
}
});
holder.iv_remove.setOnClickListener(new View.OnClickListener() {

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -19,11 +20,14 @@ import com.hjq.toast.Toaster;
import com.shehuan.niv.NiceImageView;
import com.xxpatx.os.R;
import com.xxpatx.os.activity.contact.AddWechatContactActivity;
import com.xxpatx.os.activity.selectnumber.SelectNumberActivity;
import com.xxpatx.os.bean.Contact;
import com.xxpatx.os.utils.Utils;
import java.util.List;
public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactHolder> {
private static final String TAG = "ContactAdapter";
private List<Contact> mContactList;
private Context mContext;
@@ -68,7 +72,6 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
// Toaster.show("电话功能被禁用");
// return;
// }
Intent dialIntent = new Intent(Intent.ACTION_CALL);
String phone = contact.getMobile();
if (DIALER_PACKAGE.equals(phone)) {
try {
@@ -82,9 +85,21 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactH
Intent intent = new Intent(mContext, AddWechatContactActivity.class);
mContext.startActivity(intent);
} else if (!TextUtils.isEmpty(phone)) {
Uri data = Uri.parse("tel:" + phone);
dialIntent.setData(data);
mContext.startActivity(dialIntent);
if (Utils.isMultiSim(mContext)) {
Intent intent = new Intent(mContext, SelectNumberActivity.class);
intent.putExtra("phone_number", phone);
mContext.startActivity(intent);
} else {
try {
Intent dialIntent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phone);
dialIntent.setData(data);
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(dialIntent);
} catch (Exception e) {
Log.e(TAG, "callNumber: " + e.getMessage());
}
}
}
}
});

View File

@@ -0,0 +1,104 @@
package com.xxpatx.os.adapter;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.xxpatx.os.R;
import java.util.List;
public class PhoneAdapter extends RecyclerView.Adapter<PhoneAdapter.Holder> {
//指定SIM卡拨打
public static final String[] DUAL_SIM_TYPES = {"subscription", "Subscription",
"com.android.phone.extra.slot",
"phone", "com.android.phone.DialingMode",
"simId", "simnum", "phone_type",
"simSlot"};
private Context mContext;
private List<String> mPhoneList;
private String mPhone;
public void setPhoneList(List<String> phoneList) {
mPhoneList = phoneList;
notifyDataSetChanged();
}
public void setPhone(String phone) {
mPhone = phone;
}
public interface OutCallback {
public void onCall();
}
private OutCallback mOutCallback;
public void setOutCallback(OutCallback outCallback) {
mOutCallback = outCallback;
}
@NonNull
@Override
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
mContext = parent.getContext();
return new Holder(LayoutInflater.from(mContext).inflate(R.layout.item_phone, parent, false));
}
@Override
public void onBindViewHolder(@NonNull Holder holder, int position) {
String phone = mPhoneList.get(position);
if (position == 0) {
holder.iv_card.setImageDrawable(mContext.getDrawable(R.drawable.sim_card_1));
} else if (position == 1) {
holder.iv_card.setImageDrawable(mContext.getDrawable(R.drawable.sim_card_2));
}
holder.tv_number.setText(phone);
holder.root.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent dialIntent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + mPhone);
dialIntent.setData(data);
for (int i = 0; i < DUAL_SIM_TYPES.length; i++) {
//0代表卡1,1代表卡2
dialIntent.putExtra(DUAL_SIM_TYPES[i], position);
}
mContext.startActivity(dialIntent);
if (mOutCallback != null) {
mOutCallback.onCall();
}
}
});
}
@Override
public int getItemCount() {
return mPhoneList == null ? 0 : mPhoneList.size();
}
public class Holder extends RecyclerView.ViewHolder {
ConstraintLayout root;
TextView tv_sim, tv_number;
ImageView iv_card;
public Holder(@NonNull View itemView) {
super(itemView);
root = itemView.findViewById(R.id.root);
iv_card = itemView.findViewById(R.id.iv_card);
tv_sim = itemView.findViewById(R.id.tv_sim);
tv_number = itemView.findViewById(R.id.tv_number);
}
}
}

View File

@@ -83,6 +83,7 @@ public class CommonConfig {
public static final String WECHAT_CALL_AUTO_ACCEPT = "wechat_call_auto_accept";
/*悬浮窗*/
public static final String FLOAT_WINDOW = "FloatWindowEnable";
public static final boolean FLOAT_WINDOW_STATU = false;
/*禁用音量键*/
public static final String DISABLE_VOLUME_KEY = "disable_volume_key";
/*修改联系人禁用*/

View File

@@ -94,9 +94,9 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
Log.e("initView", "onTextChanged: " + s);
if ("*#*#4636#*#*".contentEquals(s)) {
ApkUtils.openPackage(mContext, "com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
}else if ("*#*#0011234#*#*".contentEquals(s)){
} else if ("*#*#0011234#*#*".contentEquals(s)) {
ApkUtils.openPackage(mContext, "com.mediatek.factorymode", "com.mediatek.factorymode.FactoryMode");
}else if ("*#*#0011231#*#*".contentEquals(s)){
} else if ("*#*#0011231#*#*".contentEquals(s)) {
ApkUtils.openPackage(mContext, "com.android.agingtest", "com.android.agingtest.AgingTest");
}
}
@@ -124,12 +124,15 @@ public class DialerFragment extends BaseMvvmFragment<DialerViewModel, FragmentDi
Toaster.show("请输入号码");
} else {
if (Utils.isMultiSim(mContext)) {
startActivity(new Intent(mContext, SelectNumberActivity.class));
Intent intent = new Intent(mContext, SelectNumberActivity.class);
intent.putExtra("phone_number", phone);
startActivity(intent);
} else {
try {
Intent dialIntent = new Intent(Intent.ACTION_CALL);
Uri data = Uri.parse("tel:" + phone);
dialIntent.setData(data);
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialIntent);
} catch (Exception e) {
Log.e(TAG, "callNumber: " + e.getMessage());

View File

@@ -153,7 +153,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
// ApkUtils.UninstallAPP(this, "com.joytv.live");
// ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
mFloatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, true);
mFloatWindowEnable = mMMKV.decodeBool(CommonConfig.FLOAT_WINDOW, CommonConfig.FLOAT_WINDOW_STATU);
mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
showPopupWindow();

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 内部颜色 -->
<solid android:color="@color/white" />
<!-- 圆角的幅度 -->
<corners android:radius="8dp" />
<!-- <padding-->
<!-- android:bottom="0dp"-->
<!-- android:left="8dp"-->
<!-- android:right="8dp"-->
<!-- android:top="0dp" />-->
</shape>

View File

@@ -10,12 +10,17 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:background="@drawable/phone_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/phone_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/tv_sim"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:gravity="center"
android:maxLines="1"
android:text="SIM卡"
android:textColor="@color/black"
android:textSize="14sp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageView
android:id="@+id/iv_card"
android:layout_width="32dp"
android:layout_height="32dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/sim_card_1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_number"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="11"
android:gravity="center"
android:maxLines="1"
android:text="1234567890"
android:textColor="@color/black"
android:textSize="16sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>