【Android應用開發】-(23)Android SIP 支援

來源:互聯網
上載者:User

一、什麼是sip?

請移步SIP

二、Android中如何使用sip?

目前比較完善的Sip應用:Sipdroid, Demo: android-sdk-windows\samples\android-9\ SipDemo

三、系統不支援sip?

Android自2.3之後就提供了SIP功能,SIP相關的API在目錄frameworks/base/voip/java/android/net/sip中,存在android.net.sip包中。這裡是解決不支援SIP的整個過程, 要看結果的直接移步文章最後。

在操作SIP之前必須獲得SipManager的執行個體:

SipManager.newInstance(Context);

這裡,發現有些裝置得到的instance為空白。找到SipManager.java中的newInstance方法

            /**        * Creates a manager instance. Returns null if SIP API is not supported.        *        * @param context application context for creating the manager object        * @return the manager instance or null if SIP API is not supported        */       public static SipManager newInstance(Context context) {           return (isApiSupported(context) ? new SipManager(context) : null);       }           /**        * Returns true if the SIP API is supported by the system.        */       public static boolean isApiSupported(Context context) {           return context.getPackageManager().hasSystemFeature(                   PackageManager.FEATURE_SIP);       }


通過調試,發現hasSystemFeature為空白。繼續深入,查看在PackageManager.java的方法hasSystemFeature,盡然是抽象的。

      /**        * Check whether the given feature name is one of the available        * features as returned by {@link #getSystemAvailableFeatures()}.        *        * @return Returns true if the devices supports the feature, else        * false.        */       public abstract boolean hasSystemFeature(String name);


其中這個方法在services/java/com/android/server/pm/ PackageManagerService.java中實現了。

 public boolean hasSystemFeature(String name) {        synchronized (mPackages) {            return mAvailableFeatures.containsKey(name);        }    }


在成員mAvailableFeatures中沒有尋找到PackageManager.FEATURE_SIP,返回flase。所以無法建立SipManager對象。在PackageManagerService類中,成員變數mAvailableFeatures的值是通過讀取/system/permissions下的xml檔案進行設定的。通過尋找常量PackageManager.FEATURE_SIP很容易找到兩個和SIP相關的xml檔案,在目錄frameworks/base/data/etc/下。根據以往的經驗,這兩個檔案既然存在,但/system/permissions目錄下沒有。肯定是沒有拷貝。

繼續尋找,發現在device目錄下的Vending.mk檔案中。將frameworks/base/data/etc/下的兩個和sip相關的檔案拷貝添加進去make即可。

   PRODUCT_COPY_FILES += \       device/amlogic/g04ref/tablet_core_hardware.xml:system/etc/permissions/tablet_core_hardware.xml \       frameworks/base/data/etc/android.hardware.camera.front.xml:system/etc/permissions/android.hardware.camera.front.xml \       ...       frameworks/base/data/etc/android.software.sip.voip.xml:system/etc/permissions/android.software.sip.voip.xml \       frameworks/base/data/etc/android.software.sip.xml:system/etc/permissions/android.software.sip.xml

如果不編譯系統,直接將兩個檔案拷貝到/system/permissions目錄下也是可以的。

原創文章,轉載請註明出處:http://blog.csdn.net/tangcheng_ok


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.