安卓转接电话

发布于 2024-11-04 18:03:35 字数 5805 浏览 6 评论 0原文

我今天试图找出我桌子上的一个错误。我还没有为 java/android 开发太多东西,但我还是想弄清楚这一点。

我有一个由已辞职的同事开发的 Android 应用程序。目前该应用程序可在 2.2 版本中运行。但是当使用 2.3 运行它时,应用程序失败了。

它是一款帮助在电信公司交换机内转移呼叫的应用程序。

所以发生的事情是这样的。

A(内部号码001)接到X先生的电话。 A 回答并说嗨,是的 B(内部编号 002)对这个问题非常了解!我把你转给他吧!

然后,A 用手机拨打 002,等待大约 10 秒(足以让呼叫接通并开始拨号),然后再次拨打号码 4(内部电信转接命令),将 MR.X 转接给 B。

这是简而言之,只需单击列表中的某个人,该应用程序就会执行以下操作。

首先呼叫 B,延迟 10 秒呼叫号码 4,

//Initial Call(002)
public void callNumber(String callnum){
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:"+callnum));
    startActivity(intent);

    if(isAutomaticTransfer && stateString.equals("Off Hook")){
        _initTask = new InitTask();
        _initTask.execute( this );
    }
}

然后

protected class InitTask extends AsyncTask<Context, Integer, Integer>{
    @Override
    protected Integer doInBackground(Context... arg0) {

        try {
            Thread.sleep(delayLength);
            Intent intentTransfer = new Intent(Intent.ACTION_CALL);
            intentTransfer.setData(Uri.parse("tel:" + transfernum));
            intentTransfer.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            startActivity(intentTransfer);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}

如所述,这适用于 2.2。

然而,在 2.3 中,我得到了以下堆栈跟踪。

/ActivityManager(   61): Starting: Intent { act=android.phone.extra.NEW_CALL_IN
TENT dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHan
dler (has extras) } from pid 123
V/SipCallOptionHandler(  123): Call option is SIP_ADDRESS_ONLY
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras)
} from pid 123
D/CallManager(  123): hasBgCall: false sameChannel:true
D/dalvikvm(  123): GC_CONCURRENT freed 305K, 48% free 3199K/6151K, external 6585
K/6853K, paused 14ms+5ms
D/dalvikvm(   61): GREF has increased to 401
D/dalvikvm(  123): GC_EXTERNAL_ALLOC freed 8K, 49% free 3191K/6151K, external 59
27K/6853K, paused 63ms
W/InputManagerService(   61): Starting input on non-focused client com.android.i
nternal.view.IInputMethodClient$Stub$Proxy@40530dd8 (uid=10035 pid=343)
D/dalvikvm(  130): GC_EXPLICIT freed 135K, 50% free 2949K/5895K, external 5959K/
7152K, paused 75ms
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.OutgoingCallBroadcaster }
from pid 343
D/PhoneUtils(  123): checkAndCopyPhoneProviderExtras: some or all extras are mis
sing.
D/PhoneUtils(  123): checkAndCopyPhoneProviderExtras: some or all extras are mis
sing.
I/ActivityManager(   61): Starting: Intent { act=android.phone.extra.NEW_CALL_IN
TENT dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHan
dler (has extras) } from pid 123
V/SipCallOptionHandler(  123): Call option is SIP_ADDRESS_ONLY
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras)
} from pid 123
W/PhoneUtils(  123): Exception from phone.dial()
W/PhoneUtils(  123): com.android.internal.telephony.CallStateException: cannot d
ial in current state
W/PhoneUtils(  123):    at com.android.internal.telephony.CallManager.dial(CallM
anager.java:704)
W/PhoneUtils(  123):    at com.android.phone.PhoneUtils.placeCall(PhoneUtils.jav
a:539)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.placeCall(InCallScreen
.java:2667)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.internalResolveIntent(
InCallScreen.java:1188)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.onNewIntent(InCallScre
en.java:1126)
W/PhoneUtils(  123):    at android.app.Instrumentation.callActivityOnNewIntent(I
nstrumentation.java:1119)
W/PhoneUtils(  123):    at android.app.ActivityThread.deliverNewIntents(Activity
Thread.java:1722)
W/PhoneUtils(  123):    at android.app.ActivityThread.performNewIntents(Activity
Thread.java:1734)
W/PhoneUtils(  123):    at android.app.ActivityThread.handleNewIntent(ActivityTh
read.java:1742)
W/PhoneUtils(  123):    at android.app.ActivityThread.access$2300(ActivityThread
.java:117)
W/PhoneUtils(  123):    at android.app.ActivityThread$H.handleMessage(ActivityTh
read.java:978)
W/PhoneUtils(  123):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/PhoneUtils(  123):    at android.os.Looper.loop(Looper.java:123)
W/PhoneUtils(  123):    at android.app.ActivityThread.main(ActivityThread.java:3
683)
W/PhoneUtils(  123):    at java.lang.reflect.Method.invokeNative(Native Method)
W/PhoneUtils(  123):    at java.lang.reflect.Method.invoke(Method.java:507)
W/PhoneUtils(  123):    at com.android.internal.os.ZygoteInit$MethodAndArgsCalle
r.run(ZygoteInit.java:839)
W/PhoneUtils(  123):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
va:597)
W/PhoneUtils(  123):    at dalvik.system.NativeStart.main(Native Method)
W/InCallScreen(  123): placeCall: PhoneUtils.placeCall() FAILED for number '4'.
W/InCallScreen(  123): onNewIntent: status CALL_FAILED from internalResolveInten
t()
W/InputManagerService(   61): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@406f3830
D/dalvikvm(  125): GC_CONCURRENT freed 255K, 51% free 2844K/5767K, external 2219
K/2674K, paused 6ms+94ms

