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

Commit c364d9f7 authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Cleanup separatePermissionNotifications flag" into main

parents d283aa42 fe8e6c37
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -71,14 +71,6 @@ import java.util.concurrent.atomic.AtomicLong;
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class PropertyInvalidatedCache<Query, Result> {
    /**
     * A method to report if the PermissionManager notifications can be separated from cache
     * invalidation.  The feature relies on a series of flags, all of which are committed.
     * @hide
     */
    public static boolean separatePermissionNotificationsEnabled() {
        return true;
    }

    /**
     * This is a configuration class that customizes a cache instance.
+3 −31
Original line number Diff line number Diff line
@@ -1820,40 +1820,12 @@ public final class PermissionManager {
        }
    }

    // The legacy system property "package_info" had two purposes: to invalidate PIC caches and to
    // signal that package information, and therefore permissions, might have changed.
    // AudioSystem is the only client of the signaling behavior.  The "separate permissions
    // notification" feature splits the two behaviors into two system property names.
    //
    // If the feature is disabled (legacy behavior) then the two system property names have the
    // same value.  This means there is only one system property in use.
    //
    // If the feature is enabled, then the two system property names have different values, which
    // means there is a system property used by PIC and a system property used for signaling.  The
    // legacy value is hard-coded in native code that relies on the signaling behavior, so the
    // system property name for signaling is the legacy property name, and the system property
    // name for PIC is new.
    private static String getPackageInfoCacheKey() {
        if (PropertyInvalidatedCache.separatePermissionNotificationsEnabled()) {
            return PropertyInvalidatedCache.createSystemCacheKey("package_info_cache");
        } else {
            return CACHE_KEY_PACKAGE_INFO_NOTIFY;
        }
    }

    /**
     * The system property that is used to notify clients that package information, and therefore
     * permissions, may have changed.
     * @hide
     */
    public static final String CACHE_KEY_PACKAGE_INFO_NOTIFY =
            PropertyInvalidatedCache.createSystemCacheKey("package_info");

    /**
     * The system property that is used to invalidate PIC caches.
     * The PropertyInvalidatedCache key for invalidating caches.
     * @hide
     */
    public static final String CACHE_KEY_PACKAGE_INFO_CACHE = getPackageInfoCacheKey();
    public static final String CACHE_KEY_PACKAGE_INFO_CACHE =
            PropertyInvalidatedCache.createSystemCacheKey("package_info_cache");

    /** @hide */
    private static final PropertyInvalidatedCache<PermissionQuery, Integer> sPermissionCache =
+6 −20
Original line number Diff line number Diff line
@@ -11604,8 +11604,9 @@ public class AudioService extends IAudioService.Stub
    /* Listen to permission invalidations for the PermissionProvider */
    private void setupPermissionListener()  {
        // instanceof to simplify the construction requirements of AudioService for testing: no
        // delayed execution during unit tests.
        // Use instanceof to simplify the construction requirements of AudioService for testing:
        // If not using a scheduled executor service, AudioService was constructed for unit tests,
        // so don't listen for and propagate permission changes to audioserver.
        if (mAudioServerLifecycleExecutor instanceof ScheduledExecutorService exec) {
            // The order on the task list is an embedding on the scheduling order of the executor,
            // since we synchronously add the scheduled task to our local queue. This list should
@@ -11648,19 +11649,8 @@ public class AudioService extends IAudioService.Stub
                    }, getAudioPermissionsDelay(), TimeUnit.MILLISECONDS));
                }
            };
            if (PropertyInvalidatedCache.separatePermissionNotificationsEnabled()) {
            mCacheWatcher = new CacheWatcher(task);
            mCacheWatcher.start();
            } else {
                mSysPropListenerNativeHandle = mAudioSystem.listenForSystemPropertyChange(
                        PermissionManager.CACHE_KEY_PACKAGE_INFO_NOTIFY,
                        task);
            }
        } else {
            mAudioSystem.listenForSystemPropertyChange(
                    PermissionManager.CACHE_KEY_PACKAGE_INFO_NOTIFY,
                    () -> mAudioServerLifecycleExecutor.execute(
                                mPermissionProvider::onPermissionStateChanged));
        }
    }
@@ -15863,11 +15853,7 @@ public class AudioService extends IAudioService.Stub
    /** @see AudioManager#permissionUpdateBarrier() */
    public void permissionUpdateBarrier() {
        if (!audioserverPermissions()) return;
        if (PropertyInvalidatedCache.separatePermissionNotificationsEnabled()) {
        mCacheWatcher.doCheck();
        } else {
            mAudioSystem.triggerSystemPropertyUpdate(mSysPropListenerNativeHandle);
        }
        List<Future> snapshot;
        synchronized (mScheduledPermissionTasks) {
            snapshot = List.copyOf(mScheduledPermissionTasks);