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

Commit 20dd0037 authored by Pinyao Ting's avatar Pinyao Ting Committed by Android (Google) Code Review
Browse files

Merge "Break the dependency between non-persistent user and shortcut users." into sc-dev

parents 31a5fc49 fe92808b
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -270,6 +270,7 @@ public class ShortcutService extends IShortcutService.Stub {
    final Context mContext;

    private final Object mLock = new Object();
    private final Object mNonPersistentUsersLock = new Object();

    private static List<ResolveInfo> EMPTY_RESOLVE_INFO = new ArrayList<>(0);

@@ -310,8 +311,10 @@ public class ShortcutService extends IShortcutService.Stub {

    /**
     * User ID -> ShortcutNonPersistentUser
     *
     * Note we use a fine-grained lock for {@link #mShortcutNonPersistentUsers} due to b/183618378.
     */
    @GuardedBy("mLock")
    @GuardedBy("mNonPersistentUsersLock")
    private final SparseArray<ShortcutNonPersistentUser> mShortcutNonPersistentUsers =
            new SparseArray<>();

@@ -1308,7 +1311,7 @@ public class ShortcutService extends IShortcutService.Stub {
    }

    /** Return the non-persistent per-user state. */
    @GuardedBy("mLock")
    @GuardedBy("mNonPersistentUsersLock")
    @NonNull
    ShortcutNonPersistentUser getNonPersistentUserLocked(@UserIdInt int userId) {
        ShortcutNonPersistentUser ret = mShortcutNonPersistentUsers.get(userId);
@@ -2748,7 +2751,7 @@ public class ShortcutService extends IShortcutService.Stub {
        if (injectHasAccessShortcutsPermission(callingPid, callingUid)) {
            return true;
        }
        synchronized (mLock) {
        synchronized (mNonPersistentUsersLock) {
            return getNonPersistentUserLocked(userId).hasHostPackage(callingPackage);
        }
    }
@@ -2831,7 +2834,7 @@ public class ShortcutService extends IShortcutService.Stub {

    public void setShortcutHostPackage(@NonNull String type, @Nullable String packageName,
            int userId) {
        synchronized (mLock) {
        synchronized (mNonPersistentUsersLock) {
            getNonPersistentUserLocked(userId).setShortcutHostPackage(type, packageName);
        }
    }
+3 −1
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import android.app.appsearch.IAppSearchManager;
import android.app.appsearch.IAppSearchResultCallback;
import android.app.appsearch.PackageIdentifier;
import android.app.appsearch.SearchResultPage;
import android.app.appsearch.SetSchemaResponse;
import android.app.role.OnRoleHoldersChangedListener;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ActivityNotFoundException;
@@ -672,7 +673,8 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
                    packageIdentifiers.add(new PackageIdentifier(entry.getValue().get(i)));
                }
            }
            callback.onResult(AppSearchResult.newSuccessfulResult(null));
            final SetSchemaResponse response = new SetSchemaResponse.Builder().build();
            callback.onResult(AppSearchResult.newSuccessfulResult(response.getBundle()));
        }

        @Override