所以我想问一下,在我花费这么多时间解决这个问题之前,是否有一个简单的解决方案可以解决这个问题?

谢谢!

编辑:我什至尝试过手动执行此过程(接听来电,置于保留状态,呼叫同事,然后再次呼叫数字 4 进行转接)与应用程序遇到的错误相同。那么Android是否阻止了移动交换机的功能呢?

编辑:这个错误只影响谷歌疯狂的“香草”安卓手机。 HTC三星没有!确诊病例:Nexus S

Im trying to figure out a bug liad on my table today. I haven't developed much for java/android but i'm trying to figure this out anyway.

I have an android app developed by a coworker who has quit. Currently the app is operational in 2.2. But when running it with 2.3 the app fails.

Its an app that help out with transerring calls within a telecompany switch.

So what happens is this.

Person A(internal number 001) recieves a call from Mr X.
Person A answers and sais Hi yeah Person B(internal number 002) has great knowledge of this problem! Let me transfer you to him!

Person A then calls 002 on his cellphone and waits about 10(long enough for the call to go through and start dailing) and then makes another call to number 4(internal telecompany transfer command) to transfer MR.X to Person B.

This is in short what the app does by just clicking a person in the list.

First call Person B, delay 10 sek call number 4.

//Initial Call(002)
public void callNumber(String callnum){
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:"+callnum));
    startActivity(intent);

    if(isAutomaticTransfer && stateString.equals("Off Hook")){
        _initTask = new InitTask();
        _initTask.execute( this );
    }
}

and then

protected class InitTask extends AsyncTask<Context, Integer, Integer>{
    @Override
    protected Integer doInBackground(Context... arg0) {

        try {
            Thread.sleep(delayLength);
            Intent intentTransfer = new Intent(Intent.ACTION_CALL);
            intentTransfer.setData(Uri.parse("tel:" + transfernum));
            intentTransfer.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            startActivity(intentTransfer);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
}

As stated this works with 2.2.

However with 2.3 i get the following stacktrace.

/ActivityManager(   61): Starting: Intent { act=android.phone.extra.NEW_CALL_IN
TENT dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHan
dler (has extras) } from pid 123
V/SipCallOptionHandler(  123): Call option is SIP_ADDRESS_ONLY
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras)
} from pid 123
D/CallManager(  123): hasBgCall: false sameChannel:true
D/dalvikvm(  123): GC_CONCURRENT freed 305K, 48% free 3199K/6151K, external 6585
K/6853K, paused 14ms+5ms
D/dalvikvm(   61): GREF has increased to 401
D/dalvikvm(  123): GC_EXTERNAL_ALLOC freed 8K, 49% free 3191K/6151K, external 59
27K/6853K, paused 63ms
W/InputManagerService(   61): Starting input on non-focused client com.android.i
nternal.view.IInputMethodClient$Stub$Proxy@40530dd8 (uid=10035 pid=343)
D/dalvikvm(  130): GC_EXPLICIT freed 135K, 50% free 2949K/5895K, external 5959K/
7152K, paused 75ms
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.OutgoingCallBroadcaster }
from pid 343
D/PhoneUtils(  123): checkAndCopyPhoneProviderExtras: some or all extras are mis
sing.
D/PhoneUtils(  123): checkAndCopyPhoneProviderExtras: some or all extras are mis
sing.
I/ActivityManager(   61): Starting: Intent { act=android.phone.extra.NEW_CALL_IN
TENT dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.SipCallOptionHan
dler (has extras) } from pid 123
V/SipCallOptionHandler(  123): Call option is SIP_ADDRESS_ONLY
I/ActivityManager(   61): Starting: Intent { act=android.intent.action.CALL dat=
tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.InCallScreen (has extras)
} from pid 123
W/PhoneUtils(  123): Exception from phone.dial()
W/PhoneUtils(  123): com.android.internal.telephony.CallStateException: cannot d
ial in current state
W/PhoneUtils(  123):    at com.android.internal.telephony.CallManager.dial(CallM
anager.java:704)
W/PhoneUtils(  123):    at com.android.phone.PhoneUtils.placeCall(PhoneUtils.jav
a:539)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.placeCall(InCallScreen
.java:2667)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.internalResolveIntent(
InCallScreen.java:1188)
W/PhoneUtils(  123):    at com.android.phone.InCallScreen.onNewIntent(InCallScre
en.java:1126)
W/PhoneUtils(  123):    at android.app.Instrumentation.callActivityOnNewIntent(I
nstrumentation.java:1119)
W/PhoneUtils(  123):    at android.app.ActivityThread.deliverNewIntents(Activity
Thread.java:1722)
W/PhoneUtils(  123):    at android.app.ActivityThread.performNewIntents(Activity
Thread.java:1734)
W/PhoneUtils(  123):    at android.app.ActivityThread.handleNewIntent(ActivityTh
read.java:1742)
W/PhoneUtils(  123):    at android.app.ActivityThread.access$2300(ActivityThread
.java:117)
W/PhoneUtils(  123):    at android.app.ActivityThread$H.handleMessage(ActivityTh
read.java:978)
W/PhoneUtils(  123):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/PhoneUtils(  123):    at android.os.Looper.loop(Looper.java:123)
W/PhoneUtils(  123):    at android.app.ActivityThread.main(ActivityThread.java:3
683)
W/PhoneUtils(  123):    at java.lang.reflect.Method.invokeNative(Native Method)
W/PhoneUtils(  123):    at java.lang.reflect.Method.invoke(Method.java:507)
W/PhoneUtils(  123):    at com.android.internal.os.ZygoteInit$MethodAndArgsCalle
r.run(ZygoteInit.java:839)
W/PhoneUtils(  123):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
va:597)
W/PhoneUtils(  123):    at dalvik.system.NativeStart.main(Native Method)
W/InCallScreen(  123): placeCall: PhoneUtils.placeCall() FAILED for number '4'.
W/InCallScreen(  123): onNewIntent: status CALL_FAILED from internalResolveInten
t()
W/InputManagerService(   61): Window already focused, ignoring focus gain of: co
m.android.internal.view.IInputMethodClient$Stub$Proxy@406f3830
D/dalvikvm(  125): GC_CONCURRENT freed 255K, 51% free 2844K/5767K, external 2219
K/2674K, paused 6ms+94ms

So i thought to ask if there was a simple solution to this problem before I lay all that many hours onto this problem?

Thanks!

EDIT: I have even tried doing this procedure by hand ( taking an incomming call, put in on hold, call a coworker and again calling the digit 4 to transfer it) same error as the app gets. So did android block the functinallity of mobile switchboards?

EDIT : This bug only affects "vanilla" android phones mad by Google. HTC Samsung doesnt have it! Confirmed case: Nexus S

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野却迷人 2024-11-11 18:03:35

我认为问题在于 PhoneUtils(引发异常)已经有一个正在进行的呼叫不空闲。如果您查看 PhoneUtils 的源代码(例如此处: http://hi-android.info/src/com/android/internal/telephony/gsm/GsmCallTracker.java.html)并搜索异常“无法拨入当前state”你会看到抛出这个异常的条件是有一个活跃的调用。
因此,您必须先暂停当前通话,然后再发起新的通话。

我不知道为什么它过去在 2.2 中可以工作,而在 2.3 中却不行,但我想他们已经改变了一些处理调用的方式。

I think the problem is that PhoneUtils (which throws the exception) already has an ongoing call that is not idle. If you look at the source of PhoneUtils (e.g. here: http://hi-android.info/src/com/android/internal/telephony/gsm/GsmCallTracker.java.html) and search for the exception "cannot dial in current state" you'll see that the conditions to throw this exception are that there is an active call.
So you'd have to first put the active call on hold and then initiate the new one.

I don't know why it used to work in 2.2 and it won't in 2.3 but I suppose they have changed some of the ways calls are handled.

花开柳相依 2024-11-11 18:03:35

抛出异常 此处。作为该 拨号功能描述,“如果当前无法进行新的拨出呼叫,因为不存在更多呼叫槽位或存在正在拨号、提醒、响铃或等待的呼叫”,则抛出 CallStateException ” 。在您的示例中,听起来似乎对 B 的呼叫仍在响铃中,因此无法再拨打新的呼叫。

看来 CallManager 类在 2.2 中并不存在,尽管没有进一步的研究,我无法确定取代它的是什么(以及为什么允许这种同时调用,而现在不允许)。

The exception is being thrown here. As the Javadoc for that dial function describes, CallStateException is thrown "if a new outgoing call is not currently possible because no more call slots exist or a call exists that is dialing, alerting, ringing, or waiting". It sounds as though, in your example, the call to Person B is still ringing and therefore a new call can no longer be dialed.

It appears that the CallManager class did not exist in 2.2, although without further research I cannot be sure what stood in its place (and why such simultaneous calls were permitted when they are now not).

泪之魂 2024-11-11 18:03:35

这个错误只影响谷歌疯狂的“香草”安卓手机。 HTC三星没有!确诊病例:Nexus S

This bug only affects "vanilla" android phones mad by Google. HTC Samsung doesnt have it! Confirmed case: Nexus S

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文