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

Commit 765f6821 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12888383 from d0b8249b to 25Q2-release

Change-Id: I90d4d10c6b4c484eb4c3f8060288c6705ba2a29f
parents acb6c8e5 d0b8249b
Loading
Loading
Loading
Loading
+96 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package android.content.pm;

import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.pm.RoSystemFeatures;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;


@RunWith(AndroidJUnit4.class)
@LargeTest
public class SystemFeaturesPerfTest {
    // As each query is relatively cheap, add an inner iteration loop to reduce execution noise.
    private static final int NUM_ITERATIONS = 10;

    @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    @Test
    public void hasSystemFeature_PackageManager() {
        final PackageManager pm =
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 0; i < NUM_ITERATIONS; ++i) {
                pm.hasSystemFeature(PackageManager.FEATURE_WATCH);
                pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
                pm.hasSystemFeature(PackageManager.FEATURE_IPSEC_TUNNELS);
                pm.hasSystemFeature(PackageManager.FEATURE_AUTOFILL);
                pm.hasSystemFeature("com.android.custom.feature.1");
                pm.hasSystemFeature("foo");
                pm.hasSystemFeature("");
            }
        }
    }

    @Test
    public void hasSystemFeature_SystemFeaturesCache() {
        final PackageManager pm =
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager();
        final SystemFeaturesCache cache =
                new SystemFeaturesCache(Arrays.asList(pm.getSystemAvailableFeatures()));
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 0; i < NUM_ITERATIONS; ++i) {
                cache.maybeHasFeature(PackageManager.FEATURE_WATCH, 0);
                cache.maybeHasFeature(PackageManager.FEATURE_LEANBACK, 0);
                cache.maybeHasFeature(PackageManager.FEATURE_IPSEC_TUNNELS, 0);
                cache.maybeHasFeature(PackageManager.FEATURE_AUTOFILL, 0);
                cache.maybeHasFeature("com.android.custom.feature.1", 0);
                cache.maybeHasFeature("foo", 0);
                cache.maybeHasFeature("", 0);
            }
        }
    }

    @Test
    public void hasSystemFeature_RoSystemFeatures() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 0; i < NUM_ITERATIONS; ++i) {
                RoSystemFeatures.maybeHasFeature(PackageManager.FEATURE_WATCH, 0);
                RoSystemFeatures.maybeHasFeature(PackageManager.FEATURE_LEANBACK, 0);
                RoSystemFeatures.maybeHasFeature(PackageManager.FEATURE_IPSEC_TUNNELS, 0);
                RoSystemFeatures.maybeHasFeature(PackageManager.FEATURE_AUTOFILL, 0);
                RoSystemFeatures.maybeHasFeature("com.android.custom.feature.1", 0);
                RoSystemFeatures.maybeHasFeature("foo", 0);
                RoSystemFeatures.maybeHasFeature("", 0);
            }
        }
    }
}
+55 −0
Original line number Diff line number Diff line
@@ -34,11 +34,20 @@ import android.view.WindowManagerGlobal;
import org.junit.Rule;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

/** Measure the performance of warm launch activity in the same task. */
public class InTaskTransitionTest extends WindowManagerPerfTestBase
        implements RemoteCallback.OnResultListener {

    private static final long TIMEOUT_MS = 5000;
    private static final String LOG_SEPARATOR = "LOG_SEPARATOR";

    @Rule
    public final PerfManualStatusReporter mPerfStatusReporter = new PerfManualStatusReporter();
@@ -62,6 +71,7 @@ public class InTaskTransitionTest extends WindowManagerPerfTestBase

        final ManualBenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        long measuredTimeNs = 0;
        long firstStartTime = 0;

        boolean readerStarted = false;
        while (state.keepRunning(measuredTimeNs)) {
@@ -70,6 +80,10 @@ public class InTaskTransitionTest extends WindowManagerPerfTestBase
                readerStarted = true;
            }
            final long startTime = SystemClock.elapsedRealtimeNanos();
            if (readerStarted && firstStartTime == 0) {
                firstStartTime = startTime;
                executeShellCommand("log -t " + LOG_SEPARATOR + " " + firstStartTime);
            }
            activity.startActivity(next);
            synchronized (mMetricsReader) {
                try {
@@ -89,6 +103,7 @@ public class InTaskTransitionTest extends WindowManagerPerfTestBase
                state.addExtraResult("windowsDrawnDelayMs", metrics.mWindowsDrawnDelayMs);
            }
        }
        addExtraTransitionInfo(firstStartTime, state);
    }

    @Override
