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

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

Merge changes Ia2bff16b,I0b17c3e8,Icc4a8190,I9b6ad0b3

* changes:
  Support for Watchable verification
  PackageManager lock reduction: IntentResolver
  PackageManager lock reduction: Settings on-change
  New watchables for PackageManagerService
parents e24129be e5371006
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -839,14 +839,22 @@ public abstract class IntentResolver<F, R extends Object> {
        }
    };

    // Make <this> a copy of <orig>.  The presumption is that <this> is empty.
    protected void doCopy(IntentResolver orig) {
    // Make <this> a copy of <orig>.  The presumption is that <this> is empty but all
    // arrays are cleared out explicitly, just to be sure.
    protected void copyFrom(IntentResolver orig) {
        mFilters.clear();
        mFilters.addAll(orig.mFilters);
        mTypeToFilter.clear();
        mTypeToFilter.putAll(orig.mTypeToFilter);
        mBaseTypeToFilter.clear();
        mBaseTypeToFilter.putAll(orig.mBaseTypeToFilter);
        mWildTypeToFilter.clear();
        mWildTypeToFilter.putAll(orig.mWildTypeToFilter);
        mSchemeToFilter.clear();
        mSchemeToFilter.putAll(orig.mSchemeToFilter);
        mActionToFilter.clear();
        mActionToFilter.putAll(orig.mActionToFilter);
        mTypedActionToFilter.clear();
        mTypedActionToFilter.putAll(orig.mTypedActionToFilter);
    }

+21 −2
Original line number Diff line number Diff line
@@ -14,12 +14,14 @@
 * limitations under the License.
 */

package com.android.server.utils;
package com.android.server;

import android.annotation.NonNull;
import android.annotation.Nullable;

import com.android.server.IntentResolver;
import com.android.server.utils.Watchable;
import com.android.server.utils.WatchableImpl;
import com.android.server.utils.Watcher;

import java.util.List;

@@ -37,28 +39,45 @@ public abstract class WatchableIntentResolver<F, R extends Object>
     * Watchable machinery
     */
    private final Watchable mWatchable = new WatchableImpl();

    /**
     * Register an observer to receive change notifications.
     * @param observer The observer to register.
     */
    @Override
    public void registerObserver(@NonNull Watcher observer) {
        mWatchable.registerObserver(observer);
    }

    /**
     * Unregister the observer, which will no longer receive change notifications.
     * @param observer The observer to unregister.
     */
    @Override
    public void unregisterObserver(@NonNull Watcher observer) {
        mWatchable.unregisterObserver(observer);
    }

    /**
     * Return true if the {@link Watcher) is a registered observer.
     * @param observer A {@link Watcher} that might be registered
     * @return true if the observer is registered with this {@link Watchable}.
     */
    @Override
    public boolean isRegisteredObserver(@NonNull Watcher observer) {
        return mWatchable.isRegisteredObserver(observer);
    }

    /**
     * Notify listeners that the object has changd.  The argument is a hint as to the
     * source of the change.
     * @param what The attribute or sub-object that changed, if not null.
     */
    @Override
    public void dispatchChange(@Nullable Watchable what) {
        mWatchable.dispatchChange(what);
    }

    /**
     * Notify listeners that this object has changed.
     */
+15 −2
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ public class AppsFilter implements Watchable, Snappable {
     *
     * @param observer The {@link Watcher} to be notified when the {@link Watchable} changes.
     */
    @Override
    public void registerObserver(@NonNull Watcher observer) {
        mWatchable.registerObserver(observer);
    }
@@ -177,10 +178,21 @@ public class AppsFilter implements Watchable, Snappable {
     *
     * @param observer The {@link Watcher} that should not be in the notification list.
     */
    @Override
    public void unregisterObserver(@NonNull Watcher observer) {
        mWatchable.unregisterObserver(observer);
    }

    /**
     * Return true if the {@link Watcher) is a registered observer.
     * @param observer A {@link Watcher} that might be registered
     * @return true if the observer is registered with this {@link Watchable}.
     */
    @Override
    public boolean isRegisteredObserver(@NonNull Watcher observer) {
        return mWatchable.isRegisteredObserver(observer);
    }

    /**
     * Invokes {@link Watcher#onChange} on each registered observer.  The method can be called
     * with the {@link Watchable} that generated the event.  In a tree of {@link Watchable}s, this
@@ -188,6 +200,7 @@ public class AppsFilter implements Watchable, Snappable {
     *
     * @param what The {@link Watchable} that generated the event.
     */
    @Override
    public void dispatchChange(@Nullable Watchable what) {
        mSnapshot = null;
        mWatchable.dispatchChange(what);
@@ -443,7 +456,7 @@ public class AppsFilter implements Watchable, Snappable {
        }
        final StateProvider stateProvider = command -> {
            synchronized (injector.getLock()) {
                command.currentState(injector.getSettings().getPackagesLocked().untrackedMap(),
                command.currentState(injector.getSettings().getPackagesLocked().untrackedStorage(),
                        injector.getUserManagerInternal().getUserInfos());
            }
        };
@@ -979,7 +992,7 @@ public class AppsFilter implements Watchable, Snappable {
    @Nullable
    SparseArray<int[]> getVisibilityAllowList(PackageSetting setting, int[] users,
            WatchedArrayMap<String, PackageSetting> existingSettings) {
        return getVisibilityAllowList(setting, users, existingSettings.untrackedMap());
        return getVisibilityAllowList(setting, users, existingSettings.untrackedStorage());
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.server.pm;
import android.annotation.NonNull;
import android.content.IntentFilter;

import com.android.server.WatchableIntentResolver;
import com.android.server.utils.Snappable;
import com.android.server.utils.WatchableIntentResolver;

import java.util.List;

@@ -57,7 +57,7 @@ class CrossProfileIntentResolver
     */
    public CrossProfileIntentResolver snapshot() {
        CrossProfileIntentResolver result = new CrossProfileIntentResolver();
        result.doCopy(this);
        result.copyFrom(this);
        return result;
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -154,6 +154,9 @@ class InstantAppRegistry implements Watchable, Snappable {
    public void unregisterObserver(@NonNull Watcher observer) {
        mWatchable.unregisterObserver(observer);
    }
    public boolean isRegisteredObserver(@NonNull Watcher observer) {
        return mWatchable.isRegisteredObserver(observer);
    }
    public void dispatchChange(@Nullable Watchable what) {
        mSnapshot = null;
        mWatchable.dispatchChange(what);
Loading