解决 '__pendingCallbacks[...].async' 为空或不是对象

本文介绍了如何解决在Windows Server 2003上出现的'__pendingCallbacks[...].async'为空或不是对象的JS脚本错误。提供了两种解决方案:一是通过添加特定脚本来修复,二是安装补丁。作者选择了添加脚本的方法并成功解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决 '__pendingCallbacks[...].async' 为空或不是对象

在开发者电脑win7+vs2008上,没有报这个脚本错误,但在服务器win2003上报这个错。
后来找到解决办法。

有两个,一个是添加一段脚本,

一个是安装补丁。

我比较反感装补丁,就直接添加脚本了。问题真解决了。补丁这个,我没去验证是否可行。

按文章上所说,问题是因为js中的变量的作用域与命名不规范引起的。
/* * Copyright (C) 2015 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. */ package android.media; import java.util.Arrays; import java.util.List; import android.content.Intent; import android.content.IntentFilter; import android.content.Context; import android.content.BroadcastReceiver; import android.util.Log; import android.app.ActivityThread; /** * @hide * * damon.zhang Block app too frequent getStreamVolume */ public class NtAudioManager { private static final String TAG = "NtAudioManager"; private long preGetVolumeTime = 0; private String preGetVolumePkg = ""; private int mLastIndex = 0; private static NtAudioManager mNtAudioManager; private static String mPkg; private static final BroadcastReceiver mNtAmReceiver; public NtAudioManager(String pkg) { mPkg = pkg; } public static NtAudioManager getNtAudioManager(Context contex, String pkg) { //if (!mGetStreamVolumeBlackList.contains(pkg)) { // return null; //} Context context = ActivityThread.currentApplication(); if (mNtAudioManager == null && context != null && mNtAmReceiver == null) { mNtAudioManager = new NtAudioManager(pkg); initReceiver(contex); } return mNtAudioManager; } private static final List<String> mGetStreamVolumeBlackList = Arrays.asList(new String[] { "com.tencent.mobileqq", "com.tencent.mtt", "com.tencent.mm", "com.tencent.KiHn", "com.google.android.youtube", "com.google.android.apps.youtube.music", "com.google.android.googlequicksearchbox", "com.facebook.katana", "com.instagram.android", "com.truecaller", "com.miHoYo.hkrpg", "com.spotify.music", "ahaflix.tv", "com.vkontakte.android", "com.vk.equals", "com.microsoft.appmanager", "com.jio.media.ondemand", "com.kiloo.subwaysurf", "com.hongsong.live.lite", "com.nothing.smartcenter" }); public static int[] LAST_STREAM_VOLUME = new int[] { -1, // STREAM_VOICE_CALL -1, // STREAM_SYSTEM -1, // STREAM_RING -1, // STREAM_MUSIC -1, // STREAM_ALARM -1, // STREAM_NOTIFICATION -1, // STREAM_BLUETOOTH_SCO -1, // STREAM_SYSTEM_ENFORCED -1, // STREAM_DTMF -1, // STREAM_TTS -1, // STREAM_ACCESSIBILITY -1, // STREAM_ASSISTANT }; public int getVolume(int streamType) { return LAST_STREAM_VOLUME[streamType]; } public void setVolume(int index, int streamType){ LAST_STREAM_VOLUME[streamType] = index; } public boolean isInitVolume(String pkgName, int streamType) { ensureValidStreamType(streamType); //if (!mGetStreamVolumeBlackList.contains(pkgName)) { // return false; //} if (LAST_STREAM_VOLUME[streamType] == -1) { return false; } return true; } private void ensureValidStreamType(int streamType) { if (streamType < 0 || streamType >= LAST_STREAM_VOLUME.length) { throw new IllegalArgumentException("Bad stream type " + streamType); } } private void initReceiver(Context con) { mNtAmReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(AudioManager.VOLUME_CHANGED_ACTION)) { int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); int currentVolume = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1); int lastVolume = intent.getIntExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, -1); int streamTypeAltas = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS, -1); Log.i(TAG, "mNtAudioManager: "+ mNtAudioManager + " mPkg: " + mPkg + " streamType : " + streamType + " streamTypeAltas: " + streamTypeAltas + " currentVolume: " + currentVolume + " lastVolume: " + lastVolume); LAST_STREAM_VOLUME[streamType] = currentVolume; } } }; IntentFilter intentFilter = new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION); con.registerReceiver(mNtAmReceiver, intentFilter, null, null); } }
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值