diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/EthernetDataTracker.java | 427 | ||||
| -rw-r--r-- | core/java/android/net/IpConfiguration.aidl | 19 | ||||
| -rw-r--r-- | core/java/android/view/GLRenderer.java | 3 | ||||
| -rw-r--r-- | core/java/android/view/HardwareRenderer.java | 26 | ||||
| -rw-r--r-- | core/java/android/view/ThreadedRenderer.java | 9 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 9 |
6 files changed, 48 insertions, 445 deletions
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java deleted file mode 100644 index c1afc9b..0000000 --- a/core/java/android/net/EthernetDataTracker.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Copyright (C) 2010 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 android.net; - -import android.content.Context; -import android.net.NetworkInfo.DetailedState; -import android.os.Handler; -import android.os.IBinder; -import android.os.INetworkManagementService; -import android.os.Message; -import android.os.Messenger; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.util.Log; - -import com.android.server.net.BaseNetworkObserver; - -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * This class tracks the data connection associated with Ethernet - * This is a singleton class and an instance will be created by - * ConnectivityService. - * @hide - */ -public class EthernetDataTracker extends BaseNetworkStateTracker { - private static final String NETWORKTYPE = "ETHERNET"; - private static final String TAG = "Ethernet"; - - private AtomicBoolean mTeardownRequested = new AtomicBoolean(false); - private AtomicBoolean mPrivateDnsRouteSet = new AtomicBoolean(false); - private AtomicInteger mDefaultGatewayAddr = new AtomicInteger(0); - private AtomicBoolean mDefaultRouteSet = new AtomicBoolean(false); - - private static boolean mLinkUp; - private InterfaceObserver mInterfaceObserver; - private String mHwAddr; - - /* For sending events to connectivity service handler */ - private Handler mCsHandler; - - private static EthernetDataTracker sInstance; - private static String sIfaceMatch = ""; - private static String mIface = ""; - - private INetworkManagementService mNMService; - - private static class InterfaceObserver extends BaseNetworkObserver { - private EthernetDataTracker mTracker; - - InterfaceObserver(EthernetDataTracker tracker) { - super(); - mTracker = tracker; - } - - @Override - public void interfaceStatusChanged(String iface, boolean up) { - Log.d(TAG, "Interface status changed: " + iface + (up ? "up" : "down")); - } - - @Override - public void interfaceLinkStateChanged(String iface, boolean up) { - if (mIface.equals(iface)) { - Log.d(TAG, "Interface " + iface + " link " + (up ? "up" : "down")); - mLinkUp = up; - mTracker.mNetworkInfo.setIsAvailable(up); - - // use DHCP - if (up) { - mTracker.reconnect(); - } else { - mTracker.disconnect(); - } - } - } - - @Override - public void interfaceAdded(String iface) { - mTracker.interfaceAdded(iface); - } - - @Override - public void interfaceRemoved(String iface) { - mTracker.interfaceRemoved(iface); - } - } - - private EthernetDataTracker() { - mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORKTYPE, ""); - mLinkProperties = new LinkProperties(); - mNetworkCapabilities = new NetworkCapabilities(); - } - - private void interfaceUpdated() { - // we don't get link status indications unless the iface is up - bring it up - try { - mNMService.setInterfaceUp(mIface); - String hwAddr = null; - InterfaceConfiguration config = mNMService.getInterfaceConfig(mIface); - if (config != null) { - hwAddr = config.getHardwareAddress(); - } - synchronized (this) { - mHwAddr = hwAddr; - mNetworkInfo.setExtraInfo(mHwAddr); - } - } catch (RemoteException e) { - Log.e(TAG, "Error upping interface " + mIface + ": " + e); - } - } - - private void interfaceAdded(String iface) { - if (!iface.matches(sIfaceMatch)) - return; - - Log.d(TAG, "Adding " + iface); - - synchronized(this) { - if(!mIface.isEmpty()) - return; - mIface = iface; - } - - interfaceUpdated(); - - mNetworkInfo.setIsAvailable(true); - Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); - msg.sendToTarget(); - } - - public void disconnect() { - - NetworkUtils.stopDhcp(mIface); - - mLinkProperties.clear(); - mNetworkInfo.setIsAvailable(false); - mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr); - - Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); - msg.sendToTarget(); - - msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); - msg.sendToTarget(); - - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); - try { - service.clearInterfaceAddresses(mIface); - } catch (Exception e) { - Log.e(TAG, "Failed to clear addresses or disable ipv6" + e); - } - } - - private void interfaceRemoved(String iface) { - if (!iface.equals(mIface)) - return; - - Log.d(TAG, "Removing " + iface); - disconnect(); - synchronized (this) { - mIface = ""; - mHwAddr = null; - mNetworkInfo.setExtraInfo(null); - } - } - - private void runDhcp() { - Thread dhcpThread = new Thread(new Runnable() { - public void run() { - DhcpResults dhcpResults = new DhcpResults(); - mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, mHwAddr); - if (!NetworkUtils.runDhcp(mIface, dhcpResults)) { - Log.e(TAG, "DHCP request error:" + NetworkUtils.getDhcpError()); - mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr); - return; - } - mLinkProperties = dhcpResults.linkProperties; - - mNetworkInfo.setIsAvailable(true); - mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, mHwAddr); - Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); - msg.sendToTarget(); - } - }); - dhcpThread.start(); - } - - public static synchronized EthernetDataTracker getInstance() { - if (sInstance == null) sInstance = new EthernetDataTracker(); - return sInstance; - } - - public Object Clone() throws CloneNotSupportedException { - throw new CloneNotSupportedException(); - } - - public void setTeardownRequested(boolean isRequested) { - mTeardownRequested.set(isRequested); - } - - public boolean isTeardownRequested() { - return mTeardownRequested.get(); - } - - /** - * Begin monitoring connectivity - */ - public void startMonitoring(Context context, Handler target) { - mContext = context; - mCsHandler = target; - - // register for notifications from NetworkManagement Service - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - mNMService = INetworkManagementService.Stub.asInterface(b); - - mInterfaceObserver = new InterfaceObserver(this); - - // enable and try to connect to an ethernet interface that - // already exists - sIfaceMatch = context.getResources().getString( - com.android.internal.R.string.config_ethernet_iface_regex); - try { - final String[] ifaces = mNMService.listInterfaces(); - for (String iface : ifaces) { - if (iface.matches(sIfaceMatch)) { - mIface = iface; - interfaceUpdated(); - - // if a DHCP client had previously been started for this interface, then stop it - NetworkUtils.stopDhcp(mIface); - - reconnect(); - break; - } - } - } catch (RemoteException e) { - Log.e(TAG, "Could not get list of interfaces " + e); - } - - try { - mNMService.registerObserver(mInterfaceObserver); - } catch (RemoteException e) { - Log.e(TAG, "Could not register InterfaceObserver " + e); - } - } - - /** - * Disable connectivity to a network - * TODO: do away with return value after making MobileDataStateTracker async - */ - public boolean teardown() { - mTeardownRequested.set(true); - NetworkUtils.stopDhcp(mIface); - return true; - } - - /** - * Re-enable connectivity to a network after a {@link #teardown()}. - */ - public boolean reconnect() { - if (mLinkUp) { - mTeardownRequested.set(false); - runDhcp(); - } - return mLinkUp; - } - - @Override - public void captivePortalCheckCompleted(boolean isCaptivePortal) { - // not implemented - } - - /** - * Turn the wireless radio off for a network. - * @param turnOn {@code true} to turn the radio on, {@code false} - */ - public boolean setRadio(boolean turnOn) { - return true; - } - - /** - * @return true - If are we currently tethered with another device. - */ - public synchronized boolean isAvailable() { - return mNetworkInfo.isAvailable(); - } - - /** - * Tells the underlying networking system that the caller wants to - * begin using the named feature. The interpretation of {@code feature} - * is completely up to each networking implementation. - * @param feature the name of the feature to be used - * @param callingPid the process ID of the process that is issuing this request - * @param callingUid the user ID of the process that is issuing this request - * @return an integer value representing the outcome of the request. - * The interpretation of this value is specific to each networking - * implementation+feature combination, except that the value {@code -1} - * always indicates failure. - * TODO: needs to go away - */ - public int startUsingNetworkFeature(String feature, int callingPid, int callingUid) { - return -1; - } - - /** - * Tells the underlying networking system that the caller is finished - * using the named feature. The interpretation of {@code feature} - * is completely up to each networking implementation. - * @param feature the name of the feature that is no longer needed. - * @param callingPid the process ID of the process that is issuing this request - * @param callingUid the user ID of the process that is issuing this request - * @return an integer value representing the outcome of the request. - * The interpretation of this value is specific to each networking - * implementation+feature combination, except that the value {@code -1} - * always indicates failure. - * TODO: needs to go away - */ - public int stopUsingNetworkFeature(String feature, int callingPid, int callingUid) { - return -1; - } - - @Override - public void setUserDataEnable(boolean enabled) { - Log.w(TAG, "ignoring setUserDataEnable(" + enabled + ")"); - } - - @Override - public void setPolicyDataEnable(boolean enabled) { - Log.w(TAG, "ignoring setPolicyDataEnable(" + enabled + ")"); - } - - /** - * Check if private DNS route is set for the network - */ - public boolean isPrivateDnsRouteSet() { - return mPrivateDnsRouteSet.get(); - } - - /** - * Set a flag indicating private DNS route is set - */ - public void privateDnsRouteSet(boolean enabled) { - mPrivateDnsRouteSet.set(enabled); - } - - /** - * Fetch NetworkInfo for the network - */ - public synchronized NetworkInfo getNetworkInfo() { - return mNetworkInfo; - } - - /** - * Fetch LinkProperties for the network - */ - public synchronized LinkProperties getLinkProperties() { - return new LinkProperties(mLinkProperties); - } - - /** - * Fetch default gateway address for the network - */ - public int getDefaultGatewayAddr() { - return mDefaultGatewayAddr.get(); - } - - /** - * Check if default route is set - */ - public boolean isDefaultRouteSet() { - return mDefaultRouteSet.get(); - } - - /** - * Set a flag indicating default route is set for the network - */ - public void defaultRouteSet(boolean enabled) { - mDefaultRouteSet.set(enabled); - } - - /** - * Return the system properties name associated with the tcp buffer sizes - * for this network. - */ - public String getTcpBufferSizesPropName() { - return "net.tcp.buffersize.ethernet"; - } - - public void setDependencyMet(boolean met) { - // not supported on this network - } - - @Override - public void addStackedLink(LinkProperties link) { - mLinkProperties.addStackedLink(link); - } - - @Override - public void removeStackedLink(LinkProperties link) { - mLinkProperties.removeStackedLink(link); - } - - @Override - public void supplyMessenger(Messenger messenger) { - // not supported on this network - } - - @Override - public String getNetworkInterfaceName() { - return mIface; - } -} diff --git a/core/java/android/net/IpConfiguration.aidl b/core/java/android/net/IpConfiguration.aidl new file mode 100644 index 0000000..7a30f0e --- /dev/null +++ b/core/java/android/net/IpConfiguration.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2014 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 android.net; + +parcelable IpConfiguration; diff --git a/core/java/android/view/GLRenderer.java b/core/java/android/view/GLRenderer.java index 9601a8d..6dd7c00 100644 --- a/core/java/android/view/GLRenderer.java +++ b/core/java/android/view/GLRenderer.java @@ -1097,9 +1097,10 @@ public class GLRenderer extends HardwareRenderer { } @Override - void setup(int width, int height) { + void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { if (validate()) { mCanvas.setViewport(width, height); + mCanvas.initializeLight(lightX, lightY, lightZ, lightRadius); mWidth = width; mHeight = height; } diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index e366697..a902ce7 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -273,12 +273,16 @@ public abstract class HardwareRenderer { * * @param width Width of the drawing surface. * @param height Height of the drawing surface. + * @param lightX X position of the shadow casting light + * @param lightY Y position of the shadow casting light + * @param lightZ Z position of the shadow casting light + * @param lightRadius radius of the shadow casting light */ - abstract void setup(int width, int height); + abstract void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius); /** * Gets the current width of the surface. This is the width that the surface - * was last set to in a call to {@link #setup(int, int)}. + * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * @return the current width of the surface */ @@ -286,7 +290,7 @@ public abstract class HardwareRenderer { /** * Gets the current height of the surface. This is the height that the surface - * was last set to in a call to {@link #setup(int, int)}. + * was last set to in a call to {@link #setup(int, int, float, float, float, float)}. * * @return the current width of the surface */ @@ -310,9 +314,6 @@ public abstract class HardwareRenderer { * whenever system properties are modified. Implementations can use this * to trigger live updates of the renderer based on properties. * - * @param surface The surface to update with the new properties. - * Can be null. - * * @return True if a property has changed. */ abstract boolean loadSystemProperties(); @@ -443,17 +444,18 @@ public abstract class HardwareRenderer { * @param width The width of the drawing surface. * @param height The height of the drawing surface. * @param surface The surface to hardware accelerate + * @param metrics The display metrics used to draw the output. * * @return true if the surface was initialized, false otherwise. Returning * false might mean that the surface was already initialized. */ - boolean initializeIfNeeded(int width, int height, Surface surface) + boolean initializeIfNeeded(int width, int height, Surface surface, DisplayMetrics metrics) throws OutOfResourcesException { if (isRequested()) { // We lost the gl context, so recreate it. if (!isEnabled()) { if (initialize(surface)) { - setup(width, height); + setup(width, height, metrics); return true; } } @@ -461,6 +463,14 @@ public abstract class HardwareRenderer { return false; } + void setup(int width, int height, DisplayMetrics metrics) { + float lightX = width / 2.0f; + float lightY = -400 * metrics.density; + float lightZ = 800 * metrics.density; + float lightRadius = 800 * metrics.density; + setup(width, height, lightX, lightY, lightZ, lightRadius); + } + /** * Optional, sets the name of the renderer. Useful for debugging purposes. * diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index afd9569..704d516 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -145,11 +145,11 @@ public class ThreadedRenderer extends HardwareRenderer { } @Override - void setup(int width, int height) { + void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) { mWidth = width; mHeight = height; mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight); - nSetup(mNativeProxy, width, height); + nSetup(mNativeProxy, width, height, lightX, lightY, lightZ, lightRadius); } @Override @@ -348,10 +348,9 @@ public class ThreadedRenderer extends HardwareRenderer { private static native boolean nInitialize(long nativeProxy, Surface window); private static native void nUpdateSurface(long nativeProxy, Surface window); private static native void nPauseSurface(long nativeProxy, Surface window); - private static native void nSetup(long nativeProxy, int width, int height); + private static native void nSetup(long nativeProxy, int width, int height, + float lightX, float lightY, float lightZ, float lightRadius); private static native void nSetOpaque(long nativeProxy, boolean opaque); - private static native void nSetDisplayListData(long nativeProxy, long displayList, - long newData); private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos, int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index eed6412..799a406 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -47,7 +47,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.ParcelFileDescriptor; -import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; import android.os.SystemClock; @@ -1714,7 +1713,8 @@ public final class ViewRootImpl implements ViewParent, if (hwInitialized || mWidth != mAttachInfo.mHardwareRenderer.getWidth() || mHeight != mAttachInfo.mHardwareRenderer.getHeight()) { - mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight); + mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight, + mAttachInfo.mRootView.getResources().getDisplayMetrics()); if (!hwInitialized) { mAttachInfo.mHardwareRenderer.invalidate(mSurface); mFullRedrawNeeded = true; @@ -2453,7 +2453,7 @@ public final class ViewRootImpl implements ViewParent, try { attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight, - mSurface); + mSurface, attachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { handleOutOfResourcesException(e); return; @@ -3151,7 +3151,8 @@ public final class ViewRootImpl implements ViewParent, mFullRedrawNeeded = true; try { mAttachInfo.mHardwareRenderer.initializeIfNeeded( - mWidth, mHeight, mSurface); + mWidth, mHeight, mSurface, + mAttachInfo.mRootView.getResources().getDisplayMetrics()); } catch (OutOfResourcesException e) { Log.e(TAG, "OutOfResourcesException locking surface", e); try { |
