diff options
| -rw-r--r-- | api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/widget/GridLayout.java | 98 | ||||
| -rw-r--r-- | core/tests/bandwidthtests/src/com/android/bandwidthtest/BandwidthTest.java | 5 | ||||
| -rw-r--r-- | core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java | 12 | ||||
| -rwxr-xr-x | media/libeffects/preprocessing/PreProcessing.cpp | 2 | ||||
| -rw-r--r-- | services/audioflinger/Android.mk | 3 | ||||
| -rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 25 | ||||
| -rw-r--r-- | services/audioflinger/AudioPolicyService.cpp | 20 | ||||
| -rw-r--r-- | services/audioflinger/ServiceUtilities.cpp | 55 | ||||
| -rw-r--r-- | services/audioflinger/ServiceUtilities.h | 27 | ||||
| -rw-r--r-- | services/java/com/android/server/wm/ScreenRotationAnimation.java | 42 | ||||
| -rw-r--r-- | services/java/com/android/server/wm/WindowManagerService.java | 23 |
12 files changed, 241 insertions, 73 deletions
diff --git a/api/current.txt b/api/current.txt index 9a1d394..7edfa53 100644 --- a/api/current.txt +++ b/api/current.txt @@ -26407,10 +26407,12 @@ package android.widget { field public static final android.widget.GridLayout.Alignment BASELINE; field public static final android.widget.GridLayout.Alignment BOTTOM; field public static final android.widget.GridLayout.Alignment CENTER; + field public static final android.widget.GridLayout.Alignment END; field public static final android.widget.GridLayout.Alignment FILL; field public static final int HORIZONTAL = 0; // 0x0 field public static final android.widget.GridLayout.Alignment LEFT; field public static final android.widget.GridLayout.Alignment RIGHT; + field public static final android.widget.GridLayout.Alignment START; field public static final android.widget.GridLayout.Alignment TOP; field public static final int UNDEFINED = -2147483648; // 0x80000000 field public static final int VERTICAL = 1; // 0x1 diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index 984ec79..328ccaf 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -566,6 +566,10 @@ public class GridLayout extends ViewGroup { return FILL; case AXIS_SPECIFIED: return CENTER; + case (AXIS_SPECIFIED | AXIS_PULL_BEFORE | RELATIVE_LAYOUT_DIRECTION): + return START; + case (AXIS_SPECIFIED | AXIS_PULL_AFTER | RELATIVE_LAYOUT_DIRECTION): + return END; default: return UNDEFINED_ALIGNMENT; } @@ -590,7 +594,8 @@ public class GridLayout extends ViewGroup { Spec spec = horizontal ? p.columnSpec : p.rowSpec; Axis axis = horizontal ? horizontalAxis : verticalAxis; Interval span = spec.span; - boolean isAtEdge = leading ? (span.min == 0) : (span.max == axis.getCount()); + boolean leading1 = (horizontal && isLayoutRtl()) ? !leading : leading; + boolean isAtEdge = leading1 ? (span.min == 0) : (span.max == axis.getCount()); return getDefaultMargin(c, isAtEdge, horizontal, leading); } @@ -760,10 +765,15 @@ public class GridLayout extends ViewGroup { private void drawLine(Canvas graphics, int x1, int y1, int x2, int y2, Paint paint) { int dx = getPaddingLeft(); int dy = getPaddingTop(); - graphics.drawLine(dx + x1, dy + y1, dx + x2, dy + y2, paint); + if (isLayoutRtl()) { + int width = getWidth(); + graphics.drawLine(width - dx - x1, dy + y1, width - dx - x2, dy + y2, paint); + } else { + graphics.drawLine(dx + x1, dy + y1, dx + x2, dy + y2, paint); + } } - private static void drawRect(Canvas canvas, int x1, int y1, int x2, int y2, Paint paint) { + private void drawRect(Canvas canvas, int x1, int y1, int x2, int y2, Paint paint) { canvas.drawRect(x1, y1, x2 - 1, y2 - 1, paint); } @@ -945,7 +955,7 @@ public class GridLayout extends ViewGroup { final Alignment getAlignment(Alignment alignment, boolean horizontal) { return (alignment != UNDEFINED_ALIGNMENT) ? alignment : - (horizontal ? LEFT : BASELINE); + (horizontal ? START : BASELINE); } // Layout container @@ -1003,41 +1013,41 @@ public class GridLayout extends ViewGroup { Alignment hAlign = getAlignment(columnSpec.alignment, true); Alignment vAlign = getAlignment(rowSpec.alignment, false); - int dx, dy; - Bounds colBounds = horizontalAxis.getGroupBounds().getValue(i); Bounds rowBounds = verticalAxis.getGroupBounds().getValue(i); // Gravity offsets: the location of the alignment group relative to its cell group. //noinspection NullableProblems - int c2ax = protect(hAlign.getAlignmentValue(null, cellWidth - colBounds.size(true))); + int gravityOffsetX = protect(hAlign.getAlignmentValue(null, + cellWidth - colBounds.size(true))); //noinspection NullableProblems - int c2ay = protect(vAlign.getAlignmentValue(null, cellHeight - rowBounds.size(true))); + int gravityOffsetY = protect(vAlign.getAlignmentValue(null, + cellHeight - rowBounds.size(true))); - int leftMargin = getMargin(c, true, true); + boolean rtl = isLayoutRtl(); + int startMargin = getMargin(c, true, !rtl); int topMargin = getMargin(c, false, true); - int rightMargin = getMargin(c, true, false); + int endMargin = getMargin(c, true, rtl); int bottomMargin = getMargin(c, false, false); // Same calculation as getMeasurementIncludingMargin() - int mWidth = leftMargin + pWidth + rightMargin; + int mWidth = startMargin + pWidth + endMargin; int mHeight = topMargin + pHeight + bottomMargin; // Alignment offsets: the location of the view relative to its alignment group. - int a2vx = colBounds.getOffset(c, hAlign, mWidth); - int a2vy = rowBounds.getOffset(c, vAlign, mHeight); + int alignmentOffsetX = colBounds.getOffset(c, hAlign, mWidth); + int alignmentOffsetY = rowBounds.getOffset(c, vAlign, mHeight); - dx = c2ax + a2vx + leftMargin; - dy = c2ay + a2vy + topMargin; + int dx = gravityOffsetX + alignmentOffsetX + startMargin; + int dy = gravityOffsetY + alignmentOffsetY + topMargin; - cellWidth -= leftMargin + rightMargin; + cellWidth -= startMargin + endMargin; cellHeight -= topMargin + bottomMargin; - int type = PRF; - int width = hAlign.getSizeInCell(c, pWidth, cellWidth, type); - int height = vAlign.getSizeInCell(c, pHeight, cellHeight, type); + int width = hAlign.getSizeInCell(c, pWidth, cellWidth, PRF); + int height = vAlign.getSizeInCell(c, pHeight, cellHeight, PRF); - int cx = paddingLeft + x1 + dx; + int cx = rtl ? targetWidth - paddingRight - x1 - dx - width : paddingLeft + x1 + dx; int cy = paddingTop + y1 + dy; if (width != c.getMeasuredWidth() || height != c.getMeasuredHeight()) { c.measure(makeMeasureSpec(width, EXACTLY), makeMeasureSpec(height, EXACTLY)); @@ -2049,7 +2059,7 @@ public class GridLayout extends ViewGroup { /* For each group (with a given alignment) we need to store the amount of space required before the alignment point and the amount of space required after it. One side of this - calculation is always 0 for LEADING and TRAILING alignments but we don't make use of this. + calculation is always 0 for START and END alignments but we don't make use of this. For CENTER and BASELINE alignments both sides are needed and in the BASELINE case no simple optimisations are possible. @@ -2405,18 +2415,29 @@ public class GridLayout extends ViewGroup { } static final Alignment UNDEFINED_ALIGNMENT = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { return UNDEFINED; } }; + /** + * Indicates that a view should be aligned with the <em>start</em> + * edges of the other views in its cell group. + */ private static final Alignment LEADING = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { return 0; } }; + /** + * Indicates that a view should be aligned with the <em>end</em> + * edges of the other views in its cell group. + */ private static final Alignment TRAILING = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { return viewSize; } @@ -2435,16 +2456,41 @@ public class GridLayout extends ViewGroup { public static final Alignment BOTTOM = TRAILING; /** - * Indicates that a view should be aligned with the <em>right</em> + * Indicates that a view should be aligned with the <em>start</em> * edges of the other views in its cell group. */ - public static final Alignment RIGHT = TRAILING; + public static final Alignment START = LEADING; + + /** + * Indicates that a view should be aligned with the <em>end</em> + * edges of the other views in its cell group. + */ + public static final Alignment END = TRAILING; + + private static Alignment getAbsoluteAlignment(final Alignment a1, final Alignment a2) { + return new Alignment() { + @Override + public int getAlignmentValue(View view, int viewSize) { + if (view == null) { + return UNDEFINED; + } + Alignment alignment = view.isLayoutRtl() ? a2 : a1; + return alignment.getAlignmentValue(view, viewSize); + } + }; + } /** * Indicates that a view should be aligned with the <em>left</em> * edges of the other views in its cell group. */ - public static final Alignment LEFT = LEADING; + public static final Alignment LEFT = getAbsoluteAlignment(START, END); + + /** + * Indicates that a view should be aligned with the <em>right</em> + * edges of the other views in its cell group. + */ + public static final Alignment RIGHT = getAbsoluteAlignment(END, START); /** * Indicates that a view should be <em>centered</em> with the other views in its cell group. @@ -2452,6 +2498,7 @@ public class GridLayout extends ViewGroup { * LayoutParams#columnSpec columnSpecs}. */ public static final Alignment CENTER = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { return viewSize >> 1; } @@ -2465,6 +2512,7 @@ public class GridLayout extends ViewGroup { * @see View#getBaseline() */ public static final Alignment BASELINE = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { if (view == null) { return UNDEFINED; @@ -2515,6 +2563,7 @@ public class GridLayout extends ViewGroup { * {@link LayoutParams#columnSpec columnSpecs}. */ public static final Alignment FILL = new Alignment() { + @Override public int getAlignmentValue(View view, int viewSize) { return UNDEFINED; } @@ -2530,6 +2579,5 @@ public class GridLayout extends ViewGroup { } private static final int INFLEXIBLE = 0; - private static final int CAN_STRETCH = 2; } diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/BandwidthTest.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/BandwidthTest.java index a781472..76b702e 100644 --- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/BandwidthTest.java +++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/BandwidthTest.java @@ -90,6 +90,7 @@ public class BandwidthTest extends InstrumentationTestCase { */ @LargeTest public void testWifiDownload() throws Exception { + mConnectionUtil.wifiTestInit(); assertTrue("Could not connect to wifi!", setDeviceWifiAndAirplaneMode(mSsid)); downloadFile(); } @@ -143,6 +144,7 @@ public class BandwidthTest extends InstrumentationTestCase { */ @LargeTest public void testWifiUpload() throws Exception { + mConnectionUtil.wifiTestInit(); assertTrue(setDeviceWifiAndAirplaneMode(mSsid)); uploadFile(); } @@ -197,6 +199,7 @@ public class BandwidthTest extends InstrumentationTestCase { */ @LargeTest public void testWifiDownloadWithDownloadManager() throws Exception { + mConnectionUtil.wifiTestInit(); assertTrue(setDeviceWifiAndAirplaneMode(mSsid)); downloadFileUsingDownloadManager(); } @@ -286,6 +289,8 @@ public class BandwidthTest extends InstrumentationTestCase { * @return true if we successfully connect to mobile data. */ public boolean hasMobileData() { + assertTrue(mConnectionUtil.waitForNetworkState(ConnectivityManager.TYPE_MOBILE, + State.CONNECTED, ConnectionUtil.LONG_TIMEOUT)); assertTrue("Not connected to mobile", mConnectionUtil.isConnectedToMobile()); assertFalse("Still connected to wifi.", mConnectionUtil.isConnectedToWifi()); return mConnectionUtil.hasData(); diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java index dfcbba9..7499f68 100644 --- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java +++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java @@ -57,7 +57,7 @@ public class ConnectionUtil { private static final int WAIT_FOR_SCAN_RESULT = 10 * 1000; // 10 seconds private static final int WIFI_SCAN_TIMEOUT = 50 * 1000; public static final int SHORT_TIMEOUT = 5 * 1000; - public static final int LONG_TIMEOUT = 10 * 1000; + public static final int LONG_TIMEOUT = 120 * 1000; // 2 minutes private ConnectivityReceiver mConnectivityReceiver = null; private WifiReceiver mWifiReceiver = null; private DownloadReceiver mDownloadReceiver = null; @@ -118,8 +118,14 @@ public class ConnectionUtil { initializeNetworkStates(); - mWifiManager.setWifiEnabled(true); + } + + /** + * Additional initialization needed for wifi related tests. + */ + public void wifiTestInit() { + mWifiManager.setWifiEnabled(true); Log.v(LOG_TAG, "Clear Wifi before we start the test."); sleep(SHORT_TIMEOUT); removeConfiguredNetworksAndDisableWifi(); @@ -525,7 +531,7 @@ public class ConnectionUtil { /** * Connect to Wi-Fi with the given configuration. * @param config - * @return true if we ar connected to a given + * @return true if we are connected to a given AP. */ public boolean connectToWifiWithConfiguration(WifiConfiguration config) { // The SSID in the configuration is a pure string, need to convert it to a quoted string. diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp index 4d94a75..098a1a2 100755 --- a/media/libeffects/preprocessing/PreProcessing.cpp +++ b/media/libeffects/preprocessing/PreProcessing.cpp @@ -1298,7 +1298,7 @@ int PreProcessingFx_Command(effect_handle_t self, return -EINVAL; } - Session_GetConfig(effect->session, (effect_config_t *)pCmdData); + Session_GetConfig(effect->session, (effect_config_t *)pReplyData); break; case EFFECT_CMD_SET_CONFIG_REVERSE: diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index deeb2de..157405a 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -6,7 +6,8 @@ LOCAL_SRC_FILES:= \ AudioFlinger.cpp \ AudioMixer.cpp.arm \ AudioResampler.cpp.arm \ - AudioPolicyService.cpp + AudioPolicyService.cpp \ + ServiceUtilities.cpp # AudioResamplerSinc.cpp.arm # AudioResamplerCubic.cpp.arm diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index bbc9196..5c964b2 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -48,6 +48,7 @@ #include "AudioMixer.h" #include "AudioFlinger.h" +#include "ServiceUtilities.h" #include <media/EffectsFactoryApi.h> #include <audio_effects/effect_visualizer.h> @@ -101,20 +102,6 @@ static const uint32_t kMaxThreadSleepTimeShift = 2; // ---------------------------------------------------------------------------- -static bool recordingAllowed() { - if (getpid() == IPCThreadState::self()->getCallingPid()) return true; - bool ok = checkCallingPermission(String16("android.permission.RECORD_AUDIO")); - if (!ok) ALOGE("Request requires android.permission.RECORD_AUDIO"); - return ok; -} - -static bool settingsAllowed() { - if (getpid() == IPCThreadState::self()->getCallingPid()) return true; - bool ok = checkCallingPermission(String16("android.permission.MODIFY_AUDIO_SETTINGS")); - if (!ok) ALOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS"); - return ok; -} - // To collect the amplifier usage static void addBatteryData(uint32_t params) { sp<IMediaPlayerService> service = IMediaDeathNotifier::getMediaPlayerService(); @@ -321,7 +308,7 @@ static bool tryLock(Mutex& mutex) status_t AudioFlinger::dump(int fd, const Vector<String16>& args) { - if (!checkCallingPermission(String16("android.permission.DUMP"))) { + if (!dumpAllowed()) { dumpPermissionDenial(fd, args); } else { // get state of hardware lock @@ -3436,7 +3423,7 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size) uint32_t vlr = mCblk->getVolumeLR(); snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n", mName - AudioMixer::TRACK0, - (mClient == 0) ? getpid() : mClient->pid(), + (mClient == 0) ? getpid_cached : mClient->pid(), mStreamType, mFormat, mChannelMask, @@ -3757,7 +3744,7 @@ void AudioFlinger::RecordThread::RecordTrack::stop() void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size) { snprintf(buffer, size, " %05d %03u 0x%08x %05d %04u %01d %05u %08x %08x\n", - (mClient == 0) ? getpid() : mClient->pid(), + (mClient == 0) ? getpid_cached : mClient->pid(), mFormat, mChannelMask, mSessionId, @@ -5404,7 +5391,7 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid, // Session AUDIO_SESSION_OUTPUT_STAGE is reserved for output stage effects // that can only be created by audio policy manager (running in same process) - if (sessionId == AUDIO_SESSION_OUTPUT_STAGE && getpid() != pid) { + if (sessionId == AUDIO_SESSION_OUTPUT_STAGE && getpid_cached != pid) { lStatus = PERMISSION_DENIED; goto Exit; } @@ -7022,7 +7009,7 @@ void AudioFlinger::EffectHandle::dump(char* buffer, size_t size) bool locked = mCblk != NULL && tryLock(mCblk->lock); snprintf(buffer, size, "\t\t\t%05d %05d %01u %01u %05u %05u\n", - (mClient == 0) ? getpid() : mClient->pid(), + (mClient == 0) ? getpid_cached : mClient->pid(), mPriority, mHasControl, !locked, diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp index f8b430e..21b5811 100644 --- a/services/audioflinger/AudioPolicyService.cpp +++ b/services/audioflinger/AudioPolicyService.cpp @@ -30,6 +30,7 @@ #include <utils/String16.h> #include <utils/threads.h> #include "AudioPolicyService.h" +#include "ServiceUtilities.h" #include <cutils/properties.h> #include <hardware_legacy/power.h> #include <media/AudioEffect.h> @@ -49,13 +50,6 @@ static const char kCmdDeadlockedString[] = "AudioPolicyService command thread ma static const int kDumpLockRetries = 50; static const int kDumpLockSleepUs = 20000; -static bool checkPermission() { - if (getpid() == IPCThreadState::self()->getCallingPid()) return true; - bool ok = checkCallingPermission(String16("android.permission.MODIFY_AUDIO_SETTINGS")); - if (!ok) ALOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS"); - return ok; -} - namespace { extern struct audio_policy_service_ops aps_ops; }; @@ -157,7 +151,7 @@ status_t AudioPolicyService::setDeviceConnectionState(audio_devices_t device, if (mpAudioPolicy == NULL) { return NO_INIT; } - if (!checkPermission()) { + if (!settingsAllowed()) { return PERMISSION_DENIED; } if (!audio_is_output_device(device) && !audio_is_input_device(device)) { @@ -190,7 +184,7 @@ status_t AudioPolicyService::setPhoneState(audio_mode_t state) if (mpAudioPolicy == NULL) { return NO_INIT; } - if (!checkPermission()) { + if (!settingsAllowed()) { return PERMISSION_DENIED; } if (uint32_t(state) >= AUDIO_MODE_CNT) { @@ -213,7 +207,7 @@ status_t AudioPolicyService::setForceUse(audio_policy_force_use_t usage, if (mpAudioPolicy == NULL) { return NO_INIT; } - if (!checkPermission()) { + if (!settingsAllowed()) { return PERMISSION_DENIED; } if (usage < 0 || usage >= AUDIO_POLICY_FORCE_USE_CNT) { @@ -388,7 +382,7 @@ status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream, if (mpAudioPolicy == NULL) { return NO_INIT; } - if (!checkPermission()) { + if (!settingsAllowed()) { return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT) { @@ -405,7 +399,7 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream, if (mpAudioPolicy == NULL) { return NO_INIT; } - if (!checkPermission()) { + if (!settingsAllowed()) { return PERMISSION_DENIED; } if (uint32_t(stream) >= AUDIO_STREAM_CNT) { @@ -578,7 +572,7 @@ status_t AudioPolicyService::dumpInternals(int fd) status_t AudioPolicyService::dump(int fd, const Vector<String16>& args) { - if (!checkCallingPermission(String16("android.permission.DUMP"))) { + if (!dumpAllowed()) { dumpPermissionDenial(fd); } else { bool locked = tryLock(mLock); diff --git a/services/audioflinger/ServiceUtilities.cpp b/services/audioflinger/ServiceUtilities.cpp new file mode 100644 index 0000000..6a58852 --- /dev/null +++ b/services/audioflinger/ServiceUtilities.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 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. + */ + +#include <binder/IPCThreadState.h> +#include <binder/IServiceManager.h> +#include <binder/PermissionCache.h> +#include "ServiceUtilities.h" + +namespace android { + +// This optimization assumes mediaserver process doesn't fork, which it doesn't +const pid_t getpid_cached = getpid(); + +bool recordingAllowed() { + if (getpid_cached == IPCThreadState::self()->getCallingPid()) return true; + static const String16 sRecordAudio("android.permission.RECORD_AUDIO"); + // don't use PermissionCache; this is not a system permission + bool ok = checkCallingPermission(sRecordAudio); + if (!ok) ALOGE("Request requires android.permission.RECORD_AUDIO"); + return ok; +} + +bool settingsAllowed() { + if (getpid_cached == IPCThreadState::self()->getCallingPid()) return true; + static const String16 sAudioSettings("android.permission.MODIFY_AUDIO_SETTINGS"); + // don't use PermissionCache; this is not a system permission + bool ok = checkCallingPermission(sAudioSettings); + if (!ok) ALOGE("Request requires android.permission.MODIFY_AUDIO_SETTINGS"); + return ok; +} + +bool dumpAllowed() { + // don't optimize for same pid, since mediaserver never dumps itself + static const String16 sDump("android.permission.DUMP"); + // OK to use PermissionCache; this is a system permission + bool ok = PermissionCache::checkCallingPermission(sDump); + // convention is for caller to dump an error message to fd instead of logging here + //if (!ok) ALOGE("Request requires android.permission.DUMP"); + return ok; +} + +} // namespace android diff --git a/services/audioflinger/ServiceUtilities.h b/services/audioflinger/ServiceUtilities.h new file mode 100644 index 0000000..f77ec5b --- /dev/null +++ b/services/audioflinger/ServiceUtilities.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 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. + */ + +#include <unistd.h> + +namespace android { + +extern const pid_t getpid_cached; + +bool recordingAllowed(); +bool settingsAllowed(); +bool dumpAllowed(); + +} diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java index 55fb038..04a039f 100644 --- a/services/java/com/android/server/wm/ScreenRotationAnimation.java +++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java @@ -16,6 +16,8 @@ package com.android.server.wm; +import java.io.PrintWriter; + import android.content.Context; import android.graphics.Matrix; import android.graphics.PixelFormat; @@ -96,6 +98,46 @@ class ScreenRotationAnimation { final Matrix mTmpMatrix = new Matrix(); final float[] mTmpFloats = new float[9]; + public void printTo(String prefix, PrintWriter pw) { + pw.print(prefix); pw.print("mSurface="); pw.print(mSurface); + pw.print(" mWidth="); pw.print(mWidth); + pw.print(" mHeight="); pw.println(mHeight); + pw.print(prefix); pw.print("mBlackFrame="); pw.println(mBlackFrame); + pw.print(prefix); pw.print("mSnapshotRotation="); pw.print(mSnapshotRotation); + pw.print(" mSnapshotDeltaRotation="); pw.print(mSnapshotDeltaRotation); + pw.print(" mCurRotation="); pw.println(mCurRotation); + pw.print(prefix); pw.print("mOriginalRotation="); pw.print(mOriginalRotation); + pw.print(" mOriginalWidth="); pw.print(mOriginalWidth); + pw.print(" mOriginalHeight="); pw.println(mOriginalHeight); + pw.print(prefix); pw.print("mStarted="); pw.print(mStarted); + pw.print(" mAnimRunning="); pw.print(mAnimRunning); + pw.print(" mFinishAnimReady="); pw.print(mFinishAnimReady); + pw.print(" mFinishAnimStartTime="); pw.println(mFinishAnimStartTime); + pw.print(prefix); pw.print("mStartExitAnimation="); pw.print(mStartExitAnimation); + pw.print(" "); mStartExitTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mStartEnterAnimation="); pw.print(mStartEnterAnimation); + pw.print(" "); mStartEnterTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mFinishExitAnimation="); pw.print(mFinishExitAnimation); + pw.print(" "); mFinishExitTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mFinishEnterAnimation="); pw.print(mFinishEnterAnimation); + pw.print(" "); mFinishEnterTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mRotateExitAnimation="); pw.print(mRotateExitAnimation); + pw.print(" "); mRotateExitTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mRotateEnterAnimation="); pw.print(mRotateEnterAnimation); + pw.print(" "); mRotateEnterTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mLastRotateExitAnimation="); + pw.print(mLastRotateExitAnimation); + pw.print(" "); mLastRotateExitTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mExitTransformation="); + mExitTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mEnterTransformation="); + mEnterTransformation.printShortString(pw); pw.println(); + pw.print(prefix); pw.print("mSnapshotInitialMatrix="); + mSnapshotInitialMatrix.printShortString(pw); + pw.print(" mSnapshotFinalMatrix="); mSnapshotFinalMatrix.printShortString(pw); + pw.println(); + } + public ScreenRotationAnimation(Context context, SurfaceSession session, boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) { mContext = context; diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 3b5ec03..bdbaab4 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -7636,6 +7636,8 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mAnimating = true; } else { updateRotation = true; + mScreenRotationAnimation.kill(); + mScreenRotationAnimation = null; } } } @@ -8708,7 +8710,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mAnimating = false; // SECOND LOOP: Execute animations and update visibility of windows. - updateRotation = + updateRotation |= updateAppsAndRotationAnimationsLocked(currentTime, innerDw, innerDh); if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** ANIM STEP: seq=" @@ -9012,11 +9014,6 @@ public class WindowManagerService extends IWindowManager.Stub mTurnOnScreen = false; } - if (updateRotation && mScreenRotationAnimation != null) { - mScreenRotationAnimation.kill(); - mScreenRotationAnimation = null; - } - if (updateRotation) { if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); if (updateRotationUncheckedLocked(false)) { @@ -9387,7 +9384,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (CUSTOM_SCREEN_ROTATION) { - if (mScreenRotationAnimation != null && mScreenRotationAnimation.isAnimating()) { + if (mScreenRotationAnimation != null) { mScreenRotationAnimation.kill(); mScreenRotationAnimation = null; } @@ -9918,11 +9915,15 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mLastWindowForcedOrientation"); pw.print(mLastWindowForcedOrientation); pw.print(" mForcedAppOrientation="); pw.println(mForcedAppOrientation); pw.print(" mDeferredRotationPauseCount="); pw.println(mDeferredRotationPauseCount); - pw.print(" mTraversalScheduled="); pw.print(mTraversalScheduled); - pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale); - pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale); + if (mScreenRotationAnimation != null) { + pw.println(" mScreenRotationAnimation:"); + mScreenRotationAnimation.printTo(" ", pw); + } + pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale); + pw.print(" mTransitionWindowAnimationScale="); pw.print(mTransitionAnimationScale); pw.print(" mAnimatorDurationScale="); pw.println(mAnimatorDurationScale); - pw.print(" mNextAppTransition=0x"); + pw.print(" mTraversalScheduled="); pw.print(mTraversalScheduled); + pw.print(" mNextAppTransition=0x"); pw.print(Integer.toHexString(mNextAppTransition)); pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady); pw.print(" mAppTransitionRunning="); pw.print(mAppTransitionRunning); |
