Skip to content

Commit 68e0da7

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Quiet down a lot of logging." into jb-mr1.1-dev
2 parents ceafd15 + 40e9f29 commit 68e0da7

File tree

19 files changed

+114
-96
lines changed

19 files changed

+114
-96
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4421,12 +4421,14 @@ private void installContentProviders(
44214421
new ArrayList<IActivityManager.ContentProviderHolder>();
44224422

44234423
for (ProviderInfo cpi : providers) {
4424-
StringBuilder buf = new StringBuilder(128);
4425-
buf.append("Pub ");
4426-
buf.append(cpi.authority);
4427-
buf.append(": ");
4428-
buf.append(cpi.name);
4429-
Log.i(TAG, buf.toString());
4424+
if (DEBUG_PROVIDER) {
4425+
StringBuilder buf = new StringBuilder(128);
4426+
buf.append("Pub ");
4427+
buf.append(cpi.authority);
4428+
buf.append(": ");
4429+
buf.append(cpi.name);
4430+
Log.i(TAG, buf.toString());
4431+
}
44304432
IActivityManager.ContentProviderHolder cph = installProvider(context, null, cpi,
44314433
false /*noisy*/, true /*noReleaseNeeded*/, true /*stable*/);
44324434
if (cph != null) {

core/java/android/app/ContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public boolean bindService(Intent service, ServiceConnection conn, int flags) {
168168
* context object for Activity and other application components.
169169
*/
170170
class ContextImpl extends Context {
171-
private final static String TAG = "ApplicationContext";
171+
private final static String TAG = "ContextImpl";
172172
private final static boolean DEBUG = false;
173173

174174
private static final HashMap<String, SharedPreferencesImpl> sSharedPrefs =
@@ -1715,7 +1715,7 @@ public void enforceUriPermission(
17151715
private void warnIfCallingFromSystemProcess() {
17161716
if (Process.myUid() == Process.SYSTEM_UID) {
17171717
Slog.w(TAG, "Calling a method in the system process without a qualified user: "
1718-
+ Debug.getCallers(3));
1718+
+ Debug.getCallers(5));
17191719
}
17201720
}
17211721

core/java/android/content/SyncStorageEngine.java

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
public class SyncStorageEngine extends Handler {
6565

6666
private static final String TAG = "SyncManager";
67+
private static final boolean DEBUG = false;
6768
private static final boolean DEBUG_FILE = false;
6869

6970
private static final String XML_ATTR_NEXT_AUTHORITY_ID = "nextAuthorityId";
@@ -443,7 +444,7 @@ private void reportChange(int which) {
443444
mChangeListeners.finishBroadcast();
444445
}
445446

446-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
447+
if (DEBUG) {
447448
Log.v(TAG, "reportChange " + which + " to: " + reports);
448449
}
449450

@@ -484,13 +485,17 @@ public boolean getSyncAutomatically(Account account, int userId, String provider
484485

485486
public void setSyncAutomatically(Account account, int userId, String providerName,
486487
boolean sync) {
487-
Log.d(TAG, "setSyncAutomatically: " + /* account + */" provider " + providerName
488-
+ ", user " + userId + " -> " + sync);
488+
if (DEBUG) {
489+
Log.d(TAG, "setSyncAutomatically: " + /* account + */" provider " + providerName
490+
+ ", user " + userId + " -> " + sync);
491+
}
489492
synchronized (mAuthorities) {
490493
AuthorityInfo authority = getOrCreateAuthorityLocked(account, userId, providerName, -1,
491494
false);
492495
if (authority.enabled == sync) {
493-
Log.d(TAG, "setSyncAutomatically: already set to " + sync + ", doing nothing");
496+
if (DEBUG) {
497+
Log.d(TAG, "setSyncAutomatically: already set to " + sync + ", doing nothing");
498+
}
494499
return;
495500
}
496501
authority.enabled = sync;
@@ -532,13 +537,17 @@ public void setIsSyncable(Account account, int userId, String providerName, int
532537
} else if (syncable < -1) {
533538
syncable = -1;
534539
}
535-
Log.d(TAG, "setIsSyncable: " + account + ", provider " + providerName
536-
+ ", user " + userId + " -> " + syncable);
540+
if (DEBUG) {
541+
Log.d(TAG, "setIsSyncable: " + account + ", provider " + providerName
542+
+ ", user " + userId + " -> " + syncable);
543+
}
537544
synchronized (mAuthorities) {
538545
AuthorityInfo authority = getOrCreateAuthorityLocked(account, userId, providerName, -1,
539546
false);
540547
if (authority.syncable == syncable) {
541-
Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing");
548+
if (DEBUG) {
549+
Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing");
550+
}
542551
return;
543552
}
544553
authority.syncable = syncable;
@@ -564,7 +573,7 @@ public Pair<Long, Long> getBackoff(Account account, int userId, String providerN
564573

565574
public void setBackoff(Account account, int userId, String providerName,
566575
long nextSyncTime, long nextDelay) {
567-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
576+
if (DEBUG) {
568577
Log.v(TAG, "setBackoff: " + account + ", provider " + providerName
569578
+ ", user " + userId
570579
+ " -> nextSyncTime " + nextSyncTime + ", nextDelay " + nextDelay);
@@ -615,7 +624,7 @@ public void clearAllBackoffs(SyncQueue syncQueue) {
615624
for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
616625
if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
617626
|| authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
618-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
627+
if (DEBUG) {
619628
Log.v(TAG, "clearAllBackoffs:"
620629
+ " authority:" + authorityInfo.authority
621630
+ " account:" + accountInfo.accountAndUser.account.name
@@ -641,7 +650,7 @@ public void clearAllBackoffs(SyncQueue syncQueue) {
641650

642651
public void setDelayUntilTime(Account account, int userId, String providerName,
643652
long delayUntil) {
644-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
653+
if (DEBUG) {
645654
Log.v(TAG, "setDelayUntil: " + account + ", provider " + providerName
646655
+ ", user " + userId + " -> delayUntil " + delayUntil);
647656
}
@@ -677,7 +686,7 @@ private void updateOrRemovePeriodicSync(Account account, int userId, String prov
677686
if (extras == null) {
678687
extras = new Bundle();
679688
}
680-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
689+
if (DEBUG) {
681690
Log.v(TAG, "addOrRemovePeriodicSync: " + account + ", user " + userId
682691
+ ", provider " + providerName
683692
+ " -> period " + period + ", extras " + extras);
@@ -833,7 +842,7 @@ public boolean isSyncActive(Account account, int userId, String authority) {
833842

834843
public PendingOperation insertIntoPending(PendingOperation op) {
835844
synchronized (mAuthorities) {
836-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
845+
if (DEBUG) {
837846
Log.v(TAG, "insertIntoPending: account=" + op.account
838847
+ " user=" + op.userId
839848
+ " auth=" + op.authority
@@ -865,7 +874,7 @@ public PendingOperation insertIntoPending(PendingOperation op) {
865874
public boolean deleteFromPending(PendingOperation op) {
866875
boolean res = false;
867876
synchronized (mAuthorities) {
868-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
877+
if (DEBUG) {
869878
Log.v(TAG, "deleteFromPending: account=" + op.account
870879
+ " user=" + op.userId
871880
+ " auth=" + op.authority
@@ -884,7 +893,7 @@ public boolean deleteFromPending(PendingOperation op) {
884893
AuthorityInfo authority = getAuthorityLocked(op.account, op.userId, op.authority,
885894
"deleteFromPending");
886895
if (authority != null) {
887-
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "removing - " + authority);
896+
if (DEBUG) Log.v(TAG, "removing - " + authority);
888897
final int N = mPendingOperations.size();
889898
boolean morePending = false;
890899
for (int i=0; i<N; i++) {
@@ -898,7 +907,7 @@ public boolean deleteFromPending(PendingOperation op) {
898907
}
899908

900909
if (!morePending) {
901-
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "no more pending!");
910+
if (DEBUG) Log.v(TAG, "no more pending!");
902911
SyncStatusInfo status = getOrCreateSyncStatusLocked(authority.ident);
903912
status.pending = false;
904913
}
@@ -938,16 +947,16 @@ public int getPendingOperationCount() {
938947
*/
939948
public void doDatabaseCleanup(Account[] accounts, int userId) {
940949
synchronized (mAuthorities) {
941-
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.w(TAG, "Updating for new accounts...");
950+
if (DEBUG) Log.v(TAG, "Updating for new accounts...");
942951
SparseArray<AuthorityInfo> removing = new SparseArray<AuthorityInfo>();
943952
Iterator<AccountInfo> accIt = mAccounts.values().iterator();
944953
while (accIt.hasNext()) {
945954
AccountInfo acc = accIt.next();
946955
if (!ArrayUtils.contains(accounts, acc.accountAndUser.account)
947956
&& acc.accountAndUser.userId == userId) {
948957
// This account no longer exists...
949-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
950-
Log.w(TAG, "Account removed: " + acc.accountAndUser);
958+
if (DEBUG) {
959+
Log.v(TAG, "Account removed: " + acc.accountAndUser);
951960
}
952961
for (AuthorityInfo auth : acc.authorities.values()) {
953962
removing.put(auth.ident, auth);
@@ -993,7 +1002,7 @@ public void doDatabaseCleanup(Account[] accounts, int userId) {
9931002
public SyncInfo addActiveSync(SyncManager.ActiveSyncContext activeSyncContext) {
9941003
final SyncInfo syncInfo;
9951004
synchronized (mAuthorities) {
996-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1005+
if (DEBUG) {
9971006
Log.v(TAG, "setActiveSync: account="
9981007
+ activeSyncContext.mSyncOperation.account
9991008
+ " auth=" + activeSyncContext.mSyncOperation.authority
@@ -1021,7 +1030,7 @@ public SyncInfo addActiveSync(SyncManager.ActiveSyncContext activeSyncContext) {
10211030
*/
10221031
public void removeActiveSync(SyncInfo syncInfo, int userId) {
10231032
synchronized (mAuthorities) {
1024-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1033+
if (DEBUG) {
10251034
Log.v(TAG, "removeActiveSync: account=" + syncInfo.account
10261035
+ " user=" + userId
10271036
+ " auth=" + syncInfo.authority);
@@ -1046,7 +1055,7 @@ public long insertStartSyncEvent(Account accountName, int userId, String authori
10461055
long now, int source, boolean initialization) {
10471056
long id;
10481057
synchronized (mAuthorities) {
1049-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1058+
if (DEBUG) {
10501059
Log.v(TAG, "insertStartSyncEvent: account=" + accountName + "user=" + userId
10511060
+ " auth=" + authorityName + " source=" + source);
10521061
}
@@ -1068,7 +1077,7 @@ public long insertStartSyncEvent(Account accountName, int userId, String authori
10681077
mSyncHistory.remove(mSyncHistory.size()-1);
10691078
}
10701079
id = item.historyId;
1071-
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "returning historyId " + id);
1080+
if (DEBUG) Log.v(TAG, "returning historyId " + id);
10721081
}
10731082

10741083
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_STATUS);
@@ -1096,7 +1105,7 @@ public static boolean equals(Bundle b1, Bundle b2) {
10961105
public void stopSyncEvent(long historyId, long elapsedTime, String resultMessage,
10971106
long downstreamActivity, long upstreamActivity) {
10981107
synchronized (mAuthorities) {
1099-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1108+
if (DEBUG) {
11001109
Log.v(TAG, "stopSyncEvent: historyId=" + historyId);
11011110
}
11021111
SyncHistoryItem item = null;
@@ -1358,7 +1367,7 @@ private AuthorityInfo getAuthorityLocked(Account accountName, int userId, String
13581367
AccountInfo accountInfo = mAccounts.get(au);
13591368
if (accountInfo == null) {
13601369
if (tag != null) {
1361-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1370+
if (DEBUG) {
13621371
Log.v(TAG, tag + ": unknown account " + au);
13631372
}
13641373
}
@@ -1367,7 +1376,7 @@ private AuthorityInfo getAuthorityLocked(Account accountName, int userId, String
13671376
AuthorityInfo authority = accountInfo.authorities.get(authorityName);
13681377
if (authority == null) {
13691378
if (tag != null) {
1370-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1379+
if (DEBUG) {
13711380
Log.v(TAG, tag + ": unknown authority " + authorityName);
13721381
}
13731382
}
@@ -1392,7 +1401,7 @@ private AuthorityInfo getOrCreateAuthorityLocked(Account accountName, int userId
13921401
mNextAuthorityId++;
13931402
doWrite = true;
13941403
}
1395-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
1404+
if (DEBUG) {
13961405
Log.v(TAG, "created a new AuthorityInfo for " + accountName
13971406
+ ", user " + userId
13981407
+ ", provider " + authorityName);

core/java/android/content/pm/RegisteredServicesCache.java

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
*/
7070
public abstract class RegisteredServicesCache<V> {
7171
private static final String TAG = "PackageManager";
72+
private static final boolean DEBUG = false;
7273

7374
public final Context mContext;
7475
private final String mInterfaceName;
@@ -195,7 +196,7 @@ public void setListener(RegisteredServicesCacheListener<V> listener, Handler han
195196
}
196197

197198
private void notifyListener(final V type, final int userId, final boolean removed) {
198-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
199+
if (DEBUG) {
199200
Log.d(TAG, "notifyListener: " + type + " is " + (removed ? "removed" : "added"));
200201
}
201202
RegisteredServicesCacheListener<V> listener;
@@ -291,7 +292,9 @@ private boolean inSystemImage(int callerUid) {
291292
* given {@link UserHandle}.
292293
*/
293294
private void generateServicesMap(int userId) {
294-
Slog.d(TAG, "generateServicesMap() for " + userId);
295+
if (DEBUG) {
296+
Slog.d(TAG, "generateServicesMap() for " + userId);
297+
}
295298

296299
final PackageManager pm = mContext.getPackageManager();
297300
final ArrayList<ServiceInfo<V>> serviceInfos = new ArrayList<ServiceInfo<V>>();
@@ -322,6 +325,7 @@ private void generateServicesMap(int userId) {
322325
}
323326

324327
StringBuilder changes = new StringBuilder();
328+
boolean changed = false;
325329
for (ServiceInfo<V> info : serviceInfos) {
326330
// four cases:
327331
// - doesn't exist yet
@@ -334,33 +338,41 @@ private void generateServicesMap(int userId) {
334338
// - add, notify user that it was added
335339
Integer previousUid = user.persistentServices.get(info.type);
336340
if (previousUid == null) {
337-
changes.append(" New service added: ").append(info).append("\n");
341+
if (DEBUG) {
342+
changes.append(" New service added: ").append(info).append("\n");
343+
}
344+
changed = true;
338345
user.services.put(info.type, info);
339346
user.persistentServices.put(info.type, info.uid);
340347
if (!(mPersistentServicesFileDidNotExist && firstScan)) {
341348
notifyListener(info.type, userId, false /* removed */);
342349
}
343350
} else if (previousUid == info.uid) {
344-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
351+
if (DEBUG) {
345352
changes.append(" Existing service (nop): ").append(info).append("\n");
346353
}
347354
user.services.put(info.type, info);
348355
} else if (inSystemImage(info.uid)
349356
|| !containsTypeAndUid(serviceInfos, info.type, previousUid)) {
350-
if (inSystemImage(info.uid)) {
351-
changes.append(" System service replacing existing: ").append(info)
352-
.append("\n");
353-
} else {
354-
changes.append(" Existing service replacing a removed service: ")
355-
.append(info).append("\n");
357+
if (DEBUG) {
358+
if (inSystemImage(info.uid)) {
359+
changes.append(" System service replacing existing: ").append(info)
360+
.append("\n");
361+
} else {
362+
changes.append(" Existing service replacing a removed service: ")
363+
.append(info).append("\n");
364+
}
356365
}
366+
changed = true;
357367
user.services.put(info.type, info);
358368
user.persistentServices.put(info.type, info.uid);
359369
notifyListener(info.type, userId, false /* removed */);
360370
} else {
361371
// ignore
362-
changes.append(" Existing service with new uid ignored: ").append(info)
363-
.append("\n");
372+
if (DEBUG) {
373+
changes.append(" Existing service with new uid ignored: ").append(info)
374+
.append("\n");
375+
}
364376
}
365377
}
366378

@@ -371,22 +383,25 @@ private void generateServicesMap(int userId) {
371383
}
372384
}
373385
for (V v1 : toBeRemoved) {
386+
if (DEBUG) {
387+
changes.append(" Service removed: ").append(v1).append("\n");
388+
}
389+
changed = true;
374390
user.persistentServices.remove(v1);
375-
changes.append(" Service removed: ").append(v1).append("\n");
376391
notifyListener(v1, userId, true /* removed */);
377392
}
378-
if (changes.length() > 0) {
379-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
393+
if (DEBUG) {
394+
if (changes.length() > 0) {
380395
Log.d(TAG, "generateServicesMap(" + mInterfaceName + "): " +
381396
serviceInfos.size() + " services:\n" + changes);
382-
}
383-
writePersistentServicesLocked();
384-
} else {
385-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
397+
} else {
386398
Log.d(TAG, "generateServicesMap(" + mInterfaceName + "): " +
387399
serviceInfos.size() + " services unchanged");
388400
}
389401
}
402+
if (changed) {
403+
writePersistentServicesLocked();
404+
}
390405
}
391406
}
392407

core/java/android/server/search/SearchManagerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private Searchables getSearchables(int userId) {
9292
Searchables searchables = mSearchables.get(userId);
9393

9494
if (searchables == null) {
95-
Log.i(TAG, "Building list of searchable activities for userId=" + userId);
95+
//Log.i(TAG, "Building list of searchable activities for userId=" + userId);
9696
searchables = new Searchables(mContext, userId);
9797
searchables.buildSearchableList();
9898
mSearchables.append(userId, searchables);

0 commit comments

Comments
 (0)