Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
| 17 | package com.android.launcher3; |
| 18 | |
Hyunyoung Song | 7f7894e | 2020-04-27 01:12:01 -0700 | [diff] [blame] | 19 | import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 20 | import static com.android.launcher3.util.DefaultDisplay.CHANGE_ROTATION; |
| 21 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 22 | import android.app.ActivityOptions; |
| 23 | import android.content.ActivityNotFoundException; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 24 | import android.content.Intent; |
Sunny Goyal | e7b0012 | 2019-10-02 16:13:34 -0700 | [diff] [blame] | 25 | import android.content.pm.LauncherApps; |
Lucas Dupin | eca08a1 | 2018-08-11 15:53:40 -0700 | [diff] [blame] | 26 | import android.content.res.Configuration; |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 27 | import android.graphics.Insets; |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 28 | import android.graphics.Point; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 29 | import android.graphics.Rect; |
| 30 | import android.os.Bundle; |
| 31 | import android.os.Process; |
| 32 | import android.os.StrictMode; |
| 33 | import android.os.UserHandle; |
| 34 | import android.util.Log; |
| 35 | import android.view.ActionMode; |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 36 | import android.view.Display; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 37 | import android.view.View; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 38 | import android.view.View.OnClickListener; |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 39 | import android.view.WindowInsets.Type; |
| 40 | import android.view.WindowMetrics; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 41 | import android.widget.Toast; |
| 42 | |
Winson Chung | 13c1c2c | 2019-09-06 11:46:19 -0700 | [diff] [blame] | 43 | import androidx.annotation.Nullable; |
| 44 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 45 | import com.android.launcher3.LauncherSettings.Favorites; |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 46 | import com.android.launcher3.model.AppLaunchTracker; |
Sunny Goyal | e396abf | 2020-04-06 15:11:17 -0700 | [diff] [blame] | 47 | import com.android.launcher3.model.data.ItemInfo; |
| 48 | import com.android.launcher3.model.data.WorkspaceItemInfo; |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 49 | import com.android.launcher3.touch.ItemClickHandler; |
Sunny Goyal | 18c699f | 2018-05-03 16:58:41 -0700 | [diff] [blame] | 50 | import com.android.launcher3.uioverrides.WallpaperColorInfo; |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 51 | import com.android.launcher3.util.DefaultDisplay; |
| 52 | import com.android.launcher3.util.DefaultDisplay.DisplayInfoChangeListener; |
| 53 | import com.android.launcher3.util.DefaultDisplay.Info; |
Sunny Goyal | 9dbb27c | 2019-07-17 15:12:56 -0700 | [diff] [blame] | 54 | import com.android.launcher3.util.PackageManagerHelper; |
Hyunyoung Song | fcd090d | 2019-05-01 13:15:29 -0700 | [diff] [blame] | 55 | import com.android.launcher3.util.Themes; |
Sunny Goyal | 17c72fb | 2019-10-14 14:06:38 -0700 | [diff] [blame] | 56 | import com.android.launcher3.util.TraceHelper; |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 57 | import com.android.launcher3.util.WindowBounds; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Extension of BaseActivity allowing support for drag-n-drop |
| 61 | */ |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 62 | public abstract class BaseDraggingActivity extends BaseActivity |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 63 | implements WallpaperColorInfo.OnChangeListener, DisplayInfoChangeListener { |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 64 | |
| 65 | private static final String TAG = "BaseDraggingActivity"; |
| 66 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 67 | // When starting an action mode, setting this tag will cause the action mode to be cancelled |
| 68 | // automatically when user interacts with the launcher. |
| 69 | public static final Object AUTO_CANCEL_ACTION_MODE = new Object(); |
| 70 | |
| 71 | private ActionMode mCurrentActionMode; |
| 72 | protected boolean mIsSafeModeEnabled; |
| 73 | |
Winson Chung | a19a2b7 | 2019-10-14 16:30:38 -0700 | [diff] [blame] | 74 | private Runnable mOnStartCallback; |
Sunny Goyal | 9d69c8d | 2018-03-19 13:41:31 -0700 | [diff] [blame] | 75 | |
Sunny Goyal | bd88f39 | 2018-06-07 15:42:57 -0700 | [diff] [blame] | 76 | private int mThemeRes = R.style.AppTheme; |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 77 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 78 | @Override |
| 79 | protected void onCreate(Bundle savedInstanceState) { |
| 80 | super.onCreate(savedInstanceState); |
Sunny Goyal | 17c72fb | 2019-10-14 14:06:38 -0700 | [diff] [blame] | 81 | |
| 82 | |
| 83 | mIsSafeModeEnabled = TraceHelper.whitelistIpcs("isSafeMode", |
| 84 | () -> getPackageManager().isSafeMode()); |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 85 | DefaultDisplay.INSTANCE.get(this).addChangeListener(this); |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 86 | |
| 87 | // Update theme |
Sunny Goyal | 73b5a27 | 2019-12-09 14:55:56 -0800 | [diff] [blame] | 88 | WallpaperColorInfo.INSTANCE.get(this).addOnChangeListener(this); |
Hyunyoung Song | fcd090d | 2019-05-01 13:15:29 -0700 | [diff] [blame] | 89 | int themeRes = Themes.getActivityThemeRes(this); |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 90 | if (themeRes != mThemeRes) { |
| 91 | mThemeRes = themeRes; |
| 92 | setTheme(themeRes); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public void onExtractedColorsChanged(WallpaperColorInfo wallpaperColorInfo) { |
Lucas Dupin | eca08a1 | 2018-08-11 15:53:40 -0700 | [diff] [blame] | 98 | updateTheme(); |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public void onConfigurationChanged(Configuration newConfig) { |
| 103 | super.onConfigurationChanged(newConfig); |
| 104 | updateTheme(); |
| 105 | } |
| 106 | |
| 107 | private void updateTheme() { |
Hyunyoung Song | fcd090d | 2019-05-01 13:15:29 -0700 | [diff] [blame] | 108 | if (mThemeRes != Themes.getActivityThemeRes(this)) { |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 109 | recreate(); |
| 110 | } |
| 111 | } |
| 112 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 113 | @Override |
| 114 | public void onActionModeStarted(ActionMode mode) { |
| 115 | super.onActionModeStarted(mode); |
| 116 | mCurrentActionMode = mode; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public void onActionModeFinished(ActionMode mode) { |
| 121 | super.onActionModeFinished(mode); |
| 122 | mCurrentActionMode = null; |
| 123 | } |
| 124 | |
Sunny Goyal | 87b5eb6 | 2018-07-03 15:53:39 -0700 | [diff] [blame] | 125 | @Override |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 126 | public boolean finishAutoCancelActionMode() { |
| 127 | if (mCurrentActionMode != null && AUTO_CANCEL_ACTION_MODE == mCurrentActionMode.getTag()) { |
| 128 | mCurrentActionMode.finish(); |
| 129 | return true; |
| 130 | } |
| 131 | return false; |
| 132 | } |
| 133 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 134 | public abstract <T extends View> T getOverviewPanel(); |
| 135 | |
Sunny Goyal | 9d69c8d | 2018-03-19 13:41:31 -0700 | [diff] [blame] | 136 | public abstract View getRootView(); |
| 137 | |
Vinit Nayak | f9b585b | 2019-07-10 14:25:32 -0700 | [diff] [blame] | 138 | public void returnToHomescreen() { |
| 139 | // no-op |
| 140 | } |
| 141 | |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 142 | public Rect getViewBounds(View v) { |
| 143 | int[] pos = new int[2]; |
| 144 | v.getLocationOnScreen(pos); |
| 145 | return new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight()); |
| 146 | } |
| 147 | |
Jon Miranda | 73c27ec | 2018-05-16 18:06:23 -0700 | [diff] [blame] | 148 | public final Bundle getActivityLaunchOptionsAsBundle(View v) { |
| 149 | ActivityOptions activityOptions = getActivityLaunchOptions(v); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 150 | return activityOptions == null ? null : activityOptions.toBundle(); |
| 151 | } |
| 152 | |
Jon Miranda | 73c27ec | 2018-05-16 18:06:23 -0700 | [diff] [blame] | 153 | public abstract ActivityOptions getActivityLaunchOptions(View v); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 154 | |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 155 | public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item, |
| 156 | @Nullable String sourceContainer) { |
Sunny Goyal | 9dbb27c | 2019-07-17 15:12:56 -0700 | [diff] [blame] | 157 | if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) { |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 158 | Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show(); |
| 159 | return false; |
| 160 | } |
| 161 | |
Sunny Goyal | 9018627 | 2019-01-31 12:37:41 -0800 | [diff] [blame] | 162 | Bundle optsBundle = (v != null) ? getActivityLaunchOptionsAsBundle(v) : null; |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 163 | UserHandle user = item == null ? null : item.user; |
| 164 | |
| 165 | // Prepare intent |
| 166 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 167 | if (v != null) { |
| 168 | intent.setSourceBounds(getViewBounds(v)); |
| 169 | } |
| 170 | try { |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 171 | boolean isShortcut = (item instanceof WorkspaceItemInfo) |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 172 | && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT |
| 173 | || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 174 | && !((WorkspaceItemInfo) item).isPromise(); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 175 | if (isShortcut) { |
| 176 | // Shortcuts need some special checks due to legacy reasons. |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 177 | startShortcutIntentSafely(intent, optsBundle, item, sourceContainer); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 178 | } else if (user == null || user.equals(Process.myUserHandle())) { |
| 179 | // Could be launching some bookkeeping activity |
| 180 | startActivity(intent, optsBundle); |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 181 | AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(), |
| 182 | Process.myUserHandle(), sourceContainer); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 183 | } else { |
Sunny Goyal | e7b0012 | 2019-10-02 16:13:34 -0700 | [diff] [blame] | 184 | getSystemService(LauncherApps.class).startMainActivity( |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 185 | intent.getComponent(), user, intent.getSourceBounds(), optsBundle); |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 186 | AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(), user, |
| 187 | sourceContainer); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 188 | } |
Samuel Fufa | 78e7e5f | 2019-12-10 13:23:51 -0800 | [diff] [blame] | 189 | getUserEventDispatcher().logAppLaunch(v, intent, user); |
Hyunyoung Song | f26c793 | 2020-06-06 14:44:27 -0700 | [diff] [blame^] | 190 | if (item != null) { |
| 191 | getStatsLogManager().log(LAUNCHER_APP_LAUNCH_TAP, item.buildProto()); |
| 192 | } |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 193 | return true; |
Jon Miranda | 0121d46 | 2019-08-01 15:44:55 -0700 | [diff] [blame] | 194 | } catch (NullPointerException|ActivityNotFoundException|SecurityException e) { |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 195 | Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); |
| 196 | Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e); |
| 197 | } |
| 198 | return false; |
| 199 | } |
| 200 | |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 201 | private void startShortcutIntentSafely(Intent intent, Bundle optsBundle, ItemInfo info, |
| 202 | @Nullable String sourceContainer) { |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 203 | try { |
| 204 | StrictMode.VmPolicy oldPolicy = StrictMode.getVmPolicy(); |
| 205 | try { |
| 206 | // Temporarily disable deathPenalty on all default checks. For eg, shortcuts |
| 207 | // containing file Uri's would cause a crash as penaltyDeathOnFileUriExposure |
| 208 | // is enabled by default on NYC. |
| 209 | StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll() |
| 210 | .penaltyLog().build()); |
| 211 | |
| 212 | if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { |
Sunny Goyal | 9589916 | 2019-03-27 16:03:06 -0700 | [diff] [blame] | 213 | String id = ((WorkspaceItemInfo) info).getDeepShortcutId(); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 214 | String packageName = intent.getPackage(); |
Sunny Goyal | fa39536 | 2019-12-11 10:00:47 -0800 | [diff] [blame] | 215 | startShortcut(packageName, id, intent.getSourceBounds(), optsBundle, info.user); |
Sunny Goyal | 369212a | 2019-03-26 15:03:57 -0700 | [diff] [blame] | 216 | AppLaunchTracker.INSTANCE.get(this).onStartShortcut(packageName, id, info.user, |
| 217 | sourceContainer); |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 218 | } else { |
| 219 | // Could be launching some bookkeeping activity |
| 220 | startActivity(intent, optsBundle); |
| 221 | } |
| 222 | } finally { |
| 223 | StrictMode.setVmPolicy(oldPolicy); |
| 224 | } |
| 225 | } catch (SecurityException e) { |
| 226 | if (!onErrorStartingShortcut(intent, info)) { |
| 227 | throw e; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | protected boolean onErrorStartingShortcut(Intent intent, ItemInfo info) { |
| 233 | return false; |
| 234 | } |
Sunny Goyal | 9d69c8d | 2018-03-19 13:41:31 -0700 | [diff] [blame] | 235 | |
| 236 | @Override |
| 237 | protected void onStart() { |
| 238 | super.onStart(); |
| 239 | |
| 240 | if (mOnStartCallback != null) { |
Winson Chung | a19a2b7 | 2019-10-14 16:30:38 -0700 | [diff] [blame] | 241 | mOnStartCallback.run(); |
Sunny Goyal | 9d69c8d | 2018-03-19 13:41:31 -0700 | [diff] [blame] | 242 | mOnStartCallback = null; |
| 243 | } |
| 244 | } |
| 245 | |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 246 | @Override |
| 247 | protected void onDestroy() { |
| 248 | super.onDestroy(); |
Sunny Goyal | 73b5a27 | 2019-12-09 14:55:56 -0800 | [diff] [blame] | 249 | WallpaperColorInfo.INSTANCE.get(this).removeOnChangeListener(this); |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 250 | DefaultDisplay.INSTANCE.get(this).removeChangeListener(this); |
Sunny Goyal | ab83773 | 2018-03-27 17:35:54 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Winson Chung | a19a2b7 | 2019-10-14 16:30:38 -0700 | [diff] [blame] | 253 | public void runOnceOnStart(Runnable action) { |
| 254 | mOnStartCallback = action; |
| 255 | } |
| 256 | |
| 257 | public void clearRunOnceOnStartCallback() { |
| 258 | mOnStartCallback = null; |
Sunny Goyal | 9d69c8d | 2018-03-19 13:41:31 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Sunny Goyal | 59d086c | 2018-05-07 17:31:40 -0700 | [diff] [blame] | 261 | protected void onDeviceProfileInitiated() { |
| 262 | if (mDeviceProfile.isVerticalBarLayout()) { |
Winson Chung | 13c1c2c | 2019-09-06 11:46:19 -0700 | [diff] [blame] | 263 | mDeviceProfile.updateIsSeascape(this); |
Sunny Goyal | 59d086c | 2018-05-07 17:31:40 -0700 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | |
Sunny Goyal | 9f56a2f | 2020-02-03 14:22:09 -0800 | [diff] [blame] | 267 | @Override |
| 268 | public void onDisplayInfoChanged(Info info, int flags) { |
| 269 | if ((flags & CHANGE_ROTATION) != 0 && mDeviceProfile.updateIsSeascape(this)) { |
Sunny Goyal | 59d086c | 2018-05-07 17:31:40 -0700 | [diff] [blame] | 270 | reapplyUi(); |
| 271 | } |
| 272 | } |
| 273 | |
Sunny Goyal | 9c2b960 | 2020-01-07 13:07:55 -0800 | [diff] [blame] | 274 | public OnClickListener getItemOnClickListener() { |
| 275 | return ItemClickHandler.INSTANCE; |
| 276 | } |
| 277 | |
Sunny Goyal | 59d086c | 2018-05-07 17:31:40 -0700 | [diff] [blame] | 278 | protected abstract void reapplyUi(); |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 279 | |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 280 | protected WindowBounds getMultiWindowDisplaySize() { |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 281 | if (Utilities.ATLEAST_R) { |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 282 | WindowMetrics wm = getWindowManager().getCurrentWindowMetrics(); |
| 283 | |
| 284 | Insets insets = wm.getWindowInsets().getInsets(Type.systemBars()); |
| 285 | return new WindowBounds(wm.getBounds(), |
| 286 | new Rect(insets.left, insets.top, insets.right, insets.bottom)); |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 287 | } |
| 288 | // Note: Calls to getSize() can't rely on our cached DefaultDisplay since it can return |
| 289 | // the app window size |
| 290 | Display display = getWindowManager().getDefaultDisplay(); |
| 291 | Point mwSize = new Point(); |
| 292 | display.getSize(mwSize); |
Sunny Goyal | b46703d | 2020-05-27 17:52:03 -0700 | [diff] [blame] | 293 | return new WindowBounds(new Rect(0, 0, mwSize.x, mwSize.y), new Rect()); |
Sunny Goyal | 0addbf0 | 2020-04-28 14:17:35 -0700 | [diff] [blame] | 294 | } |
Sunny Goyal | 0b0847b | 2018-03-14 12:30:11 -0700 | [diff] [blame] | 295 | } |