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

Commit 72c34b6a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11540345 from b50089ae to 24Q3-release

Change-Id: I4fd0123d64612ab0ec4b979b37cb60b7d6299dcc
parents 9ecbac94 b50089ae
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
# Bug component: 36137
# Bug template url: https://b.corp.google.com/issues/new?component=36137&template=198919

alexbuy@google.com
patb@google.com
schfan@google.com
 No newline at end of file
+141 −0
Original line number Diff line number Diff line
@@ -46,8 +46,11 @@ import android.os.Message;
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;
@@ -68,6 +71,8 @@ import com.android.server.utils.AlarmQueue;

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

/**
@@ -1620,9 +1625,21 @@ public final class FlexibilityController extends StateController {
        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<>();

@@ -1630,6 +1647,10 @@ public final class FlexibilityController extends StateController {
            @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;
@@ -1637,6 +1658,11 @@ public final class FlexibilityController extends StateController {
            }
        };

        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)) {
@@ -1654,6 +1680,12 @@ public final class FlexibilityController extends StateController {
                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;
        }
@@ -1669,9 +1701,12 @@ public final class FlexibilityController extends StateController {

        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);
                }
            }
@@ -1686,6 +1721,13 @@ public final class FlexibilityController extends StateController {
        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();
@@ -1695,9 +1737,61 @@ public final class FlexibilityController extends StateController {
            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);
        }

        /**
@@ -1762,17 +1856,64 @@ public final class FlexibilityController extends StateController {
            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);
+23 −12
Original line number Diff line number Diff line
@@ -298,6 +298,28 @@ packages_to_document = [
    "org.xmlpull",
]

// These are libs from framework-internal-utils that are required (i.e. being referenced)
// from framework-non-updatable-sources. Add more here when there's a need.
// DO NOT add the entire framework-internal-utils. It might cause unnecessary circular
// dependencies gets bigger.
android_non_updatable_stubs_libs = [
    "android.hardware.cas-V1.2-java",
    "android.hardware.health-V1.0-java-constants",
    "android.hardware.thermal-V1.0-java-constants",
    "android.hardware.thermal-V2.0-java",
    "android.hardware.tv.input-V1.0-java-constants",
    "android.hardware.usb-V1.0-java-constants",
    "android.hardware.usb-V1.1-java-constants",
    "android.hardware.usb.gadget-V1.0-java",
    "android.hardware.vibrator-V1.3-java",
    "framework-protos",
]

java_defaults {
    name: "android-non-updatable-stubs-libs-defaults",
    libs: android_non_updatable_stubs_libs,
}

// Defaults for all stubs that include the non-updatable framework. These defaults do not include
// module symbols, so will not compile correctly on their own. Users must add module APIs to the
// classpath (or sources) somehow.
@@ -329,18 +351,7 @@ stubs_defaults {
    // from framework-non-updatable-sources. Add more here when there's a need.
    // DO NOT add the entire framework-internal-utils. It might cause unnecessary circular
    // dependencies gets bigger.
    libs: [
        "android.hardware.cas-V1.2-java",
        "android.hardware.health-V1.0-java-constants",
        "android.hardware.thermal-V1.0-java-constants",
        "android.hardware.thermal-V2.0-java",
        "android.hardware.tv.input-V1.0-java-constants",
        "android.hardware.usb-V1.0-java-constants",
        "android.hardware.usb-V1.1-java-constants",
        "android.hardware.usb.gadget-V1.0-java",
        "android.hardware.vibrator-V1.3-java",
        "framework-protos",
    ],
    libs: android_non_updatable_stubs_libs,
    flags: [
        "--error NoSettingsProvider",
        "--error UnhiddenSystemApi",
+21 −21
Original line number Diff line number Diff line
@@ -5395,7 +5395,7 @@ package android.app {
  public final class AutomaticZenRule implements android.os.Parcelable {
    ctor @Deprecated public AutomaticZenRule(String, android.content.ComponentName, android.net.Uri, int, boolean);
    ctor public AutomaticZenRule(@NonNull String, @Nullable android.content.ComponentName, @Nullable android.content.ComponentName, @NonNull android.net.Uri, @Nullable android.service.notification.ZenPolicy, int, boolean);
    ctor @Deprecated public AutomaticZenRule(@NonNull String, @Nullable android.content.ComponentName, @Nullable android.content.ComponentName, @NonNull android.net.Uri, @Nullable android.service.notification.ZenPolicy, int, boolean);
    ctor public AutomaticZenRule(android.os.Parcel);
    method public int describeContents();
    method public android.net.Uri getConditionId();
@@ -6085,7 +6085,7 @@ package android.app {
  public class GrammaticalInflectionManager {
    method public int getApplicationGrammaticalGender();
    method @FlaggedApi("android.app.system_terms_of_address_enabled") public int getSystemGrammaticalGender();
    method @FlaggedApi("android.app.system_terms_of_address_enabled") @RequiresPermission("android.permission.READ_SYSTEM_GRAMMATICAL_GENDER") public int getSystemGrammaticalGender();
    method public void setRequestedApplicationGrammaticalGender(int);
  }
@@ -6674,9 +6674,9 @@ package android.app {
    method @Deprecated public android.app.Notification.Builder addPerson(String);
    method @NonNull public android.app.Notification.Builder addPerson(android.app.Person);
    method @NonNull public android.app.Notification build();
    method public android.widget.RemoteViews createBigContentView();
    method public android.widget.RemoteViews createContentView();
    method public android.widget.RemoteViews createHeadsUpContentView();
    method @Deprecated public android.widget.RemoteViews createBigContentView();
    method @Deprecated public android.widget.RemoteViews createContentView();
    method @Deprecated public android.widget.RemoteViews createHeadsUpContentView();
    method @NonNull public android.app.Notification.Builder extend(android.app.Notification.Extender);
    method public android.os.Bundle getExtras();
    method @Deprecated public android.app.Notification getNotification();
@@ -15708,7 +15708,7 @@ package android.graphics {
    method public boolean clipRect(int, int, int, int);
    method @FlaggedApi("com.android.graphics.hwui.flags.clip_shader") public void clipShader(@NonNull android.graphics.Shader);
    method public void concat(@Nullable android.graphics.Matrix);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void concat44(@Nullable android.graphics.Matrix44);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void concat(@Nullable android.graphics.Matrix44);
    method public void disableZ();
    method public void drawARGB(int, int, int, int);
    method public void drawArc(@NonNull android.graphics.RectF, float, float, boolean, @NonNull android.graphics.Paint);
@@ -16361,7 +16361,7 @@ package android.graphics {
    ctor @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public Matrix44();
    ctor @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public Matrix44(@NonNull android.graphics.Matrix);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 concat(@NonNull android.graphics.Matrix44);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public float get(int, int);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public float get(@IntRange(from=0, to=3) int, @IntRange(from=0, to=3) int);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void getValues(@NonNull float[]);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public boolean invert();
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public boolean isIdentity();
@@ -16370,7 +16370,7 @@ package android.graphics {
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void reset();
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 rotate(float, float, float, float);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 scale(float, float, float);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void set(int, int, float);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void set(@IntRange(from=0, to=3) int, @IntRange(from=0, to=3) int, float);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") public void setValues(@NonNull float[]);
    method @FlaggedApi("com.android.graphics.hwui.flags.matrix_44") @NonNull public android.graphics.Matrix44 translate(float, float, float);
  }
@@ -41153,19 +41153,19 @@ package android.service.notification {
    method public final android.service.notification.StatusBarNotification[] getSnoozedNotifications();
    method public final void migrateNotificationFilter(int, @Nullable java.util.List<java.lang.String>);
    method public android.os.IBinder onBind(android.content.Intent);
    method public void onInterruptionFilterChanged(int);
    method public void onListenerConnected();
    method public void onListenerDisconnected();
    method public void onListenerHintsChanged(int);
    method public void onNotificationChannelGroupModified(String, android.os.UserHandle, android.app.NotificationChannelGroup, int);
    method public void onNotificationChannelModified(String, android.os.UserHandle, android.app.NotificationChannel, int);
    method public void onNotificationPosted(android.service.notification.StatusBarNotification);
    method public void onNotificationPosted(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
    method public void onNotificationRankingUpdate(android.service.notification.NotificationListenerService.RankingMap);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, int);
    method public void onSilentStatusBarIconsVisibilityChanged(boolean);
    method @UiThread public void onInterruptionFilterChanged(int);
    method @UiThread public void onListenerConnected();
    method @UiThread public void onListenerDisconnected();
    method @UiThread public void onListenerHintsChanged(int);
    method @UiThread public void onNotificationChannelGroupModified(String, android.os.UserHandle, android.app.NotificationChannelGroup, int);
    method @UiThread public void onNotificationChannelModified(String, android.os.UserHandle, android.app.NotificationChannel, int);
    method @UiThread public void onNotificationPosted(android.service.notification.StatusBarNotification);
    method @UiThread public void onNotificationPosted(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
    method @UiThread public void onNotificationRankingUpdate(android.service.notification.NotificationListenerService.RankingMap);
    method @UiThread public void onNotificationRemoved(android.service.notification.StatusBarNotification);
    method @UiThread public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
    method @UiThread public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, int);
    method @UiThread public void onSilentStatusBarIconsVisibilityChanged(boolean);
    method public final void requestInterruptionFilter(int);
    method public final void requestListenerHints(int);
    method public static void requestRebind(android.content.ComponentName);
+46 −35

File changed.

Preview size limit exceeded, changes collapsed.

Loading