diff options
Diffstat (limited to 'services/java/com/android/server')
18 files changed, 233 insertions, 107 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 4e3faca..3f8d7eb 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -58,8 +58,8 @@ import android.net.INetworkPolicyManager; import android.net.INetworkStatsService; import android.net.LinkAddress; import android.net.LinkProperties; -import android.net.LinkQualityInfo; import android.net.LinkProperties.CompareResult; +import android.net.LinkQualityInfo; import android.net.MobileDataStateTracker; import android.net.NetworkConfig; import android.net.NetworkInfo; @@ -89,7 +89,6 @@ import android.os.ParcelFileDescriptor; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; -import android.os.ResultReceiver; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; @@ -114,7 +113,6 @@ import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneConstants; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.XmlUtils; -import com.android.net.IProxyService; import com.android.server.am.BatteryStatsService; import com.android.server.connectivity.DataConnectionStats; import com.android.server.connectivity.Nat464Xlat; @@ -3209,12 +3207,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { return mTethering.getTetheredIfaces(); } - @Override - public String[] getTetheredIfacePairs() { - enforceTetherAccessPermission(); - return mTethering.getTetheredIfacePairs(); - } - public String[] getTetheringErroredIfaces() { enforceTetherAccessPermission(); return mTethering.getErroredIfaces(); @@ -4684,12 +4676,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { @Override public void setAirplaneMode(boolean enable) { enforceConnectivityInternalPermission(); - final ContentResolver cr = mContext.getContentResolver(); - Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, enable ? 1 : 0); - Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); - intent.putExtra("state", enable); final long ident = Binder.clearCallingIdentity(); try { + final ContentResolver cr = mContext.getContentResolver(); + Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, enable ? 1 : 0); + Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + intent.putExtra("state", enable); mContext.sendBroadcast(intent); } finally { Binder.restoreCallingIdentity(ident); diff --git a/services/java/com/android/server/ConsumerIrService.java b/services/java/com/android/server/ConsumerIrService.java new file mode 100644 index 0000000..07f2a41 --- /dev/null +++ b/services/java/com/android/server/ConsumerIrService.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2013 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.server; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.database.ContentObserver; +import android.hardware.input.InputManager; +import android.hardware.IConsumerIrService; +import android.os.Handler; +import android.os.PowerManager; +import android.os.Process; +import android.os.RemoteException; +import android.os.IBinder; +import android.os.Binder; +import android.os.ServiceManager; +import android.os.SystemClock; +import android.os.UserHandle; +import android.os.WorkSource; +import android.provider.Settings; +import android.provider.Settings.SettingNotFoundException; +import android.util.Slog; +import android.view.InputDevice; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.ListIterator; + +public class ConsumerIrService extends IConsumerIrService.Stub { + private static final String TAG = "ConsumerIrService"; + + private static final int MAX_XMIT_TIME = 2000000; /* in microseconds */ + + private static native int halOpen(); + private static native int halTransmit(int halObject, int carrierFrequency, int[] pattern); + private static native int[] halGetCarrierFrequencies(int halObject); + + private final Context mContext; + private final PowerManager.WakeLock mWakeLock; + private final int mHal; + private final Object mHalLock = new Object(); + + ConsumerIrService(Context context) { + mContext = context; + PowerManager pm = (PowerManager)context.getSystemService( + Context.POWER_SERVICE); + mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + mWakeLock.setReferenceCounted(true); + + mHal = halOpen(); + if (mHal == 0) { + Slog.w(TAG, "No IR HAL loaded"); + } + } + + @Override + public boolean hasIrEmitter() { + return mHal != 0; + } + + private void throwIfNoIrEmitter() { + if (mHal == 0) { + throw new UnsupportedOperationException("IR emitter not available"); + } + } + + + @Override + public void transmit(String packageName, int carrierFrequency, int[] pattern) { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.TRANSMIT_IR) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Requires TRANSMIT_IR permission"); + } + + long totalXmitTime = 0; + + for (int slice : pattern) { + if (slice <= 0) { + throw new IllegalArgumentException("Non-positive IR slice"); + } + totalXmitTime += slice; + } + + if (totalXmitTime > MAX_XMIT_TIME ) { + throw new IllegalArgumentException("IR pattern too long"); + } + + throwIfNoIrEmitter(); + + // Right now there is no mechanism to ensure fair queing of IR requests + synchronized (mHalLock) { + int err = halTransmit(mHal, carrierFrequency, pattern); + + if (err < 0) { + Slog.e(TAG, "Error transmitting: " + err); + } + } + } + + @Override + public int[] getCarrierFrequencies() { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.TRANSMIT_IR) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Requires TRANSMIT_IR permission"); + } + + throwIfNoIrEmitter(); + + synchronized(mHalLock) { + return halGetCarrierFrequencies(mHal); + } + } +} diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index de29155..f70f4db 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -1773,8 +1773,12 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public boolean isProviderEnabled(String provider) { + // TODO: remove this check in next release, see b/10696351 checkResolutionLevelIsSufficientForProviderUse(getCallerAllowedResolutionLevel(), provider); + + // Fused provider is accessed indirectly via criteria rather than the provider-based APIs, + // so we discourage its use if (LocationManager.FUSED_PROVIDER.equals(provider)) return false; int uid = Binder.getCallingUid(); diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 82cc540..92f99c2 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -24,15 +24,15 @@ import static android.net.NetworkStats.TAG_NONE; import static android.net.NetworkStats.UID_ALL; import static android.net.TrafficStats.UID_TETHERING; import static com.android.server.NetworkManagementService.NetdResponseCode.ClatdStatusResult; +import static com.android.server.NetworkManagementService.NetdResponseCode.GetMarkResult; import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceGetCfgResult; import static com.android.server.NetworkManagementService.NetdResponseCode.InterfaceListResult; import static com.android.server.NetworkManagementService.NetdResponseCode.IpFwdStatusResult; import static com.android.server.NetworkManagementService.NetdResponseCode.TetherDnsFwdTgtListResult; import static com.android.server.NetworkManagementService.NetdResponseCode.TetherInterfaceListResult; import static com.android.server.NetworkManagementService.NetdResponseCode.TetherStatusResult; -import static com.android.server.NetworkManagementService.NetdResponseCode.TetheringStatsResult; +import static com.android.server.NetworkManagementService.NetdResponseCode.TetheringStatsListResult; import static com.android.server.NetworkManagementService.NetdResponseCode.TtyListResult; -import static com.android.server.NetworkManagementService.NetdResponseCode.GetMarkResult; import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED; import android.content.Context; @@ -118,6 +118,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final int TetherInterfaceListResult = 111; public static final int TetherDnsFwdTgtListResult = 112; public static final int TtyListResult = 113; + public static final int TetheringStatsListResult = 114; public static final int TetherStatusResult = 210; public static final int IpFwdStatusResult = 211; @@ -523,7 +524,8 @@ public class NetworkManagementService extends INetworkManagementService.Stub throw new IllegalStateException(msg); } - int flags, scope; + int flags; + int scope; try { flags = Integer.parseInt(cooked[5]); scope = Integer.parseInt(cooked[6]); @@ -1373,55 +1375,42 @@ public class NetworkManagementService extends INetworkManagementService.Stub } @Override - public NetworkStats getNetworkStatsTethering(String[] ifacePairs) { + public NetworkStats getNetworkStatsTethering() { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); - if (ifacePairs.length % 2 != 0) { - throw new IllegalArgumentException( - "unexpected ifacePairs; length=" + ifacePairs.length); - } - final NetworkStats stats = new NetworkStats(SystemClock.elapsedRealtime(), 1); - for (int i = 0; i < ifacePairs.length; i += 2) { - final String ifaceIn = ifacePairs[i]; - final String ifaceOut = ifacePairs[i + 1]; - if (ifaceIn != null && ifaceOut != null) { - stats.combineValues(getNetworkStatsTethering(ifaceIn, ifaceOut)); - } - } - return stats; - } - - private NetworkStats.Entry getNetworkStatsTethering(String ifaceIn, String ifaceOut) { - final NativeDaemonEvent event; try { - event = mConnector.execute("bandwidth", "gettetherstats", ifaceIn, ifaceOut); + final NativeDaemonEvent[] events = mConnector.executeForList( + "bandwidth", "gettetherstats"); + for (NativeDaemonEvent event : events) { + if (event.getCode() != TetheringStatsListResult) continue; + + // 114 ifaceIn ifaceOut rx_bytes rx_packets tx_bytes tx_packets + final StringTokenizer tok = new StringTokenizer(event.getMessage()); + try { + final String ifaceIn = tok.nextToken(); + final String ifaceOut = tok.nextToken(); + + final NetworkStats.Entry entry = new NetworkStats.Entry(); + entry.iface = ifaceOut; + entry.uid = UID_TETHERING; + entry.set = SET_DEFAULT; + entry.tag = TAG_NONE; + entry.rxBytes = Long.parseLong(tok.nextToken()); + entry.rxPackets = Long.parseLong(tok.nextToken()); + entry.txBytes = Long.parseLong(tok.nextToken()); + entry.txPackets = Long.parseLong(tok.nextToken()); + stats.combineValues(entry); + } catch (NoSuchElementException e) { + throw new IllegalStateException("problem parsing tethering stats: " + event); + } catch (NumberFormatException e) { + throw new IllegalStateException("problem parsing tethering stats: " + event); + } + } } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); } - - event.checkCode(TetheringStatsResult); - - // 221 ifaceIn ifaceOut rx_bytes rx_packets tx_bytes tx_packets - final StringTokenizer tok = new StringTokenizer(event.getMessage()); - tok.nextToken(); - tok.nextToken(); - - try { - final NetworkStats.Entry entry = new NetworkStats.Entry(); - entry.iface = ifaceIn; - entry.uid = UID_TETHERING; - entry.set = SET_DEFAULT; - entry.tag = TAG_NONE; - entry.rxBytes = Long.parseLong(tok.nextToken()); - entry.rxPackets = Long.parseLong(tok.nextToken()); - entry.txBytes = Long.parseLong(tok.nextToken()); - entry.txPackets = Long.parseLong(tok.nextToken()); - return entry; - } catch (NumberFormatException e) { - throw new IllegalStateException( - "problem parsing tethering stats for " + ifaceIn + " " + ifaceOut + ": " + e); - } + return stats; } @Override diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 0bbdcfb..d38756f 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -154,6 +154,7 @@ class ServerThread { CommonTimeManagementService commonTimeMgmtService = null; InputManagerService inputManager = null; TelephonyRegistry telephonyRegistry = null; + ConsumerIrService consumerIr = null; // Create a handler thread just for the window manager to enjoy. HandlerThread wmHandlerThread = new HandlerThread("WindowManager"); @@ -284,6 +285,10 @@ class ServerThread { vibrator = new VibratorService(context); ServiceManager.addService("vibrator", vibrator); + Slog.i(TAG, "Consumer IR Service"); + consumerIr = new ConsumerIrService(context); + ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr); + // only initialize the power service after we have started the // lights service, content providers and the battery service. power.init(context, lights, ActivityManagerService.self(), battery, diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index fb4c1cf..231a40a 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -688,19 +688,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { return retVal; } - public String[] getTetheredIfacePairs() { - final ArrayList<String> list = Lists.newArrayList(); - synchronized (mPublicSync) { - for (TetherInterfaceSM sm : mIfaces.values()) { - if (sm.isTethered()) { - list.add(sm.mMyUpstreamIfaceName); - list.add(sm.mIfaceName); - } - } - } - return list.toArray(new String[list.size()]); - } - public String[] getTetherableIfaces() { ArrayList<String> list = new ArrayList<String>(); synchronized (mPublicSync) { diff --git a/services/java/com/android/server/location/FlpHardwareProvider.java b/services/java/com/android/server/location/FlpHardwareProvider.java index ebeccfb..60893b8 100644 --- a/services/java/com/android/server/location/FlpHardwareProvider.java +++ b/services/java/com/android/server/location/FlpHardwareProvider.java @@ -141,10 +141,16 @@ public class FlpHardwareProvider { } private void onGeofenceMonitorStatus(int status, int source, Location location) { + // allow the location to be optional in this event + Location updatedLocation = null; + if(location != null) { + updatedLocation = updateLocationInformation(location); + } + getGeofenceHardwareSink().reportGeofenceMonitorStatus( GeofenceHardware.MONITORING_TYPE_FUSED_HARDWARE, status, - updateLocationInformation(location), + updatedLocation, source); } diff --git a/services/java/com/android/server/net/NetworkStatsRecorder.java b/services/java/com/android/server/net/NetworkStatsRecorder.java index 2b32b41..cea084b 100644 --- a/services/java/com/android/server/net/NetworkStatsRecorder.java +++ b/services/java/com/android/server/net/NetworkStatsRecorder.java @@ -135,6 +135,9 @@ public class NetworkStatsRecorder { } catch (IOException e) { Log.wtf(TAG, "problem completely reading network stats", e); recoverFromWtf(); + } catch (OutOfMemoryError e) { + Log.wtf(TAG, "problem completely reading network stats", e); + recoverFromWtf(); } } return complete; @@ -226,6 +229,9 @@ public class NetworkStatsRecorder { } catch (IOException e) { Log.wtf(TAG, "problem persisting pending stats", e); recoverFromWtf(); + } catch (OutOfMemoryError e) { + Log.wtf(TAG, "problem persisting pending stats", e); + recoverFromWtf(); } } } @@ -241,6 +247,9 @@ public class NetworkStatsRecorder { } catch (IOException e) { Log.wtf(TAG, "problem removing UIDs " + Arrays.toString(uids), e); recoverFromWtf(); + } catch (OutOfMemoryError e) { + Log.wtf(TAG, "problem removing UIDs " + Arrays.toString(uids), e); + recoverFromWtf(); } // Remove any pending stats diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 05eeb36..1e8a7b0 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -412,6 +412,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub { } } catch (IOException e) { Log.wtf(TAG, "problem during legacy upgrade", e); + } catch (OutOfMemoryError e) { + Log.wtf(TAG, "problem during legacy upgrade", e); } } @@ -1186,8 +1188,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { */ private NetworkStats getNetworkStatsTethering() throws RemoteException { try { - final String[] tetheredIfacePairs = mConnManager.getTetheredIfacePairs(); - return mNetworkManager.getNetworkStatsTethering(tetheredIfacePairs); + return mNetworkManager.getNetworkStatsTethering(); } catch (IllegalStateException e) { Log.wtf(TAG, "problem reading network stats", e); return new NetworkStats(0L, 10); diff --git a/services/java/com/android/server/power/ElectronBeam.java b/services/java/com/android/server/power/ElectronBeam.java index 0d92f66..729bd16 100644 --- a/services/java/com/android/server/power/ElectronBeam.java +++ b/services/java/com/android/server/power/ElectronBeam.java @@ -35,6 +35,7 @@ import android.util.FloatMath; import android.util.Slog; import android.view.Display; import android.view.DisplayInfo; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -94,7 +95,7 @@ final class ElectronBeam { // Texture names. We only use one texture, which contains the screenshot. private final int[] mTexNames = new int[1]; private boolean mTexNamesGenerated; - private float mTexMatrix[] = new float[16]; + private final float mTexMatrix[] = new float[16]; // Vertex and corresponding texture coordinates. // We have 4 2D vertices, so 8 elements. The vertices form a quad. @@ -515,7 +516,7 @@ final class ElectronBeam { mSurfaceControl = new SurfaceControl(mSurfaceSession, "ElectronBeam", mDisplayWidth, mDisplayHeight, PixelFormat.OPAQUE, flags); - } catch (SurfaceControl.OutOfResourcesException ex) { + } catch (OutOfResourcesException ex) { Slog.e(TAG, "Unable to create surface.", ex); return false; } @@ -525,7 +526,7 @@ final class ElectronBeam { mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight); mSurface = new Surface(); mSurface.copyFrom(mSurfaceControl); - + mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManager, mSurfaceControl); mSurfaceLayout.onDisplayTransaction(); } finally { diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java index 737d854..5aa266d 100644 --- a/services/java/com/android/server/wm/BlackFrame.java +++ b/services/java/com/android/server/wm/BlackFrame.java @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.graphics.PixelFormat; import android.graphics.Rect; import android.util.Slog; +import android.view.Surface.OutOfResourcesException; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -36,7 +37,7 @@ public class BlackFrame { final SurfaceControl surface; BlackSurface(SurfaceSession session, int layer, int l, int t, int r, int b, int layerStack) - throws SurfaceControl.OutOfResourcesException { + throws OutOfResourcesException { left = l; top = t; this.layer = layer; @@ -112,7 +113,7 @@ public class BlackFrame { } public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, int layerStack, - boolean forceDefaultOrientation) throws SurfaceControl.OutOfResourcesException { + boolean forceDefaultOrientation) throws OutOfResourcesException { boolean success = false; mForceDefaultOrientation = forceDefaultOrientation; diff --git a/services/java/com/android/server/wm/DisplayMagnifier.java b/services/java/com/android/server/wm/DisplayMagnifier.java index 0f51028..382d7b4 100644 --- a/services/java/com/android/server/wm/DisplayMagnifier.java +++ b/services/java/com/android/server/wm/DisplayMagnifier.java @@ -496,7 +496,7 @@ final class DisplayMagnifier { mWindowManager.getDefaultDisplay().getRealSize(mTempPoint); surfaceControl = new SurfaceControl(mWindowManagerService.mFxSession, SURFACE_TITLE, mTempPoint.x, mTempPoint.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN); - } catch (SurfaceControl.OutOfResourcesException oore) { + } catch (OutOfResourcesException oore) { /* ignore */ } mSurfaceControl = surfaceControl; @@ -629,7 +629,7 @@ final class DisplayMagnifier { } } catch (IllegalArgumentException iae) { /* ignore */ - } catch (OutOfResourcesException oore) { + } catch (Surface.OutOfResourcesException oore) { /* ignore */ } if (canvas == null) { @@ -644,7 +644,7 @@ final class DisplayMagnifier { canvas.drawPath(path, mPaint); mSurface.unlockCanvasAndPost(canvas); - + if (mAlpha > 0) { mSurfaceControl.show(); } else { diff --git a/services/java/com/android/server/wm/FocusedStackFrame.java b/services/java/com/android/server/wm/FocusedStackFrame.java index 9c18331..365b277 100644 --- a/services/java/com/android/server/wm/FocusedStackFrame.java +++ b/services/java/com/android/server/wm/FocusedStackFrame.java @@ -26,6 +26,7 @@ import android.graphics.Rect; import android.graphics.Region; import android.util.Slog; import android.view.Display; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -39,9 +40,9 @@ class FocusedStackFrame { private final SurfaceControl mSurfaceControl; private final Surface mSurface = new Surface(); - private Rect mLastBounds = new Rect(); - private Rect mBounds = new Rect(); - private Rect mTmpDrawRect = new Rect(); + private final Rect mLastBounds = new Rect(); + private final Rect mBounds = new Rect(); + private final Rect mTmpDrawRect = new Rect(); public FocusedStackFrame(Display display, SurfaceSession session) { SurfaceControl ctrl = null; @@ -56,7 +57,7 @@ class FocusedStackFrame { ctrl.setLayerStack(display.getLayerStack()); ctrl.setAlpha(ALPHA); mSurface.copyFrom(ctrl); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; } diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java index 7d90858..e630737 100644 --- a/services/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java @@ -27,6 +27,7 @@ import android.graphics.Rect; import android.util.Slog; import android.view.Display; import android.view.DisplayInfo; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -262,7 +263,7 @@ class ScreenRotationAnimation { mSurfaceControl.setAlpha(0); mSurfaceControl.show(); sur.destroy(); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate freeze surface", e); } @@ -547,7 +548,7 @@ class ScreenRotationAnimation { mCustomBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER + 3, layerStack, false); mCustomBlackFrame.setMatrix(mFrameInitialMatrix); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate black surface", e); } finally { SurfaceControl.closeTransaction(); @@ -587,7 +588,7 @@ class ScreenRotationAnimation { mExitingBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER + 2, layerStack, mForceDefaultOrientation); mExitingBlackFrame.setMatrix(mFrameInitialMatrix); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate black surface", e); } finally { SurfaceControl.closeTransaction(); @@ -609,7 +610,7 @@ class ScreenRotationAnimation { Rect inner = new Rect(0, 0, finalWidth, finalHeight); mEnteringBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER, layerStack, false); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { Slog.w(TAG, "Unable to allocate black surface", e); } finally { SurfaceControl.closeTransaction(); @@ -894,7 +895,7 @@ class ScreenRotationAnimation { && (mMoreStartEnter || mMoreStartExit || mMoreFinishEnter || mMoreFinishExit)) || (USE_CUSTOM_BLACK_FRAME && (mMoreStartFrame || mMoreRotateFrame || mMoreFinishFrame)) - || mMoreRotateEnter || mMoreRotateExit + || mMoreRotateEnter || mMoreRotateExit || !mFinishAnimReady; mSnapshotFinalMatrix.setConcat(mExitTransformation.getMatrix(), mSnapshotInitialMatrix); diff --git a/services/java/com/android/server/wm/StrictModeFlash.java b/services/java/com/android/server/wm/StrictModeFlash.java index 31628e3..fb5876b 100644 --- a/services/java/com/android/server/wm/StrictModeFlash.java +++ b/services/java/com/android/server/wm/StrictModeFlash.java @@ -23,6 +23,7 @@ import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.Region; import android.view.Display; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -47,7 +48,7 @@ class StrictModeFlash { ctrl.setPosition(0, 0); ctrl.show(); mSurface.copyFrom(ctrl); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; mDrawNeeded = true; diff --git a/services/java/com/android/server/wm/Watermark.java b/services/java/com/android/server/wm/Watermark.java index fedd314..e226e3d 100644 --- a/services/java/com/android/server/wm/Watermark.java +++ b/services/java/com/android/server/wm/Watermark.java @@ -27,10 +27,10 @@ import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.Display; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; -import android.view.Surface.OutOfResourcesException; /** * Displays a watermark on top of the window manager's windows. @@ -119,7 +119,7 @@ class Watermark { ctrl.setPosition(0, 0); ctrl.show(); mSurface.copyFrom(ctrl); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { } mSurfaceControl = ctrl; } @@ -144,11 +144,11 @@ class Watermark { try { c = mSurface.lockCanvas(dirty); } catch (IllegalArgumentException e) { - } catch (OutOfResourcesException e) { + } catch (Surface.OutOfResourcesException e) { } if (c != null) { c.drawColor(0, PorterDuff.Mode.CLEAR); - + int deltaX = mDeltaX; int deltaY = mDeltaY; diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index b8d2050..f5e0531 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -116,6 +116,7 @@ import android.view.InputEventReceiver; import android.view.KeyEvent; import android.view.MagnificationSpec; import android.view.MotionEvent; +import android.view.Surface.OutOfResourcesException; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; @@ -461,7 +462,7 @@ public class WindowManagerService extends IWindowManager.Stub // This is held as long as we have the screen frozen, to give us time to // perform a rotation animation when turning off shows the lock screen which // changes the orientation. - private PowerManager.WakeLock mScreenFrozenLock; + private final PowerManager.WakeLock mScreenFrozenLock; final AppTransition mAppTransition; boolean mStartingIconInTransition = false; @@ -664,7 +665,7 @@ public class WindowManagerService extends IWindowManager.Stub boolean mInTouchMode = true; private ViewServer mViewServer; - private ArrayList<WindowChangeListener> mWindowChangeListeners = + private final ArrayList<WindowChangeListener> mWindowChangeListeners = new ArrayList<WindowChangeListener>(); private boolean mWindowsChanged = false; @@ -6812,7 +6813,7 @@ public class WindowManagerService extends IWindowManager.Stub } else { Slog.w(TAG, "Drag already in progress"); } - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { Slog.e(TAG, "Can't allocate drag surface w=" + width + " h=" + height, e); if (mDragState != null) { mDragState.reset(); @@ -8580,12 +8581,8 @@ public class WindowManagerService extends IWindowManager.Stub mAppTransition.getStartingPoint(p); appAnimator.thumbnailX = p.x; appAnimator.thumbnailY = p.y; - } catch (SurfaceControl.OutOfResourcesException e) { - Slog.e(TAG, "Can't allocate thumbnail surface w=" + dirty.width() - + " h=" + dirty.height(), e); - appAnimator.clearThumbnail(); - } catch (Surface.OutOfResourcesException e) { - Slog.e(TAG, "Can't allocate Canvas surface w=" + dirty.width() + } catch (OutOfResourcesException e) { + Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" + dirty.width() + " h=" + dirty.height(), e); appAnimator.clearThumbnail(); } diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 73325cb..9245542 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -29,6 +29,7 @@ import android.util.Slog; import android.view.Display; import android.view.DisplayInfo; import android.view.MagnificationSpec; +import android.view.Surface.OutOfResourcesException; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.view.WindowManager; @@ -480,7 +481,7 @@ class WindowStateAnimator { private final Rect mWindowCrop = new Rect(); private boolean mShown = false; private int mLayerStack; - private String mName; + private final String mName; public SurfaceTrace(SurfaceSession s, String name, int w, int h, int format, int flags) @@ -694,7 +695,7 @@ class WindowStateAnimator { + attrs.format + " flags=0x" + Integer.toHexString(flags) + " / " + this); - } catch (SurfaceControl.OutOfResourcesException e) { + } catch (OutOfResourcesException e) { mWin.mHasSurface = false; Slog.w(TAG, "OutOfResourcesException creating surface"); mService.reclaimSomeSurfaceMemoryLocked(this, "create", true); |