diff options
author | Mathias Agopian <mathias@google.com> | 2009-04-30 14:43:18 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-04-30 14:43:18 -0700 |
commit | fa6eda01a9f3df0102ce6a65302c8674cc9c7e50 (patch) | |
tree | a0c1b31bd8e162132c54a2ef8521b3ed6cf8cad1 /services/java/com | |
parent | d504605919a62902e10cd13536390ffce84a3326 (diff) | |
parent | 072868a4d33740ee023b7364dcb38f4fc14bd8b0 (diff) | |
download | frameworks_base-fa6eda01a9f3df0102ce6a65302c8674cc9c7e50.zip frameworks_base-fa6eda01a9f3df0102ce6a65302c8674cc9c7e50.tar.gz frameworks_base-fa6eda01a9f3df0102ce6a65302c8674cc9c7e50.tar.bz2 |
Merge commit 'goog/master' into merge_master
Conflicts:
libs/surfaceflinger/Layer.cpp
libs/surfaceflinger/SurfaceFlinger.cpp
opengl/libagl/egl.cpp
opengl/libs/EGL/egl.cpp
opengl/libs/GLES_CM/gl.cpp
opengl/libs/GLES_CM/gl_api.in
opengl/libs/gl_entries.in
opengl/libs/tools/glapigen
Diffstat (limited to 'services/java/com')
22 files changed, 1178 insertions, 644 deletions
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java index d66c6e5..9c4ace1 100644 --- a/services/java/com/android/server/AlarmManagerService.java +++ b/services/java/com/android/server/AlarmManagerService.java @@ -413,41 +413,45 @@ class AlarmManagerService extends IAlarmManager.Stub { synchronized (mLock) { pw.println("Current Alarm Manager state:"); - if (mRtcWakeupAlarms.size() > 0) { + if (mRtcWakeupAlarms.size() > 0 || mRtcAlarms.size() > 0) { pw.println(" "); - pw.println(" Realtime wakeup alarms that are scheduled:"); - dumpAlarmList(pw, mRtcWakeupAlarms, " ", "RTC_WAKEUP"); - } - if (mRtcAlarms.size() > 0) { - pw.println(" "); - pw.println(" Realtime alarms that are scheduled:"); - dumpAlarmList(pw, mRtcAlarms, " ", "RTC"); - } - if (mElapsedRealtimeWakeupAlarms.size() > 0) { - pw.println(" "); - pw.println(" Elapsed realtime wakeup alarms that are scheduled:"); - dumpAlarmList(pw, mElapsedRealtimeWakeupAlarms, " ", "ELAPSED_REALTIME_WAKEUP"); + pw.print(" Realtime wakeup (now="); + pw.print(System.currentTimeMillis()); pw.println("):"); + if (mRtcWakeupAlarms.size() > 0) { + dumpAlarmList(pw, mRtcWakeupAlarms, " ", "RTC_WAKEUP"); + } + if (mRtcAlarms.size() > 0) { + dumpAlarmList(pw, mRtcAlarms, " ", "RTC"); + } } - if (mElapsedRealtimeAlarms.size() > 0) { + if (mElapsedRealtimeWakeupAlarms.size() > 0 || mElapsedRealtimeAlarms.size() > 0) { pw.println(" "); - pw.println(" Elapsed realtime alarms that are scheduled:"); - dumpAlarmList(pw, mElapsedRealtimeAlarms, " ", "ELAPSED_REALTIME"); + pw.print(" Elapsed realtime wakeup (now="); + pw.print(SystemClock.elapsedRealtime()); pw.println("):"); + if (mElapsedRealtimeWakeupAlarms.size() > 0) { + dumpAlarmList(pw, mElapsedRealtimeWakeupAlarms, " ", "ELAPSED_WAKEUP"); + } + if (mElapsedRealtimeAlarms.size() > 0) { + dumpAlarmList(pw, mElapsedRealtimeAlarms, " ", "ELAPSED"); + } } pw.println(" "); - pw.println(" Broadcast ref count: " + mBroadcastRefCount); + pw.print(" Broadcast ref count: "); pw.println(mBroadcastRefCount); pw.println(" "); pw.println(" Alarm Stats:"); for (Map.Entry<String, BroadcastStats> be : mBroadcastStats.entrySet()) { BroadcastStats bs = be.getValue(); - pw.println(" " + be.getKey()); - pw.println(" " + bs.aggregateTime + "ms running, " - + bs.numWakeup + " wakeups"); + pw.print(" "); pw.println(be.getKey()); + pw.print(" "); pw.print(bs.aggregateTime); + pw.print("ms running, "); pw.print(bs.numWakeup); + pw.println(" wakeups"); for (Map.Entry<Intent.FilterComparison, FilterStats> fe : bs.filterStats.entrySet()) { - pw.println(" " + fe.getValue().count + " alarms: " - + fe.getKey().getIntent()); + pw.print(" "); pw.print(fe.getValue().count); + pw.print(" alarms: "); + pw.println(fe.getKey().getIntent().toShortString(true, false)); } } } @@ -456,7 +460,8 @@ class AlarmManagerService extends IAlarmManager.Stub { private static final void dumpAlarmList(PrintWriter pw, ArrayList<Alarm> list, String prefix, String label) { for (int i=list.size()-1; i>=0; i--) { Alarm a = list.get(i); - pw.println(prefix + label + " #" + i + ":"); + pw.print(prefix); pw.print(label); pw.print(" #"); pw.print(i); + pw.print(": "); pw.println(a); a.dump(pw, prefix + " "); } } @@ -561,18 +566,24 @@ class AlarmManagerService extends IAlarmManager.Stub { @Override public String toString() { - return "Alarm{" - + Integer.toHexString(System.identityHashCode(this)) - + " type " + type + " " + operation.getTargetPackage() + "}"; + StringBuilder sb = new StringBuilder(128); + sb.append("Alarm{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" type "); + sb.append(type); + sb.append(" "); + sb.append(operation.getTargetPackage()); + sb.append('}'); + return sb.toString(); } public void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "type=" + type + " when=" + when - + " repeatInterval=" + repeatInterval - + " count=" + count); - pw.println(prefix + "operation=" + operation); + pw.print(prefix); pw.print("type="); pw.print(type); + pw.print(" when="); pw.print(when); + pw.print(" repeatInterval="); pw.print(repeatInterval); + pw.print(" count="); pw.println(count); + pw.print(prefix); pw.print("operation="); pw.println(operation); } } diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index de5d0ac..bb420a6 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -151,34 +151,57 @@ class AppWidgetService extends IAppWidgetService.Stub synchronized (mAppWidgetIds) { int N = mInstalledProviders.size(); - pw.println("Providers: (size=" + N + ")"); + pw.println("Providers:"); for (int i=0; i<N; i++) { Provider p = mInstalledProviders.get(i); AppWidgetProviderInfo info = p.info; - pw.println(" [" + i + "] provder=" + info.provider - + " min=(" + info.minWidth + "x" + info.minHeight + ")" - + " updatePeriodMillis=" + info.updatePeriodMillis - + " initialLayout=" + info.initialLayout + " zombie=" + p.zombie); + pw.print(" ["); pw.print(i); pw.print("] provider "); + pw.print(info.provider.flattenToShortString()); + pw.println(':'); + pw.print(" min=("); pw.print(info.minWidth); + pw.print("x"); pw.print(info.minHeight); + pw.print(") updatePeriodMillis="); + pw.print(info.updatePeriodMillis); + pw.print(" initialLayout=#"); + pw.print(Integer.toHexString(info.initialLayout)); + pw.print(" zombie="); pw.println(p.zombie); } N = mAppWidgetIds.size(); - pw.println("AppWidgetIds: (size=" + N + ")"); + pw.println(" "); + pw.println("AppWidgetIds:"); for (int i=0; i<N; i++) { AppWidgetId id = mAppWidgetIds.get(i); - pw.println(" [" + i + "] appWidgetId=" + id.appWidgetId - + " host=" + id.host.hostId + "/" + id.host.packageName + " provider=" - + (id.provider == null ? "null" : id.provider.info.provider) - + " host.callbacks=" + (id.host != null ? id.host.callbacks : "(no host)") - + " views=" + id.views); + pw.print(" ["); pw.print(i); pw.print("] id="); + pw.println(id.appWidgetId);; + pw.print(" hostId="); + pw.print(id.host.hostId); pw.print(' '); + pw.print(id.host.packageName); pw.print('/'); + pw.println(id.host.uid); + if (id.provider != null) { + pw.print(" provider="); + pw.println(id.provider.info.provider.flattenToShortString()); + } + if (id.host != null) { + pw.print(" host.callbacks="); pw.println(id.host.callbacks); + } + if (id.views != null) { + pw.print(" views="); pw.println(id.views); + } } N = mHosts.size(); - pw.println("Hosts: (size=" + N + ")"); + pw.println(" "); + pw.println("Hosts:"); for (int i=0; i<N; i++) { Host host = mHosts.get(i); - pw.println(" [" + i + "] packageName=" + host.packageName + " uid=" + host.uid - + " hostId=" + host.hostId + " callbacks=" + host.callbacks - + " instances.size=" + host.instances.size() + " zombie=" + host.zombie); + pw.print(" ["); pw.print(i); pw.print("] hostId="); + pw.print(host.hostId); pw.print(' '); + pw.print(host.packageName); pw.print('/'); + pw.print(host.uid); pw.println(':'); + pw.print(" callbacks="); pw.println(host.callbacks); + pw.print(" instances.size="); pw.print(host.instances.size()); + pw.print(" zombie="); pw.println(host.zombie); } } } diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java new file mode 100644 index 0000000..0f95318 --- /dev/null +++ b/services/java/com/android/server/BackupManagerService.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server; + +import android.backup.BackupService; +import android.backup.IBackupService; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.pm.ServiceInfo; +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.RemoteException; +import android.util.Log; +import android.util.SparseArray; + +import android.backup.IBackupManager; + +import java.lang.String; +import java.util.HashSet; +import java.util.List; + +class BackupManagerService extends IBackupManager.Stub { + private static final String TAG = "BackupManagerService"; + private static final boolean DEBUG = true; + + private static final long COLLECTION_INTERVAL = 3 * 60 * 1000; + + private static final int MSG_RUN_BACKUP = 1; + + private Context mContext; + private PackageManager mPackageManager; + private final BackupHandler mBackupHandler = new BackupHandler(); + // map UIDs to the set of backup client services within that UID's app set + private SparseArray<HashSet<ServiceInfo>> mBackupParticipants + = new SparseArray<HashSet<ServiceInfo>>(); + // set of backup services that have pending changes + private HashSet<ServiceInfo> mPendingBackups = new HashSet<ServiceInfo>(); + private final Object mQueueLock = new Object(); + + + // ----- Handler that runs the actual backup process asynchronously ----- + + private class BackupHandler extends Handler implements ServiceConnection { + private volatile Object mBindSignaller = new Object(); + private volatile boolean mBinding = false; + private IBackupService mTargetService = null; + + public void handleMessage(Message msg) { + + switch (msg.what) { + case MSG_RUN_BACKUP: + { + // snapshot the pending-backup set and work on that + HashSet<ServiceInfo> queue; + synchronized (mQueueLock) { + queue = mPendingBackups; + mPendingBackups = new HashSet<ServiceInfo>(); + // !!! TODO: start a new backup-queue journal file too + } + + // Walk the set of pending backups, setting up the relevant files and + // invoking the backup service in each participant + Intent backupIntent = new Intent(BackupService.SERVICE_ACTION); + for (ServiceInfo service : queue) { + mBinding = true; + mTargetService = null; + + backupIntent.setClassName(service.packageName, service.name); + Log.d(TAG, "binding to " + backupIntent); + if (mContext.bindService(backupIntent, this, 0)) { + synchronized (mBindSignaller) { + while (mTargetService == null && mBinding == true) { + try { + mBindSignaller.wait(); + } catch (InterruptedException e) { + } + } + } + if (mTargetService != null) { + try { + Log.d(TAG, "invoking doBackup() on " + backupIntent); + // !!! TODO: set up files + mTargetService.doBackup(-1, -1, -1); + } catch (RemoteException e) { + Log.d(TAG, "Remote target " + backupIntent + + " threw during backup:"); + e.printStackTrace(); + } + mContext.unbindService(this); + } + } else { + Log.d(TAG, "Unable to bind to " + backupIntent); + } + } + } + break; + } + } + + public void onServiceConnected(ComponentName name, IBinder service) { + synchronized (mBindSignaller) { + mTargetService = IBackupService.Stub.asInterface(service); + mBinding = false; + mBindSignaller.notifyAll(); + } + } + + public void onServiceDisconnected(ComponentName name) { + synchronized (mBindSignaller) { + mTargetService = null; + mBinding = false; + mBindSignaller.notifyAll(); + } + } + } + + public BackupManagerService(Context context) { + mContext = context; + mPackageManager = context.getPackageManager(); + + // Identify the backup participants + // !!! TODO: also watch package-install to keep this up to date + List<ResolveInfo> services = mPackageManager.queryIntentServices( + new Intent(BackupService.SERVICE_ACTION), 0); + if (DEBUG) { + Log.v(TAG, "Backup participants: " + services.size()); + for (ResolveInfo ri : services) { + Log.v(TAG, " " + ri + " : " + ri.filter); + } + } + + // Build our mapping of uid to backup client services + for (ResolveInfo ri : services) { + int uid = ri.serviceInfo.applicationInfo.uid; + HashSet<ServiceInfo> set = mBackupParticipants.get(uid); + if (set == null) { + set = new HashSet<ServiceInfo>(); + mBackupParticipants.put(uid, set); + } + set.add(ri.serviceInfo); + } + } + + + // ----- IBackupManager binder interface ----- + + public void dataChanged(String packageName) throws RemoteException { + // Record that we need a backup pass for the caller. Since multiple callers + // may share a uid, we need to note all candidates within that uid and schedule + // a backup pass for each of them. + + HashSet<ServiceInfo> targets = mBackupParticipants.get(Binder.getCallingUid()); + if (targets != null) { + synchronized (mQueueLock) { + // Note that this client has made data changes that need to be backed up + for (ServiceInfo service : targets) { + // validate the caller-supplied package name against the known set of + // packages associated with this uid + if (service.packageName.equals(packageName)) { + // add the caller to the set of pending backups + if (mPendingBackups.add(service)) { + // !!! TODO: write to the pending-backup journal file in case of crash + } + } + } + + // Schedule a backup pass in a few minutes. As backup-eligible data + // keeps changing, continue to defer the backup pass until things + // settle down, to avoid extra overhead. + mBackupHandler.removeMessages(MSG_RUN_BACKUP); + mBackupHandler.sendEmptyMessageDelayed(MSG_RUN_BACKUP, COLLECTION_INTERVAL); + } + } + } +} diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java index b534ef1..72efca5 100644 --- a/services/java/com/android/server/IntentResolver.java +++ b/services/java/com/android/server/IntentResolver.java @@ -16,6 +16,7 @@ package com.android.server; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -89,11 +90,11 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { } } - void dumpMap(Printer out, String prefix, Map<String, ArrayList<F>> map) { + void dumpMap(PrintWriter out, String prefix, Map<String, ArrayList<F>> map) { String eprefix = prefix + " "; String fprefix = prefix + " "; for (Map.Entry<String, ArrayList<F>> e : map.entrySet()) { - out.println(eprefix + e.getKey() + ":"); + out.print(eprefix); out.print(e.getKey()); out.println(":"); ArrayList<F> a = e.getValue(); final int N = a.size(); for (int i=0; i<N; i++) { @@ -102,24 +103,25 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { } } - public void dump(Printer out, String prefix) { - out.println(prefix + "Full MIME Types:"); - dumpMap(out, prefix+" ", mTypeToFilter); - out.println(prefix); - out.println(prefix + "Base MIME Types:"); - dumpMap(out, prefix+" ", mBaseTypeToFilter); - out.println(prefix); - out.println(prefix + "Wild MIME Types:"); - dumpMap(out, prefix+" ", mWildTypeToFilter); - out.println(prefix); - out.println(prefix + "Schemes:"); - dumpMap(out, prefix+" ", mSchemeToFilter); - out.println(prefix); - out.println(prefix + "Non-Data Actions:"); - dumpMap(out, prefix+" ", mActionToFilter); - out.println(prefix); - out.println(prefix + "MIME Typed Actions:"); - dumpMap(out, prefix+" ", mTypedActionToFilter); + public void dump(PrintWriter out, String prefix) { + String innerPrefix = prefix + " "; + out.print(prefix); out.println("Full MIME Types:"); + dumpMap(out, innerPrefix, mTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Base MIME Types:"); + dumpMap(out, innerPrefix, mBaseTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Wild MIME Types:"); + dumpMap(out, innerPrefix, mWildTypeToFilter); + out.println(" "); + out.print(prefix); out.println("Schemes:"); + dumpMap(out, innerPrefix, mSchemeToFilter); + out.println(" "); + out.print(prefix); out.println("Non-Data Actions:"); + dumpMap(out, innerPrefix, mActionToFilter); + out.println(" "); + out.print(prefix); out.println("MIME Typed Actions:"); + dumpMap(out, innerPrefix, mTypedActionToFilter); } private class IteratorWrapper implements Iterator<F> { @@ -275,8 +277,8 @@ public class IntentResolver<F extends IntentFilter, R extends Object> { Collections.sort(results, mResolvePrioritySorter); } - protected void dumpFilter(Printer out, String prefix, F filter) { - out.println(prefix + filter); + protected void dumpFilter(PrintWriter out, String prefix, F filter) { + out.print(prefix); out.println(filter); } private final int register_mime_types(F filter, String prefix) { diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 5e079d4..0e1e0d9 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -53,13 +53,13 @@ import android.location.ILocationProvider; import android.location.Location; import android.location.LocationManager; import android.location.LocationProvider; -import android.location.LocationProviderImpl; import android.net.ConnectivityManager; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.Process; @@ -72,9 +72,9 @@ import android.util.PrintWriterPrinter; import android.util.SparseIntArray; import com.android.internal.location.GpsLocationProvider; +import com.android.internal.location.LocationProviderImpl; import com.android.internal.location.LocationProviderProxy; import com.android.internal.location.MockProvider; -import com.android.internal.location.TrackProvider; import com.android.server.am.BatteryStatsService; /** @@ -83,7 +83,7 @@ import com.android.server.am.BatteryStatsService; * * {@hide} */ -public class LocationManagerService extends ILocationManager.Stub { +public class LocationManagerService extends ILocationManager.Stub implements Runnable { private static final String TAG = "LocationManagerService"; private static final boolean LOCAL_LOGV = false; @@ -93,10 +93,6 @@ public class LocationManagerService extends ILocationManager.Stub { // Max time to hold wake lock for, in milliseconds. private static final long MAX_TIME_FOR_WAKE_LOCK = 60 * 1000L; - // Time to wait after releasing a wake lock for clients to process location update, - // in milliseconds. - private static final long TIME_AFTER_WAKE_LOCK = 2 * 1000L; - // The last time a location was written, by provider name. private HashMap<String,Long> mLastWriteTime = new HashMap<String,Long>(); @@ -130,7 +126,6 @@ public class LocationManagerService extends ILocationManager.Stub { // Handler messages private static final int MESSAGE_LOCATION_CHANGED = 1; - private static final int MESSAGE_RELEASE_WAKE_LOCK = 2; // Alarm manager and wakelock variables private final static String ALARM_INTENT = "com.android.location.ALARM_INTENT"; @@ -138,6 +133,7 @@ public class LocationManagerService extends ILocationManager.Stub { private AlarmManager mAlarmManager; private long mAlarmInterval = 0; private PowerManager.WakeLock mWakeLock = null; + private int mPendingBroadcasts; private long mWakeLockAcquireTime = 0; private boolean mWakeLockGpsReceived = true; private boolean mWakeLockNetworkReceived = true; @@ -159,7 +155,8 @@ public class LocationManagerService extends ILocationManager.Stub { new HashMap<String,ArrayList<UpdateRecord>>(); // Proximity listeners - private Receiver mProximityListener = null; + private Receiver mProximityReceiver = null; + private ILocationListener mProximityListener = null; private HashMap<PendingIntent,ProximityAlert> mProximityAlerts = new HashMap<PendingIntent,ProximityAlert>(); private HashSet<ProximityAlert> mProximitiesEntered = @@ -181,11 +178,12 @@ public class LocationManagerService extends ILocationManager.Stub { * A wrapper class holding either an ILocationListener or a PendingIntent to receive * location updates. */ - private final class Receiver implements IBinder.DeathRecipient { + private final class Receiver implements IBinder.DeathRecipient, PendingIntent.OnFinished { final ILocationListener mListener; final PendingIntent mPendingIntent; final Object mKey; final HashMap<String,UpdateRecord> mUpdateRecords = new HashMap<String,UpdateRecord>(); + int mPendingBroadcasts; Receiver(ILocationListener listener) { mListener = listener; @@ -252,7 +250,16 @@ public class LocationManagerService extends ILocationManager.Stub { public boolean callStatusChangedLocked(String provider, int status, Bundle extras) { if (mListener != null) { try { - mListener.onStatusChanged(provider, status, extras); + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + mListener.onStatusChanged(provider, status, extras); + if (mListener != mProximityListener) { + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } + } } catch (RemoteException e) { return false; } @@ -261,7 +268,14 @@ public class LocationManagerService extends ILocationManager.Stub { statusChanged.putExtras(extras); statusChanged.putExtra(LocationManager.KEY_STATUS_CHANGED, status); try { - mPendingIntent.send(mContext, 0, statusChanged, null, null); + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + mPendingIntent.send(mContext, 0, statusChanged, this, mLocationHandler); + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } } catch (PendingIntent.CanceledException e) { return false; } @@ -272,7 +286,16 @@ public class LocationManagerService extends ILocationManager.Stub { public boolean callLocationChangedLocked(Location location) { if (mListener != null) { try { - mListener.onLocationChanged(location); + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + mListener.onLocationChanged(location); + if (mListener != mProximityListener) { + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } + } } catch (RemoteException e) { return false; } @@ -280,7 +303,53 @@ public class LocationManagerService extends ILocationManager.Stub { Intent locationChanged = new Intent(); locationChanged.putExtra(LocationManager.KEY_LOCATION_CHANGED, location); try { - mPendingIntent.send(mContext, 0, locationChanged, null, null); + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + mPendingIntent.send(mContext, 0, locationChanged, this, mLocationHandler); + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } + } catch (PendingIntent.CanceledException e) { + return false; + } + } + return true; + } + + public boolean callProviderEnabledLocked(String provider, boolean enabled) { + if (mListener != null) { + try { + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + if (enabled) { + mListener.onProviderEnabled(provider); + } else { + mListener.onProviderDisabled(provider); + } + if (mListener != mProximityListener) { + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } + } + } catch (RemoteException e) { + return false; + } + } else { + Intent providerIntent = new Intent(); + providerIntent.putExtra(LocationManager.KEY_PROVIDER_ENABLED, enabled); + try { + synchronized (this) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + mPendingIntent.send(mContext, 0, providerIntent, this, mLocationHandler); + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } } catch (PendingIntent.CanceledException e) { return false; } @@ -295,6 +364,42 @@ public class LocationManagerService extends ILocationManager.Stub { synchronized (mLock) { removeUpdatesLocked(this); } + synchronized (this) { + if (mPendingBroadcasts > 0) { + LocationManagerService.this.decrementPendingBroadcasts(); + mPendingBroadcasts = 0; + } + } + } + + public void onSendFinished(PendingIntent pendingIntent, Intent intent, + int resultCode, String resultData, Bundle resultExtras) { + decrementPendingBroadcasts(); + } + + // this must be called while synchronized by callerin a synchronized block + // containing the sending of the broadcaset + private void incrementPendingBroadcastsLocked() { + if (mPendingBroadcasts++ == 0) { + synchronized (mLock) { + LocationManagerService.this.incrementPendingBroadcastsLocked(); + } + } + } + + private void decrementPendingBroadcasts() { + synchronized (this) { + if (--mPendingBroadcasts == 0) { + LocationManagerService.this.decrementPendingBroadcasts(); + } + } + } + } + + public void locationCallbackFinished(ILocationListener listener) { + Receiver receiver = getReceiver(listener); + if (receiver != null) { + receiver.decrementPendingBroadcasts(); } } @@ -434,71 +539,6 @@ public class LocationManagerService extends ILocationManager.Stub { LocationProviderImpl.addProvider(mGpsLocationProvider); } - // Load fake providers if real providers are not available - File f = new File(LocationManager.PROVIDER_DIR); - if (f.isDirectory()) { - File[] subdirs = f.listFiles(); - for (int i = 0; i < subdirs.length; i++) { - if (!subdirs[i].isDirectory()) { - continue; - } - - String name = subdirs[i].getName(); - - if (LOCAL_LOGV) { - Log.v(TAG, "Found dir " + subdirs[i].getAbsolutePath()); - Log.v(TAG, "name = " + name); - } - - // Don't create a fake provider if a real provider exists - if (LocationProviderImpl.getProvider(name) == null) { - LocationProviderImpl provider = null; - try { - File classFile = new File(subdirs[i], "class"); - // Look for a 'class' file - provider = LocationProviderImpl.loadFromClass(classFile); - - // Look for an 'kml', 'nmea', or 'track' file - if (provider == null) { - // Load properties from 'properties' file, if present - File propertiesFile = new File(subdirs[i], "properties"); - - if (propertiesFile.exists()) { - provider = new TrackProvider(name, this); - ((TrackProvider)provider).readProperties(propertiesFile); - - File kmlFile = new File(subdirs[i], "kml"); - if (kmlFile.exists()) { - ((TrackProvider) provider).readKml(kmlFile); - } else { - File nmeaFile = new File(subdirs[i], "nmea"); - if (nmeaFile.exists()) { - ((TrackProvider) provider).readNmea(name, nmeaFile); - } else { - File trackFile = new File(subdirs[i], "track"); - if (trackFile.exists()) { - ((TrackProvider) provider).readTrack(trackFile); - } - } - } - } - } - if (provider != null) { - LocationProviderImpl.addProvider(provider); - } - // Grab the initial location of a TrackProvider and - // store it as the last known location for that provider - if (provider instanceof TrackProvider) { - TrackProvider tp = (TrackProvider) provider; - mLastKnownLocation.put(tp.getName(), tp.getInitialLocation()); - } - } catch (Exception e) { - Log.e(TAG, "Exception loading provder " + name, e); - } - } - } - } - updateProvidersLocked(); } @@ -508,14 +548,18 @@ public class LocationManagerService extends ILocationManager.Stub { public LocationManagerService(Context context) { super(); mContext = context; - mLocationHandler = new LocationWorkerHandler(); + + Thread thread = new Thread(null, this, "LocationManagerService"); + thread.start(); if (LOCAL_LOGV) { Log.v(TAG, "Constructed LocationManager Service"); } + } + private void initialize() { // Alarm manager, needs to be done before calling loadProviders() below - mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); // Create a wake lock, needs to be done before calling loadProviders() below PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); @@ -529,7 +573,7 @@ public class LocationManagerService extends ILocationManager.Stub { IntentFilter networkIntentFilter = new IntentFilter(); networkIntentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); networkIntentFilter.addAction(GpsLocationProvider.GPS_ENABLED_CHANGE_ACTION); - context.registerReceiver(networkReceiver, networkIntentFilter); + mContext.registerReceiver(networkReceiver, networkIntentFilter); // Register for power updates PowerStateBroadcastReceiver powerStateReceiver = new PowerStateBroadcastReceiver(); @@ -537,7 +581,7 @@ public class LocationManagerService extends ILocationManager.Stub { intentFilter.addAction(ALARM_INTENT); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addAction(Intent.ACTION_PACKAGE_RESTARTED); - context.registerReceiver(powerStateReceiver, intentFilter); + mContext.registerReceiver(powerStateReceiver, intentFilter); // listen for settings changes ContentResolver resolver = mContext.getContentResolver(); @@ -550,6 +594,15 @@ public class LocationManagerService extends ILocationManager.Stub { mSettings.addObserver(settingsObserver); } + public void run() + { + Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); + Looper.prepare(); + mLocationHandler = new LocationWorkerHandler(); + initialize(); + Looper.loop(); + } + public void setNetworkLocationProvider(ILocationProvider provider) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException( @@ -650,10 +703,10 @@ public class LocationManagerService extends ILocationManager.Stub { if (LOCAL_LOGV) { Log.v(TAG, "getAllProviders"); } - List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + ArrayList<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); ArrayList<String> out = new ArrayList<String>(providers.size()); - - for (LocationProviderImpl p : providers) { + for (int i = providers.size() - 1; i >= 0; i--) { + LocationProviderImpl p = providers.get(i); out.add(p.getName()); } return out; @@ -676,10 +729,10 @@ public class LocationManagerService extends ILocationManager.Stub { if (LOCAL_LOGV) { Log.v(TAG, "getProviders"); } - List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); - ArrayList<String> out = new ArrayList<String>(); - - for (LocationProviderImpl p : providers) { + ArrayList<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + ArrayList<String> out = new ArrayList<String>(providers.size()); + for (int i = providers.size() - 1; i >= 0; i--) { + LocationProviderImpl p = providers.get(i); String name = p.getName(); if (isAllowedProviderSafe(name)) { if (enabledOnly && !isAllowedBySettingsLocked(name)) { @@ -692,7 +745,9 @@ public class LocationManagerService extends ILocationManager.Stub { } private void updateProvidersLocked() { - for (LocationProviderImpl p : LocationProviderImpl.getProviders()) { + ArrayList<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + for (int i = providers.size() - 1; i >= 0; i--) { + LocationProviderImpl p = providers.get(i); boolean isEnabled = p.isEnabled(); String name = p.getName(); boolean shouldBeEnabled = isAllowedBySettingsLocked(name); @@ -722,29 +777,11 @@ public class LocationManagerService extends ILocationManager.Stub { for (int i=0; i<N; i++) { UpdateRecord record = records.get(i); // Sends a notification message to the receiver - try { - Receiver receiver = record.mReceiver; - if (receiver.isListener()) { - if (enabled) { - receiver.getListener().onProviderEnabled(provider); - } else { - receiver.getListener().onProviderDisabled(provider); - } - } else { - Intent providerIntent = new Intent(); - providerIntent.putExtra(LocationManager.KEY_PROVIDER_ENABLED, enabled); - try { - receiver.getPendingIntent().send(mContext, 0, - providerIntent, null, null); - } catch (PendingIntent.CanceledException e) { - if (deadReceivers == null) { - deadReceivers = new ArrayList<Receiver>(); - deadReceivers.add(receiver); - } - } + if (!record.mReceiver.callProviderEnabledLocked(provider, enabled)) { + if (deadReceivers == null) { + deadReceivers = new ArrayList<Receiver>(); + deadReceivers.add(record.mReceiver); } - } catch (RemoteException e) { - // The death link will clean this up. } listeners++; } @@ -958,15 +995,8 @@ public class LocationManagerService extends ILocationManager.Stub { impl.enableLocationTracking(true); updateWakelockStatusLocked(); } else { - try { - // Notify the listener that updates are currently disabled - if (receiver.isListener()) { - receiver.getListener().onProviderDisabled(provider); - } - } catch(RemoteException e) { - Log.w(TAG, "RemoteException calling onProviderDisabled on " + - receiver.getListener()); - } + // Notify the listener that updates are currently disabled + receiver.callProviderEnabledLocked(provider, false); } } finally { Binder.restoreCallingIdentity(identity); @@ -1161,7 +1191,7 @@ public class LocationManagerService extends ILocationManager.Stub { } // Listener for receiving locations to trigger proximity alerts - class ProximityListener extends ILocationListener.Stub { + class ProximityListener extends ILocationListener.Stub implements PendingIntent.OnFinished { boolean isGpsAvailable = false; @@ -1198,7 +1228,14 @@ public class LocationManagerService extends ILocationManager.Stub { Intent enteredIntent = new Intent(); enteredIntent.putExtra(LocationManager.KEY_PROXIMITY_ENTERING, true); try { - intent.send(mContext, 0, enteredIntent, null, null); + synchronized (mLock) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + intent.send(mContext, 0, enteredIntent, this, mLocationHandler); + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } } catch (PendingIntent.CanceledException e) { if (LOCAL_LOGV) { Log.v(TAG, "Canceled proximity alert: " + alert, e); @@ -1216,7 +1253,14 @@ public class LocationManagerService extends ILocationManager.Stub { Intent exitedIntent = new Intent(); exitedIntent.putExtra(LocationManager.KEY_PROXIMITY_ENTERING, false); try { - intent.send(mContext, 0, exitedIntent, null, null); + synchronized (mLock) { + // synchronize to ensure incrementPendingBroadcastsLocked() + // is called before decrementPendingBroadcasts() + intent.send(mContext, 0, exitedIntent, this, mLocationHandler); + // call this after broadcasting so we do not increment + // if we throw an exeption. + incrementPendingBroadcastsLocked(); + } } catch (PendingIntent.CanceledException e) { if (LOCAL_LOGV) { Log.v(TAG, "Canceled proximity alert: " + alert, e); @@ -1269,6 +1313,11 @@ public class LocationManagerService extends ILocationManager.Stub { isGpsAvailable = false; } } + + public void onSendFinished(PendingIntent pendingIntent, Intent intent, + int resultCode, String resultData, Bundle resultExtras) { + decrementPendingBroadcasts(); + } } public void addProximityAlert(double latitude, double longitude, @@ -1306,19 +1355,20 @@ public class LocationManagerService extends ILocationManager.Stub { latitude, longitude, radius, expiration, intent); mProximityAlerts.put(intent, alert); - if (mProximityListener == null) { - mProximityListener = new Receiver(new ProximityListener()); + if (mProximityReceiver == null) { + mProximityListener = new ProximityListener(); + mProximityReceiver = new Receiver(mProximityListener); LocationProvider provider = LocationProviderImpl.getProvider( LocationManager.GPS_PROVIDER); if (provider != null) { - requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityListener); + requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityReceiver); } provider = LocationProviderImpl.getProvider(LocationManager.NETWORK_PROVIDER); if (provider != null) { - requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityListener); + requestLocationUpdatesLocked(provider.getName(), 1000L, 1.0f, mProximityReceiver); } } } @@ -1342,7 +1392,8 @@ public class LocationManagerService extends ILocationManager.Stub { mProximityAlerts.remove(intent); if (mProximityAlerts.size() == 0) { - removeUpdatesLocked(mProximityListener); + removeUpdatesLocked(mProximityReceiver); + mProximityReceiver = null; mProximityListener = null; } } @@ -1585,35 +1636,7 @@ public class LocationManagerService extends ILocationManager.Stub { } handleLocationChangedLocked(location); - - if ((mWakeLockAcquireTime != 0) && - (SystemClock.elapsedRealtime() - mWakeLockAcquireTime - > MAX_TIME_FOR_WAKE_LOCK)) { - - removeMessages(MESSAGE_RELEASE_WAKE_LOCK); - - log("LocationWorkerHandler: Exceeded max time for wake lock"); - Message m = Message.obtain(this, MESSAGE_RELEASE_WAKE_LOCK); - sendMessageAtFrontOfQueue(m); - - } else if (mWakeLockAcquireTime != 0 && - mWakeLockGpsReceived && mWakeLockNetworkReceived) { - - removeMessages(MESSAGE_RELEASE_WAKE_LOCK); - - log("LocationWorkerHandler: Locations received."); - mWakeLockAcquireTime = 0; - Message m = Message.obtain(this, MESSAGE_RELEASE_WAKE_LOCK); - sendMessageDelayed(m, TIME_AFTER_WAKE_LOCK); - } - } - } else if (msg.what == MESSAGE_RELEASE_WAKE_LOCK) { - log("LocationWorkerHandler: Release"); - - // Update wakelock status so the next alarm is set before releasing wakelock - synchronized (mLock) { updateWakelockStatusLocked(); - releaseWakeLockLocked(); } } } catch (Exception e) { @@ -1697,8 +1720,9 @@ public class LocationManagerService extends ILocationManager.Stub { // Notify location providers of current network state synchronized (mLock) { - List<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); - for (LocationProviderImpl provider : providers) { + ArrayList<LocationProviderImpl> providers = LocationProviderImpl.getProviders(); + for (int i = providers.size() - 1; i >= 0; i--) { + LocationProviderImpl provider = providers.get(i); if (provider.requiresNetwork()) { provider.updateNetworkState(mNetworkState); } @@ -1727,7 +1751,7 @@ public class LocationManagerService extends ILocationManager.Stub { long callerId = Binder.clearCallingIdentity(); - boolean needsLock = false; + boolean needsLock = (mPendingBroadcasts > 0); long minTime = Integer.MAX_VALUE; if (mNetworkLocationProvider != null && mNetworkLocationProvider.isLocationTracking()) { @@ -1757,8 +1781,6 @@ public class LocationManagerService extends ILocationManager.Stub { log("No need for alarm"); mAlarmInterval = -1; - // Clear out existing wakelocks - mLocationHandler.removeMessages(MESSAGE_RELEASE_WAKE_LOCK); releaseWakeLockLocked(); } Binder.restoreCallingIdentity(callerId); @@ -1836,6 +1858,20 @@ public class LocationManagerService extends ILocationManager.Stub { } } + private void incrementPendingBroadcastsLocked() { + if (mPendingBroadcasts++ == 0) { + updateWakelockStatusLocked(); + } + } + + private void decrementPendingBroadcasts() { + synchronized (mLock) { + if (--mPendingBroadcasts == 0) { + updateWakelockStatusLocked(); + } + } + } + // Geocoder public String getFromLocation(double latitude, double longitude, int maxResults, @@ -2061,6 +2097,7 @@ public class LocationManagerService extends ILocationManager.Stub { i.dump(pw, " "); } } + pw.println(" mProximityReceiver=" + mProximityReceiver); pw.println(" mProximityListener=" + mProximityListener); if (mEnabledProviders.size() > 0) { pw.println(" Enabled Providers:"); diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index 9e062f4..159bc76 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -2932,11 +2932,12 @@ class PackageManagerService extends IPackageManager.Stub { } @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ActivityIntentInfo filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter.activity)) - + " " + filter.activity.component.flattenToShortString()); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter.activity))); + out.print(' '); + out.println(filter.activity.componentShortName); } // List<ResolveInfo> filterEnabled(List<ResolveInfo> resolveInfoList) { @@ -3064,11 +3065,12 @@ class PackageManagerService extends IPackageManager.Stub { } @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PackageParser.ServiceIntentInfo filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter.service)) - + " " + filter.service.component.flattenToShortString()); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter.service))); + out.print(' '); + out.println(filter.service.componentShortName); } // List<ResolveInfo> filterEnabled(List<ResolveInfo> resolveInfoList) { @@ -4578,80 +4580,83 @@ class PackageManagerService extends IPackageManager.Stub { return; } - Printer printer = new PrintWriterPrinter(pw); synchronized (mPackages) { pw.println("Activity Resolver Table:"); - mActivities.dump(printer, " "); + mActivities.dump(pw, " "); pw.println(" "); pw.println("Receiver Resolver Table:"); - mReceivers.dump(printer, " "); + mReceivers.dump(pw, " "); pw.println(" "); pw.println("Service Resolver Table:"); - mServices.dump(printer, " "); + mServices.dump(pw, " "); pw.println(" "); pw.println("Preferred Activities:"); - mSettings.mPreferredActivities.dump(printer, " "); + mSettings.mPreferredActivities.dump(pw, " "); pw.println(" "); pw.println("Preferred Packages:"); { for (PackageSetting ps : mSettings.mPreferredPackages) { - pw.println(" " + ps.name); + pw.print(" "); pw.println(ps.name); } } pw.println(" "); pw.println("Permissions:"); { for (BasePermission p : mSettings.mPermissions.values()) { - pw.println(" Permission [" + p.name + "] (" - + Integer.toHexString(System.identityHashCode(p)) - + "):"); - pw.println(" sourcePackage=" + p.sourcePackage); - pw.println(" uid=" + p.uid - + " gids=" + arrayToString(p.gids) - + " type=" + p.type); + pw.print(" Permission ["); pw.print(p.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(p))); + pw.println("):"); + pw.print(" sourcePackage="); pw.println(p.sourcePackage); + pw.print(" uid="); pw.print(p.uid); + pw.print(" gids="); pw.print(arrayToString(p.gids)); + pw.print(" type="); pw.println(p.type); } } pw.println(" "); pw.println("Packages:"); { for (PackageSetting ps : mSettings.mPackages.values()) { - pw.println(" Package [" + ps.name + "] (" - + Integer.toHexString(System.identityHashCode(ps)) - + "):"); - pw.println(" userId=" + ps.userId - + " gids=" + arrayToString(ps.gids)); - pw.println(" sharedUser=" + ps.sharedUser); - pw.println(" pkg=" + ps.pkg); - pw.println(" codePath=" + ps.codePathString); - pw.println(" resourcePath=" + ps.resourcePathString); + pw.print(" Package ["); pw.print(ps.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(ps))); + pw.println("):"); + pw.print(" userId="); pw.print(ps.userId); + pw.print(" gids="); pw.println(arrayToString(ps.gids)); + pw.print(" sharedUser="); pw.println(ps.sharedUser); + pw.print(" pkg="); pw.println(ps.pkg); + pw.print(" codePath="); pw.println(ps.codePathString); + pw.print(" resourcePath="); pw.println(ps.resourcePathString); if (ps.pkg != null) { - pw.println(" dataDir=" + ps.pkg.applicationInfo.dataDir); + pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir); } - pw.println(" timeStamp=" + ps.getTimeStampStr()); - pw.println(" signatures=" + ps.signatures); - pw.println(" permissionsFixed=" + ps.permissionsFixed - + " pkgFlags=0x" + Integer.toHexString(ps.pkgFlags) - + " installStatus=" + ps.installStatus - + " enabled=" + ps.enabled); + pw.print(" timeStamp="); pw.println(ps.getTimeStampStr()); + pw.print(" signatures="); pw.println(ps.signatures); + pw.print(" permissionsFixed="); pw.print(ps.permissionsFixed); + pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags)); + pw.print(" installStatus="); pw.print(ps.installStatus); + pw.print(" enabled="); pw.println(ps.enabled); if (ps.disabledComponents.size() > 0) { pw.println(" disabledComponents:"); for (String s : ps.disabledComponents) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } if (ps.enabledComponents.size() > 0) { pw.println(" enabledComponents:"); for (String s : ps.enabledComponents) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } - pw.println(" grantedPermissions:"); - for (String s : ps.grantedPermissions) { - pw.println(" " + s); + if (ps.grantedPermissions.size() > 0) { + pw.println(" grantedPermissions:"); + for (String s : ps.grantedPermissions) { + pw.print(" "); pw.println(s); + } } - pw.println(" loadedPermissions:"); - for (String s : ps.loadedPermissions) { - pw.println(" " + s); + if (ps.loadedPermissions.size() > 0) { + pw.println(" loadedPermissions:"); + for (String s : ps.loadedPermissions) { + pw.print(" "); pw.println(s); + } } } } @@ -4659,18 +4664,18 @@ class PackageManagerService extends IPackageManager.Stub { pw.println("Shared Users:"); { for (SharedUserSetting su : mSettings.mSharedUsers.values()) { - pw.println(" SharedUser [" + su.name + "] (" - + Integer.toHexString(System.identityHashCode(su)) - + "):"); - pw.println(" userId=" + su.userId - + " gids=" + arrayToString(su.gids)); + pw.print(" SharedUser ["); pw.print(su.name); pw.print("] ("); + pw.print(Integer.toHexString(System.identityHashCode(su))); + pw.println("):"); + pw.print(" userId="); pw.print(su.userId); + pw.print(" gids="); pw.println(arrayToString(su.gids)); pw.println(" grantedPermissions:"); for (String s : su.grantedPermissions) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } pw.println(" loadedPermissions:"); for (String s : su.loadedPermissions) { - pw.println(" " + s); + pw.print(" "); pw.println(s); } } } @@ -5302,16 +5307,19 @@ class PackageManagerService extends IPackageManager.Stub { private final IntentResolver<PreferredActivity, PreferredActivity> mPreferredActivities = new IntentResolver<PreferredActivity, PreferredActivity>() { @Override - protected void dumpFilter(Printer out, String prefix, + protected void dumpFilter(PrintWriter out, String prefix, PreferredActivity filter) { - out.println(prefix - + Integer.toHexString(System.identityHashCode(filter)) - + " " + filter.mActivity.flattenToShortString() - + " match=0x" + Integer.toHexString(filter.mMatch)); + out.print(prefix); out.print( + Integer.toHexString(System.identityHashCode(filter))); + out.print(' '); + out.print(filter.mActivity.flattenToShortString()); + out.print(" match=0x"); + out.println( Integer.toHexString(filter.mMatch)); if (filter.mSetComponents != null) { - out.println(prefix + " Selected from:"); + out.print(prefix); out.println(" Selected from:"); for (int i=0; i<filter.mSetComponents.length; i++) { - out.println(prefix + " " + filter.mSetComponents[i]); + out.print(prefix); out.print(" "); + out.println(filter.mSetComponents[i]); } } } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index efca2cb..b19e2ee 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -310,6 +310,13 @@ class ServerThread extends Thread { } try { + Log.i(TAG, "Starting Backup Service"); + ServiceManager.addService(Context.BACKUP_SERVICE, new BackupManagerService(context)); + } catch (Throwable e) { + Log.e(TAG, "Failure starting Backup Service", e); + } + + try { Log.i(TAG, "Starting AppWidget Service"); appWidget = new AppWidgetService(context); ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget); diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index b0fcb1c..321b17e 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -5175,6 +5175,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo final IInputContext mInputContext; final int mUid; final int mPid; + final String mStringName; SurfaceSession mSurfaceSession; int mNumWindow = 0; boolean mClientDead = false; @@ -5198,6 +5199,14 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo mInputContext = inputContext; mUid = Binder.getCallingUid(); mPid = Binder.getCallingPid(); + StringBuilder sb = new StringBuilder(); + sb.append("Session{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" uid "); + sb.append(mUid); + sb.append("}"); + mStringName = sb.toString(); + synchronized (mWindowMap) { if (mInputMethodManager == null && mHaveInputMethods) { IBinder b = ServiceManager.getService( @@ -5377,20 +5386,24 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "mNumWindow=" + mNumWindow - + " mClientDead=" + mClientDead - + " mSurfaceSession=" + mSurfaceSession); - pw.println(prefix + "mPendingPointerWindow=" + mPendingPointerWindow - + " mPendingPointerMove=" + mPendingPointerMove); - pw.println(prefix + "mPendingTrackballWindow=" + mPendingTrackballWindow - + " mPendingTrackballMove=" + mPendingTrackballMove); + pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); + pw.print(" mClientDead="); pw.print(mClientDead); + pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); + if (mPendingPointerWindow != null || mPendingPointerMove != null) { + pw.print(prefix); + pw.print("mPendingPointerWindow="); pw.print(mPendingPointerWindow); + pw.print(" mPendingPointerMove="); pw.println(mPendingPointerMove); + } + if (mPendingTrackballWindow != null || mPendingTrackballMove != null) { + pw.print(prefix); + pw.print("mPendingTrackballWindow="); pw.print(mPendingTrackballWindow); + pw.print(" mPendingTrackballMove="); pw.println(mPendingTrackballMove); + } } @Override public String toString() { - return "Session{" - + Integer.toHexString(System.identityHashCode(this)) + "}"; + return mStringName; } } @@ -6458,67 +6471,114 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "mSession=" + mSession - + " mClient=" + mClient.asBinder()); - pw.println(prefix + "mAttrs=" + mAttrs); - pw.println(prefix + "mAttachedWindow=" + mAttachedWindow - + " mLayoutAttached=" + mLayoutAttached - + " mIsImWindow=" + mIsImWindow); - pw.println(prefix + "mBaseLayer=" + mBaseLayer - + " mSubLayer=" + mSubLayer - + " mAnimLayer=" + mLayer + "+" - + (mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment - : (mAppToken != null ? mAppToken.animLayerAdjustment : 0)) - + "=" + mAnimLayer - + " mLastLayer=" + mLastLayer); - pw.println(prefix + "mSurface=" + mSurface); - pw.println(prefix + "mToken=" + mToken); - pw.println(prefix + "mRootToken=" + mRootToken); - pw.println(prefix + "mAppToken=" + mAppToken); - pw.println(prefix + "mTargetAppToken=" + mTargetAppToken); - pw.println(prefix + "mViewVisibility=0x" + Integer.toHexString(mViewVisibility) - + " mPolicyVisibility=" + mPolicyVisibility - + " (after=" + mPolicyVisibilityAfterAnim - + ") mAttachedHidden=" + mAttachedHidden - + " mLastHidden=" + mLastHidden - + " mHaveFrame=" + mHaveFrame); - pw.println(prefix + "Requested w=" + mRequestedWidth + " h=" + mRequestedHeight - + " x=" + mReqXPos + " y=" + mReqYPos); - pw.println(prefix + "mGivenContentInsets=" + mGivenContentInsets.toShortString() - + " mGivenVisibleInsets=" + mGivenVisibleInsets.toShortString() - + " mTouchableInsets=" + mTouchableInsets - + " pending=" + mGivenInsetsPending); - pw.println(prefix + "mShownFrame=" + mShownFrame.toShortString() - + " last=" + mLastShownFrame.toShortString()); - pw.println(prefix + "mFrame=" + mFrame.toShortString() - + " last=" + mLastFrame.toShortString()); - pw.println(prefix + "mContainingFrame=" + mContainingFrame.toShortString() - + " mDisplayFrame=" + mDisplayFrame.toShortString()); - pw.println(prefix + "mContentFrame=" + mContentFrame.toShortString() - + " mVisibleFrame=" + mVisibleFrame.toShortString()); - pw.println(prefix + "mContentInsets=" + mContentInsets.toShortString() - + " last=" + mLastContentInsets.toShortString() - + " mVisibleInsets=" + mVisibleInsets.toShortString() - + " last=" + mLastVisibleInsets.toShortString()); - pw.println(prefix + "mShownAlpha=" + mShownAlpha - + " mAlpha=" + mAlpha + " mLastAlpha=" + mLastAlpha); - pw.println(prefix + "mAnimating=" + mAnimating - + " mLocalAnimating=" + mLocalAnimating - + " mAnimationIsEntrance=" + mAnimationIsEntrance - + " mAnimation=" + mAnimation); - pw.println(prefix + "XForm: has=" + mHasTransformation - + " " + mTransformation.toShortString()); - pw.println(prefix + "mDrawPending=" + mDrawPending - + " mCommitDrawPending=" + mCommitDrawPending - + " mReadyToShow=" + mReadyToShow - + " mHasDrawn=" + mHasDrawn); - pw.println(prefix + "mExiting=" + mExiting - + " mRemoveOnExit=" + mRemoveOnExit - + " mDestroying=" + mDestroying - + " mRemoved=" + mRemoved); - pw.println(prefix + "mOrientationChanging=" + mOrientationChanging - + " mAppFreezing=" + mAppFreezing); + StringBuilder sb = new StringBuilder(64); + + pw.print(prefix); pw.print("mSession="); pw.print(mSession); + pw.print(" mClient="); pw.println(mClient.asBinder()); + pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs); + if (mAttachedWindow != null || mLayoutAttached) { + pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow); + pw.print(" mLayoutAttached="); pw.println(mLayoutAttached); + } + if (mIsImWindow) { + pw.print(prefix); pw.print("mIsImWindow="); pw.println(mIsImWindow); + } + pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer); + pw.print(" mSubLayer="); pw.print(mSubLayer); + pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+"); + pw.print((mTargetAppToken != null ? mTargetAppToken.animLayerAdjustment + : (mAppToken != null ? mAppToken.animLayerAdjustment : 0))); + pw.print("="); pw.print(mAnimLayer); + pw.print(" mLastLayer="); pw.println(mLastLayer); + if (mSurface != null) { + pw.print(prefix); pw.print("mSurface="); pw.println(mSurface); + } + pw.print(prefix); pw.print("mToken="); pw.println(mToken); + pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken); + if (mAppToken != null) { + pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken); + } + if (mTargetAppToken != null) { + pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken); + } + pw.print(prefix); pw.print("mViewVisibility=0x"); + pw.print(Integer.toHexString(mViewVisibility)); + pw.print(" mLastHidden="); pw.print(mLastHidden); + pw.print(" mHaveFrame="); pw.println(mHaveFrame); + if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) { + pw.print(prefix); pw.print("mPolicyVisibility="); + pw.print(mPolicyVisibility); + pw.print(" mPolicyVisibilityAfterAnim="); + pw.print(mPolicyVisibilityAfterAnim); + pw.print(" mAttachedHidden="); pw.println(mAttachedHidden); + } + pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth); + pw.print(" h="); pw.print(mRequestedHeight); + pw.print(" x="); pw.print(mReqXPos); + pw.print(" y="); pw.println(mReqYPos); + pw.print(prefix); pw.print("mGivenContentInsets="); + mGivenContentInsets.printShortString(pw); + pw.print(" mGivenVisibleInsets="); + mGivenVisibleInsets.printShortString(pw); + pw.println(); + if (mTouchableInsets != 0 || mGivenInsetsPending) { + pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets); + pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending); + } + pw.print(prefix); pw.print("mShownFrame="); + mShownFrame.printShortString(pw); + pw.print(" last="); mLastShownFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw); + pw.print(" last="); mLastFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContainingFrame="); + mContainingFrame.printShortString(pw); + pw.print(" mDisplayFrame="); + mDisplayFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContentFrame="); mContentFrame.printShortString(pw); + pw.print(" mVisibleFrame="); mVisibleFrame.printShortString(pw); + pw.println(); + pw.print(prefix); pw.print("mContentInsets="); mContentInsets.printShortString(pw); + pw.print(" last="); mLastContentInsets.printShortString(pw); + pw.print(" mVisibleInsets="); mVisibleInsets.printShortString(pw); + pw.print(" last="); mLastVisibleInsets.printShortString(pw); + pw.println(); + if (mShownAlpha != 1 || mAlpha != 1 || mLastAlpha != 1) { + pw.print(prefix); pw.print("mShownAlpha="); pw.print(mShownAlpha); + pw.print(" mAlpha="); pw.print(mAlpha); + pw.print(" mLastAlpha="); pw.println(mLastAlpha); + } + if (mAnimating || mLocalAnimating || mAnimationIsEntrance + || mAnimation != null) { + pw.print(prefix); pw.print("mAnimating="); pw.print(mAnimating); + pw.print(" mLocalAnimating="); pw.print(mLocalAnimating); + pw.print(" mAnimationIsEntrance="); pw.print(mAnimationIsEntrance); + pw.print(" mAnimation="); pw.println(mAnimation); + } + if (mHasTransformation || mHasLocalTransformation) { + pw.print(prefix); pw.print("XForm: has="); + pw.print(mHasTransformation); + pw.print(" hasLocal="); pw.print(mHasLocalTransformation); + pw.print(" "); mTransformation.printShortString(pw); + pw.println(); + } + pw.print(prefix); pw.print("mDrawPending="); pw.print(mDrawPending); + pw.print(" mCommitDrawPending="); pw.print(mCommitDrawPending); + pw.print(" mReadyToShow="); pw.print(mReadyToShow); + pw.print(" mHasDrawn="); pw.println(mHasDrawn); + if (mExiting || mRemoveOnExit || mDestroying || mRemoved) { + pw.print(prefix); pw.print("mExiting="); pw.print(mExiting); + pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit); + pw.print(" mDestroying="); pw.print(mDestroying); + pw.print(" mRemoved="); pw.println(mRemoved); + } + if (mOrientationChanging || mAppFreezing) { + pw.print(prefix); pw.print("mOrientationChanging="); + pw.print(mOrientationChanging); + pw.print(" mAppFreezing="); pw.println(mAppFreezing); + } } @Override @@ -6544,6 +6604,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo // not be removed when all windows are removed. final boolean explicit; + // For printing. + String stringName; + // If this is an AppWindowToken, this is non-null. AppWindowToken appWindowToken; @@ -6566,18 +6629,23 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "token=" + token); - pw.println(prefix + "windows=" + windows); - pw.println(prefix + "windowType=" + windowType + " hidden=" + hidden - + " hasVisible=" + hasVisible); + pw.print(prefix); pw.print("token="); pw.println(token); + pw.print(prefix); pw.print("windows="); pw.println(windows); + pw.print(prefix); pw.print("windowType="); pw.print(windowType); + pw.print(" hidden="); pw.print(hidden); + pw.print(" hasVisible="); pw.println(hasVisible); } @Override public String toString() { - return "WindowToken{" - + Integer.toHexString(System.identityHashCode(this)) - + " token=" + token + "}"; + if (stringName == null) { + StringBuilder sb = new StringBuilder(); + sb.append("WindowToken{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" token="); sb.append(token); sb.append('}'); + stringName = sb.toString(); + } + return stringName; } }; @@ -6865,38 +6933,66 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo void dump(PrintWriter pw, String prefix) { super.dump(pw, prefix); - pw.println(prefix + "app=" + (appToken != null)); - pw.println(prefix + "allAppWindows=" + allAppWindows); - pw.println(prefix + "groupId=" + groupId - + " requestedOrientation=" + requestedOrientation); - pw.println(prefix + "hiddenRequested=" + hiddenRequested - + " clientHidden=" + clientHidden - + " willBeHidden=" + willBeHidden - + " reportedVisible=" + reportedVisible); - pw.println(prefix + "paused=" + paused - + " freezingScreen=" + freezingScreen); - pw.println(prefix + "numInterestingWindows=" + numInterestingWindows - + " numDrawnWindows=" + numDrawnWindows - + " inPendingTransaction=" + inPendingTransaction - + " allDrawn=" + allDrawn); - pw.println(prefix + "animating=" + animating - + " animation=" + animation); - pw.println(prefix + "animLayerAdjustment=" + animLayerAdjustment - + " transformation=" + transformation.toShortString()); - pw.println(prefix + "startingData=" + startingData - + " removed=" + removed - + " firstWindowDrawn=" + firstWindowDrawn); - pw.println(prefix + "startingWindow=" + startingWindow - + " startingView=" + startingView - + " startingDisplayed=" + startingDisplayed - + " startingMoved" + startingMoved); + if (appToken != null) { + pw.print(prefix); pw.println("app=true"); + } + if (allAppWindows.size() > 0) { + pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows); + } + pw.print(prefix); pw.print("groupId="); pw.print(groupId); + pw.print(" requestedOrientation="); pw.println(requestedOrientation); + pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested); + pw.print(" clientHidden="); pw.print(clientHidden); + pw.print(" willBeHidden="); pw.print(willBeHidden); + pw.print(" reportedVisible="); pw.println(reportedVisible); + if (paused || freezingScreen) { + pw.print(prefix); pw.print("paused="); pw.print(paused); + pw.print(" freezingScreen="); pw.println(freezingScreen); + } + if (numInterestingWindows != 0 || numDrawnWindows != 0 + || inPendingTransaction || allDrawn) { + pw.print(prefix); pw.print("numInterestingWindows="); + pw.print(numInterestingWindows); + pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); + pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); + pw.print(" allDrawn="); pw.println(allDrawn); + } + if (animating || animation != null) { + pw.print(prefix); pw.print("animating="); pw.print(animating); + pw.print(" animation="); pw.println(animation); + } + if (animLayerAdjustment != 0) { + pw.print(prefix); pw.print("animLayerAdjustment="); pw.println(animLayerAdjustment); + } + if (hasTransformation) { + pw.print(prefix); pw.print("hasTransformation="); pw.print(hasTransformation); + pw.print(" transformation="); transformation.printShortString(pw); + pw.println(); + } + if (startingData != null || removed || firstWindowDrawn) { + pw.print(prefix); pw.print("startingData="); pw.print(startingData); + pw.print(" removed="); pw.print(removed); + pw.print(" firstWindowDrawn="); pw.println(firstWindowDrawn); + } + if (startingWindow != null || startingView != null + || startingDisplayed || startingMoved) { + pw.print(prefix); pw.print("startingWindow="); pw.print(startingWindow); + pw.print(" startingView="); pw.print(startingView); + pw.print(" startingDisplayed="); pw.print(startingDisplayed); + pw.print(" startingMoved"); pw.println(startingMoved); + } } @Override public String toString() { - return "AppWindowToken{" - + Integer.toHexString(System.identityHashCode(this)) - + " token=" + token + "}"; + if (stringName == null) { + StringBuilder sb = new StringBuilder(); + sb.append("AppWindowToken{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" token="); sb.append(token); sb.append('}'); + stringName = sb.toString(); + } + return stringName; } } @@ -8652,7 +8748,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println("Current Window Manager state:"); for (int i=mWindows.size()-1; i>=0; i--) { WindowState w = (WindowState)mWindows.get(i); - pw.println(" Window #" + i + ":"); + pw.print(" Window #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } if (mInputMethodDialogs.size() > 0) { @@ -8660,7 +8757,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Input method dialogs:"); for (int i=mInputMethodDialogs.size()-1; i>=0; i--) { WindowState w = mInputMethodDialogs.get(i); - pw.println(" IM Dialog #" + i + ": " + w); + pw.print(" IM Dialog #"); pw.print(i); pw.print(": "); pw.println(w); } } if (mPendingRemove.size() > 0) { @@ -8668,7 +8765,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Remove pending for:"); for (int i=mPendingRemove.size()-1; i>=0; i--) { WindowState w = mPendingRemove.get(i); - pw.println(" Remove #" + i + ":"); + pw.print(" Remove #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8677,7 +8775,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows force removing:"); for (int i=mForceRemoves.size()-1; i>=0; i--) { WindowState w = mForceRemoves.get(i); - pw.println(" Removing #" + i + ":"); + pw.print(" Removing #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8686,7 +8785,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows waiting to destroy their surface:"); for (int i=mDestroySurface.size()-1; i>=0; i--) { WindowState w = mDestroySurface.get(i); - pw.println(" Destroy #" + i + ":"); + pw.print(" Destroy #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8695,7 +8795,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Windows losing focus:"); for (int i=mLosingFocus.size()-1; i>=0; i--) { WindowState w = mLosingFocus.get(i); - pw.println(" Losing #" + i + ":"); + pw.print(" Losing #"); pw.print(i); pw.print(' '); + pw.print(w); pw.println(":"); w.dump(pw, " "); } } @@ -8705,7 +8806,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Iterator<Session> it = mSessions.iterator(); while (it.hasNext()) { Session s = it.next(); - pw.println(" Session " + s); + pw.print(" Session "); pw.print(s); pw.println(':'); s.dump(pw, " "); } } @@ -8715,7 +8816,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo Iterator<WindowToken> it = mTokenMap.values().iterator(); while (it.hasNext()) { WindowToken token = it.next(); - pw.println(" Token " + token.token); + pw.print(" Token "); pw.print(token.token); pw.println(':'); token.dump(pw, " "); } } @@ -8723,14 +8824,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" "); pw.println(" Window token list:"); for (int i=0; i<mTokenList.size(); i++) { - pw.println(" WindowToken #" + i + ": " + mTokenList.get(i)); + pw.print(" #"); pw.print(i); pw.print(": "); + pw.println(mTokenList.get(i)); } } if (mAppTokens.size() > 0) { pw.println(" "); pw.println(" Application tokens in Z order:"); for (int i=mAppTokens.size()-1; i>=0; i--) { - pw.println(" AppWindowToken #" + i + ": " + mAppTokens.get(i)); + pw.print(" App #"); pw.print(i); pw.print(": "); + pw.println(mAppTokens.get(i)); } } if (mFinishedStarting.size() > 0) { @@ -8738,7 +8841,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Finishing start of application tokens:"); for (int i=mFinishedStarting.size()-1; i>=0; i--) { WindowToken token = mFinishedStarting.get(i); - pw.println(" Finish Starting App Token #" + i + ":"); + pw.print(" Finished Starting #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } @@ -8747,7 +8851,8 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Exiting tokens:"); for (int i=mExitingTokens.size()-1; i>=0; i--) { WindowToken token = mExitingTokens.get(i); - pw.println(" Exiting Token #" + i + ":"); + pw.print(" Exiting #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } @@ -8756,54 +8861,59 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo pw.println(" Exiting application tokens:"); for (int i=mExitingAppTokens.size()-1; i>=0; i--) { WindowToken token = mExitingAppTokens.get(i); - pw.println(" Exiting App Token #" + i + ":"); + pw.print(" Exiting App #"); pw.print(i); + pw.print(' '); pw.print(token); pw.println(':'); token.dump(pw, " "); } } pw.println(" "); - pw.println(" mCurrentFocus=" + mCurrentFocus); - pw.println(" mLastFocus=" + mLastFocus); - pw.println(" mFocusedApp=" + mFocusedApp); - pw.println(" mInputMethodTarget=" + mInputMethodTarget); - pw.println(" mInputMethodWindow=" + mInputMethodWindow); - pw.println(" mInTouchMode=" + mInTouchMode); - pw.println(" mSystemBooted=" + mSystemBooted - + " mDisplayEnabled=" + mDisplayEnabled); - pw.println(" mLayoutNeeded=" + mLayoutNeeded - + " mBlurShown=" + mBlurShown); - pw.println(" mDimShown=" + mDimShown - + " current=" + mDimCurrentAlpha - + " target=" + mDimTargetAlpha - + " delta=" + mDimDeltaPerMs - + " lastAnimTime=" + mLastDimAnimTime); - pw.println(" mInputMethodAnimLayerAdjustment=" - + mInputMethodAnimLayerAdjustment); - pw.println(" mDisplayFrozen=" + mDisplayFrozen - + " mWindowsFreezingScreen=" + mWindowsFreezingScreen - + " mAppsFreezingScreen=" + mAppsFreezingScreen); - pw.println(" mRotation=" + mRotation - + ", mForcedAppOrientation=" + mForcedAppOrientation - + ", mRequestedRotation=" + mRequestedRotation); - pw.println(" mAnimationPending=" + mAnimationPending - + " mWindowAnimationScale=" + mWindowAnimationScale - + " mTransitionWindowAnimationScale=" + mTransitionAnimationScale); - pw.println(" mNextAppTransition=0x" - + Integer.toHexString(mNextAppTransition) - + ", mAppTransitionReady=" + mAppTransitionReady - + ", mAppTransitionTimeout=" + mAppTransitionTimeout); - pw.println(" mStartingIconInTransition=" + mStartingIconInTransition - + ", mSkipAppTransitionAnimation=" + mSkipAppTransitionAnimation); - pw.println(" mOpeningApps=" + mOpeningApps); - pw.println(" mClosingApps=" + mClosingApps); - pw.println(" DisplayWidth=" + mDisplay.getWidth() - + " DisplayHeight=" + mDisplay.getHeight()); + pw.print(" mCurrentFocus="); pw.println(mCurrentFocus); + pw.print(" mLastFocus="); pw.println(mLastFocus); + pw.print(" mFocusedApp="); pw.println(mFocusedApp); + pw.print(" mInputMethodTarget="); pw.println(mInputMethodTarget); + pw.print(" mInputMethodWindow="); pw.println(mInputMethodWindow); + pw.print(" mInTouchMode="); pw.println(mInTouchMode); + pw.print(" mSystemBooted="); pw.print(mSystemBooted); + pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled); + pw.print(" mLayoutNeeded="); pw.print(mLayoutNeeded); + pw.print(" mBlurShown="); pw.println(mBlurShown); + pw.print(" mDimShown="); pw.print(mDimShown); + pw.print(" current="); pw.print(mDimCurrentAlpha); + pw.print(" target="); pw.print(mDimTargetAlpha); + pw.print(" delta="); pw.print(mDimDeltaPerMs); + pw.print(" lastAnimTime="); pw.println(mLastDimAnimTime); + pw.print(" mInputMethodAnimLayerAdjustment="); + pw.println(mInputMethodAnimLayerAdjustment); + pw.print(" mDisplayFrozen="); pw.print(mDisplayFrozen); + pw.print(" mWindowsFreezingScreen="); pw.print(mWindowsFreezingScreen); + pw.print(" mAppsFreezingScreen="); pw.println(mAppsFreezingScreen); + pw.print(" mRotation="); pw.print(mRotation); + pw.print(", mForcedAppOrientation="); pw.print(mForcedAppOrientation); + pw.print(", mRequestedRotation="); pw.println(mRequestedRotation); + pw.print(" mAnimationPending="); pw.print(mAnimationPending); + pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale); + pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale); + pw.print(" mNextAppTransition=0x"); + pw.print(Integer.toHexString(mNextAppTransition)); + pw.print(", mAppTransitionReady="); pw.print(mAppTransitionReady); + pw.print(", mAppTransitionTimeout="); pw.println( mAppTransitionTimeout); + pw.print(" mStartingIconInTransition="); pw.print(mStartingIconInTransition); + pw.print(", mSkipAppTransitionAnimation="); pw.println(mSkipAppTransitionAnimation); + if (mOpeningApps.size() > 0) { + pw.print(" mOpeningApps="); pw.println(mOpeningApps); + } + if (mClosingApps.size() > 0) { + pw.print(" mClosingApps="); pw.println(mClosingApps); + } + pw.print(" DisplayWidth="); pw.print(mDisplay.getWidth()); + pw.print(" DisplayHeight="); pw.println(mDisplay.getHeight()); pw.println(" KeyWaiter state:"); - pw.println(" mLastWin=" + mKeyWaiter.mLastWin - + " mLastBinder=" + mKeyWaiter.mLastBinder); - pw.println(" mFinished=" + mKeyWaiter.mFinished - + " mGotFirstWindow=" + mKeyWaiter.mGotFirstWindow - + " mEventDispatching=" + mKeyWaiter.mEventDispatching - + " mTimeToSwitch=" + mKeyWaiter.mTimeToSwitch); + pw.print(" mLastWin="); pw.print(mKeyWaiter.mLastWin); + pw.print(" mLastBinder="); pw.println(mKeyWaiter.mLastBinder); + pw.print(" mFinished="); pw.print(mKeyWaiter.mFinished); + pw.print(" mGotFirstWindow="); pw.print(mKeyWaiter.mGotFirstWindow); + pw.print(" mEventDispatching="); pw.print(mKeyWaiter.mEventDispatching); + pw.print(" mTimeToSwitch="); pw.println(mKeyWaiter.mTimeToSwitch); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index a3c23d3..b04f5a8 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -7890,24 +7890,24 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } pw.println("Activities in Current Activity Manager State:"); - dumpHistoryList(pw, mHistory, " ", "History", true); + dumpHistoryList(pw, mHistory, " ", "Hist", true); pw.println(" "); pw.println(" Running activities (most recent first):"); - dumpHistoryList(pw, mLRUActivities, " ", "Running", false); + dumpHistoryList(pw, mLRUActivities, " ", "Run", false); if (mWaitingVisibleActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting for another to become visible:"); - dumpHistoryList(pw, mWaitingVisibleActivities, " ", "Waiting", false); + dumpHistoryList(pw, mWaitingVisibleActivities, " ", "Wait", false); } if (mStoppingActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting to stop:"); - dumpHistoryList(pw, mStoppingActivities, " ", "Stopping", false); + dumpHistoryList(pw, mStoppingActivities, " ", "Stop", false); } if (mFinishingActivities.size() > 0) { pw.println(" "); pw.println(" Activities waiting to finish:"); - dumpHistoryList(pw, mFinishingActivities, " ", "Finishing", false); + dumpHistoryList(pw, mFinishingActivities, " ", "Fin", false); } pw.println(" "); @@ -7922,7 +7922,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen final int N = mRecentTasks.size(); for (int i=0; i<N; i++) { - pw.println(" Recent Task #" + i); + TaskRecord tr = mRecentTasks.get(i); + pw.print(" * Recent #"); pw.print(i); pw.print(": "); + pw.println(tr); mRecentTasks.get(i).dump(pw, " "); } } @@ -7944,8 +7946,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; } ProcessRecord r = procs.valueAt(ia); - pw.print(r.persistent ? " *PERSISTENT* Process [" : " Process ["); - pw.print(r.processName); pw.print("] UID "); pw.println(procs.keyAt(ia)); + pw.print(r.persistent ? " *PERS*" : " *APP*"); + pw.print(" UID "); pw.print(procs.keyAt(ia)); + pw.print(" "); pw.println(r); r.dump(pw, " "); if (r.persistent) { numPers++; @@ -7958,7 +7961,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Running processes (most recent first):"); dumpProcessList(pw, mLRUProcesses, " ", - "Running Norm Proc", "Running PERS Proc", true); + "App ", "PERS", true); needSep = true; } @@ -7968,8 +7971,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" PID mappings:"); for (int i=0; i<mPidsSelfLocked.size(); i++) { - pw.println(" PID #" + mPidsSelfLocked.keyAt(i) - + ": " + mPidsSelfLocked.valueAt(i)); + pw.print(" PID #"); pw.print(mPidsSelfLocked.keyAt(i)); + pw.print(": "); pw.println(mPidsSelfLocked.valueAt(i)); } } } @@ -7979,8 +7982,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Foreground Processes:"); for (int i=0; i<mForegroundProcesses.size(); i++) { - pw.println(" PID #" + mForegroundProcesses.keyAt(i) - + ": " + mForegroundProcesses.valueAt(i)); + pw.print(" PID #"); pw.print(mForegroundProcesses.keyAt(i)); + pw.print(": "); pw.println(mForegroundProcesses.valueAt(i)); } } @@ -7989,7 +7992,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Persisent processes that are starting:"); dumpProcessList(pw, mPersistentStartingProcesses, " ", - "Starting Initial Proc", "Restarting PERS Proc", false); + "Starting Norm", "Restarting PERS", false); } if (mStartingProcesses.size() > 0) { @@ -7997,7 +8000,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are starting:"); dumpProcessList(pw, mStartingProcesses, " ", - "Starting Norm Proc", "Starting PERS Proc", false); + "Starting Norm", "Starting PERS", false); } if (mRemovedProcesses.size() > 0) { @@ -8005,7 +8008,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are being removed:"); dumpProcessList(pw, mRemovedProcesses, " ", - "Removed Norm Proc", "Removed PERS Proc", false); + "Removed Norm", "Removed PERS", false); } if (mProcessesOnHold.size() > 0) { @@ -8013,7 +8016,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen needSep = true; pw.println(" Processes that are on old until the system is ready:"); dumpProcessList(pw, mProcessesOnHold, " ", - "OnHold Norm Proc", "OnHold PERS Proc", false); + "OnHold Norm", "OnHold PERS", false); } if (mProcessCrashTimes.getMap().size() > 0) { @@ -8026,10 +8029,11 @@ public final class ActivityManagerService extends ActivityManagerNative implemen SparseArray<Long> uids = procs.getValue(); final int N = uids.size(); for (int i=0; i<N; i++) { - pw.println(" Process " + procs.getKey() - + " uid " + uids.keyAt(i) - + ": last crashed " - + (now-uids.valueAt(i)) + " ms ago"); + pw.print(" Process "); pw.print(procs.getKey()); + pw.print(" uid "); pw.print(uids.keyAt(i)); + pw.print(": last crashed "); + pw.print((now-uids.valueAt(i))); + pw.println(" ms ago"); } } } @@ -8043,9 +8047,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen SparseArray<Long> uids = procs.getValue(); final int N = uids.size(); for (int i=0; i<N; i++) { - pw.println(" Bad process " + procs.getKey() - + " uid " + uids.keyAt(i) - + ": crashed at time " + uids.valueAt(i)); + pw.print(" Bad process "); pw.print(procs.getKey()); + pw.print(" uid "); pw.print(uids.keyAt(i)); + pw.print(": crashed at time "); + pw.println(uids.valueAt(i)); } } } @@ -8144,14 +8149,14 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Iterator it = mRegisteredReceivers.values().iterator(); while (it.hasNext()) { ReceiverList r = (ReceiverList)it.next(); - pw.println(" Receiver " + r.receiver); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } } pw.println(" "); pw.println("Receiver Resolver Table:"); - mReceiverResolver.dump(new PrintWriterPrinter(pw), " "); + mReceiverResolver.dump(pw, " "); if (mParallelBroadcasts.size() > 0 || mOrderedBroadcasts.size() > 0 || mPendingBroadcast != null) { @@ -8185,13 +8190,23 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (mStickyBroadcasts != null) { pw.println(" "); pw.println(" Sticky broadcasts:"); + StringBuilder sb = new StringBuilder(128); for (Map.Entry<String, ArrayList<Intent>> ent : mStickyBroadcasts.entrySet()) { - pw.println(" Sticky action " + ent.getKey() + ":"); + pw.print(" * Sticky action "); pw.print(ent.getKey()); + pw.println(":"); ArrayList<Intent> intents = ent.getValue(); final int N = intents.size(); for (int i=0; i<N; i++) { - pw.println(" " + intents.get(i)); + sb.setLength(0); + sb.append(" Intent: "); + intents.get(i).toShortString(sb, true, false); + pw.println(sb.toString()); + Bundle bundle = intents.get(i).getExtras(); + if (bundle != null) { + pw.print(" "); + pw.println(bundle.toString()); + } } } } @@ -8222,7 +8237,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Iterator<ServiceRecord> it = mServices.values().iterator(); while (it.hasNext()) { ServiceRecord r = it.next(); - pw.println(" Service " + r.shortName); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8233,7 +8248,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Pending services:"); for (int i=0; i<mPendingServices.size(); i++) { ServiceRecord r = mPendingServices.get(i); - pw.println(" Pending Service " + r.shortName); + pw.print(" * Pending "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8244,7 +8259,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Restarting services:"); for (int i=0; i<mRestartingServices.size(); i++) { ServiceRecord r = mRestartingServices.get(i); - pw.println(" Restarting Service " + r.shortName); + pw.print(" * Restarting "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8255,7 +8270,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.println(" Stopping services:"); for (int i=0; i<mStoppingServices.size(); i++) { ServiceRecord r = mStoppingServices.get(i); - pw.println(" Stopping Service " + r.shortName); + pw.print(" * Stopping "); pw.println(r); r.dump(pw, " "); } needSep = true; @@ -8268,8 +8283,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen = mServiceConnections.values().iterator(); while (it.hasNext()) { ConnectionRecord r = it.next(); - pw.println(" " + r.binding.service.shortName - + " -> " + r.conn.asBinder()); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } } @@ -8292,27 +8306,28 @@ public final class ActivityManagerService extends ActivityManagerNative implemen boolean needSep = false; - if (mProvidersByName.size() > 0) { - pw.println(" Published content providers (by name):"); - Iterator it = mProvidersByName.entrySet().iterator(); + if (mProvidersByClass.size() > 0) { + if (needSep) pw.println(" "); + pw.println(" Published content providers (by class):"); + Iterator it = mProvidersByClass.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry)it.next(); ContentProviderRecord r = (ContentProviderRecord)e.getValue(); - pw.println(" Provider " + (String)e.getKey()); + pw.print(" * "); pw.println(r); r.dump(pw, " "); } needSep = true; } - if (mProvidersByClass.size() > 0) { - if (needSep) pw.println(" "); - pw.println(" Published content providers (by class):"); - Iterator it = mProvidersByClass.entrySet().iterator(); + if (mProvidersByName.size() > 0) { + pw.println(" "); + pw.println(" Authority to provider mappings:"); + Iterator it = mProvidersByName.entrySet().iterator(); while (it.hasNext()) { Map.Entry e = (Map.Entry)it.next(); ContentProviderRecord r = (ContentProviderRecord)e.getValue(); - pw.println(" Provider " + (String)e.getKey()); - r.dump(pw, " "); + pw.print(" "); pw.print(e.getKey()); pw.print(": "); + pw.println(r); } needSep = true; } @@ -8321,21 +8336,25 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (needSep) pw.println(" "); pw.println(" Launching content providers:"); for (int i=mLaunchingProviders.size()-1; i>=0; i--) { - pw.println(" Provider #" + i + ":"); - ((ContentProviderRecord)mLaunchingProviders.get(i)).dump(pw, " "); + pw.print(" Launching #"); pw.print(i); pw.print(": "); + pw.println(mLaunchingProviders.get(i)); } needSep = true; } - pw.println(); - pw.println("Granted Uri Permissions:"); - for (int i=0; i<mGrantedUriPermissions.size(); i++) { - int uid = mGrantedUriPermissions.keyAt(i); - HashMap<Uri, UriPermission> perms - = mGrantedUriPermissions.valueAt(i); - pw.println(" Uris granted to uid " + uid + ":"); - for (UriPermission perm : perms.values()) { - perm.dump(pw, " "); + if (mGrantedUriPermissions.size() > 0) { + pw.println(); + pw.println("Granted Uri Permissions:"); + for (int i=0; i<mGrantedUriPermissions.size(); i++) { + int uid = mGrantedUriPermissions.keyAt(i); + HashMap<Uri, UriPermission> perms + = mGrantedUriPermissions.valueAt(i); + pw.print(" * UID "); pw.print(uid); + pw.println(" holds:"); + for (UriPermission perm : perms.values()) { + pw.print(" "); pw.println(perm); + perm.dump(pw, " "); + } } } } @@ -8353,7 +8372,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen return; } - pw.println("Intent Senders in Current Activity Manager State:"); + pw.println("Pending Intents in Current Activity Manager State:"); if (this.mIntentSenderRecords.size() > 0) { Iterator<WeakReference<PendingIntentRecord>> it @@ -8362,10 +8381,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen WeakReference<PendingIntentRecord> ref = it.next(); PendingIntentRecord rec = ref != null ? ref.get(): null; if (rec != null) { - pw.println(" IntentSender " + rec); + pw.print(" * "); pw.println(rec); rec.dump(pw, " "); } else { - pw.println(" IntentSender " + ref); + pw.print(" * "); pw.print(ref); } } } @@ -8377,24 +8396,21 @@ public final class ActivityManagerService extends ActivityManagerNative implemen TaskRecord lastTask = null; for (int i=list.size()-1; i>=0; i--) { HistoryRecord r = (HistoryRecord)list.get(i); + final boolean full = complete || !r.inHistory; if (lastTask != r.task) { lastTask = r.task; - if (complete || !r.inHistory) { + pw.print(prefix); + pw.print(full ? "* " : " "); + pw.println(lastTask); + if (full) { lastTask.dump(pw, prefix + " "); - } else { - pw.print(prefix); - pw.print(" "); - pw.println(lastTask); } } - if (complete || !r.inHistory) { - pw.print(prefix); pw.print(" "); pw.print(label); - pw.print(" #"); pw.print(i); pw.println(":"); + pw.print(prefix); pw.print(full ? " * " : " "); pw.print(label); + pw.print(" #"); pw.print(i); pw.print(": "); + pw.println(r); + if (full) { r.dump(pw, prefix + " "); - } else { - pw.print(prefix); pw.print(" "); pw.print(label); - pw.print(" #"); pw.print(i); pw.print(": "); - pw.println(r); } } } diff --git a/services/java/com/android/server/am/AppBindRecord.java b/services/java/com/android/server/am/AppBindRecord.java index ce6f6dc..9c57360 100644 --- a/services/java/com/android/server/am/AppBindRecord.java +++ b/services/java/com/android/server/am/AppBindRecord.java @@ -32,9 +32,12 @@ class AppBindRecord { // All ConnectionRecord for this client. void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); pw.println(prefix + "service=" + service); pw.println(prefix + "client=" + client); + dumpInIntentBind(pw, prefix); + } + + void dumpInIntentBind(PrintWriter pw, String prefix) { if (connections.size() > 0) { pw.println(prefix + "Per-process Connections:"); Iterator<ConnectionRecord> it = connections.iterator(); diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java index e265f43..ddc3e68 100644 --- a/services/java/com/android/server/am/BatteryStatsService.java +++ b/services/java/com/android/server/am/BatteryStatsService.java @@ -302,7 +302,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub { } } if (isCheckin) mStats.dumpCheckinLocked(pw, args); - else mStats.dumpLocked(new PrintWriterPrinter(pw)); + else mStats.dumpLocked(pw); } } } diff --git a/services/java/com/android/server/am/BroadcastFilter.java b/services/java/com/android/server/am/BroadcastFilter.java index cd7f720..0eeb393 100644 --- a/services/java/com/android/server/am/BroadcastFilter.java +++ b/services/java/com/android/server/am/BroadcastFilter.java @@ -18,6 +18,7 @@ package com.android.server.am; import android.content.IntentFilter; import android.util.PrintWriterPrinter; +import android.util.Printer; import java.io.PrintWriter; @@ -33,19 +34,25 @@ class BroadcastFilter extends IntentFilter { requiredPermission = _requiredPermission; } - public void dumpLocal(PrintWriter pw, String prefix) { - super.dump(new PrintWriterPrinter(pw), prefix); - } - public void dump(PrintWriter pw, String prefix) { - dumpLocal(pw, prefix); - pw.println(prefix + "requiredPermission=" + requiredPermission); + dumpInReceiverList(pw, new PrintWriterPrinter(pw), prefix); receiverList.dumpLocal(pw, prefix); } + public void dumpInReceiverList(PrintWriter pw, Printer pr, String prefix) { + super.dump(pr, prefix); + if (requiredPermission != null) { + pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission); + } + } + public String toString() { - return "BroadcastFilter{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + receiverList + "}"; + StringBuilder sb = new StringBuilder(); + sb.append("BroadcastFilter{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(receiverList); + sb.append('}'); + return sb.toString(); } } diff --git a/services/java/com/android/server/am/ConnectionRecord.java b/services/java/com/android/server/am/ConnectionRecord.java index b4c7df1..b3343dd 100644 --- a/services/java/com/android/server/am/ConnectionRecord.java +++ b/services/java/com/android/server/am/ConnectionRecord.java @@ -31,9 +31,10 @@ class ConnectionRecord { String stringName; // Caching of toString. void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); pw.println(prefix + "binding=" + binding); - pw.println(prefix + "activity=" + activity); + if (activity != null) { + pw.println(prefix + "activity=" + activity); + } pw.println(prefix + "conn=" + conn.asBinder() + " flags=0x" + Integer.toHexString(flags)); } diff --git a/services/java/com/android/server/am/ContentProviderRecord.java b/services/java/com/android/server/am/ContentProviderRecord.java index 2b9e006..c764635 100644 --- a/services/java/com/android/server/am/ContentProviderRecord.java +++ b/services/java/com/android/server/am/ContentProviderRecord.java @@ -54,19 +54,27 @@ class ContentProviderRecord extends ContentProviderHolder { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "package=" + info.applicationInfo.packageName - + " process=" + info.processName); - pw.println(prefix + "app=" + app); - pw.println(prefix + "launchingApp=" + launchingApp); - pw.println(prefix + "provider=" + provider); - pw.println(prefix + "name=" + info.authority); - pw.println(prefix + "isSyncable=" + info.isSyncable); - pw.println(prefix + "multiprocess=" + info.multiprocess - + " initOrder=" + info.initOrder - + " uid=" + uid); - pw.println(prefix + "clients=" + clients); - pw.println(prefix + "externals=" + externals); + pw.print(prefix); pw.print("package="); + pw.print(info.applicationInfo.packageName); + pw.print("process="); pw.println(info.processName); + pw.print(prefix); pw.print("app="); pw.println(app); + if (launchingApp != null) { + pw.print(prefix); pw.print("launchingApp="); pw.println(launchingApp); + } + pw.print(prefix); pw.print("uid="); pw.print(uid); + pw.print(" provider="); pw.println(provider); + pw.print(prefix); pw.print("name="); pw.println(info.authority); + if (info.isSyncable || info.multiprocess || info.initOrder != 0) { + pw.print(prefix); pw.print("isSyncable="); pw.print(info.isSyncable); + pw.print("multiprocess="); pw.print(info.multiprocess); + pw.print(" initOrder="); pw.println(info.initOrder); + } + if (clients.size() > 0) { + pw.print(prefix); pw.print("clients="); pw.println(clients); + } + if (externals != 0) { + pw.print(prefix); pw.print("externals="); pw.println(externals); + } } public String toString() { diff --git a/services/java/com/android/server/am/HistoryRecord.java b/services/java/com/android/server/am/HistoryRecord.java index a2fd62b..1488791 100644 --- a/services/java/com/android/server/am/HistoryRecord.java +++ b/services/java/com/android/server/am/HistoryRecord.java @@ -103,7 +103,6 @@ class HistoryRecord extends IApplicationToken.Stub { String stringName; // for caching of toString(). void dump(PrintWriter pw, String prefix) { - pw.print(prefix); pw.println(this); pw.print(prefix); pw.print("packageName="); pw.print(packageName); pw.print(" processName="); pw.println(processName); pw.print(prefix); pw.print("launchedFromUid="); pw.print(launchedFromUid); @@ -112,9 +111,10 @@ class HistoryRecord extends IApplicationToken.Stub { pw.print(prefix); pw.print("frontOfTask="); pw.print(frontOfTask); pw.print(" task="); pw.println(task); pw.print(prefix); pw.print("taskAffinity="); pw.println(taskAffinity); - pw.print(prefix); pw.print("realActivity="); pw.println(realActivity); - pw.print(prefix); pw.print("dir="); pw.print(baseDir); - pw.print(" res="); pw.print(resDir); + pw.print(prefix); pw.print("realActivity="); + pw.println(realActivity.flattenToShortString()); + pw.print(prefix); pw.print("base="); pw.print(baseDir); + if (!resDir.equals(baseDir)) pw.print(" res="); pw.print(resDir); pw.print(" data="); pw.println(dataDir); pw.print(prefix); pw.print("labelRes=0x"); pw.print(Integer.toHexString(labelRes)); @@ -504,7 +504,7 @@ class HistoryRecord extends IApplicationToken.Stub { sb.append("HistoryRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(' '); - sb.append(intent.getComponent().toShortString()); + sb.append(intent.getComponent().flattenToShortString()); sb.append('}'); return stringName = sb.toString(); } diff --git a/services/java/com/android/server/am/IntentBindRecord.java b/services/java/com/android/server/am/IntentBindRecord.java index 24c3943..3a5ca66 100644 --- a/services/java/com/android/server/am/IntentBindRecord.java +++ b/services/java/com/android/server/am/IntentBindRecord.java @@ -45,22 +45,30 @@ class IntentBindRecord { /** Set when the service's onUnbind() has asked to be told about new clients. */ boolean doRebind; + String stringName; // caching of toString + void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "service=" + service); - pw.println(prefix + "intent=" + intent.getIntent()); - pw.println(prefix + "binder=" + binder - + " requested=" + requested - + " received=" + received - + " hasBound=" + hasBound - + " doRebind=" + doRebind); + pw.print(prefix); pw.print("service="); pw.println(service); + dumpInService(pw, prefix); + } + + void dumpInService(PrintWriter pw, String prefix) { + pw.print(prefix); pw.print("intent={"); + pw.print(intent.getIntent().toShortString(true, false)); + pw.println('}'); + pw.print(prefix); pw.print("binder="); pw.println(binder); + pw.print(prefix); pw.print("requested="); pw.print(requested); + pw.print(" received="); pw.print(received); + pw.print(" hasBound="); pw.print(hasBound); + pw.print(" doRebind="); pw.println(doRebind); if (apps.size() > 0) { - pw.println(prefix + "Application Bindings:"); Iterator<AppBindRecord> it = apps.values().iterator(); while (it.hasNext()) { AppBindRecord a = it.next(); - pw.println(prefix + "Client " + a.client); - a.dump(pw, prefix + " "); + pw.print(prefix); pw.print("* Client AppBindRecord{"); + pw.print(Integer.toHexString(System.identityHashCode(a))); + pw.print(' '); pw.print(a.client); pw.println('}'); + a.dumpInIntentBind(pw, prefix + " "); } } } @@ -71,9 +79,19 @@ class IntentBindRecord { } public String toString() { - return "IntentBindRecord{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + service.name.toShortString() - + ":" + intent + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("IntentBindRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(service.shortName); + sb.append(':'); + if (intent != null) { + intent.getIntent().toShortString(sb, false, false); + } + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java index b18aaf7..4381392 100644 --- a/services/java/com/android/server/am/PendingIntentRecord.java +++ b/services/java/com/android/server/am/PendingIntentRecord.java @@ -36,6 +36,8 @@ class PendingIntentRecord extends IIntentSender.Stub { boolean sent = false; boolean canceled = false; + String stringName; + final static class Key { final int type; final String packageName; @@ -142,7 +144,7 @@ class PendingIntentRecord extends IIntentSender.Stub { public String toString() { return "Key{" + typeName() + " pkg=" + packageName - + " intent=" + requestIntent + " flags=0x" + + " intent=" + requestIntent.toShortString(true, false) + " flags=0x" + Integer.toHexString(flags) + "}"; } @@ -260,19 +262,38 @@ class PendingIntentRecord extends IIntentSender.Stub { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + "packageName=" + key.packageName - + " type=" + key.typeName() - + " flags=0x" + Integer.toHexString(key.flags)); - pw.println(prefix + "activity=" + key.activity + " who=" + key.who); - pw.println(prefix + "requestCode=" + key.requestCode - + " requestResolvedType=" + key.requestResolvedType); - pw.println(prefix + "requestIntent=" + key.requestIntent); - pw.println(prefix + "sent=" + sent + " canceled=" + canceled); + pw.print(prefix); pw.print("uid="); pw.print(uid); + pw.print(" packageName="); pw.print(key.packageName); + pw.print(" type="); pw.print(key.typeName()); + pw.print(" flags=0x"); pw.println(Integer.toHexString(key.flags)); + if (key.activity != null || key.who != null) { + pw.print(prefix); pw.print("activity="); pw.print(key.activity); + pw.print(" who="); pw.println(key.who); + } + if (key.requestCode != 0 || key.requestResolvedType != null) { + pw.print(prefix); pw.print("requestCode="); pw.print(key.requestCode); + pw.print(" requestResolvedType="); pw.println(key.requestResolvedType); + } + pw.print(prefix); pw.print("requestIntent="); + pw.println(key.requestIntent.toShortString(true, true)); + if (sent || canceled) { + pw.print(prefix); pw.print("sent="); pw.print(sent); + pw.print(" canceled="); pw.println(canceled); + } } public String toString() { - return "IntentSenderRecord{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + key.packageName + " " + key.typeName() + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("PendingIntentRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(key.packageName); + sb.append(' '); + sb.append(key.typeName()); + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java index d2667e7..b76547a 100644 --- a/services/java/com/android/server/am/ProcessRecord.java +++ b/services/java/com/android/server/am/ProcessRecord.java @@ -106,7 +106,6 @@ class ProcessRecord implements Watchdog.PssRequestor { ActivityManager.ProcessErrorStateInfo notRespondingReport; void dump(PrintWriter pw, String prefix) { - pw.print(prefix); pw.println(this); if (info.className != null) { pw.print(prefix); pw.print("class="); pw.println(info.className); } diff --git a/services/java/com/android/server/am/ReceiverList.java b/services/java/com/android/server/am/ReceiverList.java index b8bf30c..0facefc 100644 --- a/services/java/com/android/server/am/ReceiverList.java +++ b/services/java/com/android/server/am/ReceiverList.java @@ -18,9 +18,12 @@ package com.android.server.am; import android.app.IIntentReceiver; import android.content.Intent; +import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.util.PrintWriterPrinter; +import android.util.Printer; import java.io.PrintWriter; import java.util.ArrayList; @@ -64,22 +67,26 @@ class ReceiverList extends ArrayList<BroadcastFilter> } void dumpLocal(PrintWriter pw, String prefix) { - pw.println(prefix + "receiver=IBinder " - + Integer.toHexString(System.identityHashCode(receiver.asBinder()))); - pw.println(prefix + "app=" + app + " pid=" + pid + " uid=" + uid); - pw.println(prefix + "curBroadcast=" + curBroadcast - + " linkedToDeath=" + linkedToDeath); + pw.print(prefix); pw.print("app="); pw.print(app); + pw.print(" pid="); pw.print(pid); pw.print(" uid="); pw.println(uid); + if (curBroadcast != null || linkedToDeath) { + pw.print(prefix); pw.print("curBroadcast="); pw.print(curBroadcast); + pw.print(" linkedToDeath="); pw.println(linkedToDeath); + } } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); + Printer pr = new PrintWriterPrinter(pw); dumpLocal(pw, prefix); String p2 = prefix + " "; final int N = size(); for (int i=0; i<N; i++) { BroadcastFilter bf = get(i); - pw.println(prefix + "Filter #" + i + ": " + bf); - bf.dump(pw, p2); + pw.print(prefix); pw.print("Filter #"); pw.print(i); + pw.print(": BroadcastFilter{"); + pw.print(Integer.toHexString(System.identityHashCode(bf))); + pw.println('}'); + bf.dumpInReceiverList(pw, pr, p2); } } @@ -96,7 +103,7 @@ class ReceiverList extends ArrayList<BroadcastFilter> sb.append((app != null ? app.processName : "(unknown name)")); sb.append('/'); sb.append(uid); - sb.append(" client "); + sb.append((receiver.asBinder() instanceof Binder) ? " local:" : " remote:"); sb.append(Integer.toHexString(System.identityHashCode(receiver.asBinder()))); sb.append('}'); return stringName = sb.toString(); diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java index a8fc761..fc93b69 100644 --- a/services/java/com/android/server/am/ServiceRecord.java +++ b/services/java/com/android/server/am/ServiceRecord.java @@ -80,40 +80,46 @@ class ServiceRecord extends Binder { String stringName; // caching of toString void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "intent=" + intent.getIntent()); - pw.println(prefix + "packageName=" + packageName); - pw.println(prefix + "processName=" + processName); - pw.println(prefix + "permission=" + permission); - pw.println(prefix + "baseDir=" + baseDir+ " resDir=" + resDir + " dataDir=" + dataDir); - pw.println(prefix + "app=" + app); - pw.println(prefix + "isForeground=" + isForeground - + " lastActivity=" + lastActivity); - pw.println(prefix + "startRequested=" + startRequested - + " startId=" + lastStartId - + " executeNesting=" + executeNesting - + " executingStart=" + executingStart - + " crashCount=" + crashCount); - pw.println(prefix + "totalRestartCount=" + totalRestartCount - + " restartCount=" + restartCount - + " restartDelay=" + restartDelay - + " restartTime=" + restartTime - + " nextRestartTime=" + nextRestartTime); + pw.print(prefix); pw.print("intent={"); + pw.print(intent.getIntent().toShortString(true, false)); + pw.println('}'); + pw.print(prefix); pw.print("packageName="); pw.println(packageName); + pw.print(prefix); pw.print("processName="); pw.println(processName); + if (permission != null) { + pw.print(prefix); pw.print("permission="); pw.println(permission); + } + pw.print(prefix); pw.print("baseDir="); pw.print(baseDir); + if (!resDir.equals(baseDir)) pw.print(" resDir="); pw.print(resDir); + pw.print(" dataDir="); pw.println(dataDir); + pw.print(prefix); pw.print("app="); pw.println(app); + pw.print(prefix); pw.print("isForeground="); pw.print(isForeground); + pw.print(" lastActivity="); pw.println(lastActivity); + pw.print(prefix); pw.print("startRequested="); pw.print(startRequested); + pw.print(" startId="); pw.print(lastStartId); + pw.print(" executeNesting="); pw.print(executeNesting); + pw.print(" executingStart="); pw.print(executingStart); + pw.print(" crashCount="); pw.println(crashCount); + pw.print(prefix); pw.print("totalRestartCount="); pw.print(totalRestartCount); + pw.print(" restartCount="); pw.print(restartCount); + pw.print(" restartDelay="); pw.print(restartDelay); + pw.print(" restartTime="); pw.print(restartTime); + pw.print(" nextRestartTime="); pw.println(nextRestartTime); if (bindings.size() > 0) { - pw.println(prefix + "Bindings:"); Iterator<IntentBindRecord> it = bindings.values().iterator(); while (it.hasNext()) { IntentBindRecord b = it.next(); - pw.println(prefix + "Binding " + b); - b.dump(pw, prefix + " "); + pw.print(prefix); pw.print("* IntentBindRecord{"); + pw.print(Integer.toHexString(System.identityHashCode(b))); + pw.println("}:"); + b.dumpInService(pw, prefix + " "); } } if (connections.size() > 0) { - pw.println(prefix + "All Connections:"); + pw.print(prefix); pw.println("All Connections:"); Iterator<ConnectionRecord> it = connections.values().iterator(); while (it.hasNext()) { ConnectionRecord c = it.next(); - pw.println(prefix + " " + c); + pw.print(prefix); pw.print(" "); pw.println(c); } } } @@ -165,11 +171,9 @@ class ServiceRecord extends Binder { return stringName; } StringBuilder sb = new StringBuilder(128); - sb.append("ServiceRecord{"); - sb.append(Integer.toHexString(System.identityHashCode(this))); - sb.append(' '); - sb.append(shortName); - sb.append('}'); + sb.append("ServiceRecord{") + .append(Integer.toHexString(System.identityHashCode(this))) + .append(' ').append(shortName).append('}'); return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/TaskRecord.java b/services/java/com/android/server/am/TaskRecord.java index aab3736..bcb8f54 100644 --- a/services/java/com/android/server/am/TaskRecord.java +++ b/services/java/com/android/server/am/TaskRecord.java @@ -36,6 +36,8 @@ class TaskRecord { boolean rootWasReset; // True if the intent at the root of the task had // the FLAG_ACTIVITY_RESET_TASK_IF_NEEDED flag. + String stringName; // caching of toString() result. + TaskRecord(int _taskId, ActivityInfo info, Intent _intent, boolean _clearOnBackground) { taskId = _taskId; @@ -53,6 +55,8 @@ class TaskRecord { } void setIntent(Intent _intent, ActivityInfo info) { + stringName = null; + if (info.targetActivity == null) { intent = _intent; realActivity = _intent != null ? _intent.getComponent() : null; @@ -82,23 +86,63 @@ class TaskRecord { } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + "clearOnBackground=" + clearOnBackground - + " numActivities=" + numActivities - + " rootWasReset=" + rootWasReset); - pw.println(prefix + "affinity=" + affinity); - pw.println(prefix + "intent=" + intent); - pw.println(prefix + "affinityIntent=" + affinityIntent); - pw.println(prefix + "origActivity=" + origActivity); - pw.println(prefix + "lastActiveTime=" + lastActiveTime - +" (inactive for " + (getInactiveDuration()/1000) + "s)"); + if (clearOnBackground || numActivities != 0 || rootWasReset) { + pw.print(prefix); pw.print("clearOnBackground="); pw.print(clearOnBackground); + pw.print(" numActivities="); pw.print(numActivities); + pw.print(" rootWasReset="); pw.println(rootWasReset); + } + if (affinity != null) { + pw.print(prefix); pw.print("affinity="); pw.println(affinity); + } + if (intent != null) { + StringBuilder sb = new StringBuilder(128); + sb.append(prefix); sb.append("intent={"); + intent.toShortString(sb, true, false); + sb.append('}'); + pw.println(sb.toString()); + } + if (affinityIntent != null) { + StringBuilder sb = new StringBuilder(128); + sb.append(prefix); sb.append("affinityIntent={"); + affinityIntent.toShortString(sb, true, false); + sb.append('}'); + pw.println(sb.toString()); + } + if (origActivity != null) { + pw.print(prefix); pw.print("origActivity="); + pw.println(origActivity.flattenToShortString()); + } + if (realActivity != null) { + pw.print(prefix); pw.print("realActivity="); + pw.println(realActivity.flattenToShortString()); + } + pw.print(prefix); pw.print("lastActiveTime="); pw.print(lastActiveTime); + pw.print(" (inactive for "); + pw.print((getInactiveDuration()/1000)); pw.println("s)"); } public String toString() { - return "Task{" + taskId + " " - + (affinity != null ? affinity - : (intent != null ? intent.getComponent().flattenToShortString() - : affinityIntent != null ? affinityIntent.getComponent().flattenToShortString() : "??")) - + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("TaskRecord{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" #"); + sb.append(taskId); + if (affinity != null) { + sb.append(" A "); + sb.append(affinity); + } else if (intent != null) { + sb.append(" I "); + sb.append(intent.getComponent().flattenToShortString()); + } else if (affinityIntent != null) { + sb.append(" aI "); + sb.append(affinityIntent.getComponent().flattenToShortString()); + } else { + sb.append(" ??"); + } + sb.append('}'); + return stringName = sb.toString(); } } diff --git a/services/java/com/android/server/am/UriPermission.java b/services/java/com/android/server/am/UriPermission.java index fb7a745..ffa8a2a 100644 --- a/services/java/com/android/server/am/UriPermission.java +++ b/services/java/com/android/server/am/UriPermission.java @@ -30,6 +30,8 @@ class UriPermission { final HashSet<HistoryRecord> readActivities = new HashSet<HistoryRecord>(); final HashSet<HistoryRecord> writeActivities = new HashSet<HistoryRecord>(); + String stringName; + UriPermission(int _uid, Uri _uri) { uid = _uid; uri = _uri; @@ -65,18 +67,29 @@ class UriPermission { } public String toString() { - return "UriPermission{" - + Integer.toHexString(System.identityHashCode(this)) - + " " + uri + "}"; + if (stringName != null) { + return stringName; + } + StringBuilder sb = new StringBuilder(128); + sb.append("UriPermission{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(' '); + sb.append(uri); + sb.append('}'); + return stringName = sb.toString(); } void dump(PrintWriter pw, String prefix) { - pw.println(prefix + this); - pw.println(prefix + " modeFlags=0x" + Integer.toHexString(modeFlags) - + " uid=" + uid - + " globalModeFlags=0x" - + Integer.toHexString(globalModeFlags)); - pw.println(prefix + " readActivities=" + readActivities); - pw.println(prefix + " writeActivities=" + writeActivities); + pw.print(prefix); pw.print("modeFlags=0x"); + pw.print(Integer.toHexString(modeFlags)); + pw.print(" uid="); pw.print(uid); + pw.print(" globalModeFlags=0x"); + pw.println(Integer.toHexString(globalModeFlags)); + if (readActivities.size() != 0) { + pw.print(prefix); pw.print("readActivities="); pw.println(readActivities); + } + if (writeActivities.size() != 0) { + pw.print(prefix); pw.print("writeActivities="); pw.println(writeActivities); + } } } |