Loading libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @file:JvmName("AppToWebUtils") package com.android.wm.shell.apptoweb import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.net.Uri private val browserIntent = Intent() .setAction(Intent.ACTION_VIEW) .addCategory(Intent.CATEGORY_BROWSABLE) .setData(Uri.parse("http:")) /** * Returns a boolean indicating whether a given package is a browser app. */ fun isBrowserApp(context: Context, packageName: String, userId: Int): Boolean { browserIntent.setPackage(packageName) val list = context.packageManager.queryIntentActivitiesAsUser( browserIntent, PackageManager.MATCH_ALL, userId ) list.forEach { if (it.activityInfo != null && it.handleAllWebDataURI) { return true } } return false } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +7 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.wm.shell.R; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.apptoweb.AppToWebGenericLinksParser; import com.android.wm.shell.apptoweb.AppToWebUtils; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.MultiInstanceHelper; Loading Loading @@ -478,6 +479,12 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin @Nullable private Uri getBrowserLink() { // Do not show browser link in browser applications final ComponentName baseActivity = mTaskInfo.baseActivity; if (baseActivity != null && AppToWebUtils.isBrowserApp(mContext, baseActivity.getPackageName(), mUserContext.getUserId())) { return null; } // If the captured link is available and has not expired, return the captured link. // Otherwise, return the generic link which is set to null if a generic link is unavailable. if (mCapturedLink != null && !mCapturedLink.mExpired) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @file:JvmName("AppToWebUtils") package com.android.wm.shell.apptoweb import android.content.Context import android.content.Intent import android.content.pm.PackageManager import android.net.Uri private val browserIntent = Intent() .setAction(Intent.ACTION_VIEW) .addCategory(Intent.CATEGORY_BROWSABLE) .setData(Uri.parse("http:")) /** * Returns a boolean indicating whether a given package is a browser app. */ fun isBrowserApp(context: Context, packageName: String, userId: Int): Boolean { browserIntent.setPackage(packageName) val list = context.packageManager.queryIntentActivitiesAsUser( browserIntent, PackageManager.MATCH_ALL, userId ) list.forEach { if (it.activityInfo != null && it.handleAllWebDataURI) { return true } } return false }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +7 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ import com.android.wm.shell.R; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.apptoweb.AppToWebGenericLinksParser; import com.android.wm.shell.apptoweb.AppToWebUtils; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.MultiInstanceHelper; Loading Loading @@ -478,6 +479,12 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin @Nullable private Uri getBrowserLink() { // Do not show browser link in browser applications final ComponentName baseActivity = mTaskInfo.baseActivity; if (baseActivity != null && AppToWebUtils.isBrowserApp(mContext, baseActivity.getPackageName(), mUserContext.getUserId())) { return null; } // If the captured link is available and has not expired, return the captured link. // Otherwise, return the generic link which is set to null if a generic link is unavailable. if (mCapturedLink != null && !mCapturedLink.mExpired) { Loading