sprd9820 来电归属地

一、来电归属地没有出来

sprd\packages\apps\InCallUI\src\com\sprd\incallui\geocode\GeocodeHelper.java
private static final String KEY = "ro.device.support.geocode";
private static final boolean SUPPORT_SPRD_GROCODE = SystemProperties.getBoolean(KEY, true) && (OperatorUtils.IS_CMCC || OperatorUtils.IS_CUCC);
//SystemProperties.getBoolean(KEY, true),获取ro.device.support.geocode的属性值默认为true
//(OperatorUtils.IS_CMCC || OperatorUtils.IS_CUCC):这个sprd本意实现是想判断是联通还是移动,实际打log出来插入移动 OperatorUtils.IS_CMCC获取的值也是false.
private static final boolean SUPPORT_SPRD_GROCODE = SystemProperties.getBoolean(KEY, true); //zxw modify

二、按照一的做了,还是没有出来,

sprd\packages\apps\InCallUI\src\com\android\incallui\CallCardFragment.java
	@Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ...
		/* SPRD: for call geocode @ { */
        mGeocodeView = (TextView)view.findViewById(R.id.geocode);
		Log.d("zxw","setPrimary mGeocodeView = " + mGeocodeView);//打log发现mGeocodeView为空,没有显示来电归属地
		...
	}

那么在哪里加入mGeocodeView?
还在CallCardFragment.java,onCreateView有加载layout文件

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        mDensity = getResources().getDisplayMetrics().density;
        View view;
        // SPRD: add for Universe UI
        if(SprdUtils.PIKEL_UI_SUPPORT) {
            view = inflater.inflate(R.layout.call_card_sprd_pikel, container, false);
            mSimManager = SimManager.get(getActivity());
        } else if (SprdUtils.UNIVERSE_UI_SUPPORT){
            view = inflater.inflate(R.layout.call_card_sprd, container, false);
            mSimManager = SimManager.get(getActivity());
        } else {
            view = inflater.inflate(R.layout.call_card, container, false);
        }
        return view;
    }

后面通过分析是走的call_card_sprd_pikel.xml文件,然后在call_card_sprd_pikel.xml会搜到
layout="@layout/primary_call_info_sprd_pikel"/>
所以在primary_call_info_sprd_pikel.xml增加mGeocodeView 控件
sprd\packages\apps\InCallUI\res\layout\primary_call_info_sprd_pikel.xml
加在LinearLayout phoneNumber后面,其实后面发现这样加并不合理,因为屏的分辨率比较小,这样call的状态放到下面去了,看不到了。
后面改成callStateLabel和geocode用LinearLayout包起来,做一行显示

<TextView android:id="@+id/geocode"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_gravity="center_horizontal"
		android:textColor="@color/incall_main_info_text_color_sprd"
		android:textSize="@dimen/call_status_text_size"
        android:singleLine="true"/>

callStateLabel和geocode用LinearLayout包起来,做一行显示;
<RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center">
	    <LinearLayout
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:layout_gravity="center_horizontal"
	            android:orientation="horizontal">
				<TextView android:id="@+id/geocode"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_gravity="center_horizontal"
					android:textColor="@color/incall_main_info_text_color_sprd"
					android:textSize="@dimen/call_status_text_size"
	                android:singleLine="true"/>
		    
	            <TextView android:id="@+id/callStateLabel"
	                android:layout_width="wrap_content"
	                android:layout_height="wrap_content"
	                android:textSize="@dimen/call_status_text_size"
	                android:textColor="@color/incall_main_info_text_color_sprd"
	                android:layout_marginRight="@dimen/call_button_margin_vertical"
	                android:singleLine="true"
	                android:ellipsize="end"/>
	    </LinearLayout>
            <!-- Elapsed time indication for a call in progress. -->
            <TextView android:id="@+id/elapsedTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/incall_main_info_text_color_sprd"
                android:singleLine="true"
                android:textSize="@dimen/call_status_text_size"
                android:visibility="gone"
                android:layout_toRightOf="@id/callStateLabel"/>

            <!-- Call type indication: a special label and/or branding
                 for certain kinds of calls (like "Internet call" for a SIP call.) -->
            <TextView android:id="@+id/callTypeLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/incall_main_info_text_color_sprd"
                android:maxLines="1"
                android:ellipsize="end"
                android:visibility="gone" />
        </RelativeLayout>

三、发现还是没有问题。

sprd\packages\apps\InCallUI\src\com\sprd\incallui\geocode\GeocodeHelper.java
public static void getGeocodeMessage(TextView view, String number) {
        if (isSupportSprdGeocode()) {
			Log.d(TAG,"zxw getGeocodeMessage number = " + number);
            if(!TextUtils.isEmpty(number)){
                GeocodeAsyncTask task = new GeocodeAsyncTask(view, number);
                task.execute();
            }
        } else {
            Log.w(TAG, " Can not support sprd geocode !");
        }
    }

加个log,发现number为空,导致TextUtils.isEmpty(number)为true,!TextUtils.isEmpty(number)为false,导致GeocodeAsyncTask异步线程没有跑进去。
调试时可以赋值一个number: number = new String(“13510678888”);

然后搜索GeocodeHelper,看在哪里会调用GeocodeHelper的getGeocodeMessage方法

sprd\packages\apps\InCallUI\src\com\android\incallui\CallCardFragment.java
	@Override
    public void setPrimary(String number, String name, boolean nameIsNumber, String label,
            Drawable photo, boolean isConference, boolean isGeneric, boolean isSipCall,
            boolean isRealNoName, String googleGeocode) {
        Log.d(this, "Setting primary call");

        if (isConference) {
            name = getConferenceString(isGeneric);
            photo = getConferencePhoto(isGeneric);
            nameIsNumber = false;
        }
		Log.d("zxw","setPrimary mGeocodeView = " + mGeocodeView);
        /* SPRD: Modify for bug789304 @{ */
        if (mGeocodeView != null) {
			Log.d("zxw","setPrimary googleGeocode = " + googleGeocode + ",TextUtils.isEmpty(googleGeocode) = " + TextUtils.isEmpty(googleGeocode));
            if (!TextUtils.isEmpty(googleGeocode)){
                mGeocodeView.setVisibility(View.VISIBLE);
                mGeocodeView.setText(googleGeocode);
            } else if (GeocodeHelper.isSupportSprdGeocode()) {
                mGeocodeView.setVisibility(View.VISIBLE);
                GeocodeHelper.getGeocodeMessage(mGeocodeView, nameIsNumber ? name : number); //zxw 
            }else {
                mGeocodeView.setVisibility(View.GONE);
            }
        }

其实在定义CallCardFragment时,

public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPresenter.CallCardUi>
        implements CallCardPresenter.CallCardUi {

sprd\packages\apps\InCallUI\src\com\android\incallui\CallCardPresenter.java 有CallCardUi接口的定义

public interface CallCardUi extends Ui {
        void setVisible(boolean on);
        void setPrimary(String number, String name, boolean nameIsNumber, String label,
                Drawable photo, boolean isConference, boolean isGeneric, boolean isSipCall,
                boolean isRealNoName, String googleGeocode); //Modify for bug789304
        void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
                Drawable photo, boolean isConference, boolean isGeneric);
        void setSecondary(boolean show, String number, String name, boolean nameIsNumber, String label,
                Drawable photo, boolean isConference, boolean isGeneric);
        void setSecondaryImage(Drawable image);
        //@orig setCallState(int, Call.DisconnectCause, boolean, String, String);
        void setCallState(int phoneId, int state, Call.DisconnectCause cause, boolean bluetoothOn,
                String gatewayLabel, String gatewayNumber);
        void setPrimaryCallElapsedTime(boolean show, String duration);
        void setPrimaryName(String name, boolean nameIsNumber, boolean isRealNoName);
        void setPrimaryImage(Drawable image);
        void setPrimaryPhoneNumber(String phoneNumber);
        void setPrimaryLabel(String label);
        void displayPhoneView(boolean show);
    }

在CallCardPresenter.java里会发现

private void updatePrimaryDisplayInfo(ContactCacheEntry entry, boolean isConference) {
        Log.d(TAG, "Update primary display " + entry);
        final CallCardUi ui = getUi();
        if (ui == null || mPrimary == null) {
            // TODO: May also occur if search result comes back after ui is destroyed. Look into
            // removing that case completely.
            Log.d(TAG, "updatePrimaryDisplayInfo called but ui or primary call is null!");
            return;
        }

        final boolean isGenericConf = isGenericConference(mPrimary);
        if (entry != null) {
            final String name = getNameForCall(entry);
            final String number = isConference ? mPrimary.getNumber() : getNumberForCall(entry);
            final String googleGeocode = getGeocodeForCall(entry);
            final boolean nameIsNumber = name != null && name.equals(entry.number);
			Log.d(TAG, "zxw updatePrimaryDisplayInfo number = " + number + ",nameIsNumber" + nameIsNumber + ",isConference" + isConference);
            ui.setPrimary(number, name, nameIsNumber, entry.label, entry.photo,
                    isConference, isGenericConf, entry.isSipCall, entry.isRealNoName, googleGeocode);//zxw 调用CallCardFragment的setPrimary
        } else {
            ui.setPrimary(mPrimary.getNumber(), null, false, null, null, isConference,
                    isGenericConf, false, false, null);
        }

    }

在CallCardPresenter.java里会发现,会发现因为已经用了sprd的来电归属,所以GeocodeHelper.isSupportGoogleGeocode()一直为false,没有传递contactInfo.number,而是一个name进去,这就是为什么在前面number为空。换成sprd的
private static String getNameForCall(ContactCacheEntry contactInfo) {
//if (TextUtils.isEmpty(contactInfo.name) && GeocodeHelper.isSupportGoogleGeocode()) {
if (TextUtils.isEmpty(contactInfo.name) && GeocodeHelper.isSupportSprdGeocode()) {//zxw modify
return contactInfo.number;
}
return contactInfo.name;
}

四,这个GeocodeAsyncTask任务跑起来了,但doInBackground里执行cursor = context.getContentResolver().query(uri, new String[] {
“province”, “city”
}, number, null, null);报错
D GecodeHelper: zxw doInBackground
01-01 08:02:58.829 1165 1941 W System.err: java.lang.SecurityException: Permission Denial: opening provider com.sprd.providers.geocode.GeocodeProvider from ProcessRecord{41c6e318 1165:com.android.incallui/u0a22} (pid=1165, uid=10022) that is not exported from uid 10012
01-01 08:02:58.829 1165 1941 W System.err: at android.os.Parcel.readException(Parcel.java:1465)
01-01 08:02:58.829 1165 1941 W System.err: at android.os.Parcel.readException(Parcel.java:1419)
01-01 08:02:58.829 660 715 D Settings: newValuesVersion = 15
01-01 08:02:58.829 1165 1941 W System.err: at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2993)
01-01 08:02:58.829 660 715 D Settings: mValues.get(name) = null
01-01 08:02:58.829 1165 1941 W System.err: at android.app.ActivityThread.acquireProvider(ActivityThread.java:4735)
01-01 08:02:58.829 1165 1941 W System.err: at android.app.ContextImpl A p p l i c a t i o n C o n t e n t R e s o l v e r . a c q u i r e U n s t a b l e P r o v i d e r ( C o n t e x t I m p l . j a v a : 2253 ) 01 − 0108 : 02 : 58.82911651941 W S y s t e m . e r r : a t a n d r o i d . c o n t e n t . C o n t e n t R e s o l v e r . a c q u i r e U n s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值