diff options
author | Yashdev Singh <yashdevs@codeaurora.org> | 2015-07-14 15:36:49 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:22:57 -0600 |
commit | 59654f388d17693552a2e8b777dd64314ce5eded (patch) | |
tree | be3af175897ef63743c6094cd368614d03841e6e | |
parent | 4b1190fa26e88b6faaa099a6f236f7034763d4bb (diff) | |
download | android_frameworks_opt_telephony-59654f388d17693552a2e8b777dd64314ce5eded.tar.gz android_frameworks_opt_telephony-59654f388d17693552a2e8b777dd64314ce5eded.tar.bz2 android_frameworks_opt_telephony-59654f388d17693552a2e8b777dd64314ce5eded.zip |
Implement framework for TelephonyPlugin.
- Create a plugin interface.
- Create a base implementation.
- Create a delegate object to dynamically load
one of the plugin.
- Modify AOSP clients to use delegate for plugable
components.
Change-Id: Id8374c8ffed983e3c834dac3886eb844eb718a09
5 files changed, 261 insertions, 1 deletions
diff --git a/src/java/com/android/internal/telephony/DefaultTelephonyPlugin.java b/src/java/com/android/internal/telephony/DefaultTelephonyPlugin.java new file mode 100644 index 000000000..52b120cc9 --- /dev/null +++ b/src/java/com/android/internal/telephony/DefaultTelephonyPlugin.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Code Aurora nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.internal.telephony; + +import android.content.Context; + +import com.android.internal.telephony.dataconnection.DcTracker; +import com.android.internal.telephony.dataconnection.DctController; + +/** + * Default implementation in Abstract class is sufficient for AOSP + * functionality. + */ +public class DefaultTelephonyPlugin extends TelephonyPluginBase { + private String TAG = "DefaultTelephonyPlugin"; + +} diff --git a/src/java/com/android/internal/telephony/ProxyController.java b/src/java/com/android/internal/telephony/ProxyController.java index 0b8480037..77a4e9d22 100644 --- a/src/java/com/android/internal/telephony/ProxyController.java +++ b/src/java/com/android/internal/telephony/ProxyController.java @@ -133,7 +133,8 @@ public class ProxyController { mUiccController = uiccController; mCi = ci; - mDctController = DctController.makeDctController(phoneProxy); + mDctController = TelephonyPluginDelegate.getInstance() + .makeDctController((PhoneProxy[])phoneProxy); mUiccPhoneBookController = new UiccPhoneBookController(mProxyPhones); mPhoneSubInfoController = new PhoneSubInfoController(mProxyPhones); mUiccSmsController = new UiccSmsController(mProxyPhones); diff --git a/src/java/com/android/internal/telephony/TelephonyPluginBase.java b/src/java/com/android/internal/telephony/TelephonyPluginBase.java new file mode 100644 index 000000000..346c2ecb1 --- /dev/null +++ b/src/java/com/android/internal/telephony/TelephonyPluginBase.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Code Aurora nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.internal.telephony; + +import android.content.Context; + +import com.android.internal.telephony.dataconnection.DcTracker; +import com.android.internal.telephony.dataconnection.DctController; + +public abstract class TelephonyPluginBase implements TelephonyPluginInterface { + private String TAG = "TelephonyPluginBase"; + + @Override + public void makeDefaultPhones(Context context) { + PhoneFactory.makeDefaultPhones(context); + } + + @Override + public DcTracker makeDcTracker(PhoneBase phone) { + return new DcTracker(phone); + } + + @Override + public DctController makeDctController(PhoneProxy[] phones) { + return DctController.makeDctController(phones); + } + + @Override + public void initSubscriptionController(Context context, + CommandsInterface[] commandsInterfaces) { + SubscriptionController.init(context, commandsInterfaces); + } +} diff --git a/src/java/com/android/internal/telephony/TelephonyPluginDelegate.java b/src/java/com/android/internal/telephony/TelephonyPluginDelegate.java new file mode 100644 index 000000000..e2a0ee0d2 --- /dev/null +++ b/src/java/com/android/internal/telephony/TelephonyPluginDelegate.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Code Aurora nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.internal.telephony; + +import android.content.Context; +import android.util.Log; +import android.telephony.Rlog; + +import com.android.internal.telephony.dataconnection.DcTracker; +import com.android.internal.telephony.dataconnection.DctController; +import com.android.internal.telephony.TelephonyPluginBase; +import com.android.internal.telephony.DefaultTelephonyPlugin; +import com.android.internal.R; + +import dalvik.system.PathClassLoader; + +import java.lang.reflect.Method; +import java.lang.reflect.Constructor; +import java.io.File; + +public class TelephonyPluginDelegate { + static final String LOG_TAG = "TelephonyPluginDelegate"; + + private static TelephonyPluginBase sPlugin = null; + private static TelephonyPluginDelegate sMe = null; + + private TelephonyPluginDelegate() { + } + + public static TelephonyPluginDelegate getInstance() { + if (sMe == null) { + Log.e(LOG_TAG, "error: TelephonyPluginDelegate instance is not created!!"); + } + return sMe; + } + + public static void init(Context context) { + if (sMe == null) { + String fullClsName = context.getResources() + .getString(R.string.telephony_plugin_class_name); + String libPath = context.getResources().getString(R.string.telephony_plugin_lib_path); + + PathClassLoader classLoader = new PathClassLoader(libPath, + ClassLoader.getSystemClassLoader()); + Rlog.d(LOG_TAG, "classLoader = " + classLoader); + + if (fullClsName == null || fullClsName.length() == 0) { + Rlog.d(LOG_TAG, "No customized TelephonyPlugin available, fallback to default"); + fullClsName = "com.android.internal.telephony.DefaultTelephonyPlugin"; + } + Class<?> cls = null; + try { + cls = Class.forName(fullClsName, false, classLoader); + Rlog.d(LOG_TAG, "cls = " + cls); + Constructor custMethod = cls.getConstructor(); + Rlog.d(LOG_TAG, "constructor method = " + custMethod); + sPlugin = (TelephonyPluginBase) custMethod.newInstance(); + } catch (Exception e) { + e.printStackTrace(); + Rlog.e(LOG_TAG, "Error loading TelephonyPlugin"); + sPlugin = new DefaultTelephonyPlugin(); + } + + sMe = new TelephonyPluginDelegate(); + } else { + Rlog.e(LOG_TAG, "Multiple init of TelephonyPluginDelegate not allowed"); + } + } + + public DcTracker makeDcTracker(PhoneBase phone) { + return sPlugin.makeDcTracker(phone); + } + + public void makeDefaultPhones(Context context) { + sPlugin.makeDefaultPhones(context); + } + + public DctController makeDctController(PhoneProxy[] phones) { + return sPlugin.makeDctController(phones); + } + + public void initSubscriptionController(Context context, + CommandsInterface[] commandsInterfaces) { + sPlugin.initSubscriptionController(context, commandsInterfaces); + } +} diff --git a/src/java/com/android/internal/telephony/TelephonyPluginInterface.java b/src/java/com/android/internal/telephony/TelephonyPluginInterface.java new file mode 100644 index 000000000..3f70ad44b --- /dev/null +++ b/src/java/com/android/internal/telephony/TelephonyPluginInterface.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Code Aurora nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.internal.telephony; +import android.content.Context; + +import com.android.internal.telephony.dataconnection.DcTracker; +import com.android.internal.telephony.dataconnection.DctController; + +public interface TelephonyPluginInterface { + + public void makeDefaultPhones(Context context); + + public DcTracker makeDcTracker(PhoneBase phone); + + public DctController makeDctController(PhoneProxy[] phones); + + public void initSubscriptionController(Context context, + CommandsInterface[] commandsInterfaces); +} |