美文网首页
Android 上隐藏launch上小部件(android13)

Android 上隐藏launch上小部件(android13)

作者: gale_小米 | 来源:发表于2023-11-21 09:35 被阅读0次

    1.客户需求隐藏桌面上第三方的桌面小部件;


    image.png

    1.根据UI定位到对应的视图QsbContainerView,发现里面有直接find小部件对应包名的方法,那就直接根据包名过滤掉对应的视图创建就行;

    Index: src/com/android/launcher3/qsb/QsbContainerView.java
    ===================================================================
    @@ -53,6 +53,7 @@
     import com.android.launcher3.config.FeatureFlags;
     import com.android.launcher3.graphics.FragmentWithPreview;
     import com.android.launcher3.widget.util.WidgetSizes;
    +import android.util.Log;
     
     /**
      * A frame layout which contains a QSB. This internally uses fragment to bind the view, which
    @@ -193,7 +194,11 @@
                 // Only add the view when enabled
                 if (isQsbEnabled()) {
                     mQsbWidgetHost.startListening();
    -                mWrapper.addView(createQsb(mWrapper));
    +                String providerPkg = getSearchWidgetPackageName(getContext());
    +                Log.e("QsbContainerView", "onCreateView createQsb providerPkg="+providerPkg);
    +                if (!providerPkg.contains("com.qiyi.video.pad")) {
    +                    mWrapper.addView(createQsb(mWrapper));
    +                }
                 }
                 Utilities.getPrefs(getContext()).registerOnSharedPreferenceChangeListener(this);
                 return mWrapper;
    @@ -311,7 +316,11 @@
     
                 if (mWrapper != null && getContext() != null) {
                     mWrapper.removeAllViews();
    -                mWrapper.addView(createQsb(mWrapper));
    +                String providerPkg = getSearchWidgetPackageName(getContext());
    +                Log.e("QsbContainerView", "rebindFragment createQsb providerPkg="+providerPkg);
    +                if (!providerPkg.contains("com.qiyi.video.pad")) {
    +                    mWrapper.addView(createQsb(mWrapper));
    +                }
                 }
             }
    

    相关文章

      网友评论

          本文标题:Android 上隐藏launch上小部件(android13)

          本文链接:https://www.haomeiwen.com/subject/poebwdtx.html