diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:33 -0800 |
commit | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch) | |
tree | aa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /services | |
parent | 15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff) | |
download | frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.zip frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.gz frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.bz2 |
auto import from //depot/cupcake/@137055
Diffstat (limited to 'services')
17 files changed, 511 insertions, 150 deletions
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index d8012b2..07c7299 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -34,21 +34,26 @@ import android.os.PowerManager; import android.os.SystemClock; import android.os.SystemProperties; import android.text.TextUtils; -import android.util.Config; +import android.text.format.Time; +import android.util.EventLog; import android.util.Log; import java.io.FileDescriptor; -import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.TimeZone; class AlarmManagerService extends IAlarmManager.Stub { + // The threshold for how long an alarm can be late before we print a + // warning message. The time duration is in milliseconds. + private static final long LATE_ALARM_THRESHOLD = 10 * 1000; + private static final int RTC_WAKEUP_MASK = 1 << AlarmManager.RTC_WAKEUP; private static final int RTC_MASK = 1 << AlarmManager.RTC; private static final int ELAPSED_REALTIME_WAKEUP_MASK = 1 << AlarmManager.ELAPSED_REALTIME_WAKEUP; @@ -72,6 +77,7 @@ class AlarmManagerService extends IAlarmManager.Stub { private final ArrayList<Alarm> mRtcAlarms = new ArrayList<Alarm>(); private final ArrayList<Alarm> mElapsedRealtimeWakeupAlarms = new ArrayList<Alarm>(); private final ArrayList<Alarm> mElapsedRealtimeAlarms = new ArrayList<Alarm>(); + private final IncreasingTimeOrder mIncreasingTimeOrder = new IncreasingTimeOrder(); // slots corresponding with the inexact-repeat interval buckets, // ordered from shortest to longest @@ -338,11 +344,26 @@ class AlarmManagerService extends IAlarmManager.Stub { private int addAlarmLocked(Alarm alarm) { ArrayList<Alarm> alarmList = getAlarmList(alarm.type); - int index = Collections.binarySearch(alarmList, alarm); - index = (index < 0) ? ((index + 1) * -1) : index; - if (localLOGV) Log.v( - TAG, "Adding alarm " + alarm + " at " + index); + int index = Collections.binarySearch(alarmList, alarm, mIncreasingTimeOrder); + if (index < 0) { + index = 0 - index - 1; + } + if (localLOGV) Log.v(TAG, "Adding alarm " + alarm + " at " + index); alarmList.add(index, alarm); + + if (localLOGV) { + // Display the list of alarms for this alarm type + Log.v(TAG, "alarms: " + alarmList.size() + " type: " + alarm.type); + int position = 0; + for (Alarm a : alarmList) { + Time time = new Time(); + time.set(a.when); + String timeStr = time.format("%b %d %I:%M:%S %p"); + Log.v(TAG, position + ": " + timeStr + + " " + a.operation.getTargetPackage()); + position += 1; + } + } return index; } @@ -459,14 +480,22 @@ class AlarmManagerService extends IAlarmManager.Stub { if (localLOGV) Log.v(TAG, "Checking active alarm when=" + alarm.when + " " + alarm); - if (alarm.when > now) - { + if (alarm.when > now) { // don't fire alarms in the future break; } + + // If the alarm is late, then print a warning message. + // Note that this can happen if the user creates a new event on + // the Calendar app with a reminder that is in the past. In that + // case, the reminder alarm will fire immediately. + if (localLOGV && now - alarm.when > LATE_ALARM_THRESHOLD) { + Log.v(TAG, "alarm is late! alarm time: " + alarm.when + + " now: " + now + " delay (in seconds): " + + (now - alarm.when) / 1000); + } - // add it to the trigger list so we can trigger it without the lock held. - // recurring alarms may have passed several alarm intervals while the + // Recurring alarms may have passed several alarm intervals while the // phone was asleep or off, so pass a trigger count when sending them. if (localLOGV) Log.v(TAG, "Alarm triggering: " + alarm); alarm.count = 1; @@ -481,28 +510,42 @@ class AlarmManagerService extends IAlarmManager.Stub { it.remove(); // if it repeats queue it up to be read-added to the list - if (alarm.repeatInterval > 0) - { + if (alarm.repeatInterval > 0) { repeats.add(alarm); } } // reset any repeating alarms. it = repeats.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { Alarm alarm = it.next(); alarm.when += alarm.count * alarm.repeatInterval; addAlarmLocked(alarm); } - if (alarmList.size() > 0) - { + if (alarmList.size() > 0) { setLocked(alarmList.get(0)); } } - private class Alarm implements Comparable<Alarm> { + /** + * This Comparator sorts Alarms into increasing time order. + */ + public static class IncreasingTimeOrder implements Comparator<Alarm> { + public int compare(Alarm a1, Alarm a2) { + long when1 = a1.when; + long when2 = a2.when; + if (when1 - when2 > 0) { + return 1; + } + if (when1 - when2 < 0) { + return -1; + } + return 0; + } + } + + private static class Alarm { public int type; public int count; public long when; @@ -515,15 +558,7 @@ class AlarmManagerService extends IAlarmManager.Stub { operation = null; } - public int compareTo(Alarm obj) - { - if (obj.when > this.when) return -1; - if (obj.when < this.when) return 1; - if (obj.operation.equals(this.operation) - && obj.repeatInterval == this.repeatInterval) return 0; - return -1; - } - + @Override public String toString() { return "Alarm{" @@ -701,11 +736,11 @@ class AlarmManagerService extends IAlarmManager.Stub { public void scheduleDateChangedEvent() { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); - calendar.add(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); + calendar.add(Calendar.DAY_OF_MONTH, 1); set(AlarmManager.RTC, calendar.getTimeInMillis(), mDateChangeSender); } diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java index 9c9a580..3a9a59f 100644 --- a/services/java/com/android/server/BatteryService.java +++ b/services/java/com/android/server/BatteryService.java @@ -20,20 +20,31 @@ import com.android.internal.app.IBatteryStats; import com.android.server.am.BatteryStatsService; import android.app.ActivityManagerNative; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.BatteryManager; import android.os.Binder; +import android.os.Debug; +import android.os.IBinder; import android.os.RemoteException; +import android.os.ServiceManager; import android.os.SystemClock; import android.os.UEventObserver; +import android.provider.Checkin; +import android.provider.Settings; import android.util.EventLog; import android.util.Log; +import java.io.File; import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.io.PrintWriter; -import java.lang.String; + + /** * <p>BatteryService monitors the charging status, and charge level of the device @@ -60,12 +71,24 @@ import java.lang.String; class BatteryService extends Binder { private static final String TAG = BatteryService.class.getSimpleName(); + private static final boolean LOCAL_LOGV = false; + static final int LOG_BATTERY_LEVEL = 2722; static final int LOG_BATTERY_STATUS = 2723; static final int LOG_BATTERY_DISCHARGE_STATUS = 2730; static final int BATTERY_SCALE = 100; // battery capacity is a percentage + // Used locally for determining when to make a last ditch effort to log + // discharge stats before the device dies. + private static final int CRITICAL_BATTERY_LEVEL = 4; + + private static final int DUMP_MAX_LENGTH = 24 * 1024; + private static final String[] DUMPSYS_ARGS = new String[] { "-c", "-u" }; + private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo"; + + private static final String DUMPSYS_DATA_PATH = "/data/system/"; + // This should probably be exposed in the API, though it's not critical private static final int BATTERY_PLUGGED_NONE = 0; @@ -81,6 +104,7 @@ class BatteryService extends Binder { private int mBatteryVoltage; private int mBatteryTemperature; private String mBatteryTechnology; + private boolean mBatteryLevelCritical; private int mLastBatteryStatus; private int mLastBatteryHealth; @@ -88,6 +112,7 @@ class BatteryService extends Binder { private int mLastBatteryLevel; private int mLastBatteryVoltage; private int mLastBatteryTemperature; + private boolean mLastBatteryLevelCritical; private int mPlugType; private int mLastPlugType = -1; // Extra state so we can detect first run @@ -95,6 +120,7 @@ class BatteryService extends Binder { private long mDischargeStartTime; private int mDischargeStartLevel; + public BatteryService(Context context) { mContext = context; mBatteryStats = BatteryStatsService.getService(); @@ -149,6 +175,8 @@ class BatteryService extends Binder { private synchronized final void update() { native_update(); + + mBatteryLevelCritical = mBatteryLevel <= CRITICAL_BATTERY_LEVEL; if (mAcOnline) { mPlugType = BatteryManager.BATTERY_PLUGGED_AC; } else if (mUsbOnline) { @@ -176,6 +204,8 @@ class BatteryService extends Binder { mDischargeStartLevel, mBatteryLevel); // make sure we see a discharge event before logging again mDischargeStartTime = 0; + + logOutlier(duration); } } else if (mPlugType == BATTERY_PLUGGED_NONE) { // charging -> discharging or we just powered up @@ -197,6 +227,12 @@ class BatteryService extends Binder { EventLog.writeEvent(LOG_BATTERY_LEVEL, mBatteryLevel, mBatteryVoltage, mBatteryTemperature); } + if (mBatteryLevelCritical && !mLastBatteryLevelCritical && + mPlugType == BATTERY_PLUGGED_NONE) { + // We want to make sure we log discharge cycle outliers + // if the battery is about to die. + logOutlier(SystemClock.elapsedRealtime() - mDischargeStartTime); + } mLastBatteryStatus = mBatteryStatus; mLastBatteryHealth = mBatteryHealth; @@ -205,6 +241,7 @@ class BatteryService extends Binder { mLastPlugType = mPlugType; mLastBatteryVoltage = mBatteryVoltage; mLastBatteryTemperature = mBatteryTemperature; + mLastBatteryLevelCritical = mBatteryLevelCritical; sendIntent(); } @@ -247,6 +284,83 @@ class BatteryService extends Binder { ActivityManagerNative.broadcastStickyIntent(intent, null); } + private final void logBatteryStats() { + + IBinder batteryInfoService = ServiceManager.getService(BATTERY_STATS_SERVICE_NAME); + if (batteryInfoService != null) { + byte[] buffer = new byte[DUMP_MAX_LENGTH]; + File dumpFile = null; + FileOutputStream dumpStream = null; + try { + // dump the service to a file + dumpFile = new File(DUMPSYS_DATA_PATH + BATTERY_STATS_SERVICE_NAME + ".dump"); + dumpStream = new FileOutputStream(dumpFile); + batteryInfoService.dump(dumpStream.getFD(), DUMPSYS_ARGS); + dumpStream.getFD().sync(); + + // read dumped file above into buffer truncated to DUMP_MAX_LENGTH + // and insert into events table. + int length = (int) Math.min(dumpFile.length(), DUMP_MAX_LENGTH); + FileInputStream fileInputStream = new FileInputStream(dumpFile); + int nread = fileInputStream.read(buffer, 0, length); + if (nread > 0) { + Checkin.logEvent(mContext.getContentResolver(), + Checkin.Events.Tag.BATTERY_DISCHARGE_INFO, + new String(buffer, 0, nread)); + if (LOCAL_LOGV) Log.v(TAG, "dumped " + nread + "b from " + + batteryInfoService + "to log"); + if (LOCAL_LOGV) Log.v(TAG, "actual dump:" + new String(buffer, 0, nread)); + } + } catch (RemoteException e) { + Log.e(TAG, "failed to dump service '" + BATTERY_STATS_SERVICE_NAME + + "':" + e); + } catch (IOException e) { + Log.e(TAG, "failed to write dumpsys file: " + e); + } finally { + // make sure we clean up + if (dumpStream != null) { + try { + dumpStream.close(); + } catch (IOException e) { + Log.e(TAG, "failed to close dumpsys output stream"); + } + } + if (dumpFile != null && !dumpFile.delete()) { + Log.e(TAG, "failed to delete temporary dumpsys file: " + + dumpFile.getAbsolutePath()); + } + } + } + } + + private final void logOutlier(long duration) { + ContentResolver cr = mContext.getContentResolver(); + String dischargeThresholdString = Settings.Gservices.getString(cr, + Settings.Gservices.BATTERY_DISCHARGE_THRESHOLD); + String durationThresholdString = Settings.Gservices.getString(cr, + Settings.Gservices.BATTERY_DISCHARGE_DURATION_THRESHOLD); + + if (dischargeThresholdString != null && durationThresholdString != null) { + try { + long durationThreshold = Long.parseLong(durationThresholdString); + int dischargeThreshold = Integer.parseInt(dischargeThresholdString); + if (duration <= durationThreshold && + mDischargeStartLevel - mBatteryLevel >= dischargeThreshold) { + // If the discharge cycle is bad enough we want to know about it. + logBatteryStats(); + } + if (LOCAL_LOGV) Log.v(TAG, "duration threshold: " + durationThreshold + + " discharge threshold: " + dischargeThreshold); + if (LOCAL_LOGV) Log.v(TAG, "duration: " + duration + " discharge: " + + (mDischargeStartLevel - mBatteryLevel)); + } catch (NumberFormatException e) { + Log.e(TAG, "Invalid DischargeThresholds GService string: " + + durationThresholdString + " or " + dischargeThresholdString); + return; + } + } + } + private final int getIcon(int level) { if (mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) { return com.android.internal.R.drawable.stat_sys_battery_charge; diff --git a/services/java/com/android/server/GadgetService.java b/services/java/com/android/server/GadgetService.java index 4a430e0..0943778 100644 --- a/services/java/com/android/server/GadgetService.java +++ b/services/java/com/android/server/GadgetService.java @@ -229,7 +229,7 @@ class GadgetService extends IGadgetService.Stub int callingUid = getCallingUid(); final int N = mHosts.size(); boolean changed = false; - for (int i=0; i<N; i++) { + for (int i=N-1; i>=0; i--) { Host host = mHosts.get(i); if (host.uid == callingUid) { deleteHostLocked(host); @@ -244,7 +244,7 @@ class GadgetService extends IGadgetService.Stub void deleteHostLocked(Host host) { final int N = host.instances.size(); - for (int i=0; i<N; i++) { + for (int i=N-1; i>=0; i--) { GadgetId id = host.instances.get(i); deleteGadgetLocked(id); } @@ -622,6 +622,17 @@ class GadgetService extends IGadgetService.Stub } return gadgetIds; } + + public int[] getGadgetIds(ComponentName provider) { + synchronized (mGadgetIds) { + Provider p = lookupProviderLocked(provider); + if (p != null && getCallingUid() == p.uid) { + return getGadgetIds(p); + } else { + return new int[0]; + } + } + } private Provider parseProviderInfoXml(ComponentName component, ResolveInfo ri) { Provider p = null; diff --git a/services/java/com/android/server/HardwareService.java b/services/java/com/android/server/HardwareService.java index 40456ff..2131ffd 100755 --- a/services/java/com/android/server/HardwareService.java +++ b/services/java/com/android/server/HardwareService.java @@ -25,6 +25,7 @@ import android.os.Hardware; import android.os.IHardwareService; import android.os.Power; import android.os.PowerManager; +import android.os.Process; import android.os.RemoteException; import android.os.IBinder; import android.os.Binder; @@ -240,6 +241,7 @@ public class HardwareService extends IHardwareService.Stub { } public void run() { + Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_DISPLAY); synchronized (this) { int index = 0; long[] pattern = mPattern; diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index bc8da93..9d69114 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -214,7 +214,6 @@ public class LocationManagerService extends ILocationManager.Stub // Last known cell service state private TelephonyManager mTelephonyManager; - private int mSignalStrength = -1; // Location collector private ILocationCollector mCollector; @@ -1764,7 +1763,7 @@ public class LocationManagerService extends ILocationManager.Stub Log.d(TAG, "installing network location provider"); INetworkLocationManager.InstallCallback callback = (INetworkLocationManager.InstallCallback)msg.obj; - callback.installNetworkLocationProvider(mContext, LocationManagerService.this); + callback.installNetworkLocationProvider(LocationManagerService.this); } } } catch (Exception e) { @@ -1774,40 +1773,90 @@ public class LocationManagerService extends ILocationManager.Stub } } - PhoneStateListener mPhoneStateListener = new PhoneStateListener() { - - private CellState mLastCellState = null; + class CellLocationUpdater extends Thread { + CellLocation mNextLocation; + + CellLocationUpdater() { + super("CellLocationUpdater"); + } + @Override - public void onCellLocationChanged(CellLocation cellLocation) { - try { + public void run() { + int curAsu = -1; + CellLocation curLocation = null; + + while (true) { + // See if there is more work to do... synchronized (mLocationListeners) { - int asu = mSignalStrength; - - // Gets cell state - mLastCellState = new CellState(mTelephonyManager, cellLocation, asu); - - // Notify collector - if (mCollector != null) { - mCollector.updateCellState(mLastCellState); + if (curLocation == mNextLocation) { + mCellLocationUpdater = null; + break; + } + + curLocation = mNextLocation; + if (curLocation == null) { + mCellLocationUpdater = null; + break; } + + curAsu = mLastSignalStrength; + + mNextLocation = null; + } + + try { + // Gets cell state. This can block so must be done without + // locks held. + CellState cs = new CellState(mTelephonyManager, curLocation, curAsu); + + synchronized (mLocationListeners) { + mLastCellState = cs; + + cs.updateSignalStrength(mLastSignalStrength); + cs.updateRadioType(mLastRadioType); + + // Notify collector + if (mCollector != null) { + mCollector.updateCellState(cs); + } - // Updates providers - List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); - for (LocationProviderImpl provider : providers) { - if (provider.requiresCell()) { - provider.updateCellState(mLastCellState); + // Updates providers + List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + for (LocationProviderImpl provider : providers) { + if (provider.requiresCell()) { + provider.updateCellState(cs); + } } } + } catch (RuntimeException e) { + Log.e(TAG, "Exception in PhoneStateListener.onCellLocationChanged:", e); } - } catch (Exception e) { - Log.e(TAG, "Exception in PhoneStateListener.onCellLocationCahnged:", e); + } + } + } + + CellLocationUpdater mCellLocationUpdater = null; + CellState mLastCellState = null; + int mLastSignalStrength = -1; + int mLastRadioType = -1; + + PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + + @Override + public void onCellLocationChanged(CellLocation cellLocation) { + synchronized (mLocationListeners) { + if (mCellLocationUpdater == null) { + mCellLocationUpdater = new CellLocationUpdater(); + mCellLocationUpdater.start(); + } + mCellLocationUpdater.mNextLocation = cellLocation; } } @Override public void onSignalStrengthChanged(int asu) { synchronized (mLocationListeners) { - mSignalStrength = asu; + mLastSignalStrength = asu; if (mLastCellState != null) { mLastCellState.updateSignalStrength(asu); @@ -1818,8 +1867,18 @@ public class LocationManagerService extends ILocationManager.Stub @Override public void onDataConnectionStateChanged(int state) { synchronized (mLocationListeners) { + // Get radio type + int radioType = mTelephonyManager.getNetworkType(); + if (radioType == TelephonyManager.NETWORK_TYPE_GPRS || + radioType == TelephonyManager.NETWORK_TYPE_EDGE) { + radioType = CellState.RADIO_TYPE_GPRS; + } else if (radioType == TelephonyManager.NETWORK_TYPE_UMTS) { + radioType = CellState.RADIO_TYPE_WCDMA; + } + mLastRadioType = radioType; + if (mLastCellState != null) { - mLastCellState.updateRadioType(mTelephonyManager); + mLastCellState.updateRadioType(radioType); } } } @@ -2555,8 +2614,11 @@ public class LocationManagerService extends ILocationManager.Stub pw.println(" mGpsNavigating=" + mGpsNavigating); pw.println(" mNetworkLocationProvider=" + mNetworkLocationProvider); pw.println(" mNetworkLocationInterface=" + mNetworkLocationInterface); + pw.println(" mLastSignalStrength=" + mLastSignalStrength + + " mLastRadioType=" + mLastRadioType); + pw.println(" mCellLocationUpdater=" + mCellLocationUpdater); + pw.println(" mLastCellState=" + mLastCellState); pw.println(" mCollector=" + mCollector); - pw.println(" mSignalStrength=" + mSignalStrength); pw.println(" mAlarmInterval=" + mAlarmInterval + " mScreenOn=" + mScreenOn + " mWakeLockAcquireTime=" + mWakeLockAcquireTime); diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 0feb1da..8814e48 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -505,9 +505,12 @@ class MountService extends IMountService.Stub { if (mMediaStorageNotification == null) { mMediaStorageNotification = new Notification(); mMediaStorageNotification.when = 0; - if (mPlaySounds) { - mMediaStorageNotification.defaults |= Notification.DEFAULT_SOUND; - } + } + + if (mPlaySounds) { + mMediaStorageNotification.defaults |= Notification.DEFAULT_SOUND; + } else { + mMediaStorageNotification.defaults &= ~Notification.DEFAULT_SOUND; } if (dismissable) { diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index e5de7f9..bc4b169 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -311,6 +311,17 @@ class NotificationManagerService extends INotificationManager.Stub mBatteryFull = batteryFull; updateLights(); } + } else if (action.equals(Intent.ACTION_PACKAGE_REMOVED) + || action.equals(Intent.ACTION_PACKAGE_RESTARTED)) { + Uri uri = intent.getData(); + if (uri == null) { + return; + } + String pkgName = uri.getSchemeSpecificPart(); + if (pkgName == null) { + return; + } + cancelAllNotifications(pkgName); } } }; @@ -331,6 +342,8 @@ class NotificationManagerService extends INotificationManager.Stub // register for battery changed notifications IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addAction(Intent.ACTION_PACKAGE_RESTARTED); mContext.registerReceiver(mIntentReceiver, filter); } diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index c490e42..fec3608 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -1828,7 +1828,7 @@ class PackageManagerService extends IPackageManager.Stub { } return true; } - + private PackageParser.Package scanPackageLI( File scanFile, File destCodeFile, File destResourceFile, PackageParser.Package pkg, int parseFlags, int scanMode) { @@ -1925,19 +1925,18 @@ class PackageManagerService extends IPackageManager.Stub { } } + // Just create the setting, don't add it yet pkgSetting = mSettings.getPackageLP(pkg, suid, destCodeFile, - destResourceFile, pkg.applicationInfo.flags, true); + destResourceFile, pkg.applicationInfo.flags, true, false); if (pkgSetting == null) { Log.w(TAG, "Creating application package " + pkgName + " failed"); mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; return null; } - synchronized(mPackages) { - if(mSettings.mDisabledSysPackages.get(pkg.packageName) != null) { - pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; - } + if(mSettings.mDisabledSysPackages.get(pkg.packageName) != null) { + pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; } - + pkg.applicationInfo.uid = pkgSetting.userId; pkg.mExtras = pkgSetting; @@ -1985,24 +1984,12 @@ class PackageManagerService extends IPackageManager.Stub { long scanFileTime = scanFile.lastModified(); final boolean forceDex = (scanMode&SCAN_FORCE_DEX) != 0; final boolean scanFileNewer = forceDex || scanFileTime != pkgSetting.getTimeStamp(); - - // At this point we know it is okay to accept the package, though - // errors can still happen as we try to install... - - if ((scanMode&SCAN_MONITOR) != 0) { - pkg.mPath = destCodeFile.getAbsolutePath(); - mAppDirs.put(pkg.mPath, pkg); - } pkg.applicationInfo.processName = fixProcessName( pkg.applicationInfo.packageName, pkg.applicationInfo.processName, pkg.applicationInfo.uid); pkg.applicationInfo.publicSourceDir = pkgSetting.resourcePathString; - synchronized (mPackages) { - mPackages.put(pkg.applicationInfo.packageName, pkg); - } - File dataPath; if (mPlatformPackage == pkg) { // The system package is special. @@ -2045,8 +2032,7 @@ class PackageManagerService extends IPackageManager.Stub { return null; } } - - } + } if (!recovered) { mHasSystemUidErrors = true; } @@ -2078,7 +2064,7 @@ class PackageManagerService extends IPackageManager.Stub { int ret = mInstaller.install(pkgName, pkg.applicationInfo.uid, pkg.applicationInfo.uid); if(ret < 0) { - //error from installer + // Error from installer mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; return null; } @@ -2148,8 +2134,17 @@ class PackageManagerService extends IPackageManager.Stub { pkg.applicationInfo.flags |= ApplicationInfo.FLAG_FACTORY_TEST; } + if ((scanMode&SCAN_MONITOR) != 0) { + pkg.mPath = destCodeFile.getAbsolutePath(); + mAppDirs.put(pkg.mPath, pkg); + } + synchronized (mPackages) { - + // We don't expect installation to fail beyond this point + // Add the new setting to mSettings + mSettings.insertPackageSettingLP(pkgSetting, pkg.packageName, suid); + // Add the new setting to mPackages + mPackages.put(pkg.applicationInfo.packageName, pkg); int N = pkg.providers.size(); StringBuilder r = null; int i; @@ -3197,7 +3192,7 @@ class PackageManagerService extends IPackageManager.Stub { private final String mRootDir; private final boolean mIsRom; } - + /* Called when a downloaded package installation has been confirmed by the user */ public void installPackage( final Uri packageURI, final IPackageInstallObserver observer, final int flags) { @@ -3248,7 +3243,7 @@ class PackageManagerService extends IPackageManager.Stub { /* * Install a non-existing package. */ - private void installNewPackageLI(String pkgName, int parseFlags, + private void installNewPackageLI(String pkgName, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3272,7 +3267,7 @@ class PackageManagerService extends IPackageManager.Stub { } mLastScanError = PackageManager.INSTALL_SUCCEEDED; PackageParser.Package newPackage = scanPackageLI(tmpPackageFile, destPackageFile, - destResourceFile, pkg, parseFlags, + destResourceFile, pkg, 0, SCAN_MONITOR | SCAN_FORCE_DEX | SCAN_UPDATE_SIGNATURE | (forwardLocked ? SCAN_FORWARD_LOCKED : 0)); @@ -3304,7 +3299,7 @@ class PackageManagerService extends IPackageManager.Stub { } } - private void replacePackageLI(String pkgName, int parseFlags, + private void replacePackageLI(String pkgName, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3321,16 +3316,15 @@ class PackageManagerService extends IPackageManager.Stub { boolean sysPkg = ((deletedPackage.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0); if(sysPkg) { replaceSystemPackageLI(deletedPackage, - parseFlags, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, res); } else { - replaceNonSystemPackageLI(deletedPackage, parseFlags, tmpPackageFile, destFilePath, + replaceNonSystemPackageLI(deletedPackage, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, res); } } - private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage, int parseFlags, + private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3339,6 +3333,7 @@ class PackageManagerService extends IPackageManager.Stub { String pkgName = deletedPackage.packageName; boolean deletedPkg = true; boolean updatedSettings = false; + int parseFlags = PackageManager.REPLACE_EXISTING_PACKAGE; // First delete the existing package while retaining the data directory if (!deletePackageLI(pkgName, false, PackageManager.DONT_DELETE_DATA, res.removedInfo)) { @@ -3414,14 +3409,15 @@ class PackageManagerService extends IPackageManager.Stub { } } - private void replaceSystemPackageLI(PackageParser.Package deletedPackage, int parseFlags, + private void replaceSystemPackageLI(PackageParser.Package deletedPackage, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, PackageInstalledInfo res) { PackageParser.Package newPackage = null; boolean updatedSettings = false; - parseFlags |= PackageParser.PARSE_IS_SYSTEM; + int parseFlags = PackageManager.REPLACE_EXISTING_PACKAGE | + PackageParser.PARSE_IS_SYSTEM; String packageName = deletedPackage.packageName; res.returnCode = PackageManager.INSTALL_FAILED_REPLACE_COULDNT_DELETE; if (packageName == null) { @@ -3565,7 +3561,6 @@ class PackageManagerService extends IPackageManager.Stub { String pkgName = null; boolean forwardLocked = false; boolean replacingExistingPackage = false; - // Result object to be returned PackageInstalledInfo res = new PackageInstalledInfo(); res.returnCode = PackageManager.INSTALL_SUCCEEDED; @@ -3671,13 +3666,13 @@ class PackageManagerService extends IPackageManager.Stub { } if(replacingExistingPackage) { - replacePackageLI(pkgName, pFlags, + replacePackageLI(pkgName, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, res); } else { - installNewPackageLI(pkgName, pFlags, + installNewPackageLI(pkgName, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, @@ -4002,7 +3997,6 @@ class PackageManagerService extends IPackageManager.Stub { File sourceFile = new File(applicationInfo.sourceDir); if (!sourceFile.exists()) { Log.w(TAG, "Package source " + applicationInfo.sourceDir + " does not exist."); - return false; } outInfo.uid = applicationInfo.uid; @@ -5318,10 +5312,10 @@ class PackageManagerService extends IPackageManager.Stub { PackageSetting getPackageLP(PackageParser.Package pkg, SharedUserSetting sharedUser, File codePath, File resourcePath, - int pkgFlags, boolean create) { + int pkgFlags, boolean create, boolean add) { final String name = pkg.packageName; PackageSetting p = getPackageLP(name, sharedUser, codePath, - resourcePath, pkgFlags, create); + resourcePath, pkgFlags, create, add); if (p != null) { p.pkg = pkg; @@ -5452,7 +5446,7 @@ class PackageManagerService extends IPackageManager.Stub { private PackageSetting getPackageLP(String name, SharedUserSetting sharedUser, File codePath, File resourcePath, - int pkgFlags, boolean create) { + int pkgFlags, boolean create, boolean add) { PackageSetting p = mPackages.get(name); if (p != null) { if (!p.codePath.equals(codePath)) { @@ -5497,15 +5491,25 @@ class PackageManagerService extends IPackageManager.Stub { } else { p.userId = FIRST_APPLICATION_UID; } - if (p.userId < 0) { reportSettingsProblem(Log.WARN, "Package " + name + " could not be assigned a valid uid"); return null; } - mPackages.put(name, p); + if (add) { + // Finish adding new package by adding it and updating shared + // user preferences + insertPackageSettingLP(p, name, sharedUser); + } } - + return p; + } + + // Utility method that adds a PackageSetting to mPackages and + // completes updating the shared user attributes + private void insertPackageSettingLP(PackageSetting p, String name, + SharedUserSetting sharedUser) { + mPackages.put(name, p); if (sharedUser != null) { if (p.sharedUser != null && p.sharedUser != sharedUser) { reportSettingsProblem(Log.ERROR, @@ -5515,17 +5519,16 @@ class PackageManagerService extends IPackageManager.Stub { p.sharedUser.packages.remove(p); } else if (p.userId != sharedUser.userId) { reportSettingsProblem(Log.ERROR, - "Package " + p.name + " was user id " + p.userId - + " but is now user " + sharedUser - + " with id " + sharedUser.userId - + "; I am not changing its files so it will probably fail!"); + "Package " + p.name + " was user id " + p.userId + + " but is now user " + sharedUser + + " with id " + sharedUser.userId + + "; I am not changing its files so it will probably fail!"); } sharedUser.packages.add(p); p.sharedUser = sharedUser; p.userId = sharedUser.userId; } - return p; } private void updateSharedUserPerms (PackageSetting deletedPs) { @@ -5980,7 +5983,7 @@ class PackageManagerService extends IPackageManager.Stub { if (idObj != null && idObj instanceof SharedUserSetting) { PackageSetting p = getPackageLP(pp.name, (SharedUserSetting)idObj, pp.codePath, pp.resourcePath, - pp.pkgFlags, true); + pp.pkgFlags, true, true); if (p == null) { Log.w(TAG, "Unable to create application package for " + pp.name); diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index f41d21f..ad30ffc 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -973,11 +973,9 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage if (mSpew) { Log.d(TAG, "mBroadcastWakeLock=" + mBroadcastWakeLock); } - if (mContext != null) { - if (ActivityManagerNative.isSystemReady()) { - mContext.sendOrderedBroadcast(mScreenOnIntent, null, - mScreenOnBroadcastDone, mHandler, 0, null, null); - } + if (mContext != null && ActivityManagerNative.isSystemReady()) { + mContext.sendOrderedBroadcast(mScreenOnIntent, null, + mScreenOnBroadcastDone, mHandler, 0, null, null); } else { synchronized (mLocks) { EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 2, @@ -996,7 +994,7 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage // ignore it. } - if (mContext != null) { + if (mContext != null && ActivityManagerNative.isSystemReady()) { mContext.sendOrderedBroadcast(mScreenOffIntent, null, mScreenOffBroadcastDone, mHandler, 0, null, null); } else { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index fc25e38..77383bd 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -188,7 +188,6 @@ class ServerThread extends Thread { Log.i(TAG, "Starting Status Bar Service."); statusBar = new StatusBarService(context); ServiceManager.addService("statusbar", statusBar); - com.android.server.status.StatusBarPolicy.installIcons(context, statusBar); } catch (Throwable e) { Log.e(TAG, "Failure starting StatusBarService", e); } @@ -315,6 +314,12 @@ class ServerThread extends Thread { } catch (Throwable e) { Log.e(TAG, "Failure starting Gadget Service", e); } + + try { + com.android.server.status.StatusBarPolicy.installIcons(context, statusBar); + } catch (Throwable e) { + Log.e(TAG, "Failure installing status bar icons", e); + } } // make sure the ADB_ENABLED setting value matches the secure property value diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index b5cf1aa..5e5fb93 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -33,12 +33,14 @@ import java.util.ArrayList; import java.io.FileDescriptor; import java.io.PrintWriter; +import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.DefaultPhoneNotifier; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneStateIntentReceiver; import com.android.internal.telephony.TelephonyIntents; +import com.android.server.am.BatteryStatsService; /** @@ -55,8 +57,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { int events; } - private Context mContext; - private ArrayList<Record> mRecords = new ArrayList(); + private final Context mContext; + private final ArrayList<Record> mRecords = new ArrayList(); + private final IBatteryStats mBatteryStats; private int mCallState = TelephonyManager.CALL_STATE_IDLE; private String mCallIncomingNumber = ""; @@ -81,6 +84,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyRegistry(Context context) { CellLocation.getEmpty().fillInNotifierBundle(mCellLocation); mContext = context; + mBatteryStats = BatteryStatsService.getService(); } public void listen(String pkgForDebug, IPhoneStateListener callback, int events, @@ -414,6 +418,18 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } private void broadcastCallStateChanged(int state, String incomingNumber) { + long ident = Binder.clearCallingIdentity(); + try { + if (state == TelephonyManager.CALL_STATE_IDLE) { + mBatteryStats.notePhoneOff(); + } else { + mBatteryStats.notePhoneOn(); + } + } catch (RemoteException e) { + } finally { + Binder.restoreCallingIdentity(ident); + } + Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString()); diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 10a2d29..a3ceb71 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -3954,6 +3954,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo synchronized(mWindowMap) { mKeyWaiter.bindTargetWindowLocked(focus); } + + // NOSHIP extra state logging + mKeyWaiter.recordDispatchState(event, focus); + // END NOSHIP try { if (DEBUG_INPUT || DEBUG_FOCUS) { @@ -4097,6 +4101,55 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo * but not the other way around. */ final class KeyWaiter { + // NOSHIP debugging + public class DispatchState { + private KeyEvent event; + private WindowState focus; + private long time; + private WindowState lastWin; + private IBinder lastBinder; + private boolean finished; + private boolean gotFirstWindow; + private boolean eventDispatching; + private long timeToSwitch; + private boolean wasFrozen; + private boolean focusPaused; + + DispatchState(KeyEvent theEvent, WindowState theFocus) { + focus = theFocus; + event = theEvent; + time = System.currentTimeMillis(); + // snapshot KeyWaiter state + lastWin = mLastWin; + lastBinder = mLastBinder; + finished = mFinished; + gotFirstWindow = mGotFirstWindow; + eventDispatching = mEventDispatching; + timeToSwitch = mTimeToSwitch; + wasFrozen = mWasFrozen; + // cache the paused state at ctor time as well + if (theFocus == null || theFocus.mToken == null) { + Log.i(TAG, "focus " + theFocus + " mToken is null at event dispatch!"); + focusPaused = false; + } else { + focusPaused = theFocus.mToken.paused; + } + } + + public String toString() { + return "{{" + event + " to " + focus + " @ " + time + + " lw=" + lastWin + " lb=" + lastBinder + + " fin=" + finished + " gfw=" + gotFirstWindow + + " ed=" + eventDispatching + " tts=" + timeToSwitch + + " wf=" + wasFrozen + " fp=" + focusPaused + "}}"; + } + }; + private DispatchState mDispatchState = null; + public void recordDispatchState(KeyEvent theEvent, WindowState theFocus) { + mDispatchState = new DispatchState(theEvent, theFocus); + } + // END NOSHIP + public static final int RETURN_NOTHING = 0; public static final int RETURN_PENDING_POINTER = 1; public static final int RETURN_PENDING_TRACKBALL = 2; @@ -4258,6 +4311,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Log.w(TAG, "Key dispatching timed out sending to " + (targetWin != null ? targetWin.mAttrs.getTitle() : "<null>")); + // NOSHIP debugging + Log.w(TAG, "Dispatch state: " + mDispatchState); + Log.w(TAG, "Current state: " + new DispatchState(nextKey, targetWin)); + // END NOSHIP //dump(); if (targetWin != null) { at = targetWin.getAppToken(); @@ -4640,7 +4697,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo newWindow.mToken.paused = false; mGotFirstWindow = true; - boolean doNotify = true; + boolean doNotify = false; if ((newWindow.mAttrs.flags & FLAG_SYSTEM_ERROR) != 0) { if (DEBUG_INPUT) Log.v(TAG, @@ -4649,6 +4706,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mLastBinder = null; mMotionTarget = null; mFinished = true; + doNotify = true; // ensure that we reset the key waiters after hijacking } else if (mLastWin != null) { // If the new window is above the window we are // waiting on, then stop waiting and let key dispatching @@ -4657,15 +4715,15 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo TAG, "Last win layer=" + mLastWin.mLayer + ", new win layer=" + newWindow.mLayer); if (newWindow.mLayer >= mLastWin.mLayer) { - if (!mLastWin.canReceiveKeys()) { - mLastWin.mToken.paused = false; - doFinishedKeyLocked(true); // does a notifyAll() - doNotify = false; - } - } else { - // the new window is lower; no need to wake key waiters - doNotify = false; + // The new window is above the old; finish pending input to the last + // window and start directing it to the new one. + mLastWin.mToken.paused = false; + doFinishedKeyLocked(true); // does a notifyAll() } + // Either the new window is lower, so there is no need to wake key waiters, + // or we just finished key input to the previous window, which implicitly + // notified the key waiters. In both cases, we don't need to issue the + // notification here, so we do not set doNotify. } if (doNotify) { @@ -6405,7 +6463,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo public String toString() { return "Window{" + Integer.toHexString(System.identityHashCode(this)) - + " " + mAttrs.getTitle() + "}"; + + " " + mAttrs.getTitle() + " paused=" + mToken.paused + "}"; } } @@ -8644,7 +8702,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo + " mLastBinder=" + mKeyWaiter.mLastBinder); pw.println(" mFinished=" + mKeyWaiter.mFinished + " mGotFirstWindow=" + mKeyWaiter.mGotFirstWindow - + " mEventDispatching" + mKeyWaiter.mEventDispatching + + " mEventDispatching=" + mKeyWaiter.mEventDispatching + " mTimeToSwitch=" + mKeyWaiter.mTimeToSwitch); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 6443d53..141569e 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -361,6 +361,13 @@ public final class ActivityManagerService extends ActivityManagerNative implemen HistoryRecord mFocusedActivity = null; /** + * This is the last activity that we put into the paused state. This is + * used to determine if we need to do an activity transition while sleeping, + * when we normally hold the top activity paused. + */ + HistoryRecord mLastPausedActivity = null; + + /** * List of activities that are waiting for a new activity * to become visible before completing whatever operation they are * supposed to do. @@ -1819,6 +1826,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (DEBUG_PAUSE) Log.v(TAG, "Start pausing: " + prev); mResumedActivity = null; mPausingActivity = prev; + mLastPausedActivity = prev; prev.state = ActivityState.PAUSING; prev.task.touchActiveTime(); @@ -1837,9 +1845,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Ignore exception, if process died other code will cleanup. Log.w(TAG, "Exception thrown during pause", e); mPausingActivity = null; + mLastPausedActivity = null; } } else { mPausingActivity = null; + mLastPausedActivity = null; } // If we are not going to sleep, we want to ensure the device is @@ -2002,7 +2012,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // First: if this is not the current activity being started, make // sure it matches the current configuration. if (r != starting && doThisProcess) { - ensureActivityConfigurationLocked(r); + ensureActivityConfigurationLocked(r, 0); } if (r.app == null || r.app.thread == null) { @@ -2192,6 +2202,15 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return false; } + // If we are sleeping, and there is no resumed activity, and the top + // activity is paused, well that is the state we want. + if (mSleeping && mLastPausedActivity == next && next.state == ActivityState.PAUSED) { + // Make sure we have executed any pending transitions, since there + // should be nothing left to do at this point. + mWindowManager.executeAppTransition(); + return false; + } + // The activity may be waiting for stop, but that is no longer // appropriate for it. mStoppingActivities.remove(next); @@ -2311,6 +2330,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Do over! mHandler.sendEmptyMessage(RESUME_TOP_ACTIVITY_MSG); } + mWindowManager.executeAppTransition(); return true; } @@ -3839,6 +3859,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (DEBUG_PAUSE) Log.v(TAG, "App died while pausing: " + mPausingActivity); mPausingActivity = null; } + if (mLastPausedActivity != null && mLastPausedActivity.app == app) { + mLastPausedActivity = null; + } // Remove this application's activities from active lists. removeHistoryRecordsForAppLocked(mLRUActivities, app); @@ -4432,7 +4455,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Log.w(TAG, "Process " + app + " failed to attach"); mProcessNames.remove(app.processName, app.info.uid); Process.killProcess(pid); - if (mPendingBroadcast.curApp.pid == pid) { + if (mPendingBroadcast != null && mPendingBroadcast.curApp.pid == pid) { Log.w(TAG, "Unattached app died before broadcast acknowledged, skipping"); mPendingBroadcast = null; scheduleBroadcastsLocked(); @@ -7836,6 +7859,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" mPausingActivity: " + mPausingActivity); pw.println(" mResumedActivity: " + mResumedActivity); pw.println(" mFocusedActivity: " + mFocusedActivity); + pw.println(" mLastPausedActivity: " + mLastPausedActivity); if (mRecentTasks.size() > 0) { pw.println(" "); @@ -10975,7 +10999,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (starting != null) { - kept = ensureActivityConfigurationLocked(starting); + kept = ensureActivityConfigurationLocked(starting, changes); if (kept) { // If this didn't result in the starting activity being // destroyed, then we need to make sure at this point that all @@ -11032,7 +11056,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen * for whatever reason. Ensures the HistoryRecord is updated with the * correct configuration and all other bookkeeping is handled. */ - private final boolean ensureActivityConfigurationLocked(HistoryRecord r) { + private final boolean ensureActivityConfigurationLocked(HistoryRecord r, + int globalChanges) { if (DEBUG_SWITCH) Log.i(TAG, "Ensuring correct configuration: " + r); // Short circuit: if the two configurations are the exact same @@ -11079,7 +11104,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if ((changes&(~r.info.configChanges)) != 0) { // Aha, the activity isn't handling the change, so DIE DIE DIE. r.configChangeFlags |= changes; - r.startFreezingScreenLocked(r.app, changes); + r.startFreezingScreenLocked(r.app, globalChanges); if (r.app == null || r.app.thread == null) { if (DEBUG_SWITCH) Log.i(TAG, "Switch is destroying non-running " + r); destroyActivityLocked(r, true); diff --git a/services/java/com/android/server/am/BaseErrorDialog.java b/services/java/com/android/server/am/BaseErrorDialog.java index 4f62f62..bed2768 100644 --- a/services/java/com/android/server/am/BaseErrorDialog.java +++ b/services/java/com/android/server/am/BaseErrorDialog.java @@ -31,6 +31,8 @@ class BaseErrorDialog extends AlertDialog { super(context, com.android.internal.R.style.Theme_Dialog_AppError); getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, + WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); getWindow().setTitle("Error Dialog"); setIcon(R.drawable.ic_dialog_alert); } diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java index 9ba1198..27d0401 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -70,15 +70,13 @@ public final class BatteryStatsService extends IBatteryStats.Stub { public byte[] getStatistics() { mContext.enforceCallingPermission( android.Manifest.permission.BATTERY_STATS, null); - synchronized (mStats) { - //Log.i("foo", "SENDING BATTERY INFO:"); - //mStats.dumpLocked(new LogPrinter(Log.INFO, "foo")); - Parcel out = Parcel.obtain(); - mStats.writeToParcel(out, 0); - byte[] data = out.marshall(); - out.recycle(); - return data; - } + //Log.i("foo", "SENDING BATTERY INFO:"); + //mStats.dumpLocked(new LogPrinter(Log.INFO, "foo")); + Parcel out = Parcel.obtain(); + mStats.writeToParcel(out, 0); + byte[] data = out.marshall(); + out.recycle(); + return data; } public void noteStartWakelock(int uid, String name, int type) { @@ -137,6 +135,20 @@ public final class BatteryStatsService extends IBatteryStats.Stub { } } + public void notePhoneOn() { + enforceCallingPermission(); + synchronized (mStats) { + mStats.notePhoneOnLocked(); + } + } + + public void notePhoneOff() { + enforceCallingPermission(); + synchronized (mStats) { + mStats.notePhoneOffLocked(); + } + } + public boolean isOnBattery() { return mStats.isOnBattery(); } diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java index 3a5b13c..f4ff5df 100644 --- a/services/java/com/android/server/status/StatusBarPolicy.java +++ b/services/java/com/android/server/status/StatusBarPolicy.java @@ -234,7 +234,7 @@ public class StatusBarPolicy { } else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) || action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) { - updateVolume(intent); + updateVolume(); } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { updateSimState(intent); @@ -326,6 +326,7 @@ public class StatusBarPolicy { null, com.android.internal.R.drawable.stat_sys_ringer_silent, 0, 0); mVolumeIcon = service.addIcon(mVolumeData, null); service.setIconVisibility(mVolumeIcon, false); + updateVolume(); IntentFilter filter = new IntentFilter(); @@ -755,9 +756,7 @@ public class StatusBarPolicy { } } - private final void updateVolume(Intent intent) { - // This can be called from two different received intents, so don't use extras. - + private final void updateVolume() { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); final int ringerMode = audioManager.getRingerMode(); final boolean visible = ringerMode == AudioManager.RINGER_MODE_SILENT || diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index 4748389..5442e1d 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -176,11 +176,11 @@ public class StatusBarService extends IStatusBar.Stub WindowManager.LayoutParams mExpandedParams; ScrollView mScrollView; View mNotificationLinearLayout; - View mOngoingTitle; + TextView mOngoingTitle; LinearLayout mOngoingItems; - View mLatestTitle; + TextView mLatestTitle; LinearLayout mLatestItems; - View mNoNotificationsTitle; + TextView mNoNotificationsTitle; TextView mSpnLabel; TextView mPlmnLabel; TextView mClearButton; @@ -270,11 +270,11 @@ public class StatusBarService extends IStatusBar.Stub mExpandedDialog = new ExpandedDialog(context); mExpandedView = expanded; - mOngoingTitle = expanded.findViewById(R.id.ongoingTitle); + mOngoingTitle = (TextView)expanded.findViewById(R.id.ongoingTitle); mOngoingItems = (LinearLayout)expanded.findViewById(R.id.ongoingItems); - mLatestTitle = expanded.findViewById(R.id.latestTitle); + mLatestTitle = (TextView)expanded.findViewById(R.id.latestTitle); mLatestItems = (LinearLayout)expanded.findViewById(R.id.latestItems); - mNoNotificationsTitle = expanded.findViewById(R.id.noNotificationsTitle); + mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button); mClearButton.setOnClickListener(mClearButtonListener); mSpnLabel = (TextView)expanded.findViewById(R.id.spnLabel); @@ -1705,6 +1705,9 @@ public class StatusBarService extends IStatusBar.Stub */ void updateResources() { mClearButton.setText(mContext.getText(R.string.status_bar_clear_all_button)); + mOngoingTitle.setText(mContext.getText(R.string.status_bar_ongoing_events_title)); + mLatestTitle.setText(mContext.getText(R.string.status_bar_latest_events_title)); + mNoNotificationsTitle.setText(mContext.getText(R.string.status_bar_no_notifications_title)); Log.d(TAG, "updateResources"); } |