Skip to content

Commit

Permalink
Merge ZP1A.240313.003
Browse files Browse the repository at this point in the history
Change-Id: I716b9c9a442f1cadbef4b6ca0a3841dbde6a464a
  • Loading branch information
Scott Lobdell committed Mar 27, 2024
2 parents 06d14c3 + 8c96680 commit 5cd3318
Show file tree
Hide file tree
Showing 2,342 changed files with 63,481 additions and 25,593 deletions.
32 changes: 32 additions & 0 deletions AconfigFlags.bp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ aconfig_declarations_group {
"camera_platform_flags_core_java_lib",
"com.android.hardware.input-aconfig-java",
"com.android.input.flags-aconfig-java",
"com.android.internal.compat.flags-aconfig-java",
"com.android.internal.foldables.flags-aconfig-java",
"com.android.internal.pm.pkg.component.flags-aconfig-java",
"com.android.media.flags.bettertogether-aconfig-java",
Expand Down Expand Up @@ -335,6 +336,23 @@ java_aconfig_library {
mode: "exported",
}

cc_aconfig_library {
name: "android.os.flags-aconfig-cc",
aconfig_declarations: "android.os.flags-aconfig",
}

cc_aconfig_library {
name: "android.os.flags-aconfig-cc-test",
aconfig_declarations: "android.os.flags-aconfig",
mode: "test",
}

cc_aconfig_library {
name: "android.os.flags-aconfig-cc-host",
aconfig_declarations: "android.os.flags-aconfig",
host_supported: true,
}

// VirtualDeviceManager
cc_aconfig_library {
name: "android.companion.virtualdevice.flags-aconfig-cc",
Expand Down Expand Up @@ -492,6 +510,13 @@ java_aconfig_library {
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

java_aconfig_library {
name: "android.content.res.flags-aconfig-java-host",
aconfig_declarations: "android.content.res.flags-aconfig",
host_supported: true,
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Media BetterTogether
aconfig_declarations {
name: "com.android.media.flags.bettertogether-aconfig",
Expand Down Expand Up @@ -639,6 +664,13 @@ java_aconfig_library {
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Platform Compat
java_aconfig_library {
name: "com.android.internal.compat.flags-aconfig-java",
aconfig_declarations: "compat_logging_flags",
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// Multi user
aconfig_declarations {
name: "android.multiuser.flags-aconfig",
Expand Down
1 change: 1 addition & 0 deletions Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ java_defaults {
// TODO(b/120066492): remove gps_debug and protolog.conf.json when the build
// system propagates "required" properly.
"gps_debug.conf",
"protolog.conf.json.gz",
"core.protolog.pb",
"framework-res",
// any install dependencies should go into framework-minus-apex-install-dependencies
Expand Down
3 changes: 3 additions & 0 deletions PACKAGE_MANAGER_OWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Bug component: 36137
# Bug template url: https://b.corp.google.com/issues/new?component=36137&template=198919

[email protected]
[email protected]
[email protected]
6 changes: 6 additions & 0 deletions Ravenwood.bp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ java_library {
installable: false,
srcs: [":services.fakes-sources"],
libs: [
"ravenwood-framework",
"services.core.ravenwood",
],
jarjar_rules: ":ravenwood-services-jarjar-rules",
Expand Down Expand Up @@ -204,7 +205,10 @@ android_ravenwood_libgroup {
// Provide runtime versions of utils linked in below
"junit",
"truth",
"flag-junit",
"ravenwood-framework",
"ravenwood-junit-impl",
"ravenwood-junit-impl-flag",
"mockito-ravenwood-prebuilt",
"inline-mockito-ravenwood-prebuilt",
],
Expand All @@ -218,6 +222,8 @@ android_ravenwood_libgroup {
libs: [
"junit",
"truth",
"flag-junit",
"ravenwood-framework",
"ravenwood-junit",
"mockito-ravenwood-prebuilt",
"inline-mockito-ravenwood-prebuilt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import com.android.adservices.service.adselection.AdWithBidArgumentUtil;
import com.android.adservices.service.adselection.CustomAudienceBiddingSignalsArgumentUtil;
import com.android.adservices.service.adselection.CustomAudienceScoringSignalsArgumentUtil;
import com.android.adservices.service.common.NoOpRetryStrategyImpl;
import com.android.adservices.service.js.IsolateSettings;
import com.android.adservices.service.js.JSScriptArgument;
import com.android.adservices.service.js.JSScriptArrayArgument;
Expand Down Expand Up @@ -411,7 +412,8 @@ private static ListenableFuture<String> callJSEngineAsync(
jsScript,
args,
functionName,
IsolateSettings.forMaxHeapSizeEnforcementDisabled());
IsolateSettings.forMaxHeapSizeEnforcementDisabled(),
new NoOpRetryStrategyImpl());
result.addListener(resultLatch::countDown, sExecutorService);
return result;
}
Expand All @@ -430,7 +432,8 @@ private ListenableFuture<String> callJSEngineAsync(
wasmScript,
args,
functionName,
IsolateSettings.forMaxHeapSizeEnforcementDisabled());
IsolateSettings.forMaxHeapSizeEnforcementDisabled(),
new NoOpRetryStrategyImpl());
result.addListener(resultLatch::countDown, sExecutorService);
return result;
}
Expand Down
2 changes: 2 additions & 0 deletions apex/jobscheduler/service/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ java_library {
],

libs: [
"androidx.annotation_annotation",
"app-compat-annotations",
"error_prone_annotations",
"framework",
"services.core",
"unsupportedappusage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
import android.os.PowerManager;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.telephony.TelephonyManager;
import android.telephony.UiccSlotMapping;
import android.util.ArraySet;
import android.util.IndentingPrintWriter;
import android.util.IntArray;
import android.util.KeyValueListParser;
import android.util.Log;
import android.util.Slog;
Expand All @@ -68,6 +71,8 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.function.Predicate;

/**
Expand Down Expand Up @@ -1620,23 +1625,44 @@ private class SpecialAppTracker {
private final Object mSatLock = new Object();

private DeviceIdleInternal mDeviceIdleInternal;
private TelephonyManager mTelephonyManager;

private final boolean mHasFeatureTelephonySubscription;

/** Set of all apps that have been deemed special, keyed by user ID. */
private final SparseSetArray<String> mSpecialApps = new SparseSetArray<>();
/**
* Set of carrier privileged apps, keyed by the logical ID of the SIM their privileged
* for.
*/
@GuardedBy("mSatLock")
private final SparseSetArray<String> mCarrierPrivilegedApps = new SparseSetArray<>();
@GuardedBy("mSatLock")
private final SparseArray<LogicalIndexCarrierPrivilegesCallback>
mCarrierPrivilegedCallbacks = new SparseArray<>();
@GuardedBy("mSatLock")
private final ArraySet<String> mPowerAllowlistedApps = new ArraySet<>();

private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED:
updateCarrierPrivilegedCallbackRegistration();
break;

case PowerManager.ACTION_POWER_SAVE_WHITELIST_CHANGED:
mHandler.post(SpecialAppTracker.this::updatePowerAllowlistCache);
break;
}
}
};

SpecialAppTracker() {
mHasFeatureTelephonySubscription = mContext.getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION);
}

public boolean isSpecialApp(final int userId, @NonNull String packageName) {
synchronized (mSatLock) {
if (mSpecialApps.contains(UserHandle.USER_ALL, packageName)) {
Expand All @@ -1654,6 +1680,12 @@ private boolean isSpecialAppInternal(final int userId, @NonNull String packageNa
if (mPowerAllowlistedApps.contains(packageName)) {
return true;
}
for (int l = mCarrierPrivilegedApps.size() - 1; l >= 0; --l) {
if (mCarrierPrivilegedApps.contains(
mCarrierPrivilegedApps.keyAt(l), packageName)) {
return true;
}
}
}
return false;
}
Expand All @@ -1669,9 +1701,12 @@ private void onAppRemoved(final int userId, String packageName) {

private void onSystemServicesReady() {
mDeviceIdleInternal = LocalServices.getService(DeviceIdleInternal.class);
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);

synchronized (mLock) {
if (mFlexibilityEnabled) {
mHandler.post(
SpecialAppTracker.this::updateCarrierPrivilegedCallbackRegistration);
mHandler.post(SpecialAppTracker.this::updatePowerAllowlistCache);
}
}
Expand All @@ -1686,6 +1721,13 @@ private void onUserRemoved(final int userId) {
private void startTracking() {
IntentFilter filter = new IntentFilter(
PowerManager.ACTION_POWER_SAVE_WHITELIST_CHANGED);

if (mHasFeatureTelephonySubscription) {
filter.addAction(TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED);

updateCarrierPrivilegedCallbackRegistration();
}

mContext.registerReceiver(mBroadcastReceiver, filter);

updatePowerAllowlistCache();
Expand All @@ -1695,9 +1737,61 @@ private void stopTracking() {
mContext.unregisterReceiver(mBroadcastReceiver);

synchronized (mSatLock) {
mCarrierPrivilegedApps.clear();
mPowerAllowlistedApps.clear();
mSpecialApps.clear();

for (int i = mCarrierPrivilegedCallbacks.size() - 1; i >= 0; --i) {
mTelephonyManager.unregisterCarrierPrivilegesCallback(
mCarrierPrivilegedCallbacks.valueAt(i));
}
mCarrierPrivilegedCallbacks.clear();
}
}

private void updateCarrierPrivilegedCallbackRegistration() {
if (mTelephonyManager == null) {
return;
}
if (!mHasFeatureTelephonySubscription) {
return;
}

Collection<UiccSlotMapping> simSlotMapping = mTelephonyManager.getSimSlotMapping();
final ArraySet<String> changedPkgs = new ArraySet<>();
synchronized (mSatLock) {
final IntArray callbacksToRemove = new IntArray();
for (int i = mCarrierPrivilegedCallbacks.size() - 1; i >= 0; --i) {
callbacksToRemove.add(mCarrierPrivilegedCallbacks.keyAt(i));
}
for (UiccSlotMapping mapping : simSlotMapping) {
final int logicalIndex = mapping.getLogicalSlotIndex();
if (mCarrierPrivilegedCallbacks.contains(logicalIndex)) {
// Callback already exists. No need to create a new one or remove it.
callbacksToRemove.remove(logicalIndex);
continue;
}
final LogicalIndexCarrierPrivilegesCallback callback =
new LogicalIndexCarrierPrivilegesCallback(logicalIndex);
mCarrierPrivilegedCallbacks.put(logicalIndex, callback);
// Upon registration, the callbacks will be called with the current list of
// apps, so there's no need to query the app list synchronously.
mTelephonyManager.registerCarrierPrivilegesCallback(logicalIndex,
AppSchedulingModuleThread.getExecutor(), callback);
}

for (int i = callbacksToRemove.size() - 1; i >= 0; --i) {
final int logicalIndex = callbacksToRemove.get(i);
final LogicalIndexCarrierPrivilegesCallback callback =
mCarrierPrivilegedCallbacks.get(logicalIndex);
mTelephonyManager.unregisterCarrierPrivilegesCallback(callback);
mCarrierPrivilegedCallbacks.remove(logicalIndex);
changedPkgs.addAll(mCarrierPrivilegedApps.get(logicalIndex));
mCarrierPrivilegedApps.remove(logicalIndex);
}
}

updateSpecialAppSetUnlocked(UserHandle.USER_ALL, changedPkgs);
}

/**
Expand Down Expand Up @@ -1762,17 +1856,64 @@ private void updatePowerAllowlistCache() {
updateSpecialAppSetUnlocked(UserHandle.USER_ALL, changedPkgs);
}

class LogicalIndexCarrierPrivilegesCallback implements
TelephonyManager.CarrierPrivilegesCallback {
public final int logicalIndex;

LogicalIndexCarrierPrivilegesCallback(int logicalIndex) {
this.logicalIndex = logicalIndex;
}

@Override
public void onCarrierPrivilegesChanged(@NonNull Set<String> privilegedPackageNames,
@NonNull Set<Integer> privilegedUids) {
final ArraySet<String> changedPkgs = new ArraySet<>();
synchronized (mSatLock) {
final ArraySet<String> oldPrivilegedSet =
mCarrierPrivilegedApps.get(logicalIndex);
if (oldPrivilegedSet != null) {
changedPkgs.addAll(oldPrivilegedSet);
mCarrierPrivilegedApps.remove(logicalIndex);
}
for (String pkgName : privilegedPackageNames) {
mCarrierPrivilegedApps.add(logicalIndex, pkgName);
if (!changedPkgs.remove(pkgName)) {
// The package wasn't in the previous set of privileged apps. Add it
// since its state has changed.
changedPkgs.add(pkgName);
}
}
}

// The carrier privileged list doesn't provide a simple userId correlation,
// so for now, use USER_ALL for these packages.
// TODO(141645789): use the UID list to narrow down to specific userIds
updateSpecialAppSetUnlocked(UserHandle.USER_ALL, changedPkgs);
}
}

public void dump(@NonNull IndentingPrintWriter pw) {
pw.println("Special apps:");
pw.increaseIndent();

synchronized (mSatLock) {
for (int u = 0; u < mSpecialApps.size(); ++u) {
pw.print("User ");
pw.print(mSpecialApps.keyAt(u));
pw.print(": ");
pw.println(mSpecialApps.valuesAt(u));
}

pw.println();
pw.println("Carrier privileged packages:");
pw.increaseIndent();
for (int i = 0; i < mCarrierPrivilegedApps.size(); ++i) {
pw.print(mCarrierPrivilegedApps.keyAt(i));
pw.print(": ");
pw.println(mCarrierPrivilegedApps.valuesAt(i));
}
pw.decreaseIndent();

pw.println();
pw.print("Power allowlisted packages: ");
pw.println(mPowerAllowlistedApps);
Expand Down
Loading

0 comments on commit 5cd3318

Please sign in to comment.