Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9e28017 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 25092 into eclair

* changes:
  New field in CallerInfo to cache if the call is an emergency one.
parents 6ee7b04d e2241581
Loading
Loading
Loading
Loading
+34 −7
Original line number Diff line number Diff line
@@ -100,10 +100,14 @@ public class CallerInfo {
    public Drawable cachedPhoto;
    public boolean isCachedPhotoCurrent;

    private boolean mIsEmergency;

    // Don't keep checking VM if it's going to throw an exception for this proc.
    private static boolean sSkipVmCheck = false;

    public CallerInfo() {
        // TODO: Move all the basic initialization here?
        mIsEmergency = false;
    }

    /**
@@ -221,13 +225,7 @@ public class CallerInfo {
            // or if it is the voicemail number.  If it is either, take a
            // shortcut and skip the query.
            if (PhoneNumberUtils.isEmergencyNumber(number)) {
                CallerInfo ci = new CallerInfo();

                // Note we're setting the phone number here (refer to javadoc
                // comments at the top of CallerInfo class).
                ci.phoneNumber = context.getString(
                        com.android.internal.R.string.emergency_call_dialog_number_for_display);
                return ci;
                return new CallerInfo().markAsEmergency(context);
            } else {
                try {
                    if (!sSkipVmCheck && PhoneNumberUtils.compare(number,
@@ -296,6 +294,35 @@ public class CallerInfo {
        return callerID;
    }

    // Accessors

    /**
     * @return true if the caller info is an emergency number.
     */
    public boolean isEmergencyNumber() {
        return mIsEmergency;
    }

    /**
     * Mark this CallerInfo as an emergency call.
     * @param context To lookup the localized 'Emergency Number' string.
     * @return this instance.
     */
    // TODO: Note we're setting the phone number here (refer to
    // javadoc comments at the top of CallerInfo class) to a localized
    // string 'Emergency Number'. This is pretty bad because we are
    // making UI work here instead of just packaging the data. We
    // should set the phone number to the dialed number and name to
    // 'Emergency Number' and let the UI make the decision about what
    // should be displayed.
    /* package */ CallerInfo markAsEmergency(Context context) {
        phoneNumber = context.getString(
            com.android.internal.R.string.emergency_call_dialog_number_for_display);
        photoResource = com.android.internal.R.drawable.picture_emergency;
        mIsEmergency = true;
        return this;
    }

    private static String normalize(String s) {
        if (s == null || s.length() > 0) {
            return s;
+2 −7
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import android.util.Log;
public class CallerInfoAsyncQuery {

    private static final boolean DBG = false;
    private static final String LOG_TAG = "PHONE";
    private static final String LOG_TAG = "CallerInfoAsyncQuery";

    private static final int EVENT_NEW_QUERY = 1;
    private static final int EVENT_ADD_LISTENER = 2;
@@ -223,13 +223,9 @@ public class CallerInfoAsyncQuery {
                // voicemail number, and adjust other data (including photoResource)
                // accordingly.
                if (cw.event == EVENT_EMERGENCY_NUMBER) {
                    mCallerInfo = new CallerInfo();
                    // Note we're setting the phone number here (refer to javadoc
                    // comments at the top of CallerInfo class).
                    mCallerInfo.phoneNumber = mQueryContext.getString(com.android.internal
                            .R.string.emergency_call_dialog_number_for_display);
                    mCallerInfo.photoResource = com.android.internal.R.drawable.picture_emergency;

                    mCallerInfo = new CallerInfo().markAsEmergency(mQueryContext);
                } else if (cw.event == EVENT_VOICEMAIL_NUMBER) {
                    mCallerInfo = new CallerInfo();
                    try {
@@ -390,4 +386,3 @@ public class CallerInfoAsyncQuery {
        Log.d(LOG_TAG, msg);
    }
}
+12 −0
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_JAVA_LIBRARIES := android.test.runner

LOCAL_PACKAGE_NAME := telephonytest

include $(BUILD_PACKAGE)
+35 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.telephonytest">

    <application>
        <uses-library android:name="android.test.runner" />
        <activity android:label="TelephonyTest"
                android:name="TelephonyTest">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
     <instrumentation android:name=".TelephonyUnitTestRunner"
         android:targetPackage="com.android.telephonytest"
         android:label="Telephony unit tests InstrumentationRunner">
     </instrumentation>
</manifest>
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.telephonytest;

import junit.framework.TestSuite;

import android.test.InstrumentationTestRunner;
import android.test.InstrumentationTestSuite;

/**
 * Instrumentation Test Runner for all Telephony unit tests.
 *
 * Running all tests:
 *
 *   runtest telephony-unit
 * or
 *   adb shell am instrument -w com.android.telephonytest/.TelephonyUnitTestRunner
 */

public class TelephonyUnitTestRunner extends InstrumentationTestRunner {

    @Override
    public TestSuite getAllTests() {
        TestSuite suite = new InstrumentationTestSuite(this);
        suite.addTestSuite(com.android.telephonytest.unit.CallerInfoUnitTest.class);
        return suite;
    }

    @Override
    public ClassLoader getLoader() {
        return TelephonyUnitTestRunner.class.getClassLoader();
    }
}
Loading