1 package com.android.systemui.statusbar.notification.fsi 2 3 import android.app.ActivityOptions 4 import android.content.Context 5 import android.content.Intent 6 import android.graphics.PixelFormat 7 import android.graphics.Rect 8 import android.os.Binder 9 import android.view.ViewGroup 10 import android.view.WindowManager 11 12 /** 13 * Config for adding the FsiChromeView window to WindowManager and starting the FSI activity. 14 */ 15 class FsiTaskViewConfig { 16 17 companion object { 18 19 private const val classTag = "FsiTaskViewConfig" 20 getWmLayoutParamsnull21 fun getWmLayoutParams(packageName: String): WindowManager.LayoutParams { 22 val params: WindowManager.LayoutParams? 23 params = 24 WindowManager.LayoutParams( 25 ViewGroup.LayoutParams.MATCH_PARENT, 26 ViewGroup.LayoutParams.MATCH_PARENT, 27 WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, 28 WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE or 29 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED or 30 WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER, 31 PixelFormat.TRANSLUCENT 32 ) 33 params.setTrustedOverlay() 34 params.fitInsetsTypes = 0 35 params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE 36 params.token = Binder() 37 params.packageName = packageName 38 params.layoutInDisplayCutoutMode = 39 WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS 40 params.privateFlags = 41 params.privateFlags or WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS 42 return params 43 } 44 getFillInIntentnull45 fun getFillInIntent(): Intent { 46 val fillInIntent = Intent() 47 fillInIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT) 48 fillInIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK) 49 // FLAG_ACTIVITY_NEW_TASK is auto-applied because 50 // we're starting the FSI activity from a non-Activity context 51 return fillInIntent 52 } 53 getLaunchBoundsnull54 fun getLaunchBounds(windowManager: WindowManager): Rect { 55 // TODO(b/243421660) check this works for non-resizeable activity 56 return Rect() 57 } 58 getActivityOptionsnull59 fun getActivityOptions(context: Context, windowManager: WindowManager): ActivityOptions { 60 // Custom options so there is no activity transition animation 61 val options = 62 ActivityOptions.makeCustomAnimation(context, 0 /* enterResId */, 0 /* exitResId */) 63 64 options.taskAlwaysOnTop = true 65 66 options.pendingIntentLaunchFlags = 67 Intent.FLAG_ACTIVITY_NEW_DOCUMENT or 68 Intent.FLAG_ACTIVITY_MULTIPLE_TASK or 69 Intent.FLAG_ACTIVITY_NEW_TASK 70 71 options.launchBounds = getLaunchBounds(windowManager) 72 return options 73 } 74 } 75 } 76