Some tiles are statically not available on boot, etc.
based on hardware availability or settings, but most
are just always visible.
Change-Id: Ib1a45ef5b029fe710f9957cb997496dcb14f5875
</intent-filter>
</receiver>
- <receiver android:name=".qs.tiles.HotspotTile$APChangedReceiver"
- androidprv:systemUserOnly="true">
- <intent-filter>
- <action android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
- </intent-filter>
- </receiver>
-
<activity android:name=".tuner.TunerActivity"
android:enabled="false"
android:icon="@drawable/tuner"
}
@Override
- public void setTileVisibility(TileRecord tile, int visibility) {
- tile.tileView.setVisibility(visibility);
- }
-
- @Override
public void addTile(TileRecord tile) {
mTiles.add(tile);
distributeTiles();
mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget();
}
- private void setTileVisibility(TileRecord record, int visibility) {
- mHandler.obtainMessage(H.SET_TILE_VISIBILITY, visibility, 0, record).sendToTarget();
- }
-
- private void handleSetTileVisibility(TileRecord tile, int visibility) {
- if (visibility == tile.tileView.getVisibility()) return;
- mTileLayout.setTileVisibility(tile, visibility);
- }
-
public void setTiles(Collection<QSTile<?>> tiles) {
for (TileRecord record : mRecords) {
mTileLayout.removeTile(record);
}
private void drawTile(TileRecord r, QSTile.State state) {
- final int visibility = state.visible ? VISIBLE : GONE;
- setTileVisibility(r, visibility);
r.tileView.onStateChanged(state);
}
final TileRecord r = new TileRecord();
r.tile = tile;
r.tileView = createTileView(tile);
- r.tileView.setVisibility(View.GONE);
final QSTile.Callback callback = new QSTile.Callback() {
@Override
public void onStateChanged(QSTile.State state) {
private void logTiles() {
for (int i = 0; i < mRecords.size(); i++) {
TileRecord tileRecord = mRecords.get(i);
- if (tileRecord.tile.getState().visible) {
- MetricsLogger.visible(mContext, tileRecord.tile.getMetricsCategory());
- }
+ MetricsLogger.visible(mContext, tileRecord.tile.getMetricsCategory());
}
}
public void handleMessage(Message msg) {
if (msg.what == SHOW_DETAIL) {
handleShowDetail((Record)msg.obj, msg.arg1 != 0);
- } else if (msg.what == SET_TILE_VISIBILITY) {
- handleSetTileVisibility((TileRecord) msg.obj, msg.arg1);
}
}
}
public interface QSTileLayout {
void addTile(TileRecord tile);
void removeTile(TileRecord tile);
- void setTileVisibility(TileRecord tile, int visibility);
int getOffsetTop(TileRecord tile);
void updateResources();
}
public interface Host {
void startActivityDismissingKeyguard(Intent intent);
void startActivityDismissingKeyguard(PendingIntent intent);
+ void startRunnableDismissingKeyguard(Runnable runnable);
void warn(String message, Throwable t);
void collapsePanels();
+ void openPanels();
Looper getLooper();
Context getContext();
Collection<QSTile<?>> getTiles();
UserSwitcherController getUserSwitcherController();
UserInfoController getUserInfoController();
BatteryController getBatteryController();
+ void removeTile(String tileSpec);
public interface Callback {
void onTilesChanged();
}
public static class State {
- public boolean visible;
public Icon icon;
public CharSequence label;
public CharSequence contentDescription;
public boolean copyTo(State other) {
if (other == null) throw new IllegalArgumentException();
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
- final boolean changed = other.visible != visible
- || !Objects.equals(other.icon, icon)
+ final boolean changed = !Objects.equals(other.icon, icon)
|| !Objects.equals(other.label, label)
|| !Objects.equals(other.contentDescription, contentDescription)
|| !Objects.equals(other.autoMirrorDrawable, autoMirrorDrawable)
|| !Objects.equals(other.dualLabelContentDescription,
dualLabelContentDescription);
- other.visible = visible;
other.icon = icon;
other.label = label;
other.contentDescription = contentDescription;
protected StringBuilder toStringBuilder() {
final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
- sb.append("visible=").append(visible);
sb.append(",icon=").append(icon);
sb.append(",label=").append(label);
sb.append(",contentDescription=").append(contentDescription);
}
@Override
- public void setTileVisibility(TileRecord tile, int visibility) {
- tile.tileView.setVisibility(visibility);
- }
-
- @Override
public int getOffsetTop(TileRecord tile) {
return 0;
}
super.removeAllViews();
}
- @Override
- public void setTileVisibility(TileRecord tile, int visibility) {
- tile.tileView.setVisibility(visibility);
- }
-
public void updateResources() {
final Resources res = mContext.getResources();
final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
+++ /dev/null
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.qs;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.IntentFilter;
-
-import com.android.systemui.Prefs;
-import com.android.systemui.R;
-import com.android.systemui.statusbar.phone.SystemUIDialog;
-import com.android.systemui.statusbar.policy.Listenable;
-
-public class UsageTracker implements Listenable {
- private static final long MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
-
- private final Context mContext;
- private final long mTimeToShowTile;
- @Prefs.Key private final String mPrefKey;
- private final String mResetAction;
-
- private boolean mRegistered;
-
- public UsageTracker(Context context, @Prefs.Key String prefKey, Class<?> tile,
- int timeoutResource) {
- mContext = context;
- mPrefKey = prefKey;
- mTimeToShowTile = MILLIS_PER_DAY * mContext.getResources().getInteger(timeoutResource);
- mResetAction = "com.android.systemui.qs." + tile.getSimpleName() + ".usage_reset";
- }
-
- @Override
- public void setListening(boolean listen) {
- if (listen && !mRegistered) {
- mContext.registerReceiver(mReceiver, new IntentFilter(mResetAction));
- mRegistered = true;
- } else if (!listen && mRegistered) {
- mContext.unregisterReceiver(mReceiver);
- mRegistered = false;
- }
- }
-
- public boolean isRecentlyUsed() {
- long lastUsed = Prefs.getLong(mContext, mPrefKey, 0L /* defaultValue */);
- return (System.currentTimeMillis() - lastUsed) < mTimeToShowTile;
- }
-
- public void trackUsage() {
- Prefs.putLong(mContext, mPrefKey, System.currentTimeMillis());
- }
-
- public void reset() {
- Prefs.remove(mContext, mPrefKey);
- }
-
- public void showResetConfirmation(String title, final Runnable onConfirmed) {
- final SystemUIDialog d = new SystemUIDialog(mContext);
- d.setTitle(title);
- d.setMessage(mContext.getString(R.string.quick_settings_reset_confirmation_message));
- d.setNegativeButton(android.R.string.cancel, null);
- d.setPositiveButton(R.string.quick_settings_reset_confirmation_button,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- reset();
- if (onConfirmed != null) {
- onConfirmed.run();
- }
- }
- });
- d.setCanceledOnTouchOutside(true);
- d.show();
- }
-
- private BroadcastReceiver mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (mResetAction.equals(intent.getAction())) {
- reset();
- }
- }
- };
-}
try {
PackageManager pm = mContext.getPackageManager();
ServiceInfo info = pm.getServiceInfo(mComponent, 0);
- state.visible = true;
state.icon = new DrawableIcon(info.loadIcon(pm));
state.label = info.loadLabel(pm).toString();
state.contentDescription = state.label;
} catch (Exception e) {
- state.visible = false;
}
}
if (mTiles.get(i).startsWith(CustomTile.PREFIX)) {
mCurrentTiles.add(BlankCustomTile.create(mHost, mTiles.get(i)));
} else {
- mCurrentTiles.add(mHost.createTile(mTiles.get(i)));
+ QSTile<?> tile = mHost.createTile(mTiles.get(i));
+ if (tile != null) {
+ mCurrentTiles.add(tile);
+ }
}
mCurrentTiles.get(mCurrentTiles.size() - 1).setTileSpec(mTiles.get(i));
}
super.setTiles(mCurrentTiles);
}
-
+
public void addTile(String spec) {
mTiles.add(spec);
setTilesInternal();
}
@Override
- public void setTileVisibility(TileRecord tile, int visibility) {
- // All tiles visible here, so that they can be re-arranged.
- tile.tileView.setVisibility(View.VISIBLE);
- }
-
- @Override
public int getOffsetTop(TileRecord tile) {
// No touch feedback, so this isn't required.
return 0;
}
Log.d(TAG, "Trying " + spec);
final QSTile<?> tile = host.createTile(spec);
+ if (tile == null) {
+ continue;
+ }
// Bad, bad, very bad.
tile.setListening(true);
tile.clearState();
final int value = arg instanceof Integer ? (Integer)arg : mSetting.getValue();
final boolean airplaneMode = value != 0;
state.value = airplaneMode;
- state.visible = true;
state.label = mContext.getString(R.string.airplane_mode);
if (airplaneMode) {
state.icon = mEnable;
int level = (arg != null) ? (Integer) arg : mLevel;
String percentage = NumberFormat.getPercentInstance().format((double) level / 100.0);
- state.visible = true;
state.icon = new Icon() {
@Override
public Drawable getDrawable(Context context) {
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
- final boolean supported = mController.isBluetoothSupported();
final boolean enabled = mController.isBluetoothEnabled();
final boolean connected = mController.isBluetoothConnected();
final boolean connecting = mController.isBluetoothConnecting();
- state.visible = supported;
state.value = enabled;
state.autoMirrorDrawable = false;
if (enabled) {
}
}
+ public static boolean isSupported(Host host) {
+ return host.getBluetoothController().isBluetoothSupported();
+ }
+
private final BluetoothController.Callback mCallback = new BluetoothController.Callback() {
@Override
public void onBluetoothStateChange(boolean enabled) {
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
-
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
-import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.CastController.CastDevice;
@Override
protected void handleClick() {
+ if (mKeyguard.isSecure() && !mKeyguard.canSkipBouncer()) {
+ mHost.startRunnableDismissingKeyguard(new Runnable() {
+ @Override
+ public void run() {
+ MetricsLogger.action(mContext, getMetricsCategory());
+ showDetail(true);
+ mHost.openPanels();
+ }
+ });
+ return;
+ }
MetricsLogger.action(mContext, getMetricsCategory());
showDetail(true);
}
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
- state.visible = !mKeyguard.isSecure() || !mKeyguard.isShowing()
- || mKeyguard.canSkipBouncer() || QSPanel.isTheNewQS(mContext);
state.label = mContext.getString(R.string.quick_settings_cast_title);
state.value = false;
state.autoMirrorDrawable = false;
@Override
protected void handleUpdateState(SignalState state, Object arg) {
- state.visible = mController.hasMobileDataFeature();
- if (!state.visible) return;
CallbackInfo cb = (CallbackInfo) arg;
if (cb == null) {
cb = mSignalCallback.mInfo;
return string;
}
+ public static boolean isSupported(Host host) {
+ return host.getNetworkController().hasMobileDataFeature();
+ }
+
private static final class CallbackInfo {
boolean enabled;
boolean wifiEnabled;
package com.android.systemui.qs.tiles;
import android.provider.Settings.Secure;
-
import com.android.internal.logging.MetricsLogger;
-import com.android.systemui.Prefs;
import com.android.systemui.R;
-import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.SecureSetting;
-import com.android.systemui.qs.UsageTracker;
/** Quick settings tile: Invert colors **/
public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
private final AnimationIcon mDisable
= new AnimationIcon(R.drawable.ic_invert_colors_disable_animation);
private final SecureSetting mSetting;
- private final UsageTracker mUsageTracker;
private boolean mListening;
Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) {
@Override
protected void handleValueChanged(int value, boolean observedChange) {
- if (value != 0 || observedChange) {
- mUsageTracker.trackUsage();
- }
- if (mListening) {
- handleRefreshState(value);
- }
+ handleRefreshState(value);
}
};
- mUsageTracker = new UsageTracker(host.getContext(),
- Prefs.Key.COLOR_INVERSION_TILE_LAST_USED, ColorInversionTile.class,
- R.integer.days_to_show_color_inversion_tile);
- if (mSetting.getValue() != 0 && !mUsageTracker.isRecentlyUsed()) {
- mUsageTracker.trackUsage();
- }
- mUsageTracker.setListening(true);
- mSetting.setListening(true);
}
@Override
protected void handleDestroy() {
super.handleDestroy();
- mUsageTracker.setListening(false);
mSetting.setListening(false);
}
@Override
public void setListening(boolean listening) {
- mListening = listening;
+ mSetting.setListening(listening);
}
@Override
}
@Override
- protected void handleLongClick() {
- if (mState.value) return; // don't allow usage reset if inversion is active
- final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
- mState.label);
- mUsageTracker.showResetConfirmation(title, new Runnable() {
- @Override
- public void run() {
- refreshState();
- }
- });
- }
-
- @Override
protected void handleUpdateState(BooleanState state, Object arg) {
final int value = arg instanceof Integer ? (Integer) arg : mSetting.getValue();
final boolean enabled = value != 0;
- state.visible = enabled || mUsageTracker.isRecentlyUsed() || QSPanel.isTheNewQS(mContext);
state.value = enabled;
state.label = mContext.getString(R.string.quick_settings_inversion_label);
state.icon = enabled ? mEnable : mDisable;
@Override
protected void handleUpdateState(State state, Object arg) {
- state.visible = true;
Drawable drawable = mTile.getIcon().loadDrawable(mContext);
drawable.setTint(mContext.getColor(android.R.color.white));
state.icon = new DrawableIcon(drawable);
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
import android.widget.Toast;
-
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
final boolean newValue = zen != Global.ZEN_MODE_OFF;
final boolean valueChanged = state.value != newValue;
state.value = newValue;
- state.visible = isVisible(mContext);
switch (zen) {
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
state.icon = ResourceIcon.get(R.drawable.ic_qs_dnd_on);
}
};
+ public static boolean isSupported(Host host) {
+ return isVisible(host.getContext());
+ }
+
private final class DndDetailAdapter implements DetailAdapter, OnAttachStateChangeListener {
@Override
package com.android.systemui.qs.tiles;
import android.app.ActivityManager;
-
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
- state.visible = mFlashlightController.isAvailable();
+ // TODO: Flashlight available handling...
+// state.visible = mFlashlightController.isAvailable();
state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label);
if (arg instanceof UserBoolean) {
boolean value = ((UserBoolean) arg).value;
package com.android.systemui.qs.tiles;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
import com.android.internal.logging.MetricsLogger;
-import com.android.systemui.Prefs;
import com.android.systemui.R;
-import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
-import com.android.systemui.qs.UsageTracker;
import com.android.systemui.statusbar.policy.HotspotController;
/** Quick settings tile: Hotspot **/
new AnimationIcon(R.drawable.ic_hotspot_disable_animation);
private final HotspotController mController;
private final Callback mCallback = new Callback();
- private final UsageTracker mUsageTracker;
public HotspotTile(Host host) {
super(host);
mController = host.getHotspotController();
- mUsageTracker = newUsageTracker(host.getContext());
- mUsageTracker.setListening(true);
}
@Override
protected void handleDestroy() {
super.handleDestroy();
- mUsageTracker.setListening(false);
}
@Override
}
@Override
- protected void handleLongClick() {
- if (mState.value) return; // don't allow usage reset if hotspot is active
- final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
- mState.label);
- mUsageTracker.showResetConfirmation(title, new Runnable() {
- @Override
- public void run() {
- refreshState();
- }
- });
- }
-
- @Override
protected void handleUpdateState(BooleanState state, Object arg) {
- state.visible = (mController.isHotspotSupported() && mUsageTracker.isRecentlyUsed())
- || QSPanel.isTheNewQS(mContext);
state.label = mContext.getString(R.string.quick_settings_hotspot_label);
if (arg instanceof Boolean) {
} else {
state.value = mController.isHotspotEnabled();
}
- state.icon = state.visible && state.value ? mEnable : mDisable;
+ state.icon = state.value ? mEnable : mDisable;
}
@Override
}
}
- private static UsageTracker newUsageTracker(Context context) {
- return new UsageTracker(context, Prefs.Key.HOTSPOT_TILE_LAST_USED, HotspotTile.class,
- R.integer.days_to_show_hotspot_tile);
- }
-
private final class Callback implements HotspotController.Callback {
@Override
public void onHotspotChanged(boolean enabled) {
refreshState(enabled);
}
};
-
- /**
- * This will catch broadcasts for changes in hotspot state so we can show
- * the hotspot tile for a number of days after use.
- */
- public static class APChangedReceiver extends BroadcastReceiver {
- private UsageTracker mUsageTracker;
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (mUsageTracker == null) {
- mUsageTracker = newUsageTracker(context);
- }
- mUsageTracker.trackUsage();
- }
- }
}
}
// Save the last one in case we need it later.
mLastIntent = intent;
- state.visible = intent.getBooleanExtra("visible", true);
state.contentDescription = intent.getStringExtra("contentDescription");
state.label = intent.getStringExtra("label");
state.icon = null;
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
-import com.android.systemui.qs.QSPanel;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.LocationController;
@Override
protected void handleClick() {
+ if (mKeyguard.isSecure() && mKeyguard.isShowing()) {
+ mHost.startRunnableDismissingKeyguard(new Runnable() {
+ @Override
+ public void run() {
+ final boolean wasEnabled = (Boolean) mState.value;
+ mHost.openPanels();
+ MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
+ mController.setLocationEnabled(!wasEnabled);
+ mEnable.setAllowAnimation(true);
+ mDisable.setAllowAnimation(true);
+ }
+ });
+ return;
+ }
final boolean wasEnabled = (Boolean) mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
mController.setLocationEnabled(!wasEnabled);
// Work around for bug 15916487: don't show location tile on top of lock screen. After the
// bug is fixed, this should be reverted to only hiding it on secure lock screens:
// state.visible = !(mKeyguard.isSecure() && mKeyguard.isShowing());
- state.visible = !mKeyguard.isShowing() || QSPanel.isTheNewQS(mContext);
state.value = locationEnabled;
if (locationEnabled) {
state.icon = mEnable;
final boolean rotationLocked = arg != null ? ((UserBoolean) arg).value
: mController.isRotationLocked();
final boolean userInitiated = arg != null ? ((UserBoolean) arg).userInitiated : false;
- state.visible = mController.isRotationLockAffordanceVisible();
+ // TODO: Handle accessibility rotation lock and whatnot.
+// state.visible = mController.isRotationLockAffordanceVisible();
if (state.value == rotationLocked && state.contentDescription != null) {
// No change and initialized, no need to update all the values.
return;
@Override
protected void handleUpdateState(State state, Object arg) {
final Pair<String, Drawable> p = arg != null ? (Pair<String, Drawable>) arg : mLastUpdate;
- state.visible = p != null;
- if (!state.visible) return;
- state.label = p.first;
- // TODO: Better content description.
- state.contentDescription = p.first;
- state.icon = new Icon() {
- @Override
- public Drawable getDrawable(Context context) {
- return p.second;
- }
- };
+ if (p != null) {
+ state.label = p.first;
+ // TODO: Better content description.
+ state.contentDescription = p.first;
+ state.icon = new Icon() {
+ @Override
+ public Drawable getDrawable(Context context) {
+ return p.second;
+ }
+ };
+ } else {
+ // TODO: Default state.
+ }
}
@Override
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.provider.Settings;
import android.util.Log;
@Override
protected void handleUpdateState(SignalState state, Object arg) {
- state.visible = true;
if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
CallbackInfo cb = (CallbackInfo) arg;
if (cb == null) {
return string;
}
+ public static boolean isSupported(Host host) {
+ return host.getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
+ }
+
protected static final class CallbackInfo {
boolean enabled;
boolean connected;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.UserInfo;
-import android.os.IUserManager;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
-import android.util.ArraySet;
-import android.util.Log;
-
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@Override
protected void handleUpdateState(BooleanState state, Object arg) {
if (!hasActiveProfile()) {
- state.visible = false;
- state.value = false;
+ mHost.removeTile(getTileSpec());
return;
}
userInitialized = false;
}
- state.visible = true;
final AnimationIcon icon;
state.label = mContext.getString(R.string.quick_settings_work_mode_label);
if (state.value) {
mHandler.post(mAnimateCollapsePanels);
}
+ public void postAnimateOpenPanels() {
+ mHandler.sendEmptyMessage(MSG_OPEN_SETTINGS_PANEL);
+ }
+
public void animateCollapsePanels(int flags) {
animateCollapsePanels(flags, false /* force */, false /* delayed */,
1.0f /* speedUpFactor */);
return !isDeviceProvisioned() || (mDisabled1 & StatusBarManager.DISABLE_SEARCH) != 0;
}
+ public void postQSRunnableDismissingKeyguard(final Runnable runnable) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mLeaveOpenOnKeyguardHide = true;
+ executeRunnableDismissingKeyguard(runnable, null, false, true);
+ }
+ });
+ }
+
public void postStartActivityDismissingKeyguard(final PendingIntent intent) {
mHandler.post(new Runnable() {
@Override
package com.android.systemui.statusbar.phone;
+import android.app.ActivityManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
+import android.provider.Settings;
import android.service.quicksettings.IQSService;
import android.service.quicksettings.Tile;
+import android.text.TextUtils;
import android.util.Log;
-
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.tiles.AirplaneModeTile;
}
@Override
+ public void startRunnableDismissingKeyguard(Runnable runnable) {
+ mStatusBar.postQSRunnableDismissingKeyguard(runnable);
+ }
+
+ @Override
public void warn(String message, Throwable t) {
// already logged
}
}
@Override
+ public void openPanels() {
+ mStatusBar.postAnimateOpenPanels();
+ }
+
+ @Override
public Looper getLooper() {
return mLooper;
}
if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec);
try {
QSTile<?> tile = createTile(tileSpec);
- tile.setTileSpec(tileSpec);
- newTiles.put(tileSpec, tile);
+ if (tile != null) {
+ tile.setTileSpec(tileSpec);
+ newTiles.put(tileSpec, tile);
+ }
} catch (Throwable t) {
Log.w(TAG, "Error creating tile for spec: " + tileSpec, t);
}
}
@Override
+ public void removeTile(String tileSpec) {
+ ArrayList<String> specs = new ArrayList<>(mTileSpecs);
+ specs.remove(tileSpec);
+ Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
+ TextUtils.join(",", specs), ActivityManager.getCurrentUser());
+ }
+
+ @Override
public void updateQsTile(Tile tile) throws RemoteException {
verifyCaller(tile.getComponentName().getPackageName());
CustomTile customTile = getTileForComponent(tile.getComponentName());
}
public QSTile<?> createTile(String tileSpec) {
- if (tileSpec.equals("wifi")) return new WifiTile(this);
- else if (tileSpec.equals("bt")) return new BluetoothTile(this);
+ if (tileSpec.equals("wifi")) return WifiTile.isSupported(this)
+ ? new WifiTile(this) : null;
+ else if (tileSpec.equals("bt")) return BluetoothTile.isSupported(this)
+ ? new BluetoothTile(this) : null;
+ else if (tileSpec.equals("cell")) return CellularTile.isSupported(this)
+ ? new CellularTile(this) : null;
+ else if (tileSpec.equals("dnd")) return DndTile.isSupported(this)
+ ? new DndTile(this) : null;
else if (tileSpec.equals("inversion")) return new ColorInversionTile(this);
- else if (tileSpec.equals("cell")) return new CellularTile(this);
else if (tileSpec.equals("airplane")) return new AirplaneModeTile(this);
else if (tileSpec.equals("work")) return new WorkModeTile(this);
- else if (tileSpec.equals("dnd")) return new DndTile(this);
else if (tileSpec.equals("rotation")) return new RotationLockTile(this);
else if (tileSpec.equals("flashlight")) return new FlashlightTile(this);
else if (tileSpec.equals("location")) return new LocationTile(this);