diff options
author | Craig Mautner <cmautner@google.com> | 2013-08-19 23:11:50 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-19 23:13:47 +0000 |
commit | 007751276c210c39bd405ae9fa69854e67e80951 (patch) | |
tree | e3dc7267ee3cb3679626d764e485d2368165881d | |
parent | b6c38e9de1a2824ce599d7074fa4a226926177c1 (diff) | |
parent | bc57cd1b248bf23e443581f9fe44167c94699ce8 (diff) | |
download | frameworks_base-007751276c210c39bd405ae9fa69854e67e80951.zip frameworks_base-007751276c210c39bd405ae9fa69854e67e80951.tar.gz frameworks_base-007751276c210c39bd405ae9fa69854e67e80951.tar.bz2 |
Merge "Notify ViewRootImpl when it's safe to modify Canvas." into klp-dev
-rw-r--r-- | core/java/android/app/Activity.java | 11 | ||||
-rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 14 | ||||
-rw-r--r-- | core/java/android/app/IActivityManager.java | 4 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 5 | ||||
-rw-r--r-- | core/java/android/view/WindowManagerGlobal.java | 15 | ||||
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 12 |
6 files changed, 49 insertions, 12 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 8f2f9ca..e02410a 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -747,6 +747,7 @@ public class Activity extends ContextThemeWrapper int mResultCode = RESULT_CANCELED; Intent mResultData = null; private TranslucentConversionListener mTranslucentCallback; + private boolean mChangeCanvasToTranslucent; private boolean mTitleReady = false; @@ -4903,7 +4904,9 @@ public class Activity extends ContextThemeWrapper public void convertFromTranslucent() { try { mTranslucentCallback = null; - ActivityManagerNative.getDefault().convertFromTranslucent(mToken); + if (ActivityManagerNative.getDefault().convertFromTranslucent(mToken)) { + WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, true); + } } catch (RemoteException e) { // pass } @@ -4931,7 +4934,8 @@ public class Activity extends ContextThemeWrapper public void convertToTranslucent(TranslucentConversionListener callback) { try { mTranslucentCallback = callback; - ActivityManagerNative.getDefault().convertToTranslucent(mToken); + mChangeCanvasToTranslucent = + ActivityManagerNative.getDefault().convertToTranslucent(mToken); } catch (RemoteException e) { // pass } @@ -4943,6 +4947,9 @@ public class Activity extends ContextThemeWrapper mTranslucentCallback.onTranslucentConversionComplete(drawComplete); mTranslucentCallback = null; } + if (mChangeCanvasToTranslucent) { + WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, false); + } } /** diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 6a29552..6d72114 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1502,16 +1502,18 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case CONVERT_FROM_TRANSLUCENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); - convertFromTranslucent(token); + boolean converted = convertFromTranslucent(token); reply.writeNoException(); + reply.writeInt(converted ? 1 : 0); return true; } case CONVERT_TO_TRANSLUCENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder token = data.readStrongBinder(); - convertToTranslucent(token); + boolean converted = convertToTranslucent(token); reply.writeNoException(); + reply.writeInt(converted ? 1 : 0); return true; } @@ -3876,7 +3878,7 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } - public void convertFromTranslucent(IBinder token) + public boolean convertFromTranslucent(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); @@ -3884,11 +3886,13 @@ class ActivityManagerProxy implements IActivityManager data.writeStrongBinder(token); mRemote.transact(CONVERT_FROM_TRANSLUCENT_TRANSACTION, data, reply, 0); reply.readException(); + boolean res = reply.readInt() != 0; data.recycle(); reply.recycle(); + return res; } - public void convertToTranslucent(IBinder token) + public boolean convertToTranslucent(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); @@ -3896,8 +3900,10 @@ class ActivityManagerProxy implements IActivityManager data.writeStrongBinder(token); mRemote.transact(CONVERT_TO_TRANSLUCENT_TRANSACTION, data, reply, 0); reply.readException(); + boolean res = reply.readInt() != 0; data.recycle(); reply.recycle(); + return res; } public void setImmersive(IBinder token, boolean immersive) diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 6d1b6fc..af9a245 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -301,8 +301,8 @@ public interface IActivityManager extends IInterface { public void finishHeavyWeightApp() throws RemoteException; - public void convertFromTranslucent(IBinder token) throws RemoteException; - public void convertToTranslucent(IBinder token) throws RemoteException; + public boolean convertFromTranslucent(IBinder token) throws RemoteException; + public boolean convertToTranslucent(IBinder token) throws RemoteException; public void notifyActivityDrawn(IBinder token) throws RemoteException; public void setImmersive(IBinder token, boolean immersive) throws RemoteException; diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f711e7a..354e815 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -5960,6 +5960,11 @@ public final class ViewRootImpl implements ViewParent, // Do nothing. } + void changeCanvasOpacity(boolean opaque) { + // TODO(romainguy): recreate Canvas (software or hardware) to reflect the opacity change. + Log.d(TAG, "changeCanvasOpacity: opaque=" + opaque); + } + class TakenSurfaceHolder extends BaseSurfaceHolder { @Override public boolean onAllowLockCanvas() { diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index 3dd96f5..96c0ed2 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -494,6 +494,21 @@ public final class WindowManagerGlobal { } } } + + /** @hide */ + public void changeCanvasOpacity(IBinder token, boolean opaque) { + if (token == null) { + return; + } + synchronized (mLock) { + for (int i = mParams.size() - 1; i >= 0; --i) { + if (mParams.get(i).token == token) { + mRoots.get(i).changeCanvasOpacity(opaque); + return; + } + } + } + } } final class WindowLeaked extends AndroidRuntimeException { diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 3f58fa4..8f4b6c2 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -8154,18 +8154,20 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override - public void convertFromTranslucent(IBinder token) { + public boolean convertFromTranslucent(IBinder token) { final long origId = Binder.clearCallingIdentity(); try { synchronized (this) { final ActivityRecord r = ActivityRecord.isInStackLocked(token); if (r == null) { - return; + return false; } if (r.changeWindowTranslucency(true)) { mWindowManager.setAppFullscreen(token, true); mStackSupervisor.ensureActivitiesVisibleLocked(null, 0); + return true; } + return false; } } finally { Binder.restoreCallingIdentity(origId); @@ -8173,19 +8175,21 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override - public void convertToTranslucent(IBinder token) { + public boolean convertToTranslucent(IBinder token) { final long origId = Binder.clearCallingIdentity(); try { synchronized (this) { final ActivityRecord r = ActivityRecord.isInStackLocked(token); if (r == null) { - return; + return false; } if (r.changeWindowTranslucency(false)) { r.task.stack.convertToTranslucent(r); mWindowManager.setAppFullscreen(token, false); mStackSupervisor.ensureActivitiesVisibleLocked(null, 0); + return true; } + return false; } } finally { Binder.restoreCallingIdentity(origId); |