Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b0ab65e authored by Alan Viverette's avatar Alan Viverette
Browse files

Enable/disable hardware rendering on windows by application tag



Previously, hardware rendering cannot be enabled or disabled
on windows created without a parent activity (e.g. by services)
by setting the <application> tag, "android:hardwareAccelerated"
in AndroidManifest.xml. It's enabled by default in Android L
from the commit, 5e1565ea.
This patch provides a way of setting hardware rendering for
that case.

Change-Id: I60ee9566e99db39cd661fe6f196f43c3968b311a
Signed-off-by: default avatarDohyun Lee <dohyun.lee@lge.com>
parent 6022edc5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8626,6 +8626,7 @@ package android.content.pm {
    field public int descriptionRes;
    field public boolean enabled;
    field public int flags;
    field public boolean hardwareAccelerated;
    field public int largestWidthLimitDp;
    field public java.lang.String manageSpaceActivityName;
    field public java.lang.String nativeLibraryDir;
+1 −0
Original line number Diff line number Diff line
@@ -8841,6 +8841,7 @@ package android.content.pm {
    field public int descriptionRes;
    field public boolean enabled;
    field public int flags;
    field public boolean hardwareAccelerated;
    field public int largestWidthLimitDp;
    field public java.lang.String manageSpaceActivityName;
    field public java.lang.String nativeLibraryDir;
+9 −0
Original line number Diff line number Diff line
@@ -598,6 +598,11 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;

    /**
     * True when the application's rendering should be hardware accelerated.
     */
    public boolean hardwareAccelerated;

    public void dump(Printer pw, String prefix) {
        super.dumpFront(pw, prefix);
        if (className != null) {
@@ -637,6 +642,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        }
        pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion
                + " versionCode=" + versionCode);
        pw.println(prefix + "hardwareAccelerated=" + hardwareAccelerated);
        if (manageSpaceActivityName != null) {
            pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
        }
@@ -722,6 +728,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        descriptionRes = orig.descriptionRes;
        uiOptions = orig.uiOptions;
        backupAgentName = orig.backupAgentName;
        hardwareAccelerated = orig.hardwareAccelerated;
    }


@@ -773,6 +780,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeString(backupAgentName);
        dest.writeInt(descriptionRes);
        dest.writeInt(uiOptions);
        dest.writeInt(hardwareAccelerated ? 1 : 0);
    }

    public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -823,6 +831,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        backupAgentName = source.readString();
        descriptionRes = source.readInt();
        uiOptions = source.readInt();
        hardwareAccelerated = source.readInt() != 0;
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -2519,6 +2519,7 @@ public class PackageParser {
        owner.baseHardwareAccelerated = sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated,
                owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
        ai.hardwareAccelerated = owner.baseHardwareAccelerated;

        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestApplication_hasCode,
+5 −5
Original line number Diff line number Diff line
@@ -249,12 +249,12 @@ public final class WindowManagerGlobal {
        final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params;
        if (parentWindow != null) {
            parentWindow.adjustLayoutParamsForSubWindow(wparams);
        } else if (ActivityManager.isHighEndGfx()) {
            // If there's no parent and we're running on L or above (or in the
            // system context), assume we want hardware acceleration.
        } else {
            // If there's no parent, then hardware acceleration for this view is
            // set from the application's hardware acceleration setting.
            final Context context = view.getContext();
            if (context != null && context.getApplicationInfo().targetSdkVersion
                    >= Build.VERSION_CODES.LOLLIPOP) {
            if (context != null
                    && context.getApplicationInfo().hardwareAccelerated) {
                wparams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
            }
        }