A20拨号功能解决

默认A20是没有启用拨号功能的,但是phone.apk又是编译并安装了的,在Launcher界面却又看不到apk图标,所以猜想:如果在AndroidManifest.xml注释了Launcher声明,就会达到这样的效果。寻着这个思路去../packages/phone/中的AndroidManifest.xml找了几个android.intent.action.MAIN声明,但就是有看到android.intent.category.LAUNCHER,似乎看到了希望,在仅有的几个MAIN声明下面手动添加android.intent.category.LAUNCHER声明,联机调试,却仍然看不到任何图标。去mipmap中确认下是不是有图标吧 ,发现确实是有的,两个:ic_launcher_phone.png、ic_launcher_contacts.png,那我在si中搜下ic_launcher_phone吧,搜到了三条引用位置,居然不在phone中,而是在contancts中,难道contacs才是幕后,phone只是个傀儡,好吧,同样的方法,在AndroidManifest.xml中多处声明android.intent.category.LAUNCHER,仍然看不到拨号器,仔细看看AndroidManifest.xml,(写apk的肯定一下就能知道问题所在了,但是我只能猜想),猜想应该是有什么标志位吧,看到了android:enabled:..看起来像,网上搜了搜果然有屏蔽的功能,那不管它,我直接写个true给它。拨号器就这样有了。

<activity android:name=".activities.DialtactsActivity"
            android:label="@string/launcherDialer"
            android:theme="@style/DialtactsTheme"
            android:uiOptions="splitActionBarWhenNarrow"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true"
            android:icon="@mipmap/ic_launcher_phone"
            android:screenOrientation="nosensor"
            android:enabled="@*android:bool/config_voice_capable"
            android:taskAffinity="android.task.contacts.phone"
            android:windowSoftInputMode="stateAlwaysHidden|adjustNothing">
            <intent-filter>
                <action android:name="android.intent.action.DIAL" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:mimeType="vnd.android.cursor.item/phone" />
                <data android:mimeType="vnd.android.cursor.item/person" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.DIAL" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="voicemail" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.DIAL" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

<!--     <category android:name="android.intent.category.LAUNCHER" />-->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />


                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>



但是拨号还是有问题,会崩掉,看log吧,log中有提到本机是non-voice-capable,屏蔽了来电ui,si中查找log出处:InCallScreen.java:

    protected void onCreate(Bundle icicle) {
        Log.i(LOG_TAG, "onCreate()...  this = " + this);
        Profiler.callScreenOnCreate();
        super.onCreate(icicle);


        // Make sure this is a voice-capable device.
        if (!PhoneGlobals.sVoiceCapable) {
            // There should be no way to ever reach the InCallScreen on a
            // non-voice-capable device, since this activity is not exported by
            // our manifest, and we explicitly disable any other external APIs
            // like the CALL intent and ITelephony.showCallScreen().
            // So the fact that we got here indicates a phone app bug.
            Log.wtf(LOG_TAG, "onCreate() reached on non-voice-capable device");
            finish();
            return;
        }



        mApp = PhoneGlobals.getInstance();
        mApp.setInCallScreenInstance(this);


        // set this flag so this activity will stay in front of the keyguard
        int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
        if (mApp.getPhoneState() == PhoneConstants.State.OFFHOOK) {
            // While we are in call, the in-call screen should dismiss the keyguard.
            // This allows the user to press Home to go directly home without going through
            // an insecure lock screen.
            // But we do not want to do this if there is no active call so we do not
            // bypass the keyguard if the call is not answered or declined.
            flags |= WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
        }

可以看到如果被识别为non-voice-capable,就直接return了,这就清楚了。查找定义吧,最终找到定义:PhoneGlobals.java:

 public void onCreate() {
        if (VDBG) Log.v(LOG_TAG, "onCreate()...");


        ContentResolver resolver = getContentResolver();


        // Cache the "voice capable" flag.
        // This flag currently comes from a resource (which is
        // overrideable on a per-product basis):
        sVoiceCapable =
                getResources().getBoolean(com.android.internal.R.bool.config_voice_capable);

        // ...but this might eventually become a PackageManager "system
        // feature" instead, in which case we'd do something like:
        // sVoiceCapable =
        //   getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY_VOICE_CALLS);


com.android.internal.R.bool.config_voice_capable??好眼熟,回看下AndroidManifest.xml:这不是同一个标志位吗,android:enabled="@*android:bool/config_voice_capable"

si中全局搜索这个布尔值,../overlay/frameworks/base/core/res/res/values/config.xml:

  <!-- Flag indicating whether the current device is "voice capable".
         If true, this means that the device supports circuit-switched
         (i.e. voice) phone calls over the telephony network, and is
         allowed to display the in-call UI while a cellular voice call is
         active.  This can be overridden to false for "data only" devices
         which can't make voice calls and don't support any in-call UI.


         Note: this flag is subtly different from the
         PackageManager.FEATURE_TELEPHONY system feature, which is
         available on *any* device with a telephony radio, even if the
         device is data-only. -->
    <bool name="config_voice_capable">faluse</bool>


将faluse改为true,再回到AndroidManifest.xml还原android:enabled,全编一次,ok了,能呼出能接听了。但是,没有声音,据一位前辈指示,有可能是tinyalsa没设置好,网上找了找资源,adb中看了下tinymix :看到电话音频通道确实是off状态的,由于项目需求并不需要真正的通话功能,所以就没再往下追踪了。留下链接,以供以后遇到继续跟踪:http://blog.youkuaiyun.com/kangear/article/details/38139669


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值