gpt4 book ai didi

java - 无法在电信服务上注册新的电话帐户

转载 作者:太空宇宙 更新时间:2023-11-04 10:32:57 26 4
gpt4 key购买 nike

我正在尝试注册一个新的 phoneAccount但我不断收到以下错误:

04-13 01:06:11.329  1267  2435 W Telecom : com.android.server.telecom.PhoneAccountRegistrar: phoneAccount ComponentInfo{com.my.otherApp/com.my.app.RNCallConnectionService} not found: TSI.rPA@Agc
04-13 01:06:11.329 1267 2435 W Telecom : com.android.server.telecom.PhoneAccountRegistrar: Phone account ComponentInfo{com.my.otherApp/com.my.app.RNCallConnectionService}, [a50dcea6cba1c8c30324624e9e54bfd19bb0b363], UserHandle{0} does not have BIND_TELECOM_CONNECTION_SE
RVICE permission.: TSI.rPA@Agc
04-13 01:06:11.330 1267 2435 E Telecom : com.android.server.telecom.TelecomServiceImpl$1: registerPhoneAccount [[ ] PhoneAccount: ComponentInfo{com.my.otherApp/com.my.app.RNCallConnectionService}, [a50dcea6cba1c8c30324624e9e54bfd19bb0b363], UserHandle{0} Capabilities: C
allProvider Schemes: tel Extras: null]: TSI.rPA@Agc
04-13 01:06:11.330 1267 2435 E Telecom : java.lang.SecurityException: PhoneAccount connection service requires BIND_TELECOM_CONNECTION_SERVICE permission.
04-13 01:06:11.330 1267 2435 E Telecom : at com.android.server.telecom.PhoneAccountRegistrar.registerPhoneAccount(PhoneAccountRegistrar.java:587)
04-13 01:06:11.330 1267 2435 E Telecom : at com.android.server.telecom.TelecomServiceImpl$1.registerPhoneAccount(TelecomServiceImpl.java:399)
04-13 01:06:11.330 1267 2435 E Telecom : at com.android.internal.telecom.ITelecomService$Stub.onTransact(ITelecomService.java:226)
04-13 01:06:11.330 1267 2435 E Telecom : at android.os.Binder.execTransact(Binder.java:573)

我已确保添加 <uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>到我的 list 。

这是相关代码

public class RNCallModule extends ReactContextBaseJavaModule {

static private String TAG = "RNCallModule +++++";

private ReactApplicationContext reactContext;

private String appName;

private TelecomManager tm;

private PhoneAccountHandle handle;

private PhoneAccount phoneAccount;

public RNCallModule(ReactApplicationContext reactContext) {
super(reactContext);

this.reactContext = reactContext;

Boolean a = PackageManager.PERMISSION_GRANTED == this.reactContext.checkCallingOrSelfPermission(Manifest.permission.BIND_TELECOM_CONNECTION_SERVICE);

appName = getApplicationName(this.reactContext.getApplicationContext());

ComponentName cName = new ComponentName(this.reactContext.getApplicationContext(), RNCallConnectionService.class);

handle = new PhoneAccountHandle(cName, appName);

tm = (TelecomManager)this.reactContext.getApplicationContext().getSystemService(this.reactContext.getApplicationContext().TELECOM_SERVICE);

if(android.os.Build.VERSION.SDK_INT >= 26) {
phoneAccount = new PhoneAccount.Builder(handle, appName)
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
.build();
tm.registerPhoneAccount(phoneAccount);
}

phoneAccount = new PhoneAccount.Builder(handle, appName)
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
.build();


tm.registerPhoneAccount(phoneAccount); // <<<<<< Here is where the error happens

}

// ...

}

最佳答案

尽管我已经在 AndroidManifest.xml 上添加了权限,但我仍然需要添加这个额外的位:

<service android:name="com.my.app.RNCallConnectionService"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>

关于java - 无法在电信服务上注册新的电话帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49809745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com