blob: 3c4898c7658bf750494d0c3b7befbc6f7db0102f [file] [log] [blame]
John Spurlockaf8d6c42014-05-07 17:49:08 -04001/*
Jason Monke5b770e2017-03-03 21:49:29 -05002 * Copyright (C) 2017 The Android Open Source Project
John Spurlockaf8d6c42014-05-07 17:49:08 -04003 *
Jason Monke5b770e2017-03-03 21:49:29 -05004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
John Spurlockaf8d6c42014-05-07 17:49:08 -04006 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
Jason Monke5b770e2017-03-03 21:49:29 -05009 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
John Spurlockaf8d6c42014-05-07 17:49:08 -040013 */
14
Jason Monke5b770e2017-03-03 21:49:29 -050015package com.android.systemui.qs;
John Spurlockaf8d6c42014-05-07 17:49:08 -040016
Jason Monkba2318e2015-12-08 09:04:23 -050017import android.app.ActivityManager;
Jason Monk7e53f202016-01-28 10:40:20 -050018import android.content.ComponentName;
John Spurlockaf8d6c42014-05-07 17:49:08 -040019import android.content.Context;
20import android.content.Intent;
John Spurlockbceed062014-08-10 18:04:16 -040021import android.content.res.Resources;
Jason Monk7e53f202016-01-28 10:40:20 -050022import android.os.Handler;
Jason Monk30b64fa2018-12-27 13:19:34 -050023import android.os.Looper;
Jason Monk7e53f202016-01-28 10:40:20 -050024import android.os.UserHandle;
Sudheer Shankaad790492016-06-03 10:48:27 -070025import android.os.UserManager;
Jason Monkba2318e2015-12-08 09:04:23 -050026import android.provider.Settings;
Jason Monk7e53f202016-01-28 10:40:20 -050027import android.provider.Settings.Secure;
Jason Monka3453b8b2016-06-17 12:42:59 -040028import android.service.quicksettings.Tile;
Jason Monkba2318e2015-12-08 09:04:23 -050029import android.text.TextUtils;
John Spurlockbceed062014-08-10 18:04:16 -040030import android.util.Log;
Winsonc0d70582016-01-29 10:24:39 -080031
Jason Monk9c7844c2017-01-18 15:21:53 -050032import com.android.systemui.Dependency;
Fabian Kozynski00d494d2019-04-04 09:53:50 -040033import com.android.systemui.DumpController;
34import com.android.systemui.Dumpable;
John Spurlockbceed062014-08-10 18:04:16 -040035import com.android.systemui.R;
Jason Monk5d577202018-12-26 15:43:06 -050036import com.android.systemui.SysUiServiceProvider;
Jason Monk702e2eb2017-03-03 16:53:44 -050037import com.android.systemui.plugins.PluginListener;
Jason Monk702e2eb2017-03-03 16:53:44 -050038import com.android.systemui.plugins.qs.QSFactory;
Jason Monk702e2eb2017-03-03 16:53:44 -050039import com.android.systemui.plugins.qs.QSTile;
Gus Prevasab336792018-11-14 13:52:20 -050040import com.android.systemui.plugins.qs.QSTileView;
Jason Monkd5a204f2015-12-21 08:50:01 -050041import com.android.systemui.qs.external.CustomTile;
Jason Monk7e53f202016-01-28 10:40:20 -050042import com.android.systemui.qs.external.TileLifecycleManager;
Jason Monkd5a204f2015-12-21 08:50:01 -050043import com.android.systemui.qs.external.TileServices;
Jason Monk702e2eb2017-03-03 16:53:44 -050044import com.android.systemui.qs.tileimpl.QSFactoryImpl;
Gus Prevasab336792018-11-14 13:52:20 -050045import com.android.systemui.shared.plugins.PluginManager;
Jason Monke5b770e2017-03-03 21:49:29 -050046import com.android.systemui.statusbar.phone.AutoTileManager;
47import com.android.systemui.statusbar.phone.StatusBar;
48import com.android.systemui.statusbar.phone.StatusBarIconController;
Jason Monk5e745172015-06-02 19:14:44 -040049import com.android.systemui.tuner.TunerService;
50import com.android.systemui.tuner.TunerService.Tunable;
John Spurlockaf8d6c42014-05-07 17:49:08 -040051
Fabian Kozynski00d494d2019-04-04 09:53:50 -040052import java.io.FileDescriptor;
53import java.io.PrintWriter;
John Spurlockaf8d6c42014-05-07 17:49:08 -040054import java.util.ArrayList;
John Spurlockbceed062014-08-10 18:04:16 -040055import java.util.Arrays;
56import java.util.Collection;
57import java.util.LinkedHashMap;
John Spurlockaf8d6c42014-05-07 17:49:08 -040058import java.util.List;
Amin Shaikha062beb2018-07-25 11:21:54 -040059import java.util.function.Predicate;
John Spurlockaf8d6c42014-05-07 17:49:08 -040060
Jason Monk5d577202018-12-26 15:43:06 -050061import javax.inject.Inject;
62import javax.inject.Named;
Jason Monka26641f2018-12-27 14:20:53 -050063import javax.inject.Provider;
Jason Monk5d577202018-12-26 15:43:06 -050064import javax.inject.Singleton;
65
John Spurlockaf8d6c42014-05-07 17:49:08 -040066/** Platform implementation of the quick settings tile host **/
Jason Monk5d577202018-12-26 15:43:06 -050067@Singleton
Fabian Kozynski00d494d2019-04-04 09:53:50 -040068public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, Dumpable {
John Spurlockbceed062014-08-10 18:04:16 -040069 private static final String TAG = "QSTileHost";
70 private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
71
Jason Monkbaade752016-08-25 15:57:14 -040072 public static final String TILES_SETTING = Secure.QS_TILES;
John Spurlockaf8d6c42014-05-07 17:49:08 -040073
74 private final Context mContext;
Jason Monk702e2eb2017-03-03 16:53:44 -050075 private final LinkedHashMap<String, QSTile> mTiles = new LinkedHashMap<>();
Jason Monk5e745172015-06-02 19:14:44 -040076 protected final ArrayList<String> mTileSpecs = new ArrayList<>();
Jason Monkd5a204f2015-12-21 08:50:01 -050077 private final TileServices mServices;
Jason Monk30b64fa2018-12-27 13:19:34 -050078 private final TunerService mTunerService;
79 private final PluginManager mPluginManager;
Fabian Kozynski00d494d2019-04-04 09:53:50 -040080 private final DumpController mDumpController;
John Spurlockaf8d6c42014-05-07 17:49:08 -040081
Jason Monkbbadff82015-11-06 15:47:26 -050082 private final List<Callback> mCallbacks = new ArrayList<>();
Jason Monka26641f2018-12-27 14:20:53 -050083 private AutoTileManager mAutoTiles;
Jason Monk9c7844c2017-01-18 15:21:53 -050084 private final StatusBarIconController mIconController;
Jason Monk702e2eb2017-03-03 16:53:44 -050085 private final ArrayList<QSFactory> mQsFactories = new ArrayList<>();
Jason Monk1ffa11b2016-03-08 14:44:23 -050086 private int mCurrentUser;
Jason Monk5d577202018-12-26 15:43:06 -050087 private StatusBar mStatusBar;
John Spurlockbceed062014-08-10 18:04:16 -040088
Jason Monk5d577202018-12-26 15:43:06 -050089 @Inject
90 public QSTileHost(Context context,
91 StatusBarIconController iconController,
92 QSFactoryImpl defaultFactory,
Jason Monk30b64fa2018-12-27 13:19:34 -050093 @Named(Dependency.MAIN_HANDLER_NAME) Handler mainHandler,
94 @Named(Dependency.BG_LOOPER_NAME) Looper bgLooper,
95 PluginManager pluginManager,
Jason Monka26641f2018-12-27 14:20:53 -050096 TunerService tunerService,
Fabian Kozynski00d494d2019-04-04 09:53:50 -040097 Provider<AutoTileManager> autoTiles,
98 DumpController dumpController) {
Jason Monk9c7844c2017-01-18 15:21:53 -050099 mIconController = iconController;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400100 mContext = context;
Jason Monk30b64fa2018-12-27 13:19:34 -0500101 mTunerService = tunerService;
102 mPluginManager = pluginManager;
Fabian Kozynski00d494d2019-04-04 09:53:50 -0400103 mDumpController = dumpController;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400104
Jason Monk30b64fa2018-12-27 13:19:34 -0500105 mServices = new TileServices(this, bgLooper);
Jason Monkd5a204f2015-12-21 08:50:01 -0500106
Jason Monk5d577202018-12-26 15:43:06 -0500107 defaultFactory.setHost(this);
108 mQsFactories.add(defaultFactory);
Jason Monk30b64fa2018-12-27 13:19:34 -0500109 pluginManager.addPluginListener(this, QSFactory.class, true);
Fabian Kozynski00d494d2019-04-04 09:53:50 -0400110 mDumpController.addListener(this);
Jason Monk702e2eb2017-03-03 16:53:44 -0500111
Jason Monk5d577202018-12-26 15:43:06 -0500112 mainHandler.post(() -> {
113 // This is technically a hack to avoid circular dependency of
114 // QSTileHost -> XXXTile -> QSTileHost. Posting ensures creation
115 // finishes before creating any tiles.
Jason Monk30b64fa2018-12-27 13:19:34 -0500116 tunerService.addTunable(this, TILES_SETTING);
Jason Monka26641f2018-12-27 14:20:53 -0500117 // AutoTileManager can modify mTiles so make sure mTiles has already been initialized.
118 mAutoTiles = autoTiles.get();
Jason Monk5d577202018-12-26 15:43:06 -0500119 });
Jason Monk5e745172015-06-02 19:14:44 -0400120 }
John Spurlockbceed062014-08-10 18:04:16 -0400121
Jason Monk9c7844c2017-01-18 15:21:53 -0500122 public StatusBarIconController getIconController() {
123 return mIconController;
Jason Monkca894a02016-01-12 15:30:22 -0500124 }
125
Jason Monk5e745172015-06-02 19:14:44 -0400126 public void destroy() {
Jason Monk88529052016-11-04 13:29:58 -0400127 mTiles.values().forEach(tile -> tile.destroy());
Jason Monkc3f42c12016-02-05 12:33:13 -0500128 mAutoTiles.destroy();
Jason Monk30b64fa2018-12-27 13:19:34 -0500129 mTunerService.removeTunable(this);
Jason Monk88529052016-11-04 13:29:58 -0400130 mServices.destroy();
Jason Monk30b64fa2018-12-27 13:19:34 -0500131 mPluginManager.removePluginListener(this);
Fabian Kozynski00d494d2019-04-04 09:53:50 -0400132 mDumpController.removeListener(this);
Jason Monk702e2eb2017-03-03 16:53:44 -0500133 }
134
135 @Override
136 public void onPluginConnected(QSFactory plugin, Context pluginContext) {
137 // Give plugins priority over creation so they can override if they wish.
138 mQsFactories.add(0, plugin);
Jason Monk30b64fa2018-12-27 13:19:34 -0500139 String value = mTunerService.getValue(TILES_SETTING);
Jason Monk702e2eb2017-03-03 16:53:44 -0500140 // Force remove and recreate of all tiles.
141 onTuningChanged(TILES_SETTING, "");
142 onTuningChanged(TILES_SETTING, value);
143 }
144
145 @Override
146 public void onPluginDisconnected(QSFactory plugin) {
147 mQsFactories.remove(plugin);
148 // Force remove and recreate of all tiles.
Jason Monk30b64fa2018-12-27 13:19:34 -0500149 String value = mTunerService.getValue(TILES_SETTING);
Jason Monk702e2eb2017-03-03 16:53:44 -0500150 onTuningChanged(TILES_SETTING, "");
151 onTuningChanged(TILES_SETTING, value);
John Spurlockaf8d6c42014-05-07 17:49:08 -0400152 }
153
154 @Override
Jason Monkbbadff82015-11-06 15:47:26 -0500155 public void addCallback(Callback callback) {
156 mCallbacks.add(callback);
John Spurlockbceed062014-08-10 18:04:16 -0400157 }
158
159 @Override
Jason Monk46dbfb42016-02-25 14:59:20 -0500160 public void removeCallback(Callback callback) {
161 mCallbacks.remove(callback);
162 }
163
164 @Override
Jason Monk702e2eb2017-03-03 16:53:44 -0500165 public Collection<QSTile> getTiles() {
John Spurlockbceed062014-08-10 18:04:16 -0400166 return mTiles.values();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400167 }
168
169 @Override
John Spurlockaf8d6c42014-05-07 17:49:08 -0400170 public void warn(String message, Throwable t) {
171 // already logged
172 }
173
174 @Override
175 public void collapsePanels() {
Jason Monk5d577202018-12-26 15:43:06 -0500176 if (mStatusBar == null) {
177 mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
178 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400179 mStatusBar.postAnimateCollapsePanels();
180 }
181
182 @Override
Yoshinori Hiranoc673fbc2017-04-14 11:29:38 +0900183 public void forceCollapsePanels() {
Jason Monk5d577202018-12-26 15:43:06 -0500184 if (mStatusBar == null) {
185 mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
186 }
Yoshinori Hiranoc673fbc2017-04-14 11:29:38 +0900187 mStatusBar.postAnimateForceCollapsePanels();
188 }
189
190 @Override
Jason Monkba2318e2015-12-08 09:04:23 -0500191 public void openPanels() {
Jason Monk5d577202018-12-26 15:43:06 -0500192 if (mStatusBar == null) {
193 mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
194 }
Jason Monkba2318e2015-12-08 09:04:23 -0500195 mStatusBar.postAnimateOpenPanels();
196 }
197
198 @Override
John Spurlockaf8d6c42014-05-07 17:49:08 -0400199 public Context getContext() {
200 return mContext;
201 }
202
Jason Monkbbadff82015-11-06 15:47:26 -0500203
Jason Monkd5a204f2015-12-21 08:50:01 -0500204 public TileServices getTileServices() {
205 return mServices;
206 }
207
Jason Monk8c09ac72017-03-16 11:53:40 -0400208 public int indexOf(String spec) {
209 return mTileSpecs.indexOf(spec);
210 }
211
Jason Monk5e745172015-06-02 19:14:44 -0400212 @Override
213 public void onTuningChanged(String key, String newValue) {
214 if (!TILES_SETTING.equals(key)) {
215 return;
216 }
John Spurlockbceed062014-08-10 18:04:16 -0400217 if (DEBUG) Log.d(TAG, "Recreating tiles");
Sudheer Shankaad790492016-06-03 10:48:27 -0700218 if (newValue == null && UserManager.isDeviceInDemoMode(mContext)) {
219 newValue = mContext.getResources().getString(R.string.quick_settings_tiles_retail_mode);
220 }
Jason Monkbbadff82015-11-06 15:47:26 -0500221 final List<String> tileSpecs = loadTileSpecs(mContext, newValue);
Jason Monk1ffa11b2016-03-08 14:44:23 -0500222 int currentUser = ActivityManager.getCurrentUser();
223 if (tileSpecs.equals(mTileSpecs) && currentUser == mCurrentUser) return;
Jason Monk88529052016-11-04 13:29:58 -0400224 mTiles.entrySet().stream().filter(tile -> !tileSpecs.contains(tile.getKey())).forEach(
225 tile -> {
226 if (DEBUG) Log.d(TAG, "Destroying tile: " + tile.getKey());
227 tile.getValue().destroy();
228 });
Jason Monk702e2eb2017-03-03 16:53:44 -0500229 final LinkedHashMap<String, QSTile> newTiles = new LinkedHashMap<>();
John Spurlockbceed062014-08-10 18:04:16 -0400230 for (String tileSpec : tileSpecs) {
Jason Monk702e2eb2017-03-03 16:53:44 -0500231 QSTile tile = mTiles.get(tileSpec);
Jason Monk1ffa11b2016-03-08 14:44:23 -0500232 if (tile != null && (!(tile instanceof CustomTile)
233 || ((CustomTile) tile).getUser() == currentUser)) {
Akitaka Kimuraefd1c542016-09-27 20:06:00 +0900234 if (tile.isAvailable()) {
235 if (DEBUG) Log.d(TAG, "Adding " + tile);
236 tile.removeCallbacks();
Jason Monkf120cf32016-12-06 11:34:12 -0500237 if (!(tile instanceof CustomTile) && mCurrentUser != currentUser) {
238 tile.userSwitch(currentUser);
239 }
Akitaka Kimuraefd1c542016-09-27 20:06:00 +0900240 newTiles.put(tileSpec, tile);
241 } else {
242 tile.destroy();
Justin Klaassendd32d902016-07-31 10:25:36 -0700243 }
John Spurlockbceed062014-08-10 18:04:16 -0400244 } else {
245 if (DEBUG) Log.d(TAG, "Creating tile: " + tileSpec);
246 try {
Jason Monk1ffa11b2016-03-08 14:44:23 -0500247 tile = createTile(tileSpec);
Jason Monk88529052016-11-04 13:29:58 -0400248 if (tile != null) {
249 if (tile.isAvailable()) {
250 tile.setTileSpec(tileSpec);
251 newTiles.put(tileSpec, tile);
252 } else {
253 tile.destroy();
254 }
Jason Monkba2318e2015-12-08 09:04:23 -0500255 }
John Spurlockbceed062014-08-10 18:04:16 -0400256 } catch (Throwable t) {
257 Log.w(TAG, "Error creating tile for spec: " + tileSpec, t);
258 }
259 }
260 }
Jason Monk1ffa11b2016-03-08 14:44:23 -0500261 mCurrentUser = currentUser;
Jason Monk11a77442015-05-12 19:29:02 -0400262 mTileSpecs.clear();
263 mTileSpecs.addAll(tileSpecs);
John Spurlockbceed062014-08-10 18:04:16 -0400264 mTiles.clear();
265 mTiles.putAll(newTiles);
Jason Monkbbadff82015-11-06 15:47:26 -0500266 for (int i = 0; i < mCallbacks.size(); i++) {
267 mCallbacks.get(i).onTilesChanged();
John Spurlockbceed062014-08-10 18:04:16 -0400268 }
269 }
270
Jason Monkbbadff82015-11-06 15:47:26 -0500271 @Override
Amin Shaikha062beb2018-07-25 11:21:54 -0400272 public void removeTile(String spec) {
273 changeTileSpecs(tileSpecs-> tileSpecs.remove(spec));
Jason Monkba2318e2015-12-08 09:04:23 -0500274 }
275
arangelov5fe95982018-08-17 18:43:31 +0100276 @Override
277 public void unmarkTileAsAutoAdded(String spec) {
Jason Monka26641f2018-12-27 14:20:53 -0500278 if (mAutoTiles != null) mAutoTiles.unmarkTileAsAutoAdded(spec);
arangelov5fe95982018-08-17 18:43:31 +0100279 }
280
Jason Monkc3f42c12016-02-05 12:33:13 -0500281 public void addTile(String spec) {
Amin Shaikha062beb2018-07-25 11:21:54 -0400282 changeTileSpecs(tileSpecs-> tileSpecs.add(spec));
283 }
284
285 private void changeTileSpecs(Predicate<List<String>> changeFunction) {
Ricky Waib96c1eac2016-06-02 11:42:16 +0100286 final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
Amin Shaikha062beb2018-07-25 11:21:54 -0400287 TILES_SETTING, ActivityManager.getCurrentUser());
Ricky Waib96c1eac2016-06-02 11:42:16 +0100288 final List<String> tileSpecs = loadTileSpecs(mContext, setting);
Amin Shaikha062beb2018-07-25 11:21:54 -0400289 if (changeFunction.test(tileSpecs)) {
290 Settings.Secure.putStringForUser(mContext.getContentResolver(), TILES_SETTING,
Ricky Waib96c1eac2016-06-02 11:42:16 +0100291 TextUtils.join(",", tileSpecs), ActivityManager.getCurrentUser());
Amin Shaikha062beb2018-07-25 11:21:54 -0400292 }
Jason Monkc3f42c12016-02-05 12:33:13 -0500293 }
294
Jason Monk7e53f202016-01-28 10:40:20 -0500295 public void addTile(ComponentName tile) {
296 List<String> newSpecs = new ArrayList<>(mTileSpecs);
297 newSpecs.add(0, CustomTile.toSpec(tile));
298 changeTiles(mTileSpecs, newSpecs);
299 }
300
301 public void removeTile(ComponentName tile) {
302 List<String> newSpecs = new ArrayList<>(mTileSpecs);
303 newSpecs.remove(CustomTile.toSpec(tile));
304 changeTiles(mTileSpecs, newSpecs);
305 }
306
307 public void changeTiles(List<String> previousTiles, List<String> newTiles) {
308 final int NP = previousTiles.size();
309 final int NA = newTiles.size();
310 for (int i = 0; i < NP; i++) {
311 String tileSpec = previousTiles.get(i);
312 if (!tileSpec.startsWith(CustomTile.PREFIX)) continue;
313 if (!newTiles.contains(tileSpec)) {
Jason Monka3453b8b2016-06-17 12:42:59 -0400314 ComponentName component = CustomTile.getComponentFromSpec(tileSpec);
315 Intent intent = new Intent().setComponent(component);
Jason Monk7e53f202016-01-28 10:40:20 -0500316 TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(),
Jason Monkee68fd82016-06-23 13:12:23 -0400317 mContext, mServices, new Tile(), intent,
Jason Monka3453b8b2016-06-17 12:42:59 -0400318 new UserHandle(ActivityManager.getCurrentUser()));
Jason Monk7e53f202016-01-28 10:40:20 -0500319 lifecycleManager.onStopListening();
320 lifecycleManager.onTileRemoved();
Jason Monkbaade752016-08-25 15:57:14 -0400321 TileLifecycleManager.setTileAdded(mContext, component, false);
Jason Monk7e53f202016-01-28 10:40:20 -0500322 lifecycleManager.flushMessagesAndUnbind();
323 }
324 }
325 if (DEBUG) Log.d(TAG, "saveCurrentTiles " + newTiles);
326 Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING,
327 TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
328 }
329
Jason Monk702e2eb2017-03-03 16:53:44 -0500330 public QSTile createTile(String tileSpec) {
331 for (int i = 0; i < mQsFactories.size(); i++) {
332 QSTile t = mQsFactories.get(i).createTile(tileSpec);
333 if (t != null) {
334 return t;
335 }
Jason Monk2b37190f2016-01-06 10:19:04 -0500336 }
Jason Monk702e2eb2017-03-03 16:53:44 -0500337 return null;
338 }
339
340 public QSTileView createTileView(QSTile tile, boolean collapsedView) {
341 for (int i = 0; i < mQsFactories.size(); i++) {
342 QSTileView view = mQsFactories.get(i).createTileView(tile, collapsedView);
343 if (view != null) {
344 return view;
345 }
346 }
347 throw new RuntimeException("Default factory didn't create view for " + tile.getTileSpec());
John Spurlockbceed062014-08-10 18:04:16 -0400348 }
349
Amin Shaikha062beb2018-07-25 11:21:54 -0400350 protected static List<String> loadTileSpecs(Context context, String tileList) {
Jason Monkbbadff82015-11-06 15:47:26 -0500351 final Resources res = context.getResources();
John Spurlockbceed062014-08-10 18:04:16 -0400352 final String defaultTileList = res.getString(R.string.quick_settings_tiles_default);
Fabian Kozynski7f370dd2018-12-05 10:41:07 -0500353 if (TextUtils.isEmpty(tileList)) {
John Spurlockbceed062014-08-10 18:04:16 -0400354 tileList = res.getString(R.string.quick_settings_tiles);
355 if (DEBUG) Log.d(TAG, "Loaded tile specs from config: " + tileList);
356 } else {
357 if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList);
358 }
359 final ArrayList<String> tiles = new ArrayList<String>();
360 boolean addedDefault = false;
361 for (String tile : tileList.split(",")) {
362 tile = tile.trim();
363 if (tile.isEmpty()) continue;
364 if (tile.equals("default")) {
365 if (!addedDefault) {
366 tiles.addAll(Arrays.asList(defaultTileList.split(",")));
367 addedDefault = true;
368 }
369 } else {
370 tiles.add(tile);
371 }
372 }
373 return tiles;
374 }
Fabian Kozynski00d494d2019-04-04 09:53:50 -0400375
376 @Override
377 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
378 pw.println("QSTileHost:");
379 mTiles.values().stream().filter(obj -> obj instanceof Dumpable)
380 .forEach(o -> ((Dumpable) o).dump(fd, pw, args));
381 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400382}