diff options
Diffstat (limited to 'services')
22 files changed, 288 insertions, 200 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 5935bf9..c68e20d 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -5808,10 +5808,10 @@ uint32_t AudioFlinger::EffectModule::deviceAudioSystemToEffectApi(uint32_t devic // update this table when AudioSystem::audio_mode or audio_mode_e (in EffectApi.h) are modified const uint32_t AudioFlinger::EffectModule::sModeConvTable[] = { - AUDIO_MODE_NORMAL, // AudioSystem::MODE_NORMAL - AUDIO_MODE_RINGTONE, // AudioSystem::MODE_RINGTONE - AUDIO_MODE_IN_CALL, // AudioSystem::MODE_IN_CALL - AUDIO_MODE_IN_CALL // AudioSystem::MODE_IN_COMMUNICATION, same conversion as for MODE_IN_CALL + AUDIO_EFFECT_MODE_NORMAL, // AudioSystem::MODE_NORMAL + AUDIO_EFFECT_MODE_RINGTONE, // AudioSystem::MODE_RINGTONE + AUDIO_EFFECT_MODE_IN_CALL, // AudioSystem::MODE_IN_CALL + AUDIO_EFFECT_MODE_IN_CALL // AudioSystem::MODE_IN_COMMUNICATION, same conversion as for MODE_IN_CALL }; int AudioFlinger::EffectModule::modeAudioSystemToEffectApi(uint32_t mode) diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 8aaa325..433f1f7 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -975,7 +975,6 @@ void AudioMixer::process__genericResampling(state_t* state) { int32_t* const outTemp = state->outputTemp; const size_t size = sizeof(int32_t) * MAX_NUM_CHANNELS * state->frameCount; - memset(outTemp, 0, size); size_t numFrames = state->frameCount; @@ -997,6 +996,7 @@ void AudioMixer::process__genericResampling(state_t* state) } e0 &= ~(e1); int32_t *out = t1.mainBuffer; + memset(outTemp, 0, size); while (e1) { const int i = 31 - __builtin_clz(e1); e1 &= ~(1<<i); diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp index 5dabacb..245bfdf 100644 --- a/services/audioflinger/AudioResampler.cpp +++ b/services/audioflinger/AudioResampler.cpp @@ -26,11 +26,15 @@ #include "AudioResamplerSinc.h" #include "AudioResamplerCubic.h" +#ifdef __arm__ +#include <machine/cpu-features.h> +#endif + namespace android { -#ifdef __ARM_ARCH_5E__ // optimized asm option +#ifdef __ARM_HAVE_HALFWORD_MULTIPLY // optimized asm option #define ASM_ARM_RESAMP1 // enable asm optimisation for ResamplerOrder1 -#endif // __ARM_ARCH_5E__ +#endif // __ARM_HAVE_HALFWORD_MULTIPLY // ---------------------------------------------------------------------------- class AudioResamplerOrder1 : public AudioResampler { diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index 4e2f1e3..cf3ecdc 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -124,6 +124,14 @@ class AlarmManagerService extends IAlarmManager.Stub { public AlarmManagerService(Context context) { mContext = context; mDescriptor = init(); + + // We have to set current TimeZone info to kernel + // because kernel doesn't keep this after reboot + String tz = SystemProperties.get(TIMEZONE_PROPERTY); + if (tz != null) { + setTimeZone(tz); + } + PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); @@ -273,10 +281,7 @@ class AlarmManagerService extends IAlarmManager.Stub { // Update the kernel timezone information // Kernel tracks time offsets as 'minutes west of GMT' - int gmtOffset = zone.getRawOffset(); - if (zone.inDaylightTime(new Date(System.currentTimeMillis()))) { - gmtOffset += zone.getDSTSavings(); - } + int gmtOffset = zone.getOffset(System.currentTimeMillis()); setKernelTimezone(mDescriptor, -(gmtOffset / 60000)); } @@ -776,9 +781,8 @@ class AlarmManagerService extends IAlarmManager.Stub { // based off of the current Zone gmt offset + userspace tracked // daylight savings information. TimeZone zone = TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY)); - int gmtOffset = (zone.getRawOffset() + zone.getDSTSavings()) / 60000; - - setKernelTimezone(mDescriptor, -(gmtOffset)); + int gmtOffset = zone.getOffset(System.currentTimeMillis()); + setKernelTimezone(mDescriptor, -(gmtOffset / 60000)); scheduleDateChangedEvent(); } } diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 8c4bf18..555975f 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -30,6 +30,7 @@ import android.net.IConnectivityManager; import android.net.MobileDataStateTracker; import android.net.NetworkInfo; import android.net.NetworkStateTracker; +import android.net.NetworkUtils; import android.net.wifi.WifiStateTracker; import android.net.wimax.WimaxManagerConstants; import android.os.Binder; @@ -56,6 +57,8 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.List; +import java.net.InetAddress; +import java.net.UnknownHostException; @@ -901,6 +904,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { } /** + * @deprecated use requestRouteToHostAddress instead + * * Ensure that a network route exists to deliver traffic to the specified * host via the specified network interface. * @param networkType the type of the network over which traffic to the @@ -910,6 +915,25 @@ public class ConnectivityService extends IConnectivityManager.Stub { * @return {@code true} on success, {@code false} on failure */ public boolean requestRouteToHost(int networkType, int hostAddress) { + InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); + + if (inetAddress == null) { + return false; + } + + return requestRouteToHostAddress(networkType, inetAddress.getAddress()); + } + + /** + * Ensure that a network route exists to deliver traffic to the specified + * host via the specified network interface. + * @param networkType the type of the network over which traffic to the + * specified host is to be routed + * @param hostAddress the IP address of the host to which the route is + * desired + * @return {@code true} on success, {@code false} on failure + */ + public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) { enforceChangePermission(); if (!ConnectivityManager.isNetworkTypeValid(networkType)) { return false; @@ -919,11 +943,18 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (tracker == null || !tracker.getNetworkInfo().isConnected() || tracker.isTeardownRequested()) { if (DBG) { - Slog.d(TAG, "requestRouteToHost on down network (" + networkType + ") - dropped"); + Slog.d(TAG, "requestRouteToHostAddress on down network " + + "(" + networkType + ") - dropped"); } return false; } - return tracker.requestRouteToHost(hostAddress); + + try { + InetAddress inetAddress = InetAddress.getByAddress(hostAddress); + return tracker.requestRouteToHost(inetAddress); + } catch (UnknownHostException e) { + return false; + } } /** diff --git a/services/java/com/android/server/DropBoxManagerService.java b/services/java/com/android/server/DropBoxManagerService.java index 0e45145..3981525 100644 --- a/services/java/com/android/server/DropBoxManagerService.java +++ b/services/java/com/android/server/DropBoxManagerService.java @@ -218,8 +218,14 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub { } } while (read > 0); - createEntry(temp, tag, flags); + long time = createEntry(temp, tag, flags); temp = null; + + Intent dropboxIntent = new Intent(DropBoxManager.ACTION_DROPBOX_ENTRY_ADDED); + dropboxIntent.putExtra(DropBoxManager.EXTRA_TAG, tag); + dropboxIntent.putExtra(DropBoxManager.EXTRA_TIME, time); + mContext.sendBroadcast(dropboxIntent, android.Manifest.permission.READ_LOGS); + } catch (IOException e) { Slog.e(TAG, "Can't write: " + tag, e); } finally { @@ -597,7 +603,7 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub { } /** Moves a temporary file to a final log filename and enrolls it. */ - private synchronized void createEntry(File temp, String tag, int flags) throws IOException { + private synchronized long createEntry(File temp, String tag, int flags) throws IOException { long t = System.currentTimeMillis(); // Require each entry to have a unique timestamp; if there are entries @@ -636,6 +642,7 @@ public final class DropBoxManagerService extends IDropBoxManagerService.Stub { } else { enrollEntry(new EntryFile(temp, mDropBoxDir, tag, t, flags, mBlockSize)); } + return t; } /** diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index a191549..4d934b6 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -1144,6 +1144,17 @@ class MountService extends IMountService.Stub // Post a unmount message. ShutdownCallBack ucb = new ShutdownCallBack(path, observer); mHandler.sendMessage(mHandler.obtainMessage(H_UNMOUNT_PM_UPDATE, ucb)); + } else if (observer != null) { + /* + * Observer is waiting for onShutDownComplete when we are done. + * Since nothing will be done send notification directly so shutdown + * sequence can continue. + */ + try { + observer.onShutDownComplete(StorageResultCode.OperationSucceeded); + } catch (RemoteException e) { + Slog.w(TAG, "RemoteException when shutting down"); + } } } @@ -1498,7 +1509,8 @@ class MountService extends IMountService.Stub } catch (NativeDaemonConnectorException e) { int code = e.getCode(); if (code == VoldResponseCode.OpFailedStorageNotFound) { - throw new IllegalArgumentException(String.format("Container '%s' not found", id)); + Slog.i(TAG, String.format("Container '%s' not found", id)); + return null; } else { throw new IllegalStateException(String.format("Unexpected response code %d", code)); } diff --git a/services/java/com/android/server/NativeDaemonConnector.java b/services/java/com/android/server/NativeDaemonConnector.java index cf87a9d..88d94c2 100644 --- a/services/java/com/android/server/NativeDaemonConnector.java +++ b/services/java/com/android/server/NativeDaemonConnector.java @@ -97,11 +97,12 @@ final class NativeDaemonConnector implements Runnable { LocalSocketAddress.Namespace.RESERVED); socket.connect(address); - mCallbacks.onDaemonConnected(); InputStream inputStream = socket.getInputStream(); mOutputStream = socket.getOutputStream(); + mCallbacks.onDaemonConnected(); + byte[] buffer = new byte[BUFFER_SIZE]; int start = 0; diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index b26dac7..540389e 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -133,11 +133,11 @@ public class NotificationManagerService extends INotificationManager.Stub private boolean mBatteryFull; private NotificationRecord mLedNotification; - private static final int BATTERY_LOW_ARGB = 0xFFFF0000; // Charging Low - red solid on - private static final int BATTERY_MEDIUM_ARGB = 0xFFFFFF00; // Charging - orange solid on - private static final int BATTERY_FULL_ARGB = 0xFF00FF00; // Charging Full - green solid on - private static final int BATTERY_BLINK_ON = 125; - private static final int BATTERY_BLINK_OFF = 2875; + private static int mBatteryLowARGB; + private static int mBatteryMediumARGB; + private static int mBatteryFullARGB; + private static int mBatteryLedOn; + private static int mBatteryLedOff; private static String idDebugString(Context baseContext, String packageName, int id) { Context c = null; @@ -450,6 +450,17 @@ public class NotificationManagerService extends INotificationManager.Stub mDefaultNotificationLedOff = resources.getInteger( com.android.internal.R.integer.config_defaultNotificationLedOff); + mBatteryLowARGB = mContext.getResources().getInteger( + com.android.internal.R.integer.config_notificationsBatteryLowARGB); + mBatteryMediumARGB = mContext.getResources().getInteger( + com.android.internal.R.integer.config_notificationsBatteryMediumARGB); + mBatteryFullARGB = mContext.getResources().getInteger( + com.android.internal.R.integer.config_notificationsBatteryFullARGB); + mBatteryLedOn = mContext.getResources().getInteger( + com.android.internal.R.integer.config_notificationsBatteryLedOn); + mBatteryLedOff = mContext.getResources().getInteger( + com.android.internal.R.integer.config_notificationsBatteryLedOff); + // Don't start allowing notifications until the setup wizard has run once. // After that, including subsequent boots, init with notifications turned on. // This works on the first boot because the setup wizard will toggle this @@ -1065,17 +1076,17 @@ public class NotificationManagerService extends INotificationManager.Stub // Battery low always shows, other states only show if charging. if (mBatteryLow) { if (mBatteryCharging) { - mBatteryLight.setColor(BATTERY_LOW_ARGB); + mBatteryLight.setColor(mBatteryLowARGB); } else { // Flash when battery is low and not charging - mBatteryLight.setFlashing(BATTERY_LOW_ARGB, LightsService.LIGHT_FLASH_TIMED, - BATTERY_BLINK_ON, BATTERY_BLINK_OFF); + mBatteryLight.setFlashing(mBatteryLowARGB, LightsService.LIGHT_FLASH_TIMED, + mBatteryLedOn, mBatteryLedOff); } } else if (mBatteryCharging) { if (mBatteryFull) { - mBatteryLight.setColor(BATTERY_FULL_ARGB); + mBatteryLight.setColor(mBatteryFullARGB); } else { - mBatteryLight.setColor(BATTERY_MEDIUM_ARGB); + mBatteryLight.setColor(mBatteryMediumARGB); } } else { mBatteryLight.turnOff(); diff --git a/services/java/com/android/server/ProcessStats.java b/services/java/com/android/server/ProcessStats.java index 020f9ed..43dbcc0 100644 --- a/services/java/com/android/server/ProcessStats.java +++ b/services/java/com/android/server/ProcessStats.java @@ -811,7 +811,7 @@ public class ProcessStats { break; } } - return new String(mBuffer, 0, 0, i); + return new String(mBuffer, 0, i); } } catch (java.io.FileNotFoundException e) { } catch (java.io.IOException e) { diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java index f0b5955..86c30f8 100755 --- a/services/java/com/android/server/VibratorService.java +++ b/services/java/com/android/server/VibratorService.java @@ -243,6 +243,7 @@ public class VibratorService extends IVibratorService.Stub { // Lock held on mVibrations private void startNextVibrationLocked() { if (mVibrations.size() <= 0) { + mCurrentVibration = null; return; } mCurrentVibration = mVibrations.getFirst(); @@ -269,17 +270,27 @@ public class VibratorService extends IVibratorService.Stub { Vibration vib = iter.next(); if (vib.mToken == token) { iter.remove(); + unlinkVibration(vib); return vib; } } // We might be looking for a simple vibration which is only stored in // mCurrentVibration. if (mCurrentVibration != null && mCurrentVibration.mToken == token) { + unlinkVibration(mCurrentVibration); return mCurrentVibration; } return null; } + private void unlinkVibration(Vibration vib) { + if (vib.mPattern != null) { + // If Vibration object has a pattern, + // the Vibration object has also been linkedToDeath. + vib.mToken.unlinkToDeath(vib, 0); + } + } + private class VibrateThread extends Thread { final Vibration mVibration; boolean mDone; @@ -356,6 +367,7 @@ public class VibratorService extends IVibratorService.Stub { // If this vibration finished naturally, start the next // vibration. mVibrations.remove(mVibration); + unlinkVibration(mVibration); startNextVibrationLocked(); } } diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java index 859c85c..997e750 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/WallpaperManagerService.java @@ -587,6 +587,8 @@ class WallpaperManagerService extends IWallpaperManager.Stub { mIWindowManager.removeWindowToken(mWallpaperConnection.mToken); } catch (RemoteException e) { } + mWallpaperConnection.mService = null; + mWallpaperConnection.mEngine = null; mWallpaperConnection = null; } } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index efd0bb4..26cf55f 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -522,9 +522,8 @@ public class WindowManagerService extends IWindowManager.Stub } catch (InterruptedException e) { } } + return thr.mService; } - - return thr.mService; } static class WMThread extends Thread { @@ -930,6 +929,10 @@ public class WindowManagerService extends IWindowManager.Stub && w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING && i > 0) { WindowState wb = localmWindows.get(i-1); + while (i > 1 && wb.mAppToken == w.mAppToken && !canBeImeTarget(wb)) { + i--; + wb = localmWindows.get(i-1); + } if (wb.mAppToken == w.mAppToken && canBeImeTarget(wb)) { i--; w = wb; @@ -1482,6 +1485,7 @@ public class WindowManagerService extends IWindowManager.Stub WindowState wb = localmWindows.get(foundI-1); if (wb.mBaseLayer < maxLayer && wb.mAttachedWindow != foundW && + wb.mAttachedWindow != foundW.mAttachedWindow && (wb.mAttrs.type != TYPE_APPLICATION_STARTING || wb.mToken != foundW.mToken)) { // This window is not related to the previous one in any @@ -5421,6 +5425,7 @@ public class WindowManagerService extends IWindowManager.Stub int deviceId = ev.getDeviceId(); int scancode = ev.getScanCode(); int source = ev.getSource(); + int flags = ev.getFlags(); if (source == InputDevice.SOURCE_UNKNOWN) { source = InputDevice.SOURCE_KEYBOARD; @@ -5430,7 +5435,7 @@ public class WindowManagerService extends IWindowManager.Stub if (downTime == 0) downTime = eventTime; KeyEvent newEvent = new KeyEvent(downTime, eventTime, action, code, repeatCount, metaState, - deviceId, scancode, KeyEvent.FLAG_FROM_SYSTEM, source); + deviceId, scancode, flags | KeyEvent.FLAG_FROM_SYSTEM, source); final int pid = Binder.getCallingPid(); final int uid = Binder.getCallingUid(); @@ -7601,7 +7606,8 @@ public class WindowManagerService extends IWindowManager.Stub WindowState win = allAppWindows.get(i); if (win == startingWindow || win.mAppFreezing || win.mViewVisibility != View.VISIBLE - || win.mAttrs.type == TYPE_APPLICATION_STARTING) { + || win.mAttrs.type == TYPE_APPLICATION_STARTING + || win.mDestroying) { continue; } if (DEBUG_VISIBILITY) { diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index d004034..d24ce7e 100755..100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -55,6 +55,7 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.IIntentReceiver; @@ -1116,7 +1117,7 @@ public final class ActivityManagerService extends ActivityManagerNative d.setCancelable(false); d.setTitle("System UIDs Inconsistent"); d.setMessage("UIDs on the system are inconsistent, you need to wipe your data partition or your device will be unstable."); - d.setButton("I'm Feeling Lucky", + d.setButton(DialogInterface.BUTTON_POSITIVE, "I'm Feeling Lucky", mHandler.obtainMessage(IM_FEELING_LUCKY_MSG)); mUidAlert = d; d.show(); @@ -3678,10 +3679,12 @@ public final class ActivityManagerService extends ActivityManagerNative String[] pkgs = intent.getStringArrayExtra(Intent.EXTRA_PACKAGES); if (pkgs != null) { for (String pkg : pkgs) { - if (forceStopPackageLocked(pkg, -1, false, false, false)) { - setResultCode(Activity.RESULT_OK); - return; - } + synchronized (ActivityManagerService.this) { + if (forceStopPackageLocked(pkg, -1, false, false, false)) { + setResultCode(Activity.RESULT_OK); + return; + } + } } } } @@ -4382,12 +4385,15 @@ public final class ActivityManagerService extends ActivityManagerNative perm.modeFlags |= modeFlags; if (owner == null) { perm.globalModeFlags |= modeFlags; - } else if ((modeFlags&Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { - perm.readOwners.add(owner); - owner.addReadPermission(perm); - } else if ((modeFlags&Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { - perm.writeOwners.add(owner); - owner.addWritePermission(perm); + } else { + if ((modeFlags&Intent.FLAG_GRANT_READ_URI_PERMISSION) != 0) { + perm.readOwners.add(owner); + owner.addReadPermission(perm); + } + if ((modeFlags&Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0) { + perm.writeOwners.add(owner); + owner.addWritePermission(perm); + } } } @@ -6435,7 +6441,28 @@ public final class ActivityManagerService extends ActivityManagerNative sr.crashCount++; } } - + + // If the crashing process is what we consider to be the "home process" and it has been + // replaced by a third-party app, clear the package preferred activities from packages + // with a home activity running in the process to prevent a repeatedly crashing app + // from blocking the user to manually clear the list. + if (app == mHomeProcess && mHomeProcess.activities.size() > 0 + && (mHomeProcess.info.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { + Iterator it = mHomeProcess.activities.iterator(); + while (it.hasNext()) { + ActivityRecord r = (ActivityRecord)it.next(); + if (r.isHomeActivity) { + Log.i(TAG, "Clearing package preferred activities from " + r.packageName); + try { + ActivityThread.getPackageManager() + .clearPackagePreferredActivities(r.packageName); + } catch (RemoteException c) { + // pm is in same process, this will never happen. + } + } + } + } + mProcessCrashTimes.put(app.info.processName, app.info.uid, now); return true; } @@ -6707,18 +6734,25 @@ public final class ActivityManagerService extends ActivityManagerNative * to append various headers to the dropbox log text. */ private void appendDropBoxProcessHeaders(ProcessRecord process, StringBuilder sb) { + // Watchdog thread ends up invoking this function (with + // a null ProcessRecord) to add the stack file to dropbox. + // Do not acquire a lock on this (am) in such cases, as it + // could cause a potential deadlock, if and when watchdog + // is invoked due to unavailability of lock on am and it + // would prevent watchdog from killing system_server. + if (process == null) { + sb.append("Process: system_server\n"); + return; + } // Note: ProcessRecord 'process' is guarded by the service // instance. (notably process.pkgList, which could otherwise change // concurrently during execution of this method) synchronized (this) { - if (process == null || process.pid == MY_PID) { + if (process.pid == MY_PID) { sb.append("Process: system_server\n"); } else { sb.append("Process: ").append(process.processName).append("\n"); } - if (process == null) { - return; - } int flags = process.info.flags; IPackageManager pm = AppGlobals.getPackageManager(); sb.append("Flags: 0x").append(Integer.toString(flags, 16)).append("\n"); @@ -6790,6 +6824,9 @@ public final class ActivityManagerService extends ActivityManagerNative sb.append("Subject: ").append(subject).append("\n"); } sb.append("Build: ").append(Build.FINGERPRINT).append("\n"); + if (Debug.isDebuggerConnected()) { + sb.append("Debugger: Connected\n"); + } sb.append("\n"); // Do the rest in a worker thread to avoid blocking the caller on I/O diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index f52d322..463493b 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -2139,7 +2139,7 @@ public class ActivityStack { // being started, which means not bringing it to the front // if the caller is not itself in the front. ActivityRecord curTop = topRunningNonDelayedActivityLocked(notTop); - if (curTop.task != taskTop.task) { + if (curTop != null && curTop.task != taskTop.task) { r.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); boolean callerAtFront = sourceRecord == null || curTop.task == sourceRecord.task; diff --git a/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java b/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java index 8e9818d..9fb48b3 100644 --- a/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java +++ b/services/java/com/android/server/am/AppWaitingForDebuggerDialog.java @@ -17,6 +17,7 @@ package com.android.server.am; import android.content.Context; +import android.content.DialogInterface; import android.os.Handler; import android.os.Message; @@ -49,7 +50,7 @@ class AppWaitingForDebuggerDialog extends BaseErrorDialog { text.append(" is waiting for the debugger to attach."); setMessage(text.toString()); - setButton("Force Close", mHandler.obtainMessage(1, app)); + setButton(DialogInterface.BUTTON_POSITIVE, "Force Close", mHandler.obtainMessage(1, app)); setTitle("Waiting For Debugger"); getWindow().setTitle("Waiting For Debugger: " + app.info.processName); } diff --git a/services/java/com/android/server/am/FactoryErrorDialog.java b/services/java/com/android/server/am/FactoryErrorDialog.java index 2e25474..b19bb5c 100644 --- a/services/java/com/android/server/am/FactoryErrorDialog.java +++ b/services/java/com/android/server/am/FactoryErrorDialog.java @@ -17,6 +17,7 @@ package com.android.server.am; import android.content.Context; +import android.content.DialogInterface; import android.os.Handler; import android.os.Message; @@ -26,7 +27,8 @@ class FactoryErrorDialog extends BaseErrorDialog { setCancelable(false); setTitle(context.getText(com.android.internal.R.string.factorytest_failed)); setMessage(msg); - setButton(context.getText(com.android.internal.R.string.factorytest_reboot), + setButton(DialogInterface.BUTTON_POSITIVE, + context.getText(com.android.internal.R.string.factorytest_reboot), mHandler.obtainMessage(0)); getWindow().setTitle("Factory Error"); } diff --git a/services/jni/com_android_server_BatteryService.cpp b/services/jni/com_android_server_BatteryService.cpp index 8e7cadc..d4513e9 100644 --- a/services/jni/com_android_server_BatteryService.cpp +++ b/services/jni/com_android_server_BatteryService.cpp @@ -67,6 +67,7 @@ struct BatteryManagerConstants { jint healthDead; jint healthOverVoltage; jint healthUnspecifiedFailure; + jint healthCold; }; static BatteryManagerConstants gConstants; @@ -104,6 +105,7 @@ static jint getBatteryStatus(const char* status) static jint getBatteryHealth(const char* status) { switch (status[0]) { + case 'C': return gConstants.healthCold; // Cold case 'D': return gConstants.healthDead; // Dead case 'G': return gConstants.healthGood; // Good case 'O': { @@ -162,7 +164,7 @@ static void setBooleanField(JNIEnv* env, jobject obj, const char* path, jfieldID jboolean value = false; if (readFromFile(path, buf, SIZE) > 0) { - if (buf[0] == '1') { + if (buf[0] != '0') { value = true; } } @@ -390,6 +392,9 @@ int register_android_server_BatteryService(JNIEnv* env) gConstants.healthUnspecifiedFailure = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "BATTERY_HEALTH_UNSPECIFIED_FAILURE", "I")); + gConstants.healthCold = env->GetStaticIntField(clazz, + env->GetStaticFieldID(clazz, "BATTERY_HEALTH_COLD", "I")); + return jniRegisterNativeMethods(env, "com/android/server/BatteryService", sMethods, NELEM(sMethods)); } diff --git a/services/jni/com_android_server_location_GpsLocationProvider.cpp b/services/jni/com_android_server_location_GpsLocationProvider.cpp index a75e41d..6d4ad9a 100755 --- a/services/jni/com_android_server_location_GpsLocationProvider.cpp +++ b/services/jni/com_android_server_location_GpsLocationProvider.cpp @@ -217,82 +217,10 @@ AGpsRilCallbacks sAGpsRilCallbacks = { create_thread_callback, }; -static const GpsInterface* get_gps_interface() { +static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) { int err; hw_module_t* module; - const GpsInterface* interface = NULL; - - err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); - if (err == 0) { - hw_device_t* device; - err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device); - if (err == 0) { - gps_device_t* gps_device = (gps_device_t *)device; - interface = gps_device->get_gps_interface(gps_device); - } - } - - return interface; -} - -static const GpsInterface* GetGpsInterface(JNIEnv* env, jobject obj) { - // this must be set before calling into the HAL library - if (!mCallbacksObj) - mCallbacksObj = env->NewGlobalRef(obj); - - if (!sGpsInterface) { - sGpsInterface = get_gps_interface(); - if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0) { - sGpsInterface = NULL; - return NULL; - } - } - return sGpsInterface; -} - -static const AGpsInterface* GetAGpsInterface(JNIEnv* env, jobject obj) -{ - const GpsInterface* interface = GetGpsInterface(env, obj); - if (!interface) - return NULL; - - if (!sAGpsInterface) { - sAGpsInterface = (const AGpsInterface*)interface->get_extension(AGPS_INTERFACE); - if (sAGpsInterface) - sAGpsInterface->init(&sAGpsCallbacks); - } - return sAGpsInterface; -} - -static const GpsNiInterface* GetNiInterface(JNIEnv* env, jobject obj) -{ - const GpsInterface* interface = GetGpsInterface(env, obj); - if (!interface) - return NULL; - - if (!sGpsNiInterface) { - sGpsNiInterface = (const GpsNiInterface*)interface->get_extension(GPS_NI_INTERFACE); - if (sGpsNiInterface) - sGpsNiInterface->init(&sGpsNiCallbacks); - } - return sGpsNiInterface; -} - -static const AGpsRilInterface* GetAGpsRilInterface(JNIEnv* env, jobject obj) -{ - const GpsInterface* interface = GetGpsInterface(env, obj); - if (!interface) - return NULL; - - if (!sAGpsRilInterface) { - sAGpsRilInterface = (const AGpsRilInterface*)interface->get_extension(AGPS_RIL_INTERFACE); - if (sAGpsRilInterface) - sAGpsRilInterface->init(&sAGpsRilCallbacks); - } - return sAGpsRilInterface; -} -static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) { method_reportLocation = env->GetMethodID(clazz, "reportLocation", "(IDDDFFFJ)V"); method_reportStatus = env->GetMethodID(clazz, "reportStatus", "(I)V"); method_reportSvStatus = env->GetMethodID(clazz, "reportSvStatus", "()V"); @@ -300,40 +228,73 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, method_reportNmea = env->GetMethodID(clazz, "reportNmea", "(J)V"); method_setEngineCapabilities = env->GetMethodID(clazz, "setEngineCapabilities", "(I)V"); method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V"); - method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V"); + method_reportNiNotification = env->GetMethodID(clazz, "reportNiNotification", + "(IIIIILjava/lang/String;Ljava/lang/String;IILjava/lang/String;)V"); method_requestRefLocation = env->GetMethodID(clazz,"requestRefLocation","(I)V"); method_requestSetID = env->GetMethodID(clazz,"requestSetID","(I)V"); + + err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); + if (err == 0) { + hw_device_t* device; + err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device); + if (err == 0) { + gps_device_t* gps_device = (gps_device_t *)device; + sGpsInterface = gps_device->get_gps_interface(gps_device); + } + } + if (sGpsInterface) { + sGpsXtraInterface = + (const GpsXtraInterface*)sGpsInterface->get_extension(GPS_XTRA_INTERFACE); + sAGpsInterface = + (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE); + sGpsNiInterface = + (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE); + sGpsDebugInterface = + (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE); + sAGpsRilInterface = + (const AGpsRilInterface*)sGpsInterface->get_extension(AGPS_RIL_INTERFACE); + } } static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) { - return (sGpsInterface != NULL || get_gps_interface() != NULL); + return (sGpsInterface != NULL); } static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (!interface) + // this must be set before calling into the HAL library + if (!mCallbacksObj) + mCallbacksObj = env->NewGlobalRef(obj); + + // fail if the main interface fails to initialize + if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0) return false; - if (!sGpsDebugInterface) - sGpsDebugInterface = (const GpsDebugInterface*)interface->get_extension(GPS_DEBUG_INTERFACE); + // if XTRA initialization fails we will disable it by sGpsXtraInterface to null, + // but continue to allow the rest of the GPS interface to work. + if (sGpsXtraInterface && sGpsXtraInterface->init(&sGpsXtraCallbacks) != 0) + sGpsXtraInterface = NULL; + if (sAGpsInterface) + sAGpsInterface->init(&sAGpsCallbacks); + if (sGpsNiInterface) + sGpsNiInterface->init(&sGpsNiCallbacks); + if (sAGpsRilInterface) + sAGpsRilInterface->init(&sAGpsRilCallbacks); return true; } static void android_location_GpsLocationProvider_cleanup(JNIEnv* env, jobject obj) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - interface->cleanup(); + if (sGpsInterface) + sGpsInterface->cleanup(); } static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* env, jobject obj, jint mode, jint recurrence, jint min_interval, jint preferred_accuracy, jint preferred_time) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - return (interface->set_position_mode(mode, recurrence, min_interval, preferred_accuracy, + if (sGpsInterface) + return (sGpsInterface->set_position_mode(mode, recurrence, min_interval, preferred_accuracy, preferred_time) == 0); else return false; @@ -341,27 +302,24 @@ static jboolean android_location_GpsLocationProvider_set_position_mode(JNIEnv* e static jboolean android_location_GpsLocationProvider_start(JNIEnv* env, jobject obj) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - return (interface->start() == 0); + if (sGpsInterface) + return (sGpsInterface->start() == 0); else return false; } static jboolean android_location_GpsLocationProvider_stop(JNIEnv* env, jobject obj) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - return (interface->stop() == 0); + if (sGpsInterface) + return (sGpsInterface->stop() == 0); else return false; } static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env, jobject obj, jint flags) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - interface->delete_aiding_data(flags); + if (sGpsInterface) + sGpsInterface->delete_aiding_data(flags); } static jint android_location_GpsLocationProvider_read_sv_status(JNIEnv* env, jobject obj, @@ -399,8 +357,8 @@ static void android_location_GpsLocationProvider_agps_set_reference_location_cel jobject obj, jint type, jint mcc, jint mnc, jint lac, jint cid) { AGpsRefLocation location; - const AGpsRilInterface* interface = GetAGpsRilInterface(env, obj); - if (!interface) { + + if (!sAGpsRilInterface) { LOGE("no AGPS RIL interface in agps_set_reference_location_cellid"); return; } @@ -419,15 +377,15 @@ static void android_location_GpsLocationProvider_agps_set_reference_location_cel return; break; } - interface->set_ref_location(&location, sizeof(location)); + sAGpsRilInterface->set_ref_location(&location, sizeof(location)); } static void android_location_GpsLocationProvider_agps_send_ni_message(JNIEnv* env, jobject obj, jbyteArray ni_msg, jint size) { size_t sz; - const AGpsRilInterface* interface = GetAGpsRilInterface(env, obj); - if (!interface) { + + if (!sAGpsRilInterface) { LOGE("no AGPS RIL interface in send_ni_message"); return; } @@ -435,21 +393,20 @@ static void android_location_GpsLocationProvider_agps_send_ni_message(JNIEnv* en return; sz = (size_t)size; jbyte* b = env->GetByteArrayElements(ni_msg, 0); - interface->ni_message((uint8_t *)b,sz); + sAGpsRilInterface->ni_message((uint8_t *)b,sz); env->ReleaseByteArrayElements(ni_msg,b,0); } static void android_location_GpsLocationProvider_agps_set_id(JNIEnv *env, jobject obj, jint type, jstring setid_string) { - const AGpsRilInterface* interface = GetAGpsRilInterface(env, obj); - if (!interface) { + if (!sAGpsRilInterface) { LOGE("no AGPS RIL interface in agps_set_id"); return; } const char *setid = env->GetStringUTFChars(setid_string, NULL); - interface->set_set_id(type, setid); + sAGpsRilInterface->set_set_id(type, setid); env->ReleaseStringUTFChars(setid_string, setid); } @@ -469,40 +426,30 @@ static jint android_location_GpsLocationProvider_read_nmea(JNIEnv* env, jobject static void android_location_GpsLocationProvider_inject_time(JNIEnv* env, jobject obj, jlong time, jlong timeReference, jint uncertainty) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - interface->inject_time(time, timeReference, uncertainty); + if (sGpsInterface) + sGpsInterface->inject_time(time, timeReference, uncertainty); } static void android_location_GpsLocationProvider_inject_location(JNIEnv* env, jobject obj, jdouble latitude, jdouble longitude, jfloat accuracy) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (interface) - interface->inject_location(latitude, longitude, accuracy); + if (sGpsInterface) + sGpsInterface->inject_location(latitude, longitude, accuracy); } static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* env, jobject obj) { - if (!sGpsXtraInterface) { - const GpsInterface* interface = GetGpsInterface(env, obj); - if (!interface) - return false; - sGpsXtraInterface = (const GpsXtraInterface*)interface->get_extension(GPS_XTRA_INTERFACE); - if (sGpsXtraInterface) { - int result = sGpsXtraInterface->init(&sGpsXtraCallbacks); - if (result) { - sGpsXtraInterface = NULL; - } - } - } - return (sGpsXtraInterface != NULL); } static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, jobject obj, jbyteArray data, jint length) { + if (!sGpsXtraInterface) { + LOGE("no XTRA interface in inject_xtra_data"); + return; + } + jbyte* bytes = (jbyte *)env->GetPrimitiveArrayCritical(data, 0); sGpsXtraInterface->inject_xtra_data((char *)bytes, length); env->ReleasePrimitiveArrayCritical(data, bytes, JNI_ABORT); @@ -510,8 +457,7 @@ static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, j static void android_location_GpsLocationProvider_agps_data_conn_open(JNIEnv* env, jobject obj, jstring apn) { - const AGpsInterface* interface = GetAGpsInterface(env, obj); - if (!interface) { + if (!sAGpsInterface) { LOGE("no AGPS interface in agps_data_conn_open"); return; } @@ -520,53 +466,49 @@ static void android_location_GpsLocationProvider_agps_data_conn_open(JNIEnv* env return; } const char *apnStr = env->GetStringUTFChars(apn, NULL); - interface->data_conn_open(apnStr); + sAGpsInterface->data_conn_open(apnStr); env->ReleaseStringUTFChars(apn, apnStr); } static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj) { - const AGpsInterface* interface = GetAGpsInterface(env, obj); - if (!interface) { + if (!sAGpsInterface) { LOGE("no AGPS interface in agps_data_conn_open"); return; } - interface->data_conn_closed(); + sAGpsInterface->data_conn_closed(); } static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj) { - const AGpsInterface* interface = GetAGpsInterface(env, obj); - if (!interface) { + if (!sAGpsInterface) { LOGE("no AGPS interface in agps_data_conn_open"); return; } - interface->data_conn_failed(); + sAGpsInterface->data_conn_failed(); } static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj, jint type, jstring hostname, jint port) { - const AGpsInterface* interface = GetAGpsInterface(env, obj); - if (!interface) { + if (!sAGpsInterface) { LOGE("no AGPS interface in agps_data_conn_open"); return; } const char *c_hostname = env->GetStringUTFChars(hostname, NULL); - interface->set_server(type, c_hostname, port); + sAGpsInterface->set_server(type, c_hostname, port); env->ReleaseStringUTFChars(hostname, c_hostname); } static void android_location_GpsLocationProvider_send_ni_response(JNIEnv* env, jobject obj, jint notifId, jint response) { - const GpsNiInterface* interface = GetNiInterface(env, obj); - if (!interface) { + if (!sGpsNiInterface) { LOGE("no NI interface in send_ni_response"); return; } - interface->respond(notifId, response); + sGpsNiInterface->respond(notifId, response); } static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* env, jobject obj) @@ -586,14 +528,14 @@ static jstring android_location_GpsLocationProvider_get_internal_state(JNIEnv* e static void android_location_GpsLocationProvider_update_network_state(JNIEnv* env, jobject obj, jboolean connected, int type, jboolean roaming, jstring extraInfo) { - const AGpsRilInterface* interface = GetAGpsRilInterface(env, obj); - if (interface && interface->update_network_state) { + + if (sAGpsRilInterface && sAGpsRilInterface->update_network_state) { if (extraInfo) { const char *extraInfoStr = env->GetStringUTFChars(extraInfo, NULL); - interface->update_network_state(connected, type, roaming, extraInfoStr); + sAGpsRilInterface->update_network_state(connected, type, roaming, extraInfoStr); env->ReleaseStringUTFChars(extraInfo, extraInfoStr); } else { - interface->update_network_state(connected, type, roaming, NULL); + sAGpsRilInterface->update_network_state(connected, type, roaming, NULL); } } } diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 0087fd5..da06f61 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -863,8 +863,16 @@ status_t Layer::BufferManager::initEglImage(EGLDisplay dpy, ssize_t index = mActiveBuffer; if (index >= 0) { if (!mFailover) { - Image& texture(mBufferData[index].texture); - err = mTextureManager.initEglImage(&texture, dpy, buffer); + { + // Without that lock, there is a chance of race condition + // where while composing a specific index, requestBuf + // with the same index can be executed and touch the same data + // that is being used in initEglImage. + // (e.g. dirty flag in texture) + Mutex::Autolock _l(mLock); + Image& texture(mBufferData[index].texture); + err = mTextureManager.initEglImage(&texture, dpy, buffer); + } // if EGLImage fails, we switch to regular texture mode, and we // free all resources associated with using EGLImages. if (err == NO_ERROR) { diff --git a/services/surfaceflinger/LayerBuffer.cpp b/services/surfaceflinger/LayerBuffer.cpp index edc00f1..55d859d 100644 --- a/services/surfaceflinger/LayerBuffer.cpp +++ b/services/surfaceflinger/LayerBuffer.cpp @@ -93,6 +93,9 @@ bool LayerBuffer::needsBlending() const { } void LayerBuffer::setNeedsBlending(bool blending) { + if (mNeedsBlending != blending) { + mFlinger->invalidateLayerVisibility(this); + } mNeedsBlending = blending; } @@ -509,7 +512,7 @@ status_t LayerBuffer::BufferSource::initTempBuffer() const const ISurface::BufferHeap& buffers(mBufferHeap); uint32_t w = mLayer.mTransformedBounds.width(); uint32_t h = mLayer.mTransformedBounds.height(); - if (buffers.w * h != buffers.h * w) { + if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) { int t = w; w = h; h = t; } diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp index c9a15f5..9e24f90 100644 --- a/services/surfaceflinger/TextureManager.cpp +++ b/services/surfaceflinger/TextureManager.cpp @@ -186,7 +186,7 @@ status_t TextureManager::loadTexture(Texture* texture, if (texture->name == -1UL) { status_t err = initTexture(texture); LOGE_IF(err, "loadTexture failed in initTexture (%s)", strerror(err)); - return err; + if (err != NO_ERROR) return err; } if (texture->target != Texture::TEXTURE_2D) |