From d5e47f6da5b08b13ecdfa7f1edc7e12aeb83fab9 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Wed, 15 Mar 2017 14:41:07 -0700 Subject: Update Dialer source from latest green build. * Refactor voicemail component * Add new enriched calling components Test: treehugger, manual aosp testing Change-Id: I521a0f86327d4b42e14d93927c7d613044ed5942 --- .../voicemailomtp/TelephonyVvmConfigManager.java | 154 --------------------- 1 file changed, 154 deletions(-) delete mode 100644 java/com/android/voicemailomtp/TelephonyVvmConfigManager.java (limited to 'java/com/android/voicemailomtp/TelephonyVvmConfigManager.java') diff --git a/java/com/android/voicemailomtp/TelephonyVvmConfigManager.java b/java/com/android/voicemailomtp/TelephonyVvmConfigManager.java deleted file mode 100644 index ab13d36ad..000000000 --- a/java/com/android/voicemailomtp/TelephonyVvmConfigManager.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2016 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.voicemailomtp; - -import android.content.res.Resources; -import android.os.PersistableBundle; -import android.support.annotation.Nullable; -import android.support.annotation.VisibleForTesting; -import android.util.ArrayMap; -import com.android.voicemailomtp.utils.XmlUtils; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Map; -import java.util.Map.Entry; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -/** - * Load and caches telephony vvm config from res/xml/vvm_config.xml - */ -public class TelephonyVvmConfigManager { - - private static final String TAG = "TelephonyVvmCfgMgr"; - - private static final boolean USE_DEBUG_CONFIG = false; - - private static final String TAG_PERSISTABLEMAP = "pbundle_as_map"; - - static final String KEY_MCCMNC = "mccmnc"; - - private static Map sCachedConfigs; - - private final Map mConfigs; - - public TelephonyVvmConfigManager(Resources resources) { - if (sCachedConfigs == null) { - sCachedConfigs = loadConfigs(resources.getXml(R.xml.vvm_config)); - } - mConfigs = sCachedConfigs; - } - - @VisibleForTesting - TelephonyVvmConfigManager(XmlPullParser parser) { - mConfigs = loadConfigs(parser); - } - - @Nullable - public PersistableBundle getConfig(String mccMnc) { - if (USE_DEBUG_CONFIG) { - return mConfigs.get("TEST"); - } - return mConfigs.get(mccMnc); - } - - private static Map loadConfigs(XmlPullParser parser) { - Map configs = new ArrayMap<>(); - try { - ArrayList list = readBundleList(parser); - for (Object object : list) { - if (!(object instanceof PersistableBundle)) { - throw new IllegalArgumentException("PersistableBundle expected, got " + object); - } - PersistableBundle bundle = (PersistableBundle) object; - String[] mccMncs = bundle.getStringArray(KEY_MCCMNC); - if (mccMncs == null) { - throw new IllegalArgumentException("MCCMNC is null"); - } - for (String mccMnc : mccMncs) { - configs.put(mccMnc, bundle); - } - } - } catch (IOException | XmlPullParserException e) { - throw new RuntimeException(e); - } - return configs; - } - - @Nullable - public static ArrayList readBundleList(XmlPullParser in) throws IOException, - XmlPullParserException { - final int outerDepth = in.getDepth(); - int event; - while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && - (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { - if (event == XmlPullParser.START_TAG) { - final String startTag = in.getName(); - final String[] tagName = new String[1]; - in.next(); - return XmlUtils.readThisListXml(in, startTag, tagName, - new MyReadMapCallback(), false); - } - } - return null; - } - - public static PersistableBundle restoreFromXml(XmlPullParser in) throws IOException, - XmlPullParserException { - final int outerDepth = in.getDepth(); - final String startTag = in.getName(); - final String[] tagName = new String[1]; - int event; - while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && - (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { - if (event == XmlPullParser.START_TAG) { - ArrayMap map = - XmlUtils.readThisArrayMapXml(in, startTag, tagName, - new MyReadMapCallback()); - PersistableBundle result = new PersistableBundle(); - for (Entry entry : map.entrySet()) { - Object value = entry.getValue(); - if (value instanceof Integer) { - result.putInt(entry.getKey(), (int) value); - } else if (value instanceof Boolean) { - result.putBoolean(entry.getKey(), (boolean) value); - } else if (value instanceof String) { - result.putString(entry.getKey(), (String) value); - } else if (value instanceof String[]) { - result.putStringArray(entry.getKey(), (String[]) value); - } else if (value instanceof PersistableBundle) { - result.putPersistableBundle(entry.getKey(), (PersistableBundle) value); - } - } - return result; - } - } - return PersistableBundle.EMPTY; - } - - static class MyReadMapCallback implements XmlUtils.ReadMapCallback { - - @Override - public Object readThisUnknownObjectXml(XmlPullParser in, String tag) - throws XmlPullParserException, IOException { - if (TAG_PERSISTABLEMAP.equals(tag)) { - return restoreFromXml(in); - } - throw new XmlPullParserException("Unknown tag=" + tag); - } - } -} -- cgit v1.2.3