Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.multiwindow; | 5 package org.chromium.chrome.browser.multiwindow; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
| 10 import android.app.ActivityManager.AppTask; | 10 import android.app.ActivityManager.AppTask; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 // 6. Default to regular ChromeTabbedActivity. | 235 // 6. Default to regular ChromeTabbedActivity. |
| 236 return ChromeTabbedActivity.class; | 236 return ChromeTabbedActivity.class; |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @param className The class name of the Activity to look for in Android re cents | 240 * @param className The class name of the Activity to look for in Android re cents |
| 241 * @param context The current Context, used to retrieve the ActivityManager system service. | 241 * @param context The current Context, used to retrieve the ActivityManager system service. |
| 242 * @return True if the Activity still has a task in Android recents, regardl ess of whether | 242 * @return True if the Activity still has a task in Android recents, regardl ess of whether |
| 243 * the Activity has been destroyed. | 243 * the Activity has been destroyed. |
| 244 */ | 244 */ |
| 245 @TargetApi(Build.VERSION_CODES.M) | |
|
Maria
2016/08/05 23:42:06
I think this would work with L and above
estevenson
2016/08/08 14:23:49
Same as ChromeTabbedActivity, it looks like Activi
| |
| 245 private boolean isActivityTaskInRecents(String className, Context context) { | 246 private boolean isActivityTaskInRecents(String className, Context context) { |
| 246 ActivityManager activityManager = (ActivityManager) | 247 ActivityManager activityManager = (ActivityManager) |
| 247 context.getSystemService(Context.ACTIVITY_SERVICE); | 248 context.getSystemService(Context.ACTIVITY_SERVICE); |
| 248 List<AppTask> appTasks = activityManager.getAppTasks(); | 249 List<AppTask> appTasks = activityManager.getAppTasks(); |
| 249 for (AppTask task : appTasks) { | 250 for (AppTask task : appTasks) { |
| 250 if (task.getTaskInfo() == null || task.getTaskInfo().baseActivity == null) continue; | 251 if (task.getTaskInfo() == null || task.getTaskInfo().baseActivity == null) continue; |
| 251 String baseActivity = task.getTaskInfo().baseActivity.getClassName() ; | 252 String baseActivity = task.getTaskInfo().baseActivity.getClassName() ; |
| 252 if (TextUtils.equals(baseActivity, className)) return true; | 253 if (TextUtils.equals(baseActivity, className)) return true; |
| 253 } | 254 } |
| 254 return false; | 255 return false; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 if (isLegacyMultiWindow(activity)) { | 297 if (isLegacyMultiWindow(activity)) { |
| 297 if (TextUtils.equals(ChromeTabbedActivity.class.getName(), | 298 if (TextUtils.equals(ChromeTabbedActivity.class.getName(), |
| 298 intent.getComponent().getClassName())) { | 299 intent.getComponent().getClassName())) { |
| 299 intent.setClassName(activity, MultiInstanceChromeTabbedActivity. class.getName()); | 300 intent.setClassName(activity, MultiInstanceChromeTabbedActivity. class.getName()); |
| 300 } | 301 } |
| 301 intent.setFlags(intent.getFlags() | 302 intent.setFlags(intent.getFlags() |
| 302 & ~(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW _DOCUMENT)); | 303 & ~(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW _DOCUMENT)); |
| 303 } | 304 } |
| 304 } | 305 } |
| 305 } | 306 } |
| OLD | NEW |