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

Commit 7e53f20c authored by Jason Monk's avatar Jason Monk
Browse files

Add some cmds for statusbar

They will be used for tests?!

Also move around where some of the tile lifecycle happens so that
it can easily be shared with these commands.

Change-Id: I72386afce5a2d335df45ecc5946679efcd826bae
parent b61437de
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.statusbar;

import android.content.ComponentName;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;

@@ -88,4 +89,8 @@ oneway interface IStatusBar
     * Picture-in-picture overlay menu will be shown instead otherwise.
     */
    void requestTvPictureInPicture();

    void addQsTile(in ComponentName tile);
    void remQsTile(in ComponentName tile);
    void clickQsTile(in ComponentName tile);
}
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.statusbar;

import android.content.ComponentName;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;

@@ -103,4 +104,8 @@ interface IStatusBarService
     * Picture-in-picture overlay menu will be shown instead otherwise.
     */
    void requestTvPictureInPicture();

    void addTile(in ComponentName tile);
    void remTile(in ComponentName tile);
    void clickTile(in ComponentName tile);
}
+13 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.qs;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -41,6 +42,7 @@ import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile.DetailAdapter;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.qs.external.CustomTile;
import com.android.systemui.settings.BrightnessController;
import com.android.systemui.settings.ToggleSlider;
import com.android.systemui.statusbar.phone.QSTileHost;
@@ -538,6 +540,17 @@ public class QSPanel extends FrameLayout implements Tunable {
        fireScanStateChanged(scanState);
    }

    public void clickTile(ComponentName tile) {
        final String spec = CustomTile.toSpec(tile);
        final int N = mRecords.size();
        for (int i = 0; i < N; i++) {
            if (mRecords.get(i).tile.getTileSpec().equals(spec)) {
                mRecords.get(i).tile.click();
                break;
            }
        }
    }

    private class H extends Handler {
        private static final int SHOW_DETAIL = 1;
        private static final int SET_TILE_VISIBILITY = 2;
+1 −26
Original line number Diff line number Diff line
@@ -122,32 +122,7 @@ public class CustomQSPanel extends QSPanel {
    }

    public void saveCurrentTiles() {
        for (int i = 0; i < mSavedTiles.size(); i++) {
            String tileSpec = mSavedTiles.get(i);
            if (!tileSpec.startsWith(CustomTile.PREFIX)) continue;
            if (!mTiles.contains(tileSpec)) {
                Intent intent = new Intent().setComponent(CustomTile.getComponentFromSpec(tileSpec));
                TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
                        mContext, intent, new UserHandle(ActivityManager.getCurrentUser()));
                lifecycleManager.onStopListening();
                lifecycleManager.onTileRemoved();
                lifecycleManager.flushMessagesAndUnbind();
            }
        }
        for (int i = 0; i < mTiles.size(); i++) {
            String tileSpec = mTiles.get(i);
            if (!tileSpec.startsWith(CustomTile.PREFIX)) continue;
            if (!mSavedTiles.contains(tileSpec)) {
                Intent intent = new Intent().setComponent(CustomTile.getComponentFromSpec(tileSpec));
                TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
                        mContext, intent, new UserHandle(ActivityManager.getCurrentUser()));
                lifecycleManager.onTileAdded();
                lifecycleManager.flushMessagesAndUnbind();
            }
        }
        if (DEBUG) Log.d(TAG, "saveCurrentTiles " + mTiles);
        Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING,
                TextUtils.join(",", mTiles), ActivityManager.getCurrentUser());
        mHost.changeTiles(mSavedTiles, mTiles);
    }

    public void stashCurrentTiles() {
+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ public class TileAdapter extends BaseAdapter {
            for (ResolveInfo info : services) {
                String packageName = info.serviceInfo.packageName;
                ComponentName componentName = new ComponentName(packageName, info.serviceInfo.name);
                String spec = CustomTile.PREFIX + componentName.flattenToShortString() + ")";
                String spec = CustomTile.toSpec(componentName);
                if (mCurrentTiles.contains(spec)) {
                    continue;
                }
Loading