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

Commit 3c7b637a authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Do not change value read from manifest.

Current code modifies the flag 'profilable' based on another flag
'debuggable'.

Test: refactoring CL. Existing unit tests still pass.

Change-Id: Ib6564eb494a977b97fc2107f144bc87d4bd1e36a
parent 88d54c76
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -6520,7 +6520,8 @@ public final class ActivityThread extends ClientTransactionHandler {
        }

        // Allow binder tracing, and application-generated systrace messages if we're profileable.
        boolean isAppProfileable = data.appInfo.isProfileableByShell();
        boolean isAppDebuggable = (data.appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        boolean isAppProfileable = isAppDebuggable || data.appInfo.isProfileableByShell();
        Trace.setAppTracingAllowed(isAppProfileable);
        if ((isAppProfileable || Build.IS_DEBUGGABLE) && data.enableBinderTracking) {
            Binder.enableTracing();
@@ -6532,7 +6533,6 @@ public final class ActivityThread extends ClientTransactionHandler {
        }

        // Allow renderer debugging features if we're debuggable.
        boolean isAppDebuggable = (data.appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        HardwareRenderer.setDebuggingEnabled(isAppDebuggable || Build.IS_DEBUGGABLE);
        HardwareRenderer.setPackageName(data.appInfo.packageName);

+0 −6
Original line number Diff line number Diff line
@@ -1648,10 +1648,6 @@ public class PackageParser {
                    final String attr = attrs.getAttributeName(i);
                    if ("debuggable".equals(attr)) {
                        debuggable = attrs.getAttributeBooleanValue(i, false);
                        if (debuggable) {
                            // Debuggable implies profileable
                            profilableByShell = true;
                        }
                    }
                    if ("multiArch".equals(attr)) {
                        multiArch = attrs.getAttributeBooleanValue(i, false);
@@ -3471,8 +3467,6 @@ public class PackageParser {
                com.android.internal.R.styleable.AndroidManifestApplication_debuggable,
                false)) {
            ai.flags |= ApplicationInfo.FLAG_DEBUGGABLE;
            // Debuggable implies profileable
            ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_PROFILEABLE_BY_SHELL;
        }

        if (sa.getBoolean(
+0 −4
Original line number Diff line number Diff line
@@ -380,10 +380,6 @@ public class ApkLiteParseUtils {
                    switch (attr) {
                        case "debuggable":
                            debuggable = attrs.getAttributeBooleanValue(i, false);
                            if (debuggable) {
                                // Debuggable implies profileable
                                profilableByShell = true;
                            }
                            break;
                        case "multiArch":
                            multiArch = attrs.getAttributeBooleanValue(i, false);
+1 −2
Original line number Diff line number Diff line
@@ -1720,8 +1720,7 @@ public class ParsingPackageUtils {

            // TODO(b/135203078): Should parsing code be responsible for this? Maybe move to a
            //  util or just have PackageImpl return true if either flag is set
            // Debuggable implies profileable
            pkg.setProfileableByShell(pkg.isProfileableByShell() || pkg.isDebuggable());
            pkg.setProfileableByShell(pkg.isProfileableByShell());

            if (sa.hasValueOrEmpty(R.styleable.AndroidManifestApplication_resizeableActivity)) {
                pkg.setResizeableActivity(sa.getBoolean(
+3 −3
Original line number Diff line number Diff line
@@ -405,9 +405,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -8436,7 +8434,9 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized (this) {
            boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"));
            if (!isDebuggable) {
                if (!app.isProfileableByShell()) {
                boolean isAppDebuggable = (app.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
                boolean isAppProfileable = app.isProfileableByShell();
                if (!isAppDebuggable && !isAppProfileable) {
                    throw new SecurityException("Process not debuggable, "
                            + "and not profileable by shell: " + app.packageName);
                }