/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;
}
}
//*/