@@ -99,6 +114,46 @@ public class InTaskTransitionTest extends WindowManagerPerfTestBase
        }
    }

    private void addExtraTransitionInfo(long startTime, ManualBenchmarkState state) {
        final ProcessBuilder pb = new ProcessBuilder("sh");
        final String startLine = String.valueOf(startTime);
        final String commitTimeStr = " commit=";
        boolean foundStartLine = false;
        try {
            final Process process = pb.start();
            final InputStream in = process.getInputStream();
            final PrintWriter out = new PrintWriter(new BufferedWriter(
                    new OutputStreamWriter(process.getOutputStream())), true /* autoFlush */);
            out.println("logcat -v brief -d *:S WindowManager:V " + LOG_SEPARATOR + ":I"
                    + " | grep -e 'Finish Transition' -e " + LOG_SEPARATOR);
            out.println("exit");

            String line;
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
                while ((line = reader.readLine()) != null) {
                    if (!foundStartLine) {
                        if (line.contains(startLine)) {
                            foundStartLine = true;
                        }
                        continue;
                    }
                    final int strPos = line.indexOf(commitTimeStr);
                    if (strPos < 0) {
                        continue;
                    }
                    final int endPos = line.indexOf("ms", strPos);
                    if (endPos > strPos) {
                        final int commitDelayMs = Math.round(Float.parseFloat(
                                line.substring(strPos + commitTimeStr.length(), endPos)));
                        state.addExtraResult("commitDelayMs", commitDelayMs);
                    }
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /** The test activity runs on a different process to trigger metrics logs. */
    public static class TestActivity extends Activity implements Runnable {
        static final String CALLBACK = "callback";
+0 −8
Original line number Diff line number Diff line
@@ -16,14 +16,6 @@ flag {
    bug: "293491637"
}

flag {
    name: "backup_jobs_exemption"
    is_exported: true
    namespace: "backstage_power"
    description: "Introduce a new RUN_BACKUP_JOBS permission and exemption logic allowing for longer running jobs for apps whose primary purpose is to backup or sync content."
    bug: "318731461"
}

flag {
   name: "handle_abandoned_jobs"
   namespace: "backstage_power"
+1 −1
Original line number Diff line number Diff line
@@ -8905,7 +8905,7 @@ package android.app.appfunctions {
  @FlaggedApi("android.app.appfunctions.flags.enable_app_function_manager") public abstract class AppFunctionService extends android.app.Service {
    ctor public AppFunctionService();
    method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent);
    method @MainThread public abstract void onExecuteFunction(@NonNull android.app.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>);
    method @MainThread public abstract void onExecuteFunction(@NonNull android.app.appfunctions.ExecuteAppFunctionRequest, @NonNull String, @NonNull android.content.pm.SigningInfo, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.app.appfunctions.ExecuteAppFunctionResponse,android.app.appfunctions.AppFunctionException>);
    field @NonNull public static final String SERVICE_INTERFACE = "android.app.appfunctions.AppFunctionService";
  }
+6 −3
Original line number Diff line number Diff line
@@ -581,7 +581,7 @@ package android.accessibilityservice {
package android.accounts {
  public class AccountManager {
    method @FlaggedApi("android.app.admin.flags.split_create_managed_profile_enabled") @NonNull @RequiresPermission(anyOf={android.Manifest.permission.COPY_ACCOUNTS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public android.accounts.AccountManagerFuture<java.lang.Boolean> copyAccountToUser(@NonNull android.accounts.Account, @NonNull android.os.UserHandle, @NonNull android.os.UserHandle, @Nullable android.accounts.AccountManagerCallback<java.lang.Boolean>, @Nullable android.os.Handler);
    method @FlaggedApi("android.app.admin.flags.split_create_managed_profile_enabled") @NonNull @RequiresPermission(anyOf={android.Manifest.permission.COPY_ACCOUNTS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}) public android.accounts.AccountManagerFuture<java.lang.Boolean> copyAccountToUser(@NonNull android.accounts.Account, @NonNull android.os.UserHandle, @NonNull android.os.UserHandle, @Nullable android.os.Handler, @Nullable android.accounts.AccountManagerCallback<java.lang.Boolean>);
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public android.accounts.AccountManagerFuture<android.os.Bundle> finishSessionAsUser(android.os.Bundle, android.app.Activity, android.os.UserHandle, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler);
  }
@@ -15044,6 +15044,7 @@ package android.telephony {
    method public int getCellularIdentifier();
    method public int getNasProtocolMessage();
    method @NonNull public String getPlmn();
    method @FlaggedApi("com.android.internal.telephony.flags.vendor_specific_cellular_identifier_disclosure_indications") public boolean isBenign();
    method public boolean isEmergency();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int CELLULAR_IDENTIFIER_IMEI = 2; // 0x2
@@ -15061,6 +15062,8 @@ package android.telephony {
    field public static final int NAS_PROTOCOL_MESSAGE_IMSI_DETACH_INDICATION = 11; // 0xb
    field public static final int NAS_PROTOCOL_MESSAGE_LOCATION_UPDATE_REQUEST = 5; // 0x5
    field public static final int NAS_PROTOCOL_MESSAGE_REGISTRATION_REQUEST = 7; // 0x7
    field @FlaggedApi("com.android.internal.telephony.flags.vendor_specific_cellular_identifier_disclosure_indications") public static final int NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_FALSE = 12; // 0xc
    field @FlaggedApi("com.android.internal.telephony.flags.vendor_specific_cellular_identifier_disclosure_indications") public static final int NAS_PROTOCOL_MESSAGE_THREAT_IDENTIFIER_TRUE = 13; // 0xd
    field public static final int NAS_PROTOCOL_MESSAGE_TRACKING_AREA_UPDATE_REQUEST = 4; // 0x4
    field public static final int NAS_PROTOCOL_MESSAGE_UNKNOWN = 0; // 0x0
  }
@@ -18567,13 +18570,13 @@ package android.telephony.satellite {
  @FlaggedApi("com.android.internal.telephony.flags.satellite_state_change_listener") public final class SatelliteManager {
    method @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void addAttachRestrictionForCarrier(int, int, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void deprovisionSatellite(@NonNull java.util.List<android.telephony.satellite.SatelliteSubscriberInfo>, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Boolean,android.telephony.satellite.SatelliteManager.SatelliteException>);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void deprovisionSatellite(@NonNull java.util.List<android.telephony.satellite.SatelliteSubscriberInfo>, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telephony.satellite.SatelliteManager.SatelliteException>);
    method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void deprovisionService(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
    method @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") @NonNull @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public java.util.Set<java.lang.Integer> getAttachRestrictionReasonsForCarrier(int);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @NonNull @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int[] getSatelliteDisallowedReasons();
    method @FlaggedApi("com.android.internal.telephony.flags.carrier_enabled_satellite_flag") @NonNull @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public java.util.List<java.lang.String> getSatellitePlmnsForCarrier(int);
    method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void pollPendingDatagrams(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void provisionSatellite(@NonNull java.util.List<android.telephony.satellite.SatelliteSubscriberInfo>, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Boolean,android.telephony.satellite.SatelliteManager.SatelliteException>);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void provisionSatellite(@NonNull java.util.List<android.telephony.satellite.SatelliteSubscriberInfo>, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.telephony.satellite.SatelliteManager.SatelliteException>);
    method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public void provisionService(@NonNull String, @NonNull byte[], @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
    method @FlaggedApi("com.android.internal.telephony.flags.oem_enabled_satellite_flag") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForCapabilitiesChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteCapabilitiesCallback);
    method @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") @RequiresPermission(android.Manifest.permission.SATELLITE_COMMUNICATION) public int registerForCommunicationAccessStateChanged(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.satellite.SatelliteCommunicationAccessStateCallback);
Loading