diff options
| -rw-r--r-- | config/preloaded-classes | 6 | ||||
| -rw-r--r-- | core/java/android/app/job/JobSnapshot.java | 10 | ||||
| -rw-r--r-- | graphics/java/android/graphics/fonts/SystemFonts.java | 3 | ||||
| -rw-r--r-- | libs/hwui/renderthread/VulkanManager.cpp | 97 | ||||
| -rw-r--r-- | libs/hwui/renderthread/VulkanManager.h | 7 | ||||
| -rw-r--r-- | media/java/android/media/audiofx/DefaultEffect.java | 1 | ||||
| -rw-r--r-- | media/java/android/media/audiofx/SourceDefaultEffect.java | 118 | ||||
| -rw-r--r-- | media/jni/audioeffect/Android.bp | 1 | ||||
| -rw-r--r-- | media/jni/audioeffect/android_media_AudioEffect.cpp | 6 | ||||
| -rw-r--r-- | media/jni/audioeffect/android_media_SourceDefaultEffect.cpp | 142 | ||||
| -rw-r--r-- | services/core/java/com/android/server/BluetoothManagerService.java | 20 | ||||
| -rw-r--r-- | services/core/java/com/android/server/statusbar/StatusBarManagerService.java | 29 |
12 files changed, 393 insertions, 47 deletions
diff --git a/config/preloaded-classes b/config/preloaded-classes index 001479370fb9..63c583f9264c 100644 --- a/config/preloaded-classes +++ b/config/preloaded-classes @@ -6236,9 +6236,9 @@ org.json.JSONObject$1 org.json.JSONStringer org.json.JSONStringer$Scope org.json.JSONTokener -org.kxml2.io.KXmlParser -org.kxml2.io.KXmlParser$ValueContext -org.kxml2.io.KXmlSerializer +com.android.org.kxml2.io.KXmlParser +com.android.org.kxml2.io.KXmlParser$ValueContext +com.android.org.kxml2.io.KXmlSerializer org.w3c.dom.CharacterData org.w3c.dom.DOMImplementation org.w3c.dom.Document diff --git a/core/java/android/app/job/JobSnapshot.java b/core/java/android/app/job/JobSnapshot.java index d6cc70dc3631..ceeaab7c5e6e 100644 --- a/core/java/android/app/job/JobSnapshot.java +++ b/core/java/android/app/job/JobSnapshot.java @@ -50,6 +50,14 @@ public class JobSnapshot implements Parcelable { } /** + * Returning JobInfo bound to this snapshot + * @return JobInfo of this snapshot + */ + public JobInfo getJobInfo() { + return mJob; + } + + /** * Is this job actually runnable at this moment? */ public boolean isRunnable() { @@ -77,7 +85,7 @@ public class JobSnapshot implements Parcelable { */ public boolean isRequireDeviceIdleSatisfied() { return !mJob.isRequireDeviceIdle() - || satisfied(JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW); + || satisfied(JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE); } public boolean isRequireStorageNotLowSatisfied() { diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java index dae48f8b528f..26b4ec530072 100644 --- a/graphics/java/android/graphics/fonts/SystemFonts.java +++ b/graphics/java/android/graphics/fonts/SystemFonts.java @@ -24,6 +24,7 @@ import android.util.ArrayMap; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.ArrayUtils; import org.xmlpull.v1.XmlPullParserException; @@ -251,7 +252,7 @@ public class SystemFonts { return fontConfig.getAliases(); } catch (IOException | XmlPullParserException e) { Log.e(TAG, "Failed initialize system fallbacks.", e); - return null; + return ArrayUtils.emptyArray(FontConfig.Alias.class); } } diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp index a19edae26cb3..1517f579a084 100644 --- a/libs/hwui/renderthread/VulkanManager.cpp +++ b/libs/hwui/renderthread/VulkanManager.cpp @@ -25,6 +25,8 @@ #include <GrBackendSurface.h> #include <GrContext.h> #include <GrTypes.h> +#include <GrTypes.h> +#include <vk/GrVkExtensions.h> #include <vk/GrVkTypes.h> namespace android { @@ -62,7 +64,7 @@ void VulkanManager::destroy() { mInstance = VK_NULL_HANDLE; } -bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { +bool VulkanManager::setupDevice(GrVkExtensions& grExtensions, VkPhysicalDeviceFeatures2& features) { VkResult err; constexpr VkApplicationInfo app_info = { @@ -128,7 +130,7 @@ bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { GET_INST_PROC(DestroyInstance); GET_INST_PROC(EnumeratePhysicalDevices); GET_INST_PROC(GetPhysicalDeviceQueueFamilyProperties); - GET_INST_PROC(GetPhysicalDeviceFeatures); + GET_INST_PROC(GetPhysicalDeviceFeatures2); GET_INST_PROC(CreateDevice); GET_INST_PROC(EnumerateDeviceExtensionProperties); GET_INST_PROC(CreateAndroidSurfaceKHR); @@ -217,11 +219,38 @@ bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { } } - // query to get the physical device properties - mGetPhysicalDeviceFeatures(mPhysicalDevice, &deviceFeatures); + auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) { + if (device != VK_NULL_HANDLE) { + return vkGetDeviceProcAddr(device, proc_name); + } + return vkGetInstanceProcAddr(instance, proc_name); + }; + grExtensions.init(getProc, mInstance, mPhysicalDevice, instanceExtensions.size(), + instanceExtensions.data(), deviceExtensions.size(), deviceExtensions.data()); + + memset(&features, 0, sizeof(VkPhysicalDeviceFeatures2)); + features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; + features.pNext = nullptr; + + // Setup all extension feature structs we may want to use. + void** tailPNext = &features.pNext; + + if (grExtensions.hasExtension(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, 2)) { + VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT* blend; + blend = (VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT*) malloc( + sizeof(VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT)); + LOG_ALWAYS_FATAL_IF(!blend); + blend->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT; + blend->pNext = nullptr; + *tailPNext = blend; + tailPNext = &blend->pNext; + } + + // query to get the physical device features + mGetPhysicalDeviceFeatures2(mPhysicalDevice, &features); // this looks like it would slow things down, // and we can't depend on it on all platforms - deviceFeatures.robustBufferAccess = VK_FALSE; + features.features.robustBufferAccess = VK_FALSE; float queuePriorities[1] = { 0.0 }; @@ -247,7 +276,7 @@ bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { const VkDeviceCreateInfo deviceInfo = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType - nullptr, // pNext + &features, // pNext 0, // VkDeviceCreateFlags queueInfoCount, // queueCreateInfoCount queueInfo, // pQueueCreateInfos @@ -255,7 +284,7 @@ bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { nullptr, // ppEnabledLayerNames (uint32_t) deviceExtensions.size(), // extensionCount deviceExtensions.data(), // ppEnabledExtensionNames - &deviceFeatures // ppEnabledFeatures + nullptr, // ppEnabledFeatures }; err = mCreateDevice(mPhysicalDevice, &deviceInfo, nullptr, &mDevice); @@ -294,32 +323,38 @@ bool VulkanManager::setupDevice(VkPhysicalDeviceFeatures& deviceFeatures) { return true; } +static void free_features_extensions_structs(const VkPhysicalDeviceFeatures2& features) { + // All Vulkan structs that could be part of the features chain will start with the + // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader + // so we can get access to the pNext for the next struct. + struct CommonVulkanHeader { + VkStructureType sType; + void* pNext; + }; + + void* pNext = features.pNext; + while (pNext) { + void* current = pNext; + pNext = static_cast<CommonVulkanHeader*>(current)->pNext; + free(current); + } +} + void VulkanManager::initialize() { if (mDevice != VK_NULL_HANDLE) { return; } - std::vector<const char*> instanceExtensions; - std::vector<const char*> deviceExtensions; - VkPhysicalDeviceFeatures deviceFeatures; - LOG_ALWAYS_FATAL_IF(!this->setupDevice(deviceFeatures)); - - mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue); + GET_PROC(EnumerateInstanceVersion); + uint32_t instanceVersion = 0; + LOG_ALWAYS_FATAL_IF(mEnumerateInstanceVersion(&instanceVersion)); + LOG_ALWAYS_FATAL_IF(instanceVersion < VK_MAKE_VERSION(1, 1, 0)); - uint32_t extensionFlags = kKHR_surface_GrVkExtensionFlag | - kKHR_android_surface_GrVkExtensionFlag | - kKHR_swapchain_GrVkExtensionFlag; + GrVkExtensions extensions; + VkPhysicalDeviceFeatures2 features; + LOG_ALWAYS_FATAL_IF(!this->setupDevice(extensions, features)); - uint32_t featureFlags = 0; - if (deviceFeatures.geometryShader) { - featureFlags |= kGeometryShader_GrVkFeatureFlag; - } - if (deviceFeatures.dualSrcBlend) { - featureFlags |= kDualSrcBlend_GrVkFeatureFlag; - } - if (deviceFeatures.sampleRateShading) { - featureFlags |= kSampleRateShading_GrVkFeatureFlag; - } + mGetDeviceQueue(mDevice, mGraphicsQueueIndex, 0, &mGraphicsQueue); auto getProc = [] (const char* proc_name, VkInstance instance, VkDevice device) { if (device != VK_NULL_HANDLE) { @@ -334,11 +369,10 @@ void VulkanManager::initialize() { backendContext.fDevice = mDevice; backendContext.fQueue = mGraphicsQueue; backendContext.fGraphicsQueueIndex = mGraphicsQueueIndex; - backendContext.fMinAPIVersion = VK_MAKE_VERSION(1, 0, 0); - backendContext.fExtensions = extensionFlags; - backendContext.fFeatures = featureFlags; + backendContext.fInstanceVersion = instanceVersion; + backendContext.fVkExtensions = &extensions; + backendContext.fDeviceFeatures2 = &features; backendContext.fGetProc = std::move(getProc); - backendContext.fOwnsInstanceAndDevice = false; // create the command pool for the command buffers if (VK_NULL_HANDLE == mCommandPool) { @@ -361,6 +395,9 @@ void VulkanManager::initialize() { sk_sp<GrContext> grContext(GrContext::MakeVulkan(backendContext, options)); LOG_ALWAYS_FATAL_IF(!grContext.get()); mRenderThread.setGrContext(grContext); + + free_features_extensions_structs(features); + DeviceInfo::initialize(mRenderThread.getGrContext()->maxRenderTargetSize()); if (Properties::enablePartialUpdates && Properties::useBufferAge) { diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h index 69641d57ccbb..5524c39d7a0c 100644 --- a/libs/hwui/renderthread/VulkanManager.h +++ b/libs/hwui/renderthread/VulkanManager.h @@ -25,6 +25,8 @@ #include <SkSurface.h> #include <vk/GrVkBackendContext.h> +class GrVkExtensions; + namespace android { namespace uirenderer { namespace renderthread { @@ -116,7 +118,7 @@ private: // Sets up the VkInstance and VkDevice objects. Also fills out the passed in // VkPhysicalDeviceFeatures struct. - bool setupDevice(VkPhysicalDeviceFeatures& deviceFeatures); + bool setupDevice(GrVkExtensions&, VkPhysicalDeviceFeatures2&); void destroyBuffers(VulkanSurface* surface); @@ -156,13 +158,14 @@ private: VkPtr<PFN_vkCreateSharedSwapchainsKHR> mCreateSharedSwapchainsKHR; // Instance Functions + VkPtr<PFN_vkEnumerateInstanceVersion> mEnumerateInstanceVersion; VkPtr<PFN_vkEnumerateInstanceExtensionProperties> mEnumerateInstanceExtensionProperties; VkPtr<PFN_vkCreateInstance> mCreateInstance; VkPtr<PFN_vkDestroyInstance> mDestroyInstance; VkPtr<PFN_vkEnumeratePhysicalDevices> mEnumeratePhysicalDevices; VkPtr<PFN_vkGetPhysicalDeviceQueueFamilyProperties> mGetPhysicalDeviceQueueFamilyProperties; - VkPtr<PFN_vkGetPhysicalDeviceFeatures> mGetPhysicalDeviceFeatures; + VkPtr<PFN_vkGetPhysicalDeviceFeatures2> mGetPhysicalDeviceFeatures2; VkPtr<PFN_vkCreateDevice> mCreateDevice; VkPtr<PFN_vkEnumerateDeviceExtensionProperties> mEnumerateDeviceExtensionProperties; diff --git a/media/java/android/media/audiofx/DefaultEffect.java b/media/java/android/media/audiofx/DefaultEffect.java index a919868218f8..ce087adff8c1 100644 --- a/media/java/android/media/audiofx/DefaultEffect.java +++ b/media/java/android/media/audiofx/DefaultEffect.java @@ -24,6 +24,7 @@ package android.media.audiofx; * <p>Applications should not use the DefaultEffect class directly but one of its derived classes * to control specific types of defaults: * <ul> + * <li> {@link android.media.audiofx.SourceDefaultEffect}</li> * <li> {@link android.media.audiofx.StreamDefaultEffect}</li> * </ul> * <p>Creating a DefaultEffect object will register the corresponding effect engine as a default diff --git a/media/java/android/media/audiofx/SourceDefaultEffect.java b/media/java/android/media/audiofx/SourceDefaultEffect.java new file mode 100644 index 000000000000..d7a292e7e214 --- /dev/null +++ b/media/java/android/media/audiofx/SourceDefaultEffect.java @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2018 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.audiofx; + +import android.annotation.RequiresPermission; +import android.app.ActivityThread; +import android.util.Log; +import java.util.UUID; + +/** + * SourceDefaultEffect is a default effect that attaches automatically to all AudioRecord and + * MediaRecorder instances of a given source type. + * <p>see {@link android.media.audiofx.DefaultEffect} class for more details on default effects. + * @hide + */ + +public class SourceDefaultEffect extends DefaultEffect { + static { + System.loadLibrary("audioeffect_jni"); + } + + private final static String TAG = "SourceDefaultEffect-JAVA"; + + /** + * Class constructor. + * + * @param type type of effect engine to be default. This parameter is ignored if uuid is set, + * and can be set to {@link android.media.audiofx.AudioEffect#EFFECT_TYPE_NULL} + * in that case. + * @param uuid unique identifier of a particular effect implementation to be default. This + * parameter can be set to + * {@link android.media.audiofx.AudioEffect#EFFECT_TYPE_NULL}, in which case only + * the type will be used to select the effect. + * @param priority the priority level requested by the application for controlling the effect + * engine. As the same engine can be shared by several applications, this parameter + * indicates how much the requesting application needs control of effect parameters. + * The normal priority is 0, above normal is a positive number, below normal a + * negative number. + * @param source a MediaRecorder.AudioSource.* constant from + * {@link android.media.MediaRecorder.AudioSource} indicating + * what sources the given effect should attach to by default. Note that similar + * sources may share defaults. + * + * @throws java.lang.IllegalArgumentException + * @throws java.lang.UnsupportedOperationException + * @throws java.lang.RuntimeException + */ + @RequiresPermission(value = android.Manifest.permission.MODIFY_DEFAULT_AUDIO_EFFECTS, + conditional = true) // Android Things uses an alternate permission. + public SourceDefaultEffect(UUID type, UUID uuid, int priority, int source) { + int[] id = new int[1]; + int initResult = native_setup(type.toString(), + uuid.toString(), + priority, + source, + ActivityThread.currentOpPackageName(), + id); + if (initResult != AudioEffect.SUCCESS) { + Log.e(TAG, "Error code " + initResult + " when initializing SourceDefaultEffect"); + switch (initResult) { + case AudioEffect.ERROR_BAD_VALUE: + throw (new IllegalArgumentException( + "Source, type uuid, or implementation uuid not supported.")); + case AudioEffect.ERROR_INVALID_OPERATION: + throw (new UnsupportedOperationException( + "Effect library not loaded")); + default: + throw (new RuntimeException( + "Cannot initialize effect engine for type: " + type + + " Error: " + initResult)); + } + } + + mId = id[0]; + } + + + /** + * Releases the native SourceDefaultEffect resources. It is a good practice to + * release the default effect when done with use as control can be returned to + * other applications or the native resources released. + */ + public void release() { + native_release(mId); + } + + @Override + protected void finalize() { + release(); + } + + // --------------------------------------------------------- + // Native methods called from the Java side + // -------------------- + + private native final int native_setup(String type, + String uuid, + int priority, + int source, + String opPackageName, + int[] id); + + private native final void native_release(int id); +} diff --git a/media/jni/audioeffect/Android.bp b/media/jni/audioeffect/Android.bp index 0063c11a7c64..09c546ab0065 100644 --- a/media/jni/audioeffect/Android.bp +++ b/media/jni/audioeffect/Android.bp @@ -3,6 +3,7 @@ cc_library_shared { srcs: [ "android_media_AudioEffect.cpp", + "android_media_SourceDefaultEffect.cpp", "android_media_StreamDefaultEffect.cpp", "android_media_Visualizer.cpp", ], diff --git a/media/jni/audioeffect/android_media_AudioEffect.cpp b/media/jni/audioeffect/android_media_AudioEffect.cpp index d3ba9f2076dd..8c9025b85860 100644 --- a/media/jni/audioeffect/android_media_AudioEffect.cpp +++ b/media/jni/audioeffect/android_media_AudioEffect.cpp @@ -907,6 +907,7 @@ static const JNINativeMethod gMethods[] = { // ---------------------------------------------------------------------------- +extern int register_android_media_SourceDefaultEffect(JNIEnv *env); extern int register_android_media_StreamDefaultEffect(JNIEnv *env); extern int register_android_media_visualizer(JNIEnv *env); @@ -932,6 +933,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved __unused) goto bail; } + if (register_android_media_SourceDefaultEffect(env) < 0) { + ALOGE("ERROR: SourceDefaultEffect native registration failed\n"); + goto bail; + } + if (register_android_media_StreamDefaultEffect(env) < 0) { ALOGE("ERROR: StreamDefaultEffect native registration failed\n"); goto bail; diff --git a/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp b/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp new file mode 100644 index 000000000000..d244bcb71c62 --- /dev/null +++ b/media/jni/audioeffect/android_media_SourceDefaultEffect.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2018 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. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "SourceDefaultEffect-JNI" + +#include <utils/Errors.h> +#include <utils/Log.h> +#include <jni.h> +#include <nativehelper/JNIHelp.h> +#include <android_runtime/AndroidRuntime.h> +#include "media/AudioEffect.h" + +#include <nativehelper/ScopedUtfChars.h> + +#include "android_media_AudioEffect.h" + +using namespace android; + +static const char* const kClassPathName = "android/media/audiofx/SourceDefaultEffect"; + +static jint android_media_SourceDefaultEffect_native_setup(JNIEnv *env, + jobject /*thiz*/, + jstring type, + jstring uuid, + jint priority, + jint source, + jstring opPackageName, + jintArray jId) +{ + ALOGV("android_media_SourceDefaultEffect_native_setup"); + status_t lStatus = NO_ERROR; + jint* nId = NULL; + const char *typeStr = NULL; + const char *uuidStr = NULL; + + ScopedUtfChars opPackageNameStr(env, opPackageName); + + if (type != NULL) { + typeStr = env->GetStringUTFChars(type, NULL); + if (typeStr == NULL) { // Out of memory + lStatus = NO_MEMORY; + jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); + goto setup_exit; + } + } + + if (uuid != NULL) { + uuidStr = env->GetStringUTFChars(uuid, NULL); + if (uuidStr == NULL) { // Out of memory + lStatus = NO_MEMORY; + jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); + goto setup_exit; + } + } + + if (typeStr == NULL && uuidStr == NULL) { + lStatus = BAD_VALUE; + goto setup_exit; + } + + nId = reinterpret_cast<jint *>(env->GetPrimitiveArrayCritical(jId, NULL)); + if (nId == NULL) { + ALOGE("setup: Error retrieving id pointer"); + lStatus = BAD_VALUE; + goto setup_exit; + } + + // create the native SourceDefaultEffect. + audio_unique_id_t id; + lStatus = AudioEffect::addSourceDefaultEffect(typeStr, + String16(opPackageNameStr.c_str()), + uuidStr, + priority, + static_cast<audio_source_t>(source), + &id); + if (lStatus != NO_ERROR) { + ALOGE("setup: Error adding SourceDefaultEffect"); + goto setup_exit; + } + + nId[0] = static_cast<jint>(id); + +setup_exit: + // Final cleanup and return. + + if (nId != NULL) { + env->ReleasePrimitiveArrayCritical(jId, nId, 0); + nId = NULL; + } + + if (uuidStr != NULL) { + env->ReleaseStringUTFChars(uuid, uuidStr); + uuidStr = NULL; + } + + if (typeStr != NULL) { + env->ReleaseStringUTFChars(type, typeStr); + typeStr = NULL; + } + + return AudioEffectJni::translateNativeErrorToJava(lStatus); +} + +static void android_media_SourceDefaultEffect_native_release(JNIEnv */*env*/, + jobject /*thiz*/, + jint id) { + status_t lStatus = AudioEffect::removeSourceDefaultEffect(id); + if (lStatus != NO_ERROR) { + ALOGW("Error releasing SourceDefaultEffect: %d", lStatus); + } +} + +// ---------------------------------------------------------------------------- + +// Dalvik VM type signatures +static const JNINativeMethod gMethods[] = { + {"native_setup", "(Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;[I)I", + (void *)android_media_SourceDefaultEffect_native_setup}, + {"native_release", "(I)V", (void *)android_media_SourceDefaultEffect_native_release}, +}; + + +// ---------------------------------------------------------------------------- + +int register_android_media_SourceDefaultEffect(JNIEnv *env) +{ + return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); +} diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index f81541e525b2..a07939e86325 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -1171,6 +1171,26 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } private boolean bindService() { + int state = BluetoothAdapter.STATE_OFF; + try { + mBluetoothLock.readLock().lock(); + if (mBluetooth != null) { + state = mBluetooth.getState(); + } + } catch (RemoteException e) { + Slog.e(TAG, "Unable to call getState", e); + return false; + } finally { + mBluetoothLock.readLock().unlock(); + } + + if (!mEnable || state != BluetoothAdapter.STATE_ON) { + if (DBG) { + Slog.d(TAG, "Unable to bindService while Bluetooth is disabled"); + } + return false; + } + if (mIntent != null && mService == null && doBind(mIntent, this, 0, UserHandle.CURRENT_OR_SELF)) { Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE); diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java index 519881ef8c92..f418ad4bf173 100644 --- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java +++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java @@ -80,6 +80,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub { private int mDisabled2 = 0; private final Object mLock = new Object(); + private final DeathRecipient mDeathRecipient = new DeathRecipient(); // encompasses lights-out mode and other flags defined on View private int mSystemUiVisibility = 0; private int mFullscreenStackSysUiVisibility; @@ -93,6 +94,23 @@ public class StatusBarManagerService extends IStatusBarService.Stub { private IBinder mImeToken = null; private int mCurrentUserId; + private class DeathRecipient implements IBinder.DeathRecipient { + public void binderDied() { + mBar.asBinder().unlinkToDeath(this,0); + mBar = null; + notifyBarAttachChanged(); + } + + public void linkToDeath() { + try { + mBar.asBinder().linkToDeath(mDeathRecipient,0); + } catch (RemoteException e) { + Slog.e(TAG,"Unable to register Death Recipient for status bar", e); + } + } + + } + private class DisableRecord implements IBinder.DeathRecipient { int userId; String pkg; @@ -859,16 +877,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub { Slog.i(TAG, "registerStatusBar bar=" + bar); mBar = bar; - try { - mBar.asBinder().linkToDeath(new DeathRecipient() { - @Override - public void binderDied() { - mBar = null; - notifyBarAttachChanged(); - } - }, 0); - } catch (RemoteException e) { - } + mDeathRecipient.linkToDeath(); notifyBarAttachChanged(); synchronized (mIcons) { for (String slot : mIcons.keySet()) { |