隐藏音量弹框,阻止音量在某个应用界面弹窗

/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java

1.导包

 

 2.引用当前包名

//*/tyd,lxd,20221215, add top packagename
    private String getTopActivityPacakgeName(){
        String currentApp = "CurrentNULL";
        UsageStatsManager usm = (UsageStatsManager) mContext.getSystemService(Context.USAGE_STATS_SERVICE);
        long time = System.currentTimeMillis();
        List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000 * 1000, time);
        if (appList != null && appList.size() > 0) {
            SortedMap<Long, UsageStats> mySortedMap = new TreeMap<Long, UsageStats>();
            for (UsageStats usageStats : appList) {
                mySortedMap.put(usageStats.getLastTimeUsed(), usageStats);
            }
            if (mySortedMap != null && !mySortedMap.isEmpty()) {
                currentApp = mySortedMap.get(mySortedMap.lastKey()).getPackageName();
            }
        }
        Log.d("SideKey", "currentApp = "+currentApp);
        return currentApp;
    }
    //*/

 3.判断包名,并隐藏音量类型

//*/tyd,lxd,20221215,hide audio ui
            if(getTopActivityPacakgeName().equals("com.tom.talkie")){
               if (streamType== AudioSystem.STREAM_ALARM || streamType== AudioSystem.STREAM_MUSIC || streamType== AudioSystem.STREAM_VOICE_CALL  ) {
                   return;
               }
            }
            //*/

猜你喜欢

转载自blog.csdn.net/qq_46687516/article/details/128473257
今日推荐