diff options
author | Jeff Brown <jeffbrown@google.com> | 2015-02-24 18:53:21 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2015-02-25 17:04:13 -0800 |
commit | 6e53931f49f49245deef8622eb8e7dc6ccf04536 (patch) | |
tree | 0b7101049fca594901d09a089ba1f9588053cd1e /tools | |
parent | ddd30928a7d8f410d7d13d5706da44ba20bac440 (diff) | |
download | frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.zip frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.tar.gz frameworks_base-6e53931f49f49245deef8622eb8e7dc6ccf04536.tar.bz2 |
Add Context.getSystemService(Class<?>).
Added an overload of getSystemService() that takes a class instead of a
service name to eliminate the extra cast and provide more type safety.
Cleaned up docs.
Removed the default constructor of BatteryManager which should not have
existed.
Change-Id: I9da46b20641fc83ecd3342560e5b94cb721f289c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 2f62b93..d88a867 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android; import android.os.IBinder; + import com.android.annotations.Nullable; import com.android.ide.common.rendering.api.AssetRepository; import com.android.ide.common.rendering.api.ILayoutPullParser; @@ -73,6 +74,7 @@ import android.util.TypedValue; import android.view.BridgeInflater; import android.view.Display; import android.view.DisplayAdjustments; +import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; @@ -495,6 +497,34 @@ public final class BridgeContext extends Context { throw new UnsupportedOperationException("Unsupported Service: " + service); } + @Override + public String getSystemServiceName(Class<?> serviceClass) { + if (serviceClass.equals(LayoutInflater.class)) { + return LAYOUT_INFLATER_SERVICE; + } + + if (serviceClass.equals(TextServicesManager.class)) { + return TEXT_SERVICES_MANAGER_SERVICE; + } + + if (serviceClass.equals(WindowManager.class)) { + return WINDOW_SERVICE; + } + + if (serviceClass.equals(PowerManager.class)) { + return POWER_SERVICE; + } + + if (serviceClass.equals(DisplayManager.class)) { + return DISPLAY_SERVICE; + } + + if (serviceClass.equals(AccessibilityManager.class)) { + return ACCESSIBILITY_SERVICE; + } + + throw new UnsupportedOperationException("Unsupported Service: " + serviceClass); + } @Override public final BridgeTypedArray obtainStyledAttributes(int[] attrs) { |