diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2012-01-08 19:48:34 +0300 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-01-08 19:48:34 +0300 |
commit | 37d8da1876eb4583fa6a287259cb4e059c61a6eb (patch) | |
tree | 4275ad856ce8ecc55be55405f83a61436e1d14a4 /core | |
parent | 1e96778f6119ede60e49b8d956a6f10c1f6fd901 (diff) | |
parent | e3f743e1bda758be4bd246bcca644af1a10b5b5d (diff) | |
download | frameworks_base-37d8da1876eb4583fa6a287259cb4e059c61a6eb.zip frameworks_base-37d8da1876eb4583fa6a287259cb4e059c61a6eb.tar.gz frameworks_base-37d8da1876eb4583fa6a287259cb4e059c61a6eb.tar.bz2 |
Merge "Fix 4G toggle button for crespo4g and epicmtd." into gingerbread
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/net/wimax/WimaxHelper.java | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/core/java/android/net/wimax/WimaxHelper.java b/core/java/android/net/wimax/WimaxHelper.java index 69a358b..07a8fcf 100644 --- a/core/java/android/net/wimax/WimaxHelper.java +++ b/core/java/android/net/wimax/WimaxHelper.java @@ -35,7 +35,11 @@ public class WimaxHelper { private static final String TAG = "WimaxHelper"; + private static final String WIMAX_CONTROLLER_CLASSNAME = "com.htc.net.wimax.WimaxController"; + private static final String WIMAX_MANAGER_CLASSNAME = "android.net.wimax.WimaxManager"; + private static DexClassLoader sWimaxClassLoader; + private static String sWimaxManagerClassname, sGetWimaxStateMethodname; public static boolean isWimaxSupported(Context context) { return context.getResources().getBoolean( @@ -45,6 +49,17 @@ public class WimaxHelper { public static DexClassLoader getWimaxClassLoader(Context context) { if (isWimaxSupported(context)) { if (sWimaxClassLoader == null) { + sWimaxManagerClassname = context.getResources().getString( + com.android.internal.R.string.config_wimaxManagerClassname); + + // WimaxController::getWimaxState == WimaxManager::getWimaxStatus. + // However, WimaxManager also implements a different getWimaxState method, + // which returns a WimaxState object describing the connection state, not + // the enabled state. + if (sWimaxManagerClassname.equals(WIMAX_CONTROLLER_CLASSNAME)) + sGetWimaxStateMethodname = "getWimaxState"; + else if (sWimaxManagerClassname.equals(WIMAX_MANAGER_CLASSNAME)) + sGetWimaxStateMethodname = "getWimaxStatus"; String wimaxJarLocation = context.getResources().getString( com.android.internal.R.string.config_wimaxServiceJarLocation); @@ -64,20 +79,33 @@ public class WimaxHelper { try { DexClassLoader wimaxClassLoader = getWimaxClassLoader(context); - IBinder b = ServiceManager.getService(WimaxManagerConstants.WIMAX_SERVICE); - if (b != null) { - Class<?> klass = wimaxClassLoader.loadClass("com.htc.net.wimax.IWimaxController$Stub"); - if (klass != null) { - Method asInterface = klass.getMethod("asInterface", IBinder.class); - Object wc = asInterface.invoke(null, b); - if (wc != null) { - klass = wimaxClassLoader.loadClass("com.htc.net.wimax.WimaxController"); - if (klass != null) { - Constructor<?> ctor = klass.getDeclaredConstructors()[1]; - controller = ctor.newInstance(wc, handler); + if (sWimaxManagerClassname.equals(WIMAX_CONTROLLER_CLASSNAME)) { + // Load supersonic's and speedy's WimaxController. + IBinder b = ServiceManager.getService(WimaxManagerConstants.WIMAX_SERVICE); + if (b != null) { + Class<?> klass = wimaxClassLoader.loadClass("com.htc.net.wimax.IWimaxController$Stub"); + if (klass != null) { + Method asInterface = klass.getMethod("asInterface", IBinder.class); + Object wc = asInterface.invoke(null, b); + if (wc != null) { + klass = wimaxClassLoader.loadClass(WIMAX_CONTROLLER_CLASSNAME); + if (klass != null) { + Constructor<?> ctor = klass.getDeclaredConstructors()[1]; + controller = ctor.newInstance(wc, handler); + } } } } + } else if (sWimaxManagerClassname.equals(WIMAX_MANAGER_CLASSNAME)) { + // Load crespo4g's (and epicmtd's) WimaxManager. + // Note that crespo4g's implementation grabs WIMAX_SERVICE internally, so + // it doesn't need to be passed in. Other implementations (may) require + // WIMAX_SERVICE to be grabbed externally, so check WimaxManager::<init>. + Class<?> klass = wimaxClassLoader.loadClass(WIMAX_MANAGER_CLASSNAME); + if (klass != null) { + Constructor<?> ctor = klass.getDeclaredConstructors()[0]; + controller = ctor.newInstance(); + } } } catch (Exception e) { Log.e(TAG, "Unable to create WimaxController instance", e); @@ -117,7 +145,7 @@ public class WimaxHelper { int ret = 0; try { Object wimaxService = context.getSystemService(WimaxManagerConstants.WIMAX_SERVICE); - Method m = wimaxService.getClass().getMethod("getWimaxState"); + Method m = wimaxService.getClass().getMethod(sGetWimaxStateMethodname); ret = (Integer) m.invoke(wimaxService); } catch (Exception e) { Log.e(TAG, "Unable to get WiMAX state!", e); |