blob: 348d9eef2cab25a8684f7c7db65c8721ad7cf17c [file] [log] [blame]
Adam Cohen2e6da152015-05-06 11:42:25 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher3;
18
Hyunyoung Songc55a3502018-12-04 15:43:16 -080019import static com.android.launcher3.Utilities.getDevicePrefs;
Tracy Zhoued5f3082020-04-20 01:13:26 -070020import static com.android.launcher3.Utilities.getPointString;
Jon Miranda73dcc982020-12-11 14:14:46 -080021import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
Andras Kloczl8e57cce2021-02-11 23:51:19 +010022import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080023import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
Sunny Goyal8b0cb412019-04-22 09:01:26 -070024import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
Sunny Goyal87dc48b2018-10-12 11:42:33 -070025
Sunny Goyalc6205602015-05-21 20:46:33 -070026import android.annotation.TargetApi;
Sunny Goyal58fa4b62019-03-22 16:23:25 -070027import android.appwidget.AppWidgetHostView;
Hyunyoung Songe11eb472019-03-19 15:05:21 -070028import android.content.BroadcastReceiver;
Sunny Goyal58fa4b62019-03-22 16:23:25 -070029import android.content.ComponentName;
Adam Cohen2e6da152015-05-06 11:42:25 -070030import android.content.Context;
Hyunyoung Songe11eb472019-03-19 15:05:21 -070031import android.content.Intent;
Sunny Goyal27835952017-01-13 12:15:53 -080032import android.content.res.Configuration;
Hyunyoung Songc55a3502018-12-04 15:43:16 -080033import android.content.res.Resources;
Sunny Goyal819e1932016-07-07 16:43:58 -070034import android.content.res.TypedArray;
35import android.content.res.XmlResourceParser;
Adam Cohen2e6da152015-05-06 11:42:25 -070036import android.graphics.Point;
Sunny Goyal58fa4b62019-03-22 16:23:25 -070037import android.graphics.Rect;
Sunny Goyal415f1732018-11-29 10:33:47 -080038import android.text.TextUtils;
39import android.util.AttributeSet;
Adam Cohen2e6da152015-05-06 11:42:25 -070040import android.util.DisplayMetrics;
Sunny Goyal87dc48b2018-10-12 11:42:33 -070041import android.util.Log;
Sunny Goyal5bc18462019-01-07 15:13:39 -080042import android.util.SparseArray;
43import android.util.TypedValue;
Sunny Goyal819e1932016-07-07 16:43:58 -070044import android.util.Xml;
Sunny Goyal9c2b9602020-01-07 13:07:55 -080045import android.view.Display;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070046
Sunny Goyal6fe3eec2019-08-15 14:53:41 -070047import androidx.annotation.Nullable;
48import androidx.annotation.VisibleForTesting;
49
Sunny Goyal905262c2019-05-03 16:50:43 -070050import com.android.launcher3.graphics.IconShape;
Sunny Goyald0e360a2018-06-29 14:40:18 -070051import com.android.launcher3.util.ConfigMonitor;
Sunny Goyalfd58da62020-08-11 12:06:49 -070052import com.android.launcher3.util.DisplayController;
53import com.android.launcher3.util.DisplayController.Info;
Sunny Goyal5bc18462019-01-07 15:13:39 -080054import com.android.launcher3.util.IntArray;
Sunny Goyald0e360a2018-06-29 14:40:18 -070055import com.android.launcher3.util.MainThreadInitializedObject;
Sunny Goyal5bc18462019-01-07 15:13:39 -080056import com.android.launcher3.util.Themes;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070057
Sunny Goyal819e1932016-07-07 16:43:58 -070058import org.xmlpull.v1.XmlPullParser;
59import org.xmlpull.v1.XmlPullParserException;
60
61import java.io.IOException;
Adam Cohen2e6da152015-05-06 11:42:25 -070062import java.util.ArrayList;
Sunny Goyal6d55f662019-01-02 12:13:43 -080063import java.util.Collections;
Adam Cohen2e6da152015-05-06 11:42:25 -070064
65public class InvariantDeviceProfile {
Adam Cohen2e6da152015-05-06 11:42:25 -070066
Hyunyoung Songc55a3502018-12-04 15:43:16 -080067 public static final String TAG = "IDP";
Sunny Goyald0e360a2018-06-29 14:40:18 -070068 // We do not need any synchronization for this variable as its only written on UI thread.
69 public static final MainThreadInitializedObject<InvariantDeviceProfile> INSTANCE =
Sunny Goyal87dc48b2018-10-12 11:42:33 -070070 new MainThreadInitializedObject<>(InvariantDeviceProfile::new);
Adam Cohen2e6da152015-05-06 11:42:25 -070071
Tracy Zhoued5f3082020-04-20 01:13:26 -070072 public static final String KEY_MIGRATION_SRC_WORKSPACE_SIZE = "migration_src_workspace_size";
73 public static final String KEY_MIGRATION_SRC_HOTSEAT_COUNT = "migration_src_hotseat_count";
74
Hyunyoung Songc55a3502018-12-04 15:43:16 -080075 private static final String KEY_IDP_GRID_NAME = "idp_grid_name";
Sunny Goyal415f1732018-11-29 10:33:47 -080076
Sunny Goyal53d7ee42015-05-22 12:25:45 -070077 private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
78
Sunny Goyal87dc48b2018-10-12 11:42:33 -070079 public static final int CHANGE_FLAG_GRID = 1 << 0;
Hyunyoung Songc55a3502018-12-04 15:43:16 -080080 public static final int CHANGE_FLAG_ICON_PARAMS = 1 << 1;
81
82 public static final String KEY_ICON_PATH_REF = "pref_icon_shape_path";
Sunny Goyal87dc48b2018-10-12 11:42:33 -070083
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070084 // Constants that affects the interpolation curve between statically defined device profile
85 // buckets.
Hyunyoung Songc55a3502018-12-04 15:43:16 -080086 private static final float KNEARESTNEIGHBOR = 3;
87 private static final float WEIGHT_POWER = 5;
Adam Cohen2e6da152015-05-06 11:42:25 -070088
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070089 // used to offset float not being able to express extremely small weights in extreme cases.
Hyunyoung Songc55a3502018-12-04 15:43:16 -080090 private static final float WEIGHT_EFFICIENT = 100000f;
91
92 private static final int CONFIG_ICON_MASK_RES_ID = Resources.getSystem().getIdentifier(
93 "config_icon_mask", "string", "android");
Adam Cohen2e6da152015-05-06 11:42:25 -070094
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -070095 /**
96 * Number of icons per row and column in the workspace.
97 */
Adam Cohen2e6da152015-05-06 11:42:25 -070098 public int numRows;
99 public int numColumns;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700100
101 /**
102 * Number of icons per row and column in the folder.
103 */
Adam Cohen2e6da152015-05-06 11:42:25 -0700104 public int numFolderRows;
105 public int numFolderColumns;
Sunny Goyalfc218302015-09-17 14:59:10 -0700106 public float iconSize;
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800107 public String iconShapePath;
Jon Mirandab28c4fc2017-06-20 10:58:36 -0700108 public float landscapeIconSize;
Sunny Goyalfc218302015-09-17 14:59:10 -0700109 public int iconBitmapSize;
110 public int fillResIconDpi;
111 public float iconTextSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000112 public float allAppsIconSize;
113 public float allAppsIconTextSize;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700114
Jon Mirandae126d722021-02-25 10:45:20 -0500115 public float minCellHeight;
116 public float minCellWidth;
117 public float borderSpacing;
118
Sunny Goyal5bc18462019-01-07 15:13:39 -0800119 private SparseArray<TypedValue> mExtraAttrs;
120
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700121 /**
122 * Number of icons inside the hotseat area.
123 */
Sunny Goyalf862a262015-12-14 14:27:38 -0800124 public int numHotseatIcons;
Adam Cohen27824492017-09-22 17:10:55 -0700125
Jon Miranda6f7e9702019-09-16 14:44:14 -0700126 /**
127 * Number of columns in the all apps list.
128 */
129 public int numAllAppsColumns;
130
Jon Mirandae126d722021-02-25 10:45:20 -0500131 /**
132 * Do not query directly. see {@link DeviceProfile#isScalableGrid}.
133 */
134 protected boolean isScalable;
135
Tracy Zhou7df93d22020-01-27 13:44:06 -0800136 public String dbFile;
Sunny Goyal415f1732018-11-29 10:33:47 -0800137 public int defaultLayoutId;
Adam Cohen27824492017-09-22 17:10:55 -0700138 int demoModeLayoutId;
Adam Cohen2e6da152015-05-06 11:42:25 -0700139
cuijiaxingabda8d72017-03-20 09:51:36 -0700140 public DeviceProfile landscapeProfile;
141 public DeviceProfile portraitProfile;
Sunny Goyalc6205602015-05-21 20:46:33 -0700142
Jon Miranda228877d2021-02-09 11:05:00 -0500143 public DevicePaddings devicePaddings;
144
Sunny Goyal6f866092016-03-17 17:04:15 -0700145 public Point defaultWallpaperSize;
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700146 public Rect defaultWidgetPadding;
Sunny Goyal6f866092016-03-17 17:04:15 -0700147
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700148 private final ArrayList<OnIDPChangeListener> mChangeListeners = new ArrayList<>();
149 private ConfigMonitor mConfigMonitor;
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700150 private OverlayMonitor mOverlayMonitor;
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700151
Sunny Goyalf633ef52018-03-13 09:57:05 -0700152 @VisibleForTesting
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700153 public InvariantDeviceProfile() {}
Adam Cohen2e6da152015-05-06 11:42:25 -0700154
Sunny Goyalf633ef52018-03-13 09:57:05 -0700155 private InvariantDeviceProfile(InvariantDeviceProfile p) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800156 numRows = p.numRows;
157 numColumns = p.numColumns;
158 numFolderRows = p.numFolderRows;
159 numFolderColumns = p.numFolderColumns;
160 iconSize = p.iconSize;
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800161 iconShapePath = p.iconShapePath;
Sunny Goyal415f1732018-11-29 10:33:47 -0800162 landscapeIconSize = p.landscapeIconSize;
Tony Wickham9459f312020-06-15 13:30:20 -0500163 iconBitmapSize = p.iconBitmapSize;
Sunny Goyal415f1732018-11-29 10:33:47 -0800164 iconTextSize = p.iconTextSize;
165 numHotseatIcons = p.numHotseatIcons;
Jon Miranda6f7e9702019-09-16 14:44:14 -0700166 numAllAppsColumns = p.numAllAppsColumns;
Jon Mirandae126d722021-02-25 10:45:20 -0500167 isScalable = p.isScalable;
168 minCellHeight = p.minCellHeight;
169 minCellWidth = p.minCellWidth;
170 borderSpacing = p.borderSpacing;
Tracy Zhou7df93d22020-01-27 13:44:06 -0800171 dbFile = p.dbFile;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000172 allAppsIconSize = p.allAppsIconSize;
173 allAppsIconTextSize = p.allAppsIconTextSize;
Sunny Goyal415f1732018-11-29 10:33:47 -0800174 defaultLayoutId = p.defaultLayoutId;
175 demoModeLayoutId = p.demoModeLayoutId;
Sunny Goyal5bc18462019-01-07 15:13:39 -0800176 mExtraAttrs = p.mExtraAttrs;
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700177 mOverlayMonitor = p.mOverlayMonitor;
Jon Miranda228877d2021-02-09 11:05:00 -0500178 devicePaddings = p.devicePaddings;
Adam Cohen2e6da152015-05-06 11:42:25 -0700179 }
180
Sunny Goyalbbf01842015-10-08 07:41:15 -0700181 @TargetApi(23)
Sunny Goyald0e360a2018-06-29 14:40:18 -0700182 private InvariantDeviceProfile(Context context) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700183 String gridName = getCurrentGridName(context);
184 String newGridName = initGrid(context, gridName);
185 if (!newGridName.equals(gridName)) {
186 Utilities.getPrefs(context).edit().putString(KEY_IDP_GRID_NAME, newGridName).apply();
187 }
Tracy Zhoued5f3082020-04-20 01:13:26 -0700188 Utilities.getPrefs(context).edit()
189 .putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, numHotseatIcons)
190 .putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, getPointString(numColumns, numRows))
191 .apply();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700192
Sunny Goyalead22a52021-02-02 23:21:55 -0800193 mConfigMonitor = new ConfigMonitor(context, this::onConfigChanged);
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700194 mOverlayMonitor = new OverlayMonitor(context);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700195 }
196
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700197 /**
198 * This constructor should NOT have any monitors by design.
199 */
Sunny Goyaleff44f32019-01-09 17:29:49 -0800200 public InvariantDeviceProfile(Context context, String gridName) {
201 String newName = initGrid(context, gridName);
202 if (newName == null || !newName.equals(gridName)) {
203 throw new IllegalArgumentException("Unknown grid name");
204 }
205 }
206
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700207 /**
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800208 * This constructor should NOT have any monitors by design.
209 */
210 public InvariantDeviceProfile(Context context, Display display) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700211 // Ensure that the main device profile is initialized
212 InvariantDeviceProfile originalProfile = INSTANCE.get(context);
213 String gridName = getCurrentGridName(context);
214
215 // Get the display info based on default display and interpolate it to existing display
216 DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
Sunny Goyalfd58da62020-08-11 12:06:49 -0700217 DisplayController.getDefaultDisplay(context).getInfo(),
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700218 getPredefinedDeviceProfiles(context, gridName));
219
Alex Chau417bd722021-01-26 15:22:18 +0000220 Info myInfo = new Info(context, display);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700221 DisplayOption myDisplayOption = invDistWeightedInterpolate(
222 myInfo, getPredefinedDeviceProfiles(context, gridName));
223
224 DisplayOption result = new DisplayOption(defaultDisplayOption.grid)
225 .add(myDisplayOption);
226 result.iconSize = defaultDisplayOption.iconSize;
227 result.landscapeIconSize = defaultDisplayOption.landscapeIconSize;
228 result.allAppsIconSize = Math.min(
229 defaultDisplayOption.allAppsIconSize, myDisplayOption.allAppsIconSize);
Jon Mirandae126d722021-02-25 10:45:20 -0500230 result.minCellHeight = defaultDisplayOption.minCellHeight;
231 result.minCellWidth = defaultDisplayOption.minCellWidth;
232 result.borderSpacing = defaultDisplayOption.borderSpacing;
Jon Miranda228877d2021-02-09 11:05:00 -0500233
234 devicePaddings = new DevicePaddings(context);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700235 initGrid(context, myInfo, result);
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800236 }
237
Tracy Zhou42255d22020-03-13 00:38:11 -0700238 public static String getCurrentGridName(Context context) {
Andras Kloczl8e57cce2021-02-11 23:51:19 +0100239 if (ENABLE_TWO_PANEL_HOME.get()) {
240 return ENABLE_TWO_PANEL_HOME.key;
241 }
Jon Miranda73dcc982020-12-11 14:14:46 -0800242 if (ENABLE_FOUR_COLUMNS.get()) {
243 return ENABLE_FOUR_COLUMNS.key;
244 }
Tracy Zhouc6060e62020-04-27 13:05:34 -0700245 return Utilities.isGridOptionsEnabled(context)
246 ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null;
Tracy Zhou42255d22020-03-13 00:38:11 -0700247 }
248
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800249 /**
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800250 * Retrieve system defined or RRO overriden icon shape.
251 */
252 private static String getIconShapePath(Context context) {
253 if (CONFIG_ICON_MASK_RES_ID == 0) {
254 Log.e(TAG, "Icon mask res identifier failed to retrieve.");
255 return "";
256 }
257 return context.getResources().getString(CONFIG_ICON_MASK_RES_ID);
258 }
259
Sunny Goyaleff44f32019-01-09 17:29:49 -0800260 private String initGrid(Context context, String gridName) {
Sunny Goyalfd58da62020-08-11 12:06:49 -0700261 Info displayInfo = DisplayController.getDefaultDisplay(context).getInfo();
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700262 ArrayList<DisplayOption> allOptions = getPredefinedDeviceProfiles(context, gridName);
263
264 DisplayOption displayOption = invDistWeightedInterpolate(displayInfo, allOptions);
Jon Miranda228877d2021-02-09 11:05:00 -0500265 devicePaddings = new DevicePaddings(context);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700266 initGrid(context, displayInfo, displayOption);
267 return displayOption.grid.name;
Sunny Goyal9c2b9602020-01-07 13:07:55 -0800268 }
Adam Cohen2e6da152015-05-06 11:42:25 -0700269
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700270 private void initGrid(
Sunny Goyalfd58da62020-08-11 12:06:49 -0700271 Context context, Info displayInfo, DisplayOption displayOption) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700272 GridOption closestProfile = displayOption.grid;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000273 numRows = closestProfile.numRows;
274 numColumns = closestProfile.numColumns;
275 numHotseatIcons = closestProfile.numHotseatIcons;
276 dbFile = closestProfile.dbFile;
277 defaultLayoutId = closestProfile.defaultLayoutId;
278 demoModeLayoutId = closestProfile.demoModeLayoutId;
279 numFolderRows = closestProfile.numFolderRows;
280 numFolderColumns = closestProfile.numFolderColumns;
281 numAllAppsColumns = closestProfile.numAllAppsColumns;
Jon Mirandae126d722021-02-25 10:45:20 -0500282 isScalable = closestProfile.isScalable;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000283
284 mExtraAttrs = closestProfile.extraAttrs;
285
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700286 iconSize = displayOption.iconSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000287 iconShapePath = getIconShapePath(context);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700288 landscapeIconSize = displayOption.landscapeIconSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000289 iconBitmapSize = ResourceUtils.pxFromDp(iconSize, displayInfo.metrics);
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700290 iconTextSize = displayOption.iconTextSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000291 fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
292
Jon Mirandae126d722021-02-25 10:45:20 -0500293 minCellHeight = displayOption.minCellHeight;
294 minCellWidth = displayOption.minCellWidth;
295 borderSpacing = displayOption.borderSpacing;
296
Tracy Zhouc6060e62020-04-27 13:05:34 -0700297 if (Utilities.isGridOptionsEnabled(context)) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700298 allAppsIconSize = displayOption.allAppsIconSize;
299 allAppsIconTextSize = displayOption.allAppsIconTextSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000300 } else {
301 allAppsIconSize = iconSize;
302 allAppsIconTextSize = iconTextSize;
303 }
304
305 // If the partner customization apk contains any grid overrides, apply them
306 // Supported overrides: numRows, numColumns, iconSize
307 applyPartnerDeviceProfileOverrides(context, displayInfo.metrics);
Sunny Goyalc6205602015-05-21 20:46:33 -0700308
Winson Chung13c1c2c2019-09-06 11:46:19 -0700309 Point realSize = new Point(displayInfo.realSize);
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700310 // The real size never changes. smallSide and largeSide will remain the
Sunny Goyalc6205602015-05-21 20:46:33 -0700311 // same in any orientation.
312 int smallSide = Math.min(realSize.x, realSize.y);
313 int largeSide = Math.max(realSize.x, realSize.y);
314
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700315 DeviceProfile.Builder builder = new DeviceProfile.Builder(context, this, displayInfo)
316 .setSizeRange(new Point(displayInfo.smallestSize),
317 new Point(displayInfo.largestSize));
318
319 landscapeProfile = builder.setSize(largeSide, smallSide).build();
320 portraitProfile = builder.setSize(smallSide, largeSide).build();
Sunny Goyal6f866092016-03-17 17:04:15 -0700321
322 // We need to ensure that there is enough extra space in the wallpaper
323 // for the intended parallax effects
324 if (context.getResources().getConfiguration().smallestScreenWidthDp >= 720) {
325 defaultWallpaperSize = new Point(
326 (int) (largeSide * wallpaperTravelToScreenWidthRatio(largeSide, smallSide)),
327 largeSide);
328 } else {
329 defaultWallpaperSize = new Point(Math.max(smallSide * 2, largeSide), largeSide);
330 }
Sunny Goyal58fa4b62019-03-22 16:23:25 -0700331
332 ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
333 defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
Adam Cohen2e6da152015-05-06 11:42:25 -0700334 }
335
Sunny Goyal5bc18462019-01-07 15:13:39 -0800336 @Nullable
337 public TypedValue getAttrValue(int attr) {
338 return mExtraAttrs == null ? null : mExtraAttrs.get(attr);
339 }
340
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700341 public void addOnChangeListener(OnIDPChangeListener listener) {
342 mChangeListeners.add(listener);
343 }
344
Hyunyoung Songb4d1ca42019-01-08 17:15:16 -0800345 public void removeOnChangeListener(OnIDPChangeListener listener) {
346 mChangeListeners.remove(listener);
347 }
348
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800349 public void verifyConfigChangedInBackground(final Context context) {
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800350 String savedIconMaskPath = getDevicePrefs(context).getString(KEY_ICON_PATH_REF, "");
351 // Good place to check if grid size changed in themepicker when launcher was dead.
352 if (savedIconMaskPath.isEmpty()) {
353 getDevicePrefs(context).edit().putString(KEY_ICON_PATH_REF, getIconShapePath(context))
354 .apply();
355 } else if (!savedIconMaskPath.equals(getIconShapePath(context))) {
356 getDevicePrefs(context).edit().putString(KEY_ICON_PATH_REF, getIconShapePath(context))
357 .apply();
358 apply(context, CHANGE_FLAG_ICON_PARAMS);
359 }
360 }
361
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800362 public void setCurrentGrid(Context context, String gridName) {
363 Context appContext = context.getApplicationContext();
364 Utilities.getPrefs(appContext).edit().putString(KEY_IDP_GRID_NAME, gridName).apply();
Sunny Goyal6fe3eec2019-08-15 14:53:41 -0700365 MAIN_EXECUTOR.execute(() -> onConfigChanged(appContext));
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800366 }
367
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700368 private void onConfigChanged(Context context) {
369 // Config changes, what shall we do?
370 InvariantDeviceProfile oldProfile = new InvariantDeviceProfile(this);
371
372 // Re-init grid
Tracy Zhouc6060e62020-04-27 13:05:34 -0700373 String gridName = getCurrentGridName(context);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700374 initGrid(context, gridName);
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700375
376 int changeFlags = 0;
377 if (numRows != oldProfile.numRows ||
378 numColumns != oldProfile.numColumns ||
379 numFolderColumns != oldProfile.numFolderColumns ||
380 numFolderRows != oldProfile.numFolderRows ||
381 numHotseatIcons != oldProfile.numHotseatIcons) {
382 changeFlags |= CHANGE_FLAG_GRID;
383 }
384
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800385 if (iconSize != oldProfile.iconSize || iconBitmapSize != oldProfile.iconBitmapSize ||
386 !iconShapePath.equals(oldProfile.iconShapePath)) {
387 changeFlags |= CHANGE_FLAG_ICON_PARAMS;
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700388 }
Sunny Goyal90e3fbc2019-01-23 16:42:43 -0800389 if (!iconShapePath.equals(oldProfile.iconShapePath)) {
Sunny Goyal905262c2019-05-03 16:50:43 -0700390 IconShape.init(context);
Sunny Goyal90e3fbc2019-01-23 16:42:43 -0800391 }
392
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800393 apply(context, changeFlags);
394 }
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700395
Hyunyoung Songc55a3502018-12-04 15:43:16 -0800396 private void apply(Context context, int changeFlags) {
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700397 // Create a new config monitor
398 mConfigMonitor.unregister();
399 mConfigMonitor = new ConfigMonitor(context, this::onConfigChanged);
400
401 for (OnIDPChangeListener listener : mChangeListeners) {
402 listener.onIdpChanged(changeFlags, this);
403 }
404 }
405
Sunny Goyalae190ff2020-04-14 00:19:01 +0000406 static ArrayList<DisplayOption> getPredefinedDeviceProfiles(Context context, String gridName) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800407 ArrayList<DisplayOption> profiles = new ArrayList<>();
Sunny Goyal819e1932016-07-07 16:43:58 -0700408 try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
409 final int depth = parser.getDepth();
410 int type;
Sunny Goyal819e1932016-07-07 16:43:58 -0700411 while (((type = parser.next()) != XmlPullParser.END_TAG ||
412 parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800413 if ((type == XmlPullParser.START_TAG)
414 && GridOption.TAG_NAME.equals(parser.getName())) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800415
416 GridOption gridOption = new GridOption(context, Xml.asAttributeSet(parser));
417 final int displayDepth = parser.getDepth();
418 while (((type = parser.next()) != XmlPullParser.END_TAG ||
419 parser.getDepth() > displayDepth)
420 && type != XmlPullParser.END_DOCUMENT) {
421 if ((type == XmlPullParser.START_TAG) && "display-option".equals(
422 parser.getName())) {
423 profiles.add(new DisplayOption(
424 gridOption, context, Xml.asAttributeSet(parser)));
425 }
426 }
Sunny Goyal819e1932016-07-07 16:43:58 -0700427 }
428 }
429 } catch (IOException|XmlPullParserException e) {
430 throw new RuntimeException(e);
431 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800432
Sunny Goyalae190ff2020-04-14 00:19:01 +0000433 ArrayList<DisplayOption> filteredProfiles = new ArrayList<>();
Sunny Goyal415f1732018-11-29 10:33:47 -0800434 if (!TextUtils.isEmpty(gridName)) {
435 for (DisplayOption option : profiles) {
436 if (gridName.equals(option.grid.name)) {
Sunny Goyalae190ff2020-04-14 00:19:01 +0000437 filteredProfiles.add(option);
Sunny Goyal415f1732018-11-29 10:33:47 -0800438 }
439 }
440 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000441 if (filteredProfiles.isEmpty()) {
442 // No grid found, use the default options
443 for (DisplayOption option : profiles) {
444 if (option.canBeDefault) {
445 filteredProfiles.add(option);
446 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800447 }
448 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000449 if (filteredProfiles.isEmpty()) {
450 throw new RuntimeException("No display option with canBeDefault=true");
451 }
452 return filteredProfiles;
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700453 }
454
Sunny Goyal53d7ee42015-05-22 12:25:45 -0700455 private int getLauncherIconDensity(int requiredSize) {
456 // Densities typically defined by an app.
457 int[] densityBuckets = new int[] {
458 DisplayMetrics.DENSITY_LOW,
459 DisplayMetrics.DENSITY_MEDIUM,
460 DisplayMetrics.DENSITY_TV,
461 DisplayMetrics.DENSITY_HIGH,
462 DisplayMetrics.DENSITY_XHIGH,
463 DisplayMetrics.DENSITY_XXHIGH,
464 DisplayMetrics.DENSITY_XXXHIGH
465 };
466
467 int density = DisplayMetrics.DENSITY_XXXHIGH;
468 for (int i = densityBuckets.length - 1; i >= 0; i--) {
469 float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
470 / DisplayMetrics.DENSITY_DEFAULT;
471 if (expectedSize >= requiredSize) {
472 density = densityBuckets[i];
473 }
474 }
475
476 return density;
477 }
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700478
Adam Cohen2e6da152015-05-06 11:42:25 -0700479 /**
480 * Apply any Partner customization grid overrides.
481 *
482 * Currently we support: all apps row / column count.
483 */
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700484 private void applyPartnerDeviceProfileOverrides(Context context, DisplayMetrics dm) {
485 Partner p = Partner.get(context.getPackageManager());
Adam Cohen2e6da152015-05-06 11:42:25 -0700486 if (p != null) {
487 p.applyInvariantDeviceProfileOverrides(this, dm);
488 }
489 }
490
Sunny Goyal415f1732018-11-29 10:33:47 -0800491 private static float dist(float x0, float y0, float x1, float y1) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700492 return (float) Math.hypot(x1 - x0, y1 - y0);
Adam Cohen2e6da152015-05-06 11:42:25 -0700493 }
494
Sunny Goyal415f1732018-11-29 10:33:47 -0800495 @VisibleForTesting
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700496 static DisplayOption invDistWeightedInterpolate(
Sunny Goyalfd58da62020-08-11 12:06:49 -0700497 Info displayInfo, ArrayList<DisplayOption> points) {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700498 Point smallestSize = new Point(displayInfo.smallestSize);
499 Point largestSize = new Point(displayInfo.largestSize);
500
501 // This guarantees that width < height
502 float width = Utilities.dpiFromPx(Math.min(smallestSize.x, smallestSize.y),
503 displayInfo.metrics);
504 float height = Utilities.dpiFromPx(Math.min(largestSize.x, largestSize.y),
505 displayInfo.metrics);
506
507 // Sort the profiles based on the closeness to the device size
508 Collections.sort(points, (a, b) ->
509 Float.compare(dist(width, height, a.minWidthDps, a.minHeightDps),
510 dist(width, height, b.minWidthDps, b.minHeightDps)));
511
512 GridOption closestOption = points.get(0).grid;
513 float weights = 0;
514
515 DisplayOption p = points.get(0);
516 if (dist(width, height, p.minWidthDps, p.minHeightDps) == 0) {
517 return p;
518 }
519
520 DisplayOption out = new DisplayOption(closestOption);
521 for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) {
522 p = points.get(i);
523 float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER);
524 weights += w;
525 out.add(new DisplayOption().add(p).multiply(w));
526 }
527 return out.multiply(1.0f / weights);
528 }
529
530 @VisibleForTesting
Sunny Goyal415f1732018-11-29 10:33:47 -0800531 static DisplayOption invDistWeightedInterpolate(float width, float height,
Sunny Goyalae190ff2020-04-14 00:19:01 +0000532 ArrayList<DisplayOption> points) {
Adam Cohen2e6da152015-05-06 11:42:25 -0700533 float weights = 0;
Adam Cohen2e6da152015-05-06 11:42:25 -0700534
Sunny Goyal415f1732018-11-29 10:33:47 -0800535 DisplayOption p = points.get(0);
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700536 if (dist(width, height, p.minWidthDps, p.minHeightDps) == 0) {
537 return p;
Adam Cohen2e6da152015-05-06 11:42:25 -0700538 }
539
Sunny Goyal415f1732018-11-29 10:33:47 -0800540 DisplayOption out = new DisplayOption();
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700541 for (int i = 0; i < points.size() && i < KNEARESTNEIGHBOR; ++i) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800542 p = points.get(i);
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700543 float w = weight(width, height, p.minWidthDps, p.minHeightDps, WEIGHT_POWER);
544 weights += w;
Sunny Goyal415f1732018-11-29 10:33:47 -0800545 out.add(new DisplayOption().add(p).multiply(w));
Adam Cohen2e6da152015-05-06 11:42:25 -0700546 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800547 return out.multiply(1.0f / weights);
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700548 }
549
Sunny Goyal27835952017-01-13 12:15:53 -0800550 public DeviceProfile getDeviceProfile(Context context) {
551 return context.getResources().getConfiguration().orientation
552 == Configuration.ORIENTATION_LANDSCAPE ? landscapeProfile : portraitProfile;
553 }
554
Sunny Goyal415f1732018-11-29 10:33:47 -0800555 private static float weight(float x0, float y0, float x1, float y1, float pow) {
Hyunyoung Song35c3c7f2015-05-28 15:33:40 -0700556 float d = dist(x0, y0, x1, y1);
557 if (Float.compare(d, 0f) == 0) {
558 return Float.POSITIVE_INFINITY;
559 }
560 return (float) (WEIGHT_EFFICIENT / Math.pow(d, pow));
561 }
Sunny Goyal6f866092016-03-17 17:04:15 -0700562
563 /**
564 * As a ratio of screen height, the total distance we want the parallax effect to span
565 * horizontally
566 */
567 private static float wallpaperTravelToScreenWidthRatio(int width, int height) {
568 float aspectRatio = width / (float) height;
569
570 // At an aspect ratio of 16/10, the wallpaper parallax effect should span 1.5 * screen width
571 // At an aspect ratio of 10/16, the wallpaper parallax effect should span 1.2 * screen width
572 // We will use these two data points to extrapolate how much the wallpaper parallax effect
573 // to span (ie travel) at any aspect ratio:
574
575 final float ASPECT_RATIO_LANDSCAPE = 16/10f;
576 final float ASPECT_RATIO_PORTRAIT = 10/16f;
577 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE = 1.5f;
578 final float WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT = 1.2f;
579
580 // To find out the desired width at different aspect ratios, we use the following two
581 // formulas, where the coefficient on x is the aspect ratio (width/height):
582 // (16/10)x + y = 1.5
583 // (10/16)x + y = 1.2
584 // We solve for x and y and end up with a final formula:
585 final float x =
586 (WALLPAPER_WIDTH_TO_SCREEN_RATIO_LANDSCAPE - WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT) /
587 (ASPECT_RATIO_LANDSCAPE - ASPECT_RATIO_PORTRAIT);
588 final float y = WALLPAPER_WIDTH_TO_SCREEN_RATIO_PORTRAIT - x * ASPECT_RATIO_PORTRAIT;
589 return x * aspectRatio + y;
590 }
591
Sunny Goyal87dc48b2018-10-12 11:42:33 -0700592 public interface OnIDPChangeListener {
593
594 void onIdpChanged(int changeFlags, InvariantDeviceProfile profile);
595 }
Sunny Goyal415f1732018-11-29 10:33:47 -0800596
597
Sunny Goyaleff44f32019-01-09 17:29:49 -0800598 public static final class GridOption {
Sunny Goyal415f1732018-11-29 10:33:47 -0800599
Sunny Goyal7d892ff2019-01-11 15:08:44 -0800600 public static final String TAG_NAME = "grid-option";
601
Sunny Goyaleff44f32019-01-09 17:29:49 -0800602 public final String name;
603 public final int numRows;
604 public final int numColumns;
Sunny Goyal415f1732018-11-29 10:33:47 -0800605
606 private final int numFolderRows;
607 private final int numFolderColumns;
608
609 private final int numHotseatIcons;
610
Tracy Zhou7df93d22020-01-27 13:44:06 -0800611 private final String dbFile;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000612 private final int numAllAppsColumns;
613
Sunny Goyal415f1732018-11-29 10:33:47 -0800614 private final int defaultLayoutId;
615 private final int demoModeLayoutId;
616
Jon Mirandae126d722021-02-25 10:45:20 -0500617 private final boolean isScalable;
618
Sunny Goyal5bc18462019-01-07 15:13:39 -0800619 private final SparseArray<TypedValue> extraAttrs;
620
Sunny Goyaleff44f32019-01-09 17:29:49 -0800621 public GridOption(Context context, AttributeSet attrs) {
Sunny Goyal415f1732018-11-29 10:33:47 -0800622 TypedArray a = context.obtainStyledAttributes(
623 attrs, R.styleable.GridDisplayOption);
624 name = a.getString(R.styleable.GridDisplayOption_name);
625 numRows = a.getInt(R.styleable.GridDisplayOption_numRows, 0);
626 numColumns = a.getInt(R.styleable.GridDisplayOption_numColumns, 0);
627
Tracy Zhou7df93d22020-01-27 13:44:06 -0800628 dbFile = a.getString(R.styleable.GridDisplayOption_dbFile);
Sunny Goyal415f1732018-11-29 10:33:47 -0800629 defaultLayoutId = a.getResourceId(
630 R.styleable.GridDisplayOption_defaultLayoutId, 0);
631 demoModeLayoutId = a.getResourceId(
632 R.styleable.GridDisplayOption_demoModeLayoutId, defaultLayoutId);
633 numHotseatIcons = a.getInt(
634 R.styleable.GridDisplayOption_numHotseatIcons, numColumns);
635 numFolderRows = a.getInt(
636 R.styleable.GridDisplayOption_numFolderRows, numRows);
637 numFolderColumns = a.getInt(
638 R.styleable.GridDisplayOption_numFolderColumns, numColumns);
Sunny Goyalae190ff2020-04-14 00:19:01 +0000639 numAllAppsColumns = a.getInt(
640 R.styleable.GridDisplayOption_numAllAppsColumns, numColumns);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700641
Jon Mirandae126d722021-02-25 10:45:20 -0500642 isScalable = a.getBoolean(
643 R.styleable.GridDisplayOption_isScalable, false);
644
Sunny Goyal415f1732018-11-29 10:33:47 -0800645 a.recycle();
Sunny Goyal5bc18462019-01-07 15:13:39 -0800646
647 extraAttrs = Themes.createValueMap(context, attrs,
648 IntArray.wrap(R.styleable.GridDisplayOption));
Sunny Goyal415f1732018-11-29 10:33:47 -0800649 }
650 }
651
652 private static final class DisplayOption {
653 private final GridOption grid;
654
Sunny Goyal415f1732018-11-29 10:33:47 -0800655 private final float minWidthDps;
656 private final float minHeightDps;
657 private final boolean canBeDefault;
658
Jon Mirandae126d722021-02-25 10:45:20 -0500659 private float minCellHeight;
660 private float minCellWidth;
661 private float borderSpacing;
662
Sunny Goyal415f1732018-11-29 10:33:47 -0800663 private float iconSize;
Sunny Goyal415f1732018-11-29 10:33:47 -0800664 private float iconTextSize;
Jon Miranda6f7e9702019-09-16 14:44:14 -0700665 private float landscapeIconSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000666 private float allAppsIconSize;
667 private float allAppsIconTextSize;
Sunny Goyal415f1732018-11-29 10:33:47 -0800668
669 DisplayOption(GridOption grid, Context context, AttributeSet attrs) {
670 this.grid = grid;
671
672 TypedArray a = context.obtainStyledAttributes(
673 attrs, R.styleable.ProfileDisplayOption);
674
Sunny Goyal415f1732018-11-29 10:33:47 -0800675 minWidthDps = a.getFloat(R.styleable.ProfileDisplayOption_minWidthDps, 0);
676 minHeightDps = a.getFloat(R.styleable.ProfileDisplayOption_minHeightDps, 0);
677 canBeDefault = a.getBoolean(
678 R.styleable.ProfileDisplayOption_canBeDefault, false);
679
Jon Mirandae126d722021-02-25 10:45:20 -0500680 minCellHeight = a.getFloat(R.styleable.ProfileDisplayOption_minCellHeightDps, 0);
681 minCellWidth = a.getFloat(R.styleable.ProfileDisplayOption_minCellWidthDps, 0);
682 borderSpacing = a.getFloat(R.styleable.ProfileDisplayOption_borderSpacingDps, 0);
683
Ryan Mitchell01b8b682019-03-28 17:01:07 -0700684 iconSize = a.getFloat(R.styleable.ProfileDisplayOption_iconImageSize, 0);
Sunny Goyal415f1732018-11-29 10:33:47 -0800685 landscapeIconSize = a.getFloat(R.styleable.ProfileDisplayOption_landscapeIconSize,
686 iconSize);
687 iconTextSize = a.getFloat(R.styleable.ProfileDisplayOption_iconTextSize, 0);
Jon Miranda6f7e9702019-09-16 14:44:14 -0700688
Sunny Goyalae190ff2020-04-14 00:19:01 +0000689 allAppsIconSize = a.getFloat(R.styleable.ProfileDisplayOption_allAppsIconSize,
690 iconSize);
691 allAppsIconTextSize = a.getFloat(R.styleable.ProfileDisplayOption_allAppsIconTextSize,
692 iconTextSize);
Sunny Goyal415f1732018-11-29 10:33:47 -0800693 a.recycle();
694 }
695
696 DisplayOption() {
Sunny Goyal0e7a3382020-04-13 17:15:05 -0700697 this(null);
698 }
699
700 DisplayOption(GridOption grid) {
701 this.grid = grid;
Sunny Goyal415f1732018-11-29 10:33:47 -0800702 minWidthDps = 0;
703 minHeightDps = 0;
704 canBeDefault = false;
Jon Mirandae126d722021-02-25 10:45:20 -0500705 minCellHeight = 0;
706 minCellWidth = 0;
707 borderSpacing = 0;
Sunny Goyal415f1732018-11-29 10:33:47 -0800708 }
709
710 private DisplayOption multiply(float w) {
711 iconSize *= w;
712 landscapeIconSize *= w;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000713 allAppsIconSize *= w;
Sunny Goyal415f1732018-11-29 10:33:47 -0800714 iconTextSize *= w;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000715 allAppsIconTextSize *= w;
Jon Mirandae126d722021-02-25 10:45:20 -0500716 minCellHeight *= w;
717 minCellWidth *= w;
718 borderSpacing *= w;
Sunny Goyal415f1732018-11-29 10:33:47 -0800719 return this;
720 }
721
722 private DisplayOption add(DisplayOption p) {
723 iconSize += p.iconSize;
724 landscapeIconSize += p.landscapeIconSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000725 allAppsIconSize += p.allAppsIconSize;
Sunny Goyal415f1732018-11-29 10:33:47 -0800726 iconTextSize += p.iconTextSize;
Sunny Goyalae190ff2020-04-14 00:19:01 +0000727 allAppsIconTextSize += p.allAppsIconTextSize;
Jon Mirandae126d722021-02-25 10:45:20 -0500728 minCellHeight += p.minCellHeight;
729 minCellWidth += p.minCellWidth;
730 borderSpacing += p.borderSpacing;
Sunny Goyal415f1732018-11-29 10:33:47 -0800731 return this;
732 }
733 }
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700734
735 private class OverlayMonitor extends BroadcastReceiver {
736
737 private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
738
739 OverlayMonitor(Context context) {
Sunny Goyal8b0cb412019-04-22 09:01:26 -0700740 context.registerReceiver(this, getPackageFilter("android", ACTION_OVERLAY_CHANGED));
Hyunyoung Songe11eb472019-03-19 15:05:21 -0700741 }
742
743 @Override
744 public void onReceive(Context context, Intent intent) {
745 onConfigChanged(context);
746 }
747 }
Sunny Goyalae190ff2020-04-14 00:19:01 +0000748}