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

Commit 04c42c87 authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

Merge "Don\'t cache QS custom tiles across users" into nyc-dev

am: e7e4b3d8

* commit 'e7e4b3d8':
  Don't cache QS custom tiles across users
parents 5ebf4f3a e7e4b3d8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class CustomTile extends QSTile<QSTile.State> {
    private final IBinder mToken = new Binder();
    private final IQSTileService mService;
    private final TileServiceManager mServiceManager;
    private final int mUser;

    private boolean mListening;
    private boolean mBound;
@@ -71,6 +72,7 @@ public class CustomTile extends QSTile<QSTile.State> {
        mServiceManager = host.getTileServices().getTileWrapper(this);
        mService = mServiceManager.getTileService();
        mTile = new Tile(mComponent);
        mUser = ActivityManager.getCurrentUser();
        try {
            PackageManager pm = mContext.getPackageManager();
            ServiceInfo info = pm.getServiceInfo(mComponent, 0);
@@ -86,6 +88,10 @@ public class CustomTile extends QSTile<QSTile.State> {
        }
    }

    public int getUser() {
        return mUser;
    }

    public ComponentName getComponent() {
        return mComponent;
    }
+4 −3
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements
        mHandler = handler;
        mIntent = intent;
        mUser = user;
        if (DEBUG) Log.d(TAG, "Creating " + mIntent + " " + mUser);
    }

    public ComponentName getComponent() {
@@ -116,13 +117,13 @@ public class TileLifecycleManager extends BroadcastReceiver implements
            if (!checkComponentState()) {
                return;
            }
            if (DEBUG) Log.d(TAG, "Binding service " + mIntent);
            if (DEBUG) Log.d(TAG, "Binding service " + mIntent + " " + mUser);
            mBindTryCount++;
            mContext.bindServiceAsUser(mIntent, this,
                    Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
                    mUser);
        } else {
            if (DEBUG) Log.d(TAG, "Unbinding service " + mIntent);
            if (DEBUG) Log.d(TAG, "Unbinding service " + mIntent + " " + mUser);
            // Give it another chance next time it needs to be bound, out of kindness.
            mBindTryCount = 0;
            mWrapper = null;
@@ -350,7 +351,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements

    @Override
    public void onClick(IBinder iBinder) {
        if (DEBUG) Log.d(TAG, "onClick " + iBinder);
        if (DEBUG) Log.d(TAG, "onClick " + iBinder + " " + mUser);
        if (mWrapper == null || !mWrapper.onClick(iBinder)) {
            mClickBinder = iBinder;
            queueMessage(MSG_ON_CLICK);
+8 −4
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ public final class QSTileHost implements QSTile.Host, Tunable {
    private final ManagedProfileController mProfileController;
    private final NextAlarmController mNextAlarmController;
    private View mHeader;
    private int mCurrentUser;

    public QSTileHost(Context context, PhoneStatusBar statusBar,
            BluetoothController bluetooth, LocationController location,
@@ -320,7 +321,8 @@ public final class QSTileHost implements QSTile.Host, Tunable {
        }
        if (DEBUG) Log.d(TAG, "Recreating tiles");
        final List<String> tileSpecs = loadTileSpecs(mContext, newValue);
        if (tileSpecs.equals(mTileSpecs)) return;
        int currentUser = ActivityManager.getCurrentUser();
        if (tileSpecs.equals(mTileSpecs) && currentUser == mCurrentUser) return;
        for (Map.Entry<String, QSTile<?>> tile : mTiles.entrySet()) {
            if (!tileSpecs.contains(tile.getKey())) {
                if (DEBUG) Log.d(TAG, "Destroying tile: " + tile.getKey());
@@ -329,15 +331,16 @@ public final class QSTileHost implements QSTile.Host, Tunable {
        }
        final LinkedHashMap<String, QSTile<?>> newTiles = new LinkedHashMap<>();
        for (String tileSpec : tileSpecs) {
            if (mTiles.containsKey(tileSpec)) {
            QSTile<?> tile = mTiles.get(tileSpec);
            if (tile != null && (!(tile instanceof CustomTile)
                    || ((CustomTile) tile).getUser() == currentUser)) {
                if (DEBUG) Log.d(TAG, "Adding " + tile);
                tile.removeCallbacks();
                newTiles.put(tileSpec, tile);
            } else {
                if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec);
                try {
                    QSTile<?> tile = createTile(tileSpec);
                    tile = createTile(tileSpec);
                    if (tile != null && tile.isAvailable()) {
                        tile.setTileSpec(tileSpec);
                        newTiles.put(tileSpec, tile);
@@ -347,6 +350,7 @@ public final class QSTileHost implements QSTile.Host, Tunable {
                }
            }
        }
        mCurrentUser = currentUser;
        mTileSpecs.clear();
        mTileSpecs.addAll(tileSpecs);
        mTiles.clear();