Search in sources :

Example 1 with BaseBundle

use of android.os.BaseBundle in project android_frameworks_base by DirtyUnicorns.

the class ShortcutManagerTestUtils method assertBundlesEqual.

public static void assertBundlesEqual(BaseBundle b1, BaseBundle b2) {
    if (b1 == null && b2 == null) {
        // pass
        return;
    }
    assertNotNull("b1 is null but b2 is not", b1);
    assertNotNull("b2 is null but b1 is not", b2);
    // HashSet makes the error message readable.
    assertEquals(set(b1.keySet()), set(b2.keySet()));
    for (String key : b1.keySet()) {
        final Object v1 = b1.get(key);
        final Object v2 = b2.get(key);
        if (v1 == null) {
            if (v2 == null) {
                return;
            }
        }
        if (v1.equals(v2)) {
            return;
        }
        assertTrue("Only either value is null: key=" + key + " b1=" + b1 + " b2=" + b2, v1 != null && v2 != null);
        assertEquals("Class mismatch: key=" + key, v1.getClass(), v2.getClass());
        if (v1 instanceof BaseBundle) {
            assertBundlesEqual((BaseBundle) v1, (BaseBundle) v2);
        } else if (v1 instanceof boolean[]) {
            assertTrue(Arrays.equals((boolean[]) v1, (boolean[]) v2));
        } else if (v1 instanceof int[]) {
            MoreAsserts.assertEquals((int[]) v1, (int[]) v2);
        } else if (v1 instanceof double[]) {
            MoreAsserts.assertEquals((double[]) v1, (double[]) v2);
        } else if (v1 instanceof String[]) {
            MoreAsserts.assertEquals((String[]) v1, (String[]) v2);
        } else if (v1 instanceof Double) {
            if (((Double) v1).isNaN()) {
                assertTrue(((Double) v2).isNaN());
            } else {
                assertEquals(v1, v2);
            }
        } else {
            assertEquals(v1, v2);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) Matchers.anyString(org.mockito.Matchers.anyString) BaseBundle(android.os.BaseBundle)

Example 2 with BaseBundle

use of android.os.BaseBundle in project platform_frameworks_base by android.

the class ShortcutManagerTestUtils method assertBundlesEqual.

public static void assertBundlesEqual(BaseBundle b1, BaseBundle b2) {
    if (b1 == null && b2 == null) {
        // pass
        return;
    }
    assertNotNull("b1 is null but b2 is not", b1);
    assertNotNull("b2 is null but b1 is not", b2);
    // HashSet makes the error message readable.
    assertEquals(set(b1.keySet()), set(b2.keySet()));
    for (String key : b1.keySet()) {
        final Object v1 = b1.get(key);
        final Object v2 = b2.get(key);
        if (v1 == null) {
            if (v2 == null) {
                return;
            }
        }
        if (v1.equals(v2)) {
            return;
        }
        assertTrue("Only either value is null: key=" + key + " b1=" + b1 + " b2=" + b2, v1 != null && v2 != null);
        assertEquals("Class mismatch: key=" + key, v1.getClass(), v2.getClass());
        if (v1 instanceof BaseBundle) {
            assertBundlesEqual((BaseBundle) v1, (BaseBundle) v2);
        } else if (v1 instanceof boolean[]) {
            assertTrue(Arrays.equals((boolean[]) v1, (boolean[]) v2));
        } else if (v1 instanceof int[]) {
            MoreAsserts.assertEquals((int[]) v1, (int[]) v2);
        } else if (v1 instanceof double[]) {
            MoreAsserts.assertEquals((double[]) v1, (double[]) v2);
        } else if (v1 instanceof String[]) {
            MoreAsserts.assertEquals((String[]) v1, (String[]) v2);
        } else if (v1 instanceof Double) {
            if (((Double) v1).isNaN()) {
                assertTrue(((Double) v2).isNaN());
            } else {
                assertEquals(v1, v2);
            }
        } else {
            assertEquals(v1, v2);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) Matchers.anyString(org.mockito.Matchers.anyString) BaseBundle(android.os.BaseBundle)

Example 3 with BaseBundle

use of android.os.BaseBundle in project android_frameworks_opt_telephony by LineageOS.

the class SmsController method getMmsConfig.

/**
 * Filters a bundle to only contain MMS config variables.
 *
 * This is for use with bundles returned by CarrierConfigManager which contain MMS config and
 * unrelated config. It is assumed that all MMS_CONFIG_* keys are present in the supplied
 * bundle.
 *
 * @param config a Bundle that contains MMS config variables and possibly more.
 * @return a new Bundle that only contains the MMS_CONFIG_* keys defined in SmsManager.
 */
private static Bundle getMmsConfig(BaseBundle config) {
    Bundle filtered = new Bundle();
    filtered.putBoolean(SmsManager.MMS_CONFIG_APPEND_TRANSACTION_ID, config.getBoolean(SmsManager.MMS_CONFIG_APPEND_TRANSACTION_ID));
    filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_MMS_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_GROUP_MMS_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_GROUP_MMS_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_NOTIFY_WAP_MMSC_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_ALIAS_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_ALIAS_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_ALLOW_ATTACH_AUDIO, config.getBoolean(SmsManager.MMS_CONFIG_ALLOW_ATTACH_AUDIO));
    filtered.putBoolean(SmsManager.MMS_CONFIG_MULTIPART_SMS_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_MULTIPART_SMS_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_SMS_DELIVERY_REPORT_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, config.getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION));
    filtered.putBoolean(SmsManager.MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES, config.getBoolean(SmsManager.MMS_CONFIG_SEND_MULTIPART_SMS_AS_SEPARATE_MESSAGES));
    filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_READ_REPORT_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_MMS_READ_REPORT_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED, config.getBoolean(SmsManager.MMS_CONFIG_MMS_DELIVERY_REPORT_ENABLED));
    filtered.putBoolean(SmsManager.MMS_CONFIG_CLOSE_CONNECTION, config.getBoolean(SmsManager.MMS_CONFIG_CLOSE_CONNECTION));
    filtered.putInt(SmsManager.MMS_CONFIG_MAX_MESSAGE_SIZE, config.getInt(SmsManager.MMS_CONFIG_MAX_MESSAGE_SIZE));
    filtered.putInt(SmsManager.MMS_CONFIG_MAX_IMAGE_WIDTH, config.getInt(SmsManager.MMS_CONFIG_MAX_IMAGE_WIDTH));
    filtered.putInt(SmsManager.MMS_CONFIG_MAX_IMAGE_HEIGHT, config.getInt(SmsManager.MMS_CONFIG_MAX_IMAGE_HEIGHT));
    filtered.putInt(SmsManager.MMS_CONFIG_RECIPIENT_LIMIT, config.getInt(SmsManager.MMS_CONFIG_RECIPIENT_LIMIT));
    filtered.putInt(SmsManager.MMS_CONFIG_ALIAS_MIN_CHARS, config.getInt(SmsManager.MMS_CONFIG_ALIAS_MIN_CHARS));
    filtered.putInt(SmsManager.MMS_CONFIG_ALIAS_MAX_CHARS, config.getInt(SmsManager.MMS_CONFIG_ALIAS_MAX_CHARS));
    filtered.putInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD, config.getInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_THRESHOLD));
    filtered.putInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD, config.getInt(SmsManager.MMS_CONFIG_SMS_TO_MMS_TEXT_LENGTH_THRESHOLD));
    filtered.putInt(SmsManager.MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE, config.getInt(SmsManager.MMS_CONFIG_MESSAGE_TEXT_MAX_SIZE));
    filtered.putInt(SmsManager.MMS_CONFIG_SUBJECT_MAX_LENGTH, config.getInt(SmsManager.MMS_CONFIG_SUBJECT_MAX_LENGTH));
    filtered.putInt(SmsManager.MMS_CONFIG_HTTP_SOCKET_TIMEOUT, config.getInt(SmsManager.MMS_CONFIG_HTTP_SOCKET_TIMEOUT));
    filtered.putString(SmsManager.MMS_CONFIG_UA_PROF_TAG_NAME, config.getString(SmsManager.MMS_CONFIG_UA_PROF_TAG_NAME));
    filtered.putString(SmsManager.MMS_CONFIG_USER_AGENT, config.getString(SmsManager.MMS_CONFIG_USER_AGENT));
    filtered.putString(SmsManager.MMS_CONFIG_UA_PROF_URL, config.getString(SmsManager.MMS_CONFIG_UA_PROF_URL));
    filtered.putString(SmsManager.MMS_CONFIG_HTTP_PARAMS, config.getString(SmsManager.MMS_CONFIG_HTTP_PARAMS));
    filtered.putString(SmsManager.MMS_CONFIG_EMAIL_GATEWAY_NUMBER, config.getString(SmsManager.MMS_CONFIG_EMAIL_GATEWAY_NUMBER));
    filtered.putString(SmsManager.MMS_CONFIG_NAI_SUFFIX, config.getString(SmsManager.MMS_CONFIG_NAI_SUFFIX));
    filtered.putBoolean(SmsManager.MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS, config.getBoolean(SmsManager.MMS_CONFIG_SHOW_CELL_BROADCAST_APP_LINKS));
    filtered.putBoolean(SmsManager.MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER, config.getBoolean(SmsManager.MMS_CONFIG_SUPPORT_HTTP_CHARSET_HEADER));
    return filtered;
}
Also used : Bundle(android.os.Bundle) BaseBundle(android.os.BaseBundle)

Example 4 with BaseBundle

use of android.os.BaseBundle in project android_frameworks_base by ResurrectionRemix.

the class ShortcutManagerTestUtils method assertBundlesEqual.

public static void assertBundlesEqual(BaseBundle b1, BaseBundle b2) {
    if (b1 == null && b2 == null) {
        // pass
        return;
    }
    assertNotNull("b1 is null but b2 is not", b1);
    assertNotNull("b2 is null but b1 is not", b2);
    // HashSet makes the error message readable.
    assertEquals(set(b1.keySet()), set(b2.keySet()));
    for (String key : b1.keySet()) {
        final Object v1 = b1.get(key);
        final Object v2 = b2.get(key);
        if (v1 == null) {
            if (v2 == null) {
                return;
            }
        }
        if (v1.equals(v2)) {
            return;
        }
        assertTrue("Only either value is null: key=" + key + " b1=" + b1 + " b2=" + b2, v1 != null && v2 != null);
        assertEquals("Class mismatch: key=" + key, v1.getClass(), v2.getClass());
        if (v1 instanceof BaseBundle) {
            assertBundlesEqual((BaseBundle) v1, (BaseBundle) v2);
        } else if (v1 instanceof boolean[]) {
            assertTrue(Arrays.equals((boolean[]) v1, (boolean[]) v2));
        } else if (v1 instanceof int[]) {
            MoreAsserts.assertEquals((int[]) v1, (int[]) v2);
        } else if (v1 instanceof double[]) {
            MoreAsserts.assertEquals((double[]) v1, (double[]) v2);
        } else if (v1 instanceof String[]) {
            MoreAsserts.assertEquals((String[]) v1, (String[]) v2);
        } else if (v1 instanceof Double) {
            if (((Double) v1).isNaN()) {
                assertTrue(((Double) v2).isNaN());
            } else {
                assertEquals(v1, v2);
            }
        } else {
            assertEquals(v1, v2);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) Matchers.anyString(org.mockito.Matchers.anyString) BaseBundle(android.os.BaseBundle)

Example 5 with BaseBundle

use of android.os.BaseBundle in project android_frameworks_base by crdroidandroid.

the class ShortcutManagerTestUtils method assertBundlesEqual.

public static void assertBundlesEqual(BaseBundle b1, BaseBundle b2) {
    if (b1 == null && b2 == null) {
        // pass
        return;
    }
    assertNotNull("b1 is null but b2 is not", b1);
    assertNotNull("b2 is null but b1 is not", b2);
    // HashSet makes the error message readable.
    assertEquals(set(b1.keySet()), set(b2.keySet()));
    for (String key : b1.keySet()) {
        final Object v1 = b1.get(key);
        final Object v2 = b2.get(key);
        if (v1 == null) {
            if (v2 == null) {
                return;
            }
        }
        if (v1.equals(v2)) {
            return;
        }
        assertTrue("Only either value is null: key=" + key + " b1=" + b1 + " b2=" + b2, v1 != null && v2 != null);
        assertEquals("Class mismatch: key=" + key, v1.getClass(), v2.getClass());
        if (v1 instanceof BaseBundle) {
            assertBundlesEqual((BaseBundle) v1, (BaseBundle) v2);
        } else if (v1 instanceof boolean[]) {
            assertTrue(Arrays.equals((boolean[]) v1, (boolean[]) v2));
        } else if (v1 instanceof int[]) {
            MoreAsserts.assertEquals((int[]) v1, (int[]) v2);
        } else if (v1 instanceof double[]) {
            MoreAsserts.assertEquals((double[]) v1, (double[]) v2);
        } else if (v1 instanceof String[]) {
            MoreAsserts.assertEquals((String[]) v1, (String[]) v2);
        } else if (v1 instanceof Double) {
            if (((Double) v1).isNaN()) {
                assertTrue(((Double) v2).isNaN());
            } else {
                assertEquals(v1, v2);
            }
        } else {
            assertEquals(v1, v2);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) Matchers.anyString(org.mockito.Matchers.anyString) BaseBundle(android.os.BaseBundle)

Aggregations

BaseBundle (android.os.BaseBundle)5 JSONObject (org.json.JSONObject)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Bundle (android.os.Bundle)1