diff options
7 files changed, 102 insertions, 12 deletions
diff --git a/core/java/android/content/pm/dex/ArtManagerInternal.java b/core/java/android/content/pm/dex/ArtManagerInternal.java index 62ab9e02f858..23fef29803e7 100644 --- a/core/java/android/content/pm/dex/ArtManagerInternal.java +++ b/core/java/android/content/pm/dex/ArtManagerInternal.java @@ -30,5 +30,5 @@ public abstract class ArtManagerInternal { * in executes using the specified {@code abi}. */ public abstract PackageOptimizationInfo getPackageOptimizationInfo( - ApplicationInfo info, String abi); + ApplicationInfo info, String abi, String activityName); } diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java index 0ec8654f2a20..398ece4c1836 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java +++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java @@ -77,8 +77,8 @@ final class AutofillInlineSessionController { if (mSession != null) { // Destroy the existing session. mSession.destroySessionLocked(); - mInlineFillUi = null; } + mInlineFillUi = null; // TODO(b/151123764): consider reusing the same AutofillInlineSession object for the // same field. mSession = new AutofillInlineSuggestionsRequestSession(mInputMethodManagerInternal, mUserId, @@ -87,6 +87,22 @@ final class AutofillInlineSessionController { } /** + * Destroys the current session. May send an empty response to IME to clear the suggestions if + * the focus didn't change to a different field. + * + * @param autofillId the currently focused view from the autofill session + */ + @GuardedBy("mLock") + void destroyLocked(@NonNull AutofillId autofillId) { + if (mSession != null) { + mSession.onInlineSuggestionsResponseLocked(InlineFillUi.emptyUi(autofillId)); + mSession.destroySessionLocked(); + mSession = null; + } + mInlineFillUi = null; + } + + /** * Returns the {@link InlineSuggestionsRequest} provided by IME for the last request. * * <p> The caller is responsible for making sure Autofill hears back from IME before calling diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index a9a0ab69f633..c7490b3b991c 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -3702,6 +3702,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState unlinkClientVultureLocked(); mUi.destroyAll(mPendingSaveUi, this, true); mUi.clearCallback(this); + if (mCurrentViewId != null) { + mInlineSessionController.destroyLocked(mCurrentViewId); + } mDestroyed = true; // Log metrics diff --git a/services/core/java/com/android/server/pm/dex/ArtManagerService.java b/services/core/java/com/android/server/pm/dex/ArtManagerService.java index 51e07faf8443..8000c639139f 100644 --- a/services/core/java/com/android/server/pm/dex/ArtManagerService.java +++ b/services/core/java/com/android/server/pm/dex/ArtManagerService.java @@ -63,6 +63,10 @@ import libcore.io.IoUtils; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Objects; /** @@ -557,6 +561,20 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub { private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK = 12; private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_FALLBACK = 13; private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_VDEX_FALLBACK = 14; + // Filter with IORap + private static final int TRON_COMPILATION_FILTER_ASSUMED_VERIFIED_IORAP = 15; + private static final int TRON_COMPILATION_FILTER_EXTRACT_IORAP = 16; + private static final int TRON_COMPILATION_FILTER_VERIFY_IORAP = 17; + private static final int TRON_COMPILATION_FILTER_QUICKEN_IORAP = 18; + private static final int TRON_COMPILATION_FILTER_SPACE_PROFILE_IORAP = 19; + private static final int TRON_COMPILATION_FILTER_SPACE_IORAP = 20; + private static final int TRON_COMPILATION_FILTER_SPEED_PROFILE_IORAP = 21; + private static final int TRON_COMPILATION_FILTER_SPEED_IORAP = 22; + private static final int TRON_COMPILATION_FILTER_EVERYTHING_PROFILE_IORAP = 23; + private static final int TRON_COMPILATION_FILTER_EVERYTHING_IORAP = 24; + private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_IORAP = 25; + private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_FALLBACK_IORAP = 26; + private static final int TRON_COMPILATION_FILTER_FAKE_RUN_FROM_VDEX_FALLBACK_IORAP = 27; // Constants used for logging compilation reason to TRON. // DO NOT CHANGE existing values. @@ -623,6 +641,22 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub { return TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_FALLBACK; case "run-from-vdex-fallback" : return TRON_COMPILATION_FILTER_FAKE_RUN_FROM_VDEX_FALLBACK; + case "assume-verified-iorap" : return TRON_COMPILATION_FILTER_ASSUMED_VERIFIED_IORAP; + case "extract-iorap" : return TRON_COMPILATION_FILTER_EXTRACT_IORAP; + case "verify-iorap" : return TRON_COMPILATION_FILTER_VERIFY_IORAP; + case "quicken-iorap" : return TRON_COMPILATION_FILTER_QUICKEN_IORAP; + case "space-profile-iorap" : return TRON_COMPILATION_FILTER_SPACE_PROFILE_IORAP; + case "space-iorap" : return TRON_COMPILATION_FILTER_SPACE_IORAP; + case "speed-profile-iorap" : return TRON_COMPILATION_FILTER_SPEED_PROFILE_IORAP; + case "speed-iorap" : return TRON_COMPILATION_FILTER_SPEED_IORAP; + case "everything-profile-iorap" : + return TRON_COMPILATION_FILTER_EVERYTHING_PROFILE_IORAP; + case "everything-iorap" : return TRON_COMPILATION_FILTER_EVERYTHING_IORAP; + case "run-from-apk-iorap" : return TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_IORAP; + case "run-from-apk-fallback-iorap" : + return TRON_COMPILATION_FILTER_FAKE_RUN_FROM_APK_FALLBACK_IORAP; + case "run-from-vdex-fallback-iorap" : + return TRON_COMPILATION_FILTER_FAKE_RUN_FROM_VDEX_FALLBACK_IORAP; default: return TRON_COMPILATION_FILTER_UNKNOWN; } } @@ -640,9 +674,12 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub { } private class ArtManagerInternalImpl extends ArtManagerInternal { + private static final String IORAP_DIR = "/data/misc/iorapd"; + private static final String TAG = "ArtManagerInternalImpl"; + @Override public PackageOptimizationInfo getPackageOptimizationInfo( - ApplicationInfo info, String abi) { + ApplicationInfo info, String abi, String activityName) { String compilationReason; String compilationFilter; try { @@ -662,11 +699,45 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub { compilationReason = "error"; } + if (checkIorapCompiledTrace(info.packageName, activityName, info.longVersionCode)) { + compilationFilter = compilationFilter + "-iorap"; + } + int compilationFilterTronValue = getCompilationFilterTronValue(compilationFilter); int compilationReasonTronValue = getCompilationReasonTronValue(compilationReason); return new PackageOptimizationInfo( compilationFilterTronValue, compilationReasonTronValue); } + + /* + * Checks the existence of IORap compiled trace for an app. + * + * @return true if the compiled trace exists and the size is greater than 1kb. + */ + private boolean checkIorapCompiledTrace( + String packageName, String activityName, long version) { + // For example: /data/misc/iorapd/com.google.android.GoogleCamera/ + // 60092239/com.android.camera.CameraLauncher/compiled_traces/compiled_trace.pb + Path tracePath = Paths.get(IORAP_DIR, + packageName, + Long.toString(version), + activityName, + "compiled_traces", + "compiled_trace.pb"); + try { + boolean exists = Files.exists(tracePath); + Log.d(TAG, tracePath.toString() + (exists? " exists" : " doesn't exist")); + if (exists) { + long bytes = Files.size(tracePath); + Log.d(TAG, tracePath.toString() + " size is " + Long.toString(bytes)); + return bytes > 0L; + } + return exists; + } catch (IOException e) { + Log.d(TAG, e.getMessage()); + return false; + } + } } } diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java index fb29f9a93215..189b21fb81a6 100644 --- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java @@ -842,7 +842,8 @@ class ActivityMetricsLogger { ? PackageOptimizationInfo.createWithNoInfo() : artManagerInternal.getPackageOptimizationInfo( info.applicationInfo, - info.launchedActivityAppRecordRequiredAbi); + info.launchedActivityAppRecordRequiredAbi, + info.launchedActivityName); builder.addTaggedData(PACKAGE_OPTIMIZATION_COMPILATION_REASON, packageOptimizationInfo.getCompilationReason()); builder.addTaggedData(PACKAGE_OPTIMIZATION_COMPILATION_FILTER, diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index c0252363a159..8115ac8c6bef 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -247,10 +247,6 @@ class WindowStateAnimator { private final SurfaceControl.Transaction mPostDrawTransaction = new SurfaceControl.Transaction(); - // Used to track whether we have called detach children on the way to invisibility, in which - // case we need to give the client a new Surface if it lays back out to a visible state. - boolean mChildrenDetached = false; - // Set to true after the first frame of the Pinned stack animation // and reset after the last to ensure we only reset mForceScaleUntilResize // once per animation. @@ -425,7 +421,8 @@ class WindowStateAnimator { // transparent to the app. // If the children are detached, we don't want to reparent them to the new surface. // Instead let the children get removed when the old surface is deleted. - if (mSurfaceController != null && mPendingDestroySurface != null && !mChildrenDetached + if (mSurfaceController != null && mPendingDestroySurface != null + && !mPendingDestroySurface.mChildrenDetached && (mWin.mActivityRecord == null || !mWin.mActivityRecord.isRelaunching())) { mPostDrawTransaction.reparentChildren( mPendingDestroySurface.getClientViewRootSurface(), @@ -461,7 +458,6 @@ class WindowStateAnimator { if (mSurfaceController != null) { return mSurfaceController; } - mChildrenDetached = false; if ((mWin.mAttrs.privateFlags & PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY) != 0) { windowType = SurfaceControl.WINDOW_TYPE_DONT_SCREENSHOT; @@ -1365,7 +1361,7 @@ class WindowStateAnimator { mPostDrawTransaction.reparent(pendingSurfaceControl, null); // If the children are detached, we don't want to reparent them to the new surface. // Instead let the children get removed when the old surface is deleted. - if (!mChildrenDetached) { + if (!mPendingDestroySurface.mChildrenDetached) { mPostDrawTransaction.reparentChildren( mPendingDestroySurface.getClientViewRootSurface(), mSurfaceController.mSurfaceControl); @@ -1596,7 +1592,6 @@ class WindowStateAnimator { if (mSurfaceController != null) { mSurfaceController.detachChildren(); } - mChildrenDetached = true; // If the children are detached, it means the app is exiting. We don't want to tear the // content down too early, otherwise we could end up with a flicker. By preserving the // current surface, we ensure the content remains on screen until the window is completely diff --git a/services/core/java/com/android/server/wm/WindowSurfaceController.java b/services/core/java/com/android/server/wm/WindowSurfaceController.java index 0a7ca5a0cf35..b2bfcdc8a900 100644 --- a/services/core/java/com/android/server/wm/WindowSurfaceController.java +++ b/services/core/java/com/android/server/wm/WindowSurfaceController.java @@ -90,6 +90,9 @@ class WindowSurfaceController { private final SurfaceControl.Transaction mTmpTransaction; + // Used to track whether we have called detach children on the way to invisibility. + boolean mChildrenDetached; + WindowSurfaceController(String name, int w, int h, int format, int flags, WindowStateAnimator animator, int windowType, int ownerUid) { mAnimator = animator; @@ -144,6 +147,7 @@ class WindowSurfaceController { void detachChildren() { ProtoLog.i(WM_SHOW_TRANSACTIONS, "SEVER CHILDREN"); + mChildrenDetached = true; if (mSurfaceControl != null) { mSurfaceControl.detachChildren(); } |