diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 14:04:24 -0800 |
commit | 076357b8567458d4b6dfdcf839ef751634cd2bfb (patch) | |
tree | efbb2fd6f1dc67d2d606382fc3b82983e7cb2e1f /services | |
parent | 3dec7d563a2f3e1eb967ce2054a00b6620e3558c (diff) | |
download | frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.zip frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.gz frameworks_base-076357b8567458d4b6dfdcf839ef751634cd2bfb.tar.bz2 |
auto import from //depot/cupcake/@132589
Diffstat (limited to 'services')
17 files changed, 150 insertions, 511 deletions
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index 07c7299..d8012b2 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -34,26 +34,21 @@ import android.os.PowerManager; import android.os.SystemClock; import android.os.SystemProperties; import android.text.TextUtils; -import android.text.format.Time; -import android.util.EventLog; +import android.util.Config; 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; @@ -77,7 +72,6 @@ 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 @@ -344,26 +338,11 @@ class AlarmManagerService extends IAlarmManager.Stub { private int addAlarmLocked(Alarm alarm) { ArrayList<Alarm> alarmList = getAlarmList(alarm.type); - int index = Collections.binarySearch(alarmList, alarm, mIncreasingTimeOrder); - if (index < 0) { - index = 0 - index - 1; - } - if (localLOGV) Log.v(TAG, "Adding alarm " + alarm + " at " + index); + int index = Collections.binarySearch(alarmList, alarm); + index = (index < 0) ? ((index + 1) * -1) : index; + 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; } @@ -480,22 +459,14 @@ 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); - } - // Recurring alarms may have passed several alarm intervals while the + // 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 // phone was asleep or off, so pass a trigger count when sending them. if (localLOGV) Log.v(TAG, "Alarm triggering: " + alarm); alarm.count = 1; @@ -510,42 +481,28 @@ 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)); } } - /** - * 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 { + private class Alarm implements Comparable<Alarm> { public int type; public int count; public long when; @@ -558,7 +515,15 @@ class AlarmManagerService extends IAlarmManager.Stub { operation = null; } - @Override + 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; + } + public String toString() { return "Alarm{" @@ -736,11 +701,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 3a9a59f..9c9a580 100644 --- a/services/java/com/android/server/BatteryService.java +++ b/services/java/com/android/server/BatteryService.java @@ -20,31 +20,20 @@ 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 @@ -71,24 +60,12 @@ import java.io.PrintWriter; 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; @@ -104,7 +81,6 @@ class BatteryService extends Binder { private int mBatteryVoltage; private int mBatteryTemperature; private String mBatteryTechnology; - private boolean mBatteryLevelCritical; private int mLastBatteryStatus; private int mLastBatteryHealth; @@ -112,7 +88,6 @@ 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 @@ -120,7 +95,6 @@ class BatteryService extends Binder { private long mDischargeStartTime; private int mDischargeStartLevel; - public BatteryService(Context context) { mContext = context; mBatteryStats = BatteryStatsService.getService(); @@ -175,8 +149,6 @@ 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) { @@ -204,8 +176,6 @@ 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 @@ -227,12 +197,6 @@ 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; @@ -241,7 +205,6 @@ class BatteryService extends Binder { mLastPlugType = mPlugType; mLastBatteryVoltage = mBatteryVoltage; mLastBatteryTemperature = mBatteryTemperature; - mLastBatteryLevelCritical = mBatteryLevelCritical; sendIntent(); } @@ -284,83 +247,6 @@ 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 0943778..4a430e0 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=N-1; i>=0; i--) { + for (int i=0; i<N; 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=N-1; i>=0; i--) { + for (int i=0; i<N; i++) { GadgetId id = host.instances.get(i); deleteGadgetLocked(id); } @@ -622,17 +622,6 @@ 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 2131ffd..40456ff 100755 --- a/services/java/com/android/server/HardwareService.java +++ b/services/java/com/android/server/HardwareService.java @@ -25,7 +25,6 @@ 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; @@ -241,7 +240,6 @@ 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 9d69114..bc8da93 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -214,6 +214,7 @@ public class LocationManagerService extends ILocationManager.Stub // Last known cell service state private TelephonyManager mTelephonyManager; + private int mSignalStrength = -1; // Location collector private ILocationCollector mCollector; @@ -1763,7 +1764,7 @@ public class LocationManagerService extends ILocationManager.Stub Log.d(TAG, "installing network location provider"); INetworkLocationManager.InstallCallback callback = (INetworkLocationManager.InstallCallback)msg.obj; - callback.installNetworkLocationProvider(LocationManagerService.this); + callback.installNetworkLocationProvider(mContext, LocationManagerService.this); } } } catch (Exception e) { @@ -1773,90 +1774,40 @@ public class LocationManagerService extends ILocationManager.Stub } } - class CellLocationUpdater extends Thread { - CellLocation mNextLocation; - - CellLocationUpdater() { - super("CellLocationUpdater"); - } - + PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + + private CellState mLastCellState = null; @Override - public void run() { - int curAsu = -1; - CellLocation curLocation = null; - - while (true) { - // See if there is more work to do... + public void onCellLocationChanged(CellLocation cellLocation) { + try { synchronized (mLocationListeners) { - if (curLocation == mNextLocation) { - mCellLocationUpdater = null; - break; - } - - curLocation = mNextLocation; - if (curLocation == null) { - mCellLocationUpdater = null; - break; + int asu = mSignalStrength; + + // Gets cell state + mLastCellState = new CellState(mTelephonyManager, cellLocation, asu); + + // Notify collector + if (mCollector != null) { + mCollector.updateCellState(mLastCellState); } - - 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(cs); - } + // Updates providers + List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + for (LocationProviderImpl provider : providers) { + if (provider.requiresCell()) { + provider.updateCellState(mLastCellState); } } - } catch (RuntimeException e) { - Log.e(TAG, "Exception in PhoneStateListener.onCellLocationChanged:", 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; + } catch (Exception e) { + Log.e(TAG, "Exception in PhoneStateListener.onCellLocationCahnged:", e); } } @Override public void onSignalStrengthChanged(int asu) { synchronized (mLocationListeners) { - mLastSignalStrength = asu; + mSignalStrength = asu; if (mLastCellState != null) { mLastCellState.updateSignalStrength(asu); @@ -1867,18 +1818,8 @@ 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(radioType); + mLastCellState.updateRadioType(mTelephonyManager); } } } @@ -2614,11 +2555,8 @@ 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 8814e48..0feb1da 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -505,12 +505,9 @@ class MountService extends IMountService.Stub { if (mMediaStorageNotification == null) { mMediaStorageNotification = new Notification(); mMediaStorageNotification.when = 0; - } - - if (mPlaySounds) { - mMediaStorageNotification.defaults |= Notification.DEFAULT_SOUND; - } else { - mMediaStorageNotification.defaults &= ~Notification.DEFAULT_SOUND; + if (mPlaySounds) { + 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 bc4b169..e5de7f9 100644 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -311,17 +311,6 @@ 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); } } }; @@ -342,8 +331,6 @@ 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 fec3608..c490e42 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,18 +1925,19 @@ 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, false); + destResourceFile, pkg.applicationInfo.flags, true); if (pkgSetting == null) { Log.w(TAG, "Creating application package " + pkgName + " failed"); mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; return null; } - if(mSettings.mDisabledSysPackages.get(pkg.packageName) != null) { - pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; + synchronized(mPackages) { + if(mSettings.mDisabledSysPackages.get(pkg.packageName) != null) { + pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; + } } - + pkg.applicationInfo.uid = pkgSetting.userId; pkg.mExtras = pkgSetting; @@ -1984,12 +1985,24 @@ 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. @@ -2032,7 +2045,8 @@ class PackageManagerService extends IPackageManager.Stub { return null; } } - } + + } if (!recovered) { mHasSystemUidErrors = true; } @@ -2064,7 +2078,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; } @@ -2134,17 +2148,8 @@ 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; @@ -3192,7 +3197,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) { @@ -3243,7 +3248,7 @@ class PackageManagerService extends IPackageManager.Stub { /* * Install a non-existing package. */ - private void installNewPackageLI(String pkgName, + private void installNewPackageLI(String pkgName, int parseFlags, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3267,7 +3272,7 @@ class PackageManagerService extends IPackageManager.Stub { } mLastScanError = PackageManager.INSTALL_SUCCEEDED; PackageParser.Package newPackage = scanPackageLI(tmpPackageFile, destPackageFile, - destResourceFile, pkg, 0, + destResourceFile, pkg, parseFlags, SCAN_MONITOR | SCAN_FORCE_DEX | SCAN_UPDATE_SIGNATURE | (forwardLocked ? SCAN_FORWARD_LOCKED : 0)); @@ -3299,7 +3304,7 @@ class PackageManagerService extends IPackageManager.Stub { } } - private void replacePackageLI(String pkgName, + private void replacePackageLI(String pkgName, int parseFlags, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3316,15 +3321,16 @@ 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, tmpPackageFile, destFilePath, + replaceNonSystemPackageLI(deletedPackage, parseFlags, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, res); } } - private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage, + private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage, int parseFlags, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, @@ -3333,7 +3339,6 @@ 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)) { @@ -3409,15 +3414,14 @@ class PackageManagerService extends IPackageManager.Stub { } } - private void replaceSystemPackageLI(PackageParser.Package deletedPackage, + private void replaceSystemPackageLI(PackageParser.Package deletedPackage, int parseFlags, File tmpPackageFile, String destFilePath, File destPackageFile, File destResourceFile, PackageParser.Package pkg, boolean forwardLocked, PackageInstalledInfo res) { PackageParser.Package newPackage = null; boolean updatedSettings = false; - int parseFlags = PackageManager.REPLACE_EXISTING_PACKAGE | - PackageParser.PARSE_IS_SYSTEM; + parseFlags |= PackageParser.PARSE_IS_SYSTEM; String packageName = deletedPackage.packageName; res.returnCode = PackageManager.INSTALL_FAILED_REPLACE_COULDNT_DELETE; if (packageName == null) { @@ -3561,6 +3565,7 @@ 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; @@ -3666,13 +3671,13 @@ class PackageManagerService extends IPackageManager.Stub { } if(replacingExistingPackage) { - replacePackageLI(pkgName, + replacePackageLI(pkgName, pFlags, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, res); } else { - installNewPackageLI(pkgName, + installNewPackageLI(pkgName, pFlags, tmpPackageFile, destFilePath, destPackageFile, destResourceFile, pkg, forwardLocked, @@ -3997,6 +4002,7 @@ 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; @@ -5312,10 +5318,10 @@ class PackageManagerService extends IPackageManager.Stub { PackageSetting getPackageLP(PackageParser.Package pkg, SharedUserSetting sharedUser, File codePath, File resourcePath, - int pkgFlags, boolean create, boolean add) { + int pkgFlags, boolean create) { final String name = pkg.packageName; PackageSetting p = getPackageLP(name, sharedUser, codePath, - resourcePath, pkgFlags, create, add); + resourcePath, pkgFlags, create); if (p != null) { p.pkg = pkg; @@ -5446,7 +5452,7 @@ class PackageManagerService extends IPackageManager.Stub { private PackageSetting getPackageLP(String name, SharedUserSetting sharedUser, File codePath, File resourcePath, - int pkgFlags, boolean create, boolean add) { + int pkgFlags, boolean create) { PackageSetting p = mPackages.get(name); if (p != null) { if (!p.codePath.equals(codePath)) { @@ -5491,25 +5497,15 @@ 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; } - if (add) { - // Finish adding new package by adding it and updating shared - // user preferences - insertPackageSettingLP(p, name, sharedUser); - } + mPackages.put(name, p); } - 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, @@ -5519,16 +5515,17 @@ 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) { @@ -5983,7 +5980,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, true); + pp.pkgFlags, 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 ad30ffc..f41d21f 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -973,9 +973,11 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage if (mSpew) { Log.d(TAG, "mBroadcastWakeLock=" + mBroadcastWakeLock); } - if (mContext != null && ActivityManagerNative.isSystemReady()) { - mContext.sendOrderedBroadcast(mScreenOnIntent, null, - mScreenOnBroadcastDone, mHandler, 0, null, null); + if (mContext != null) { + if (ActivityManagerNative.isSystemReady()) { + mContext.sendOrderedBroadcast(mScreenOnIntent, null, + mScreenOnBroadcastDone, mHandler, 0, null, null); + } } else { synchronized (mLocks) { EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 2, @@ -994,7 +996,7 @@ class PowerManagerService extends IPowerManager.Stub implements LocalPowerManage // ignore it. } - if (mContext != null && ActivityManagerNative.isSystemReady()) { + if (mContext != null) { 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 77383bd..fc25e38 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -188,6 +188,7 @@ 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); } @@ -314,12 +315,6 @@ 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 5e5fb93..b5cf1aa 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -33,14 +33,12 @@ 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; /** @@ -57,9 +55,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { int events; } - private final Context mContext; - private final ArrayList<Record> mRecords = new ArrayList(); - private final IBatteryStats mBatteryStats; + private Context mContext; + private ArrayList<Record> mRecords = new ArrayList(); private int mCallState = TelephonyManager.CALL_STATE_IDLE; private String mCallIncomingNumber = ""; @@ -84,7 +81,6 @@ 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, @@ -418,18 +414,6 @@ 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 a3ceb71..10a2d29 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -3954,10 +3954,6 @@ 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) { @@ -4101,55 +4097,6 @@ 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; @@ -4311,10 +4258,6 @@ 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(); @@ -4697,7 +4640,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo newWindow.mToken.paused = false; mGotFirstWindow = true; - boolean doNotify = false; + boolean doNotify = true; if ((newWindow.mAttrs.flags & FLAG_SYSTEM_ERROR) != 0) { if (DEBUG_INPUT) Log.v(TAG, @@ -4706,7 +4649,6 @@ 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 @@ -4715,15 +4657,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) { - // 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() + 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; } - // 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) { @@ -6463,7 +6405,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo public String toString() { return "Window{" + Integer.toHexString(System.identityHashCode(this)) - + " " + mAttrs.getTitle() + " paused=" + mToken.paused + "}"; + + " " + mAttrs.getTitle() + "}"; } } @@ -8702,7 +8644,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 141569e..6443d53 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -361,13 +361,6 @@ 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. @@ -1826,7 +1819,6 @@ 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(); @@ -1845,11 +1837,9 @@ 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 @@ -2012,7 +2002,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, 0); + ensureActivityConfigurationLocked(r); } if (r.app == null || r.app.thread == null) { @@ -2202,15 +2192,6 @@ 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); @@ -2330,7 +2311,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Do over! mHandler.sendEmptyMessage(RESUME_TOP_ACTIVITY_MSG); } - mWindowManager.executeAppTransition(); return true; } @@ -3859,9 +3839,6 @@ 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); @@ -4455,7 +4432,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 != null && mPendingBroadcast.curApp.pid == pid) { + if (mPendingBroadcast.curApp.pid == pid) { Log.w(TAG, "Unattached app died before broadcast acknowledged, skipping"); mPendingBroadcast = null; scheduleBroadcastsLocked(); @@ -7859,7 +7836,6 @@ 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(" "); @@ -10999,7 +10975,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen } if (starting != null) { - kept = ensureActivityConfigurationLocked(starting, changes); + kept = ensureActivityConfigurationLocked(starting); if (kept) { // If this didn't result in the starting activity being // destroyed, then we need to make sure at this point that all @@ -11056,8 +11032,7 @@ 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, - int globalChanges) { + private final boolean ensureActivityConfigurationLocked(HistoryRecord r) { if (DEBUG_SWITCH) Log.i(TAG, "Ensuring correct configuration: " + r); // Short circuit: if the two configurations are the exact same @@ -11104,7 +11079,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, globalChanges); + r.startFreezingScreenLocked(r.app, changes); 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 bed2768..4f62f62 100644 --- a/services/java/com/android/server/am/BaseErrorDialog.java +++ b/services/java/com/android/server/am/BaseErrorDialog.java @@ -31,8 +31,6 @@ 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 27d0401..9ba1198 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -70,13 +70,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub { public byte[] getStatistics() { mContext.enforceCallingPermission( android.Manifest.permission.BATTERY_STATS, null); - //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; + 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; + } } public void noteStartWakelock(int uid, String name, int type) { @@ -135,20 +137,6 @@ 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 f4ff5df..3a5b13c 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(); + updateVolume(intent); } else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { updateSimState(intent); @@ -326,7 +326,6 @@ 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(); @@ -756,7 +755,9 @@ public class StatusBarPolicy { } } - private final void updateVolume() { + private final void updateVolume(Intent intent) { + // This can be called from two different received intents, so don't use extras. + 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 5442e1d..4748389 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; - TextView mOngoingTitle; + View mOngoingTitle; LinearLayout mOngoingItems; - TextView mLatestTitle; + View mLatestTitle; LinearLayout mLatestItems; - TextView mNoNotificationsTitle; + View mNoNotificationsTitle; TextView mSpnLabel; TextView mPlmnLabel; TextView mClearButton; @@ -270,11 +270,11 @@ public class StatusBarService extends IStatusBar.Stub mExpandedDialog = new ExpandedDialog(context); mExpandedView = expanded; - mOngoingTitle = (TextView)expanded.findViewById(R.id.ongoingTitle); + mOngoingTitle = expanded.findViewById(R.id.ongoingTitle); mOngoingItems = (LinearLayout)expanded.findViewById(R.id.ongoingItems); - mLatestTitle = (TextView)expanded.findViewById(R.id.latestTitle); + mLatestTitle = expanded.findViewById(R.id.latestTitle); mLatestItems = (LinearLayout)expanded.findViewById(R.id.latestItems); - mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle); + mNoNotificationsTitle = 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,9 +1705,6 @@ 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"); } |