summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/BootReceiver.java28
-rw-r--r--services/java/com/android/server/IntentResolver.java19
-rw-r--r--services/java/com/android/server/LocationManagerService.java5
-rw-r--r--services/java/com/android/server/am/ActiveServices.java30
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java33
-rw-r--r--services/java/com/android/server/am/ActivityStackSupervisor.java8
-rw-r--r--services/java/com/android/server/am/AppNotRespondingDialog.java1
-rw-r--r--services/java/com/android/server/am/ProcessStatsService.java4
-rw-r--r--services/java/com/android/server/am/ServiceRecord.java1
-rw-r--r--services/java/com/android/server/content/SyncManager.java4
-rw-r--r--services/java/com/android/server/content/SyncStorageEngine.java41
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java62
-rw-r--r--services/java/com/android/server/pm/PreferredActivity.java6
-rw-r--r--services/java/com/android/server/wifi/WifiService.java38
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java4
15 files changed, 169 insertions, 115 deletions
diff --git a/services/java/com/android/server/BootReceiver.java b/services/java/com/android/server/BootReceiver.java
index 3dade37..da1b254 100644
--- a/services/java/com/android/server/BootReceiver.java
+++ b/services/java/com/android/server/BootReceiver.java
@@ -127,6 +127,7 @@ public class BootReceiver extends BroadcastReceiver {
addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_threads",
-LOG_SIZE, "APANIC_THREADS");
addAuditErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_AUDIT");
+ addFsckErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_FSCK");
} else {
if (db != null) db.addText("SYSTEM_RESTART", headers);
}
@@ -203,4 +204,31 @@ public class BootReceiver extends BroadcastReceiver {
Slog.i(TAG, "Copied " + sb.toString().length() + " worth of audits to DropBox");
db.addText(tag, headers + sb.toString());
}
+
+ private static void addFsckErrorsToDropBox(DropBoxManager db, SharedPreferences prefs,
+ String headers, int maxSize, String tag) throws IOException {
+ boolean upload_needed = false;
+ if (db == null || !db.isTagEnabled(tag)) return; // Logging disabled
+ Slog.i(TAG, "Checking for fsck errors");
+
+ File file = new File("/dev/fscklogs/log");
+ long fileTime = file.lastModified();
+ if (fileTime <= 0) return; // File does not exist
+
+ String log = FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n");
+ StringBuilder sb = new StringBuilder();
+ for (String line : log.split("\n")) {
+ if (line.contains("FILE SYSTEM WAS MODIFIED")) {
+ upload_needed = true;
+ break;
+ }
+ }
+
+ if (upload_needed) {
+ addFileToDropBox(db, prefs, headers, "/dev/fscklogs/log", maxSize, tag);
+ }
+
+ // Remove the file so we don't re-upload if the runtime restarts.
+ file.delete();
+ }
}
diff --git a/services/java/com/android/server/IntentResolver.java b/services/java/com/android/server/IntentResolver.java
index 3a35f3f..54aa50c 100644
--- a/services/java/com/android/server/IntentResolver.java
+++ b/services/java/com/android/server/IntentResolver.java
@@ -18,6 +18,7 @@ package com.android.server;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
@@ -248,26 +249,28 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> {
// Not a wild card, so we can just look for all filters that
// completely match or wildcards whose base type matches.
firstTypeCut = mTypeToFilter.get(resolvedType);
- if (debug) Slog.v(TAG, "First type cut: " + firstTypeCut);
+ if (debug) Slog.v(TAG, "First type cut: " + Arrays.toString(firstTypeCut));
secondTypeCut = mWildTypeToFilter.get(baseType);
- if (debug) Slog.v(TAG, "Second type cut: " + secondTypeCut);
+ if (debug) Slog.v(TAG, "Second type cut: "
+ + Arrays.toString(secondTypeCut));
} else {
// We can match anything with our base type.
firstTypeCut = mBaseTypeToFilter.get(baseType);
- if (debug) Slog.v(TAG, "First type cut: " + firstTypeCut);
+ if (debug) Slog.v(TAG, "First type cut: " + Arrays.toString(firstTypeCut));
secondTypeCut = mWildTypeToFilter.get(baseType);
- if (debug) Slog.v(TAG, "Second type cut: " + secondTypeCut);
+ if (debug) Slog.v(TAG, "Second type cut: "
+ + Arrays.toString(secondTypeCut));
}
// Any */* types always apply, but we only need to do this
// if the intent type was not already */*.
thirdTypeCut = mWildTypeToFilter.get("*");
- if (debug) Slog.v(TAG, "Third type cut: " + thirdTypeCut);
+ if (debug) Slog.v(TAG, "Third type cut: " + Arrays.toString(thirdTypeCut));
} else if (intent.getAction() != null) {
// The intent specified any type ({@literal *}/*). This
// can be a whole heck of a lot of things, so as a first
// cut let's use the action instead.
firstTypeCut = mTypedActionToFilter.get(intent.getAction());
- if (debug) Slog.v(TAG, "Typed Action list: " + firstTypeCut);
+ if (debug) Slog.v(TAG, "Typed Action list: " + Arrays.toString(firstTypeCut));
}
}
}
@@ -277,7 +280,7 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> {
// on the authority and path by directly matching each resulting filter).
if (scheme != null) {
schemeCut = mSchemeToFilter.get(scheme);
- if (debug) Slog.v(TAG, "Scheme list: " + schemeCut);
+ if (debug) Slog.v(TAG, "Scheme list: " + Arrays.toString(schemeCut));
}
// If the intent does not specify any data -- either a MIME type or
@@ -285,7 +288,7 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> {
// data.
if (resolvedType == null && scheme == null && intent.getAction() != null) {
firstTypeCut = mActionToFilter.get(intent.getAction());
- if (debug) Slog.v(TAG, "Action list: " + firstTypeCut);
+ if (debug) Slog.v(TAG, "Action list: " + Arrays.toString(firstTypeCut));
}
FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index b6ccce7..3e8770e 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -223,8 +223,9 @@ public class LocationManagerService extends ILocationManager.Stub {
mGeofenceManager = new GeofenceManager(mContext, mBlacklist);
// Monitor for app ops mode changes.
- AppOpsManager.Callback callback = new AppOpsManager.Callback() {
- public void opChanged(int op, String packageName) {
+ AppOpsManager.OnOpChangedListener callback
+ = new AppOpsManager.OnOpChangedInternalListener() {
+ public void onOpChanged(int op, String packageName) {
synchronized (mLock) {
for (Receiver receiver : mReceivers.values()) {
receiver.updateMonitoring(true);
diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java
index 4379c70..fa1769f 100644
--- a/services/java/com/android/server/am/ActiveServices.java
+++ b/services/java/com/android/server/am/ActiveServices.java
@@ -1009,23 +1009,15 @@ public final class ActiveServices {
stracker.setExecuting(true, mAm.mProcessStats.getMemFactorLocked(), now);
}
if (r.app != null) {
- if (r.app.executingServices.size() == 0) {
- Message msg = mAm.mHandler.obtainMessage(
- ActivityManagerService.SERVICE_TIMEOUT_MSG);
- msg.obj = r.app;
- mAm.mHandler.sendMessageAtTime(msg,
- fg ? (now+SERVICE_TIMEOUT) : (now+ SERVICE_BACKGROUND_TIMEOUT));
- }
r.app.executingServices.add(r);
r.app.execServicesFg |= fg;
+ if (r.app.executingServices.size() == 1) {
+ scheduleServiceTimeoutLocked(r.app);
+ }
}
} else if (r.app != null && fg && !r.app.execServicesFg) {
- mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_TIMEOUT_MSG);
- Message msg = mAm.mHandler.obtainMessage(
- ActivityManagerService.SERVICE_TIMEOUT_MSG);
- msg.obj = r.app;
- mAm.mHandler.sendMessageAtTime(msg,now+SERVICE_TIMEOUT);
r.app.execServicesFg = true;
+ scheduleServiceTimeoutLocked(r.app);
}
r.executeFg |= fg;
r.executeNesting++;
@@ -2144,7 +2136,7 @@ public final class ActiveServices {
ActivityManagerService.SERVICE_TIMEOUT_MSG);
msg.obj = proc;
mAm.mHandler.sendMessageAtTime(msg, proc.execServicesFg
- ? (nextTime+SERVICE_TIMEOUT) : (nextTime+ SERVICE_BACKGROUND_TIMEOUT));
+ ? (nextTime+SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
}
}
@@ -2153,6 +2145,18 @@ public final class ActiveServices {
}
}
+ void scheduleServiceTimeoutLocked(ProcessRecord proc) {
+ if (proc.executingServices.size() == 0 || proc.thread == null) {
+ return;
+ }
+ long now = SystemClock.uptimeMillis();
+ Message msg = mAm.mHandler.obtainMessage(
+ ActivityManagerService.SERVICE_TIMEOUT_MSG);
+ msg.obj = proc;
+ mAm.mHandler.sendMessageAtTime(msg,
+ proc.execServicesFg ? (now+SERVICE_TIMEOUT) : (now+ SERVICE_BACKGROUND_TIMEOUT));
+ }
+
/**
* Prints a list of ServiceRecords (dumpsys activity services)
*/
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 47297c0..808bf88 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2230,7 +2230,8 @@ public final class ActivityManagerService extends ActivityManagerNative
mHandler.sendMessage(msg);
}
- private final int updateLruProcessInternalLocked(ProcessRecord app, long now, int index) {
+ private final int updateLruProcessInternalLocked(ProcessRecord app, long now, int index,
+ String what, Object obj, ProcessRecord srcApp) {
app.lastActivityTime = now;
if (app.activities.size() > 0) {
@@ -2240,8 +2241,9 @@ public final class ActivityManagerService extends ActivityManagerNative
int lrui = mLruProcesses.lastIndexOf(app);
if (lrui < 0) {
- throw new IllegalStateException("Adding dependent process " + app
- + " not on LRU list!");
+ Log.wtf(TAG, "Adding dependent process " + app + " not on LRU list: "
+ + what + " " + obj + " from " + srcApp);
+ return index;
}
if (lrui >= mLruProcessActivityStart) {
@@ -2306,16 +2308,18 @@ public final class ActivityManagerService extends ActivityManagerNative
// bump those processes as well.
for (int j=app.connections.size()-1; j>=0; j--) {
ConnectionRecord cr = app.connections.valueAt(j);
- if (cr.binding != null && cr.binding.service != null
+ if (cr.binding != null && !cr.serviceDead && cr.binding.service != null
&& cr.binding.service.app != null
&& cr.binding.service.app.lruSeq != mLruSeq) {
- nextIndex = updateLruProcessInternalLocked(cr.binding.service.app, now, nextIndex);
+ nextIndex = updateLruProcessInternalLocked(cr.binding.service.app, now, nextIndex,
+ "service connection", cr, app);
}
}
for (int j=app.conProviders.size()-1; j>=0; j--) {
ContentProviderRecord cpr = app.conProviders.get(j).provider;
if (cpr.proc != null && cpr.proc.lruSeq != mLruSeq) {
- nextIndex = updateLruProcessInternalLocked(cpr.proc, now, nextIndex);
+ nextIndex = updateLruProcessInternalLocked(cpr.proc, now, nextIndex,
+ "provider reference", cpr, app);
}
}
@@ -3025,6 +3029,8 @@ public final class ActivityManagerService extends ActivityManagerNative
// And we are resetting to find the next component...
intent.setComponent(null);
+ final boolean debug = ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
+
ActivityInfo aInfo = null;
try {
List<ResolveInfo> resolves =
@@ -3045,6 +3051,12 @@ public final class ActivityManagerService extends ActivityManagerNative
if (i<N) {
aInfo = resolves.get(i).activityInfo;
}
+ if (debug) {
+ Slog.v(TAG, "Next matching activity: found current " + r.packageName
+ + "/" + r.info.name);
+ Slog.v(TAG, "Next matching activity: next is " + aInfo.packageName
+ + "/" + aInfo.name);
+ }
break;
}
}
@@ -3054,6 +3066,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (aInfo == null) {
// Nobody who is next!
ActivityOptions.abort(options);
+ if (debug) Slog.d(TAG, "Next matching activity: nothing found");
return false;
}
@@ -3863,7 +3876,13 @@ public final class ActivityManagerService extends ActivityManagerNative
// 0 == show dialog, 1 = keep waiting, -1 = kill process immediately
int res = mController.appNotResponding(app.processName, app.pid, info.toString());
if (res != 0) {
- if (res < 0 && app.pid != MY_PID) Process.killProcess(app.pid);
+ if (res < 0 && app.pid != MY_PID) {
+ Process.killProcess(app.pid);
+ } else {
+ synchronized (this) {
+ mServices.scheduleServiceTimeoutLocked(app);
+ }
+ }
return;
}
} catch (RemoteException e) {
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 9549e0a..4c65a8a 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -1246,8 +1246,9 @@ public final class ActivityStackSupervisor {
mService.doPendingActivityLaunchesLocked(false);
err = startActivityUncheckedLocked(r, sourceRecord, startFlags, true, options);
- if (stack.mPausingActivity == null) {
- // Someone asked to have the keyguard dismissed on the next
+
+ if (allPausedActivitiesComplete()) {
+ // If someone asked to have the keyguard dismissed on the next
// activity start, but we are not actually doing an activity
// switch... just dismiss the keyguard now, because we
// probably want to see whatever is behind it.
@@ -2150,9 +2151,6 @@ public final class ActivityStackSupervisor {
for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = mStacks.get(stackNdx);
stack.awakeFromSleepingLocked();
- if (isFrontStack(stack)) {
- resumeTopActivitiesLocked();
- }
}
mGoingToSleepActivities.clear();
}
diff --git a/services/java/com/android/server/am/AppNotRespondingDialog.java b/services/java/com/android/server/am/AppNotRespondingDialog.java
index b5e0715..d0a0441 100644
--- a/services/java/com/android/server/am/AppNotRespondingDialog.java
+++ b/services/java/com/android/server/am/AppNotRespondingDialog.java
@@ -128,6 +128,7 @@ final class AppNotRespondingDialog extends BaseErrorDialog {
if (app.anrDialog == AppNotRespondingDialog.this) {
app.anrDialog = null;
}
+ mService.mServices.scheduleServiceTimeoutLocked(app);
}
break;
}
diff --git a/services/java/com/android/server/am/ProcessStatsService.java b/services/java/com/android/server/am/ProcessStatsService.java
index 0a1685c..be08973 100644
--- a/services/java/com/android/server/am/ProcessStatsService.java
+++ b/services/java/com/android/server/am/ProcessStatsService.java
@@ -56,12 +56,12 @@ public final class ProcessStatsService extends IProcessStats.Stub {
// exists in and the offset into the array to find it. The constants below
// define the encoding of that data in an integer.
- static final int MAX_HISTORIC_STATES = 6; // Maximum number of historic states we will keep.
+ static final int MAX_HISTORIC_STATES = 8; // Maximum number of historic states we will keep.
static final String STATE_FILE_PREFIX = "state-"; // Prefix to use for state filenames.
static final String STATE_FILE_SUFFIX = ".bin"; // Suffix to use for state filenames.
static final String STATE_FILE_CHECKIN_SUFFIX = ".ci"; // State files that have checked in.
static long WRITE_PERIOD = 30*60*1000; // Write file every 30 minutes or so.
- static long COMMIT_PERIOD = 12*60*60*1000; // Commit current stats every 12 hours.
+ static long COMMIT_PERIOD = 3*60*60*1000; // Commit current stats every 3 hours.
final ActivityManagerService mAm;
final File mBaseDir;
diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java
index 448117e..ac14da9 100644
--- a/services/java/com/android/server/am/ServiceRecord.java
+++ b/services/java/com/android/server/am/ServiceRecord.java
@@ -253,6 +253,7 @@ final class ServiceRecord extends Binder {
pw.print(" executeFg="); pw.print(executeFg);
pw.print(" executingStart=");
TimeUtils.formatDuration(executingStart, now, pw);
+ pw.println();
}
if (crashCount != 0 || restartCount != 0
|| restartDelay != 0 || nextRestartTime != 0) {
diff --git a/services/java/com/android/server/content/SyncManager.java b/services/java/com/android/server/content/SyncManager.java
index 9a41166..635ba5c 100644
--- a/services/java/com/android/server/content/SyncManager.java
+++ b/services/java/com/android/server/content/SyncManager.java
@@ -315,7 +315,9 @@ public class SyncManager {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Reconnection detected: clearing all backoffs");
}
- mSyncStorageEngine.clearAllBackoffs(mSyncQueue);
+ synchronized(mSyncQueue) {
+ mSyncStorageEngine.clearAllBackoffsLocked(mSyncQueue);
+ }
}
sendCheckAlarmsMessage();
}
diff --git a/services/java/com/android/server/content/SyncStorageEngine.java b/services/java/com/android/server/content/SyncStorageEngine.java
index 1b9ed98..d51c2d7 100644
--- a/services/java/com/android/server/content/SyncStorageEngine.java
+++ b/services/java/com/android/server/content/SyncStorageEngine.java
@@ -710,28 +710,31 @@ public class SyncStorageEngine extends Handler {
}
}
- public void clearAllBackoffs(SyncQueue syncQueue) {
+ /**
+ * Callers of this function need to hold a lock for syncQueue object passed in. Bear in mind
+ * this function grabs the lock for {@link #mAuthorities}
+ * @param syncQueue queue containing pending sync operations.
+ */
+ public void clearAllBackoffsLocked(SyncQueue syncQueue) {
boolean changed = false;
synchronized (mAuthorities) {
- synchronized (syncQueue) {
- for (AccountInfo accountInfo : mAccounts.values()) {
- for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
- if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
- || authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
- if (DEBUG) {
- Log.v(TAG, "clearAllBackoffs:"
- + " authority:" + authorityInfo.authority
- + " account:" + accountInfo.accountAndUser.account.name
- + " user:" + accountInfo.accountAndUser.userId
- + " backoffTime was: " + authorityInfo.backoffTime
- + " backoffDelay was: " + authorityInfo.backoffDelay);
- }
- authorityInfo.backoffTime = NOT_IN_BACKOFF_MODE;
- authorityInfo.backoffDelay = NOT_IN_BACKOFF_MODE;
- syncQueue.onBackoffChanged(accountInfo.accountAndUser.account,
- accountInfo.accountAndUser.userId, authorityInfo.authority, 0);
- changed = true;
+ for (AccountInfo accountInfo : mAccounts.values()) {
+ for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
+ if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
+ || authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
+ if (DEBUG) {
+ Log.v(TAG, "clearAllBackoffs:"
+ + " authority:" + authorityInfo.authority
+ + " account:" + accountInfo.accountAndUser.account.name
+ + " user:" + accountInfo.accountAndUser.userId
+ + " backoffTime was: " + authorityInfo.backoffTime
+ + " backoffDelay was: " + authorityInfo.backoffDelay);
}
+ authorityInfo.backoffTime = NOT_IN_BACKOFF_MODE;
+ authorityInfo.backoffDelay = NOT_IN_BACKOFF_MODE;
+ syncQueue.onBackoffChanged(accountInfo.accountAndUser.account,
+ accountInfo.accountAndUser.userId, authorityInfo.authority, 0);
+ changed = true;
}
}
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index d1ca35e..f221598 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -2616,7 +2616,7 @@ public class PackageManagerService extends IPackageManager.Stub {
List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId);
// Find any earlier preferred or last chosen entries and nuke them
findPreferredActivity(intent, resolvedType,
- flags, query, 0, false, true, userId);
+ flags, query, 0, false, true, false, userId);
// Add the new activity as the last chosen for this filter
addPreferredActivityInternal(filter, match, null, activity, false, userId);
}
@@ -2627,7 +2627,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (DEBUG_PREFERRED) Log.v(TAG, "Querying last chosen activity for " + intent);
List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags, userId);
return findPreferredActivity(intent, resolvedType, flags, query, 0,
- false, false, userId);
+ false, false, false, userId);
}
private ResolveInfo chooseBestActivity(Intent intent, String resolvedType,
@@ -2637,12 +2637,13 @@ public class PackageManagerService extends IPackageManager.Stub {
if (N == 1) {
return query.get(0);
} else if (N > 1) {
+ final boolean debug = ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
// If there is more than one activity with the same priority,
// then let the user decide between them.
ResolveInfo r0 = query.get(0);
ResolveInfo r1 = query.get(1);
- if (DEBUG_INTENT_MATCHING) {
- Log.d(TAG, r0.activityInfo.name + "=" + r0.priority + " vs "
+ if (DEBUG_INTENT_MATCHING || debug) {
+ Slog.v(TAG, r0.activityInfo.name + "=" + r0.priority + " vs "
+ r1.activityInfo.name + "=" + r1.priority);
}
// If the first activity has a higher priority, or a different
@@ -2655,7 +2656,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// If we have saved a preference for a preferred activity for
// this Intent, use that.
ResolveInfo ri = findPreferredActivity(intent, resolvedType,
- flags, query, r0.priority, true, false, userId);
+ flags, query, r0.priority, true, false, debug, userId);
if (ri != null) {
return ri;
}
@@ -2676,7 +2677,7 @@ public class PackageManagerService extends IPackageManager.Stub {
ResolveInfo findPreferredActivity(Intent intent, String resolvedType, int flags,
List<ResolveInfo> query, int priority, boolean always,
- boolean removeMatches, int userId) {
+ boolean removeMatches, boolean debug, int userId) {
if (!sUserManager.exists(userId)) return null;
// writer
synchronized (mPackages) {
@@ -2686,6 +2687,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (DEBUG_PREFERRED) intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
PreferredIntentResolver pir = mSettings.mPreferredActivities.get(userId);
// Get the list of preferred activities that handle the intent
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Looking for preferred activities...");
List<PreferredActivity> prefs = pir != null
? pir.queryIntent(intent, resolvedType,
(flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId)
@@ -2696,59 +2698,50 @@ public class PackageManagerService extends IPackageManager.Stub {
// from the same match quality.
int match = 0;
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Figuring out best match...");
- }
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Figuring out best match...");
final int N = query.size();
for (int j=0; j<N; j++) {
final ResolveInfo ri = query.get(j);
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Match for " + ri.activityInfo + ": 0x"
- + Integer.toHexString(match));
- }
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Match for " + ri.activityInfo
+ + ": 0x" + Integer.toHexString(match));
if (ri.match > match) {
match = ri.match;
}
}
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Best match: 0x" + Integer.toHexString(match));
- }
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Best match: 0x"
+ + Integer.toHexString(match));
match &= IntentFilter.MATCH_CATEGORY_MASK;
final int M = prefs.size();
for (int i=0; i<M; i++) {
final PreferredActivity pa = prefs.get(i);
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Checking PreferredActivity ds="
+ if (DEBUG_PREFERRED || debug) {
+ Slog.v(TAG, "Checking PreferredActivity ds="
+ (pa.countDataSchemes() > 0 ? pa.getDataScheme(0) : "<none>")
+ "\n component=" + pa.mPref.mComponent);
- pa.dump(new PrintStreamPrinter(System.out), " ");
+ pa.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), " ");
}
if (pa.mPref.mMatch != match) {
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Skipping bad match "
- + Integer.toHexString(pa.mPref.mMatch));
- }
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Skipping bad match "
+ + Integer.toHexString(pa.mPref.mMatch));
continue;
}
// If it's not an "always" type preferred activity and that's what we're
// looking for, skip it.
if (always && !pa.mPref.mAlways) {
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Skipping lastChosen entry");
- }
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Skipping mAlways=false entry");
continue;
}
final ActivityInfo ai = getActivityInfo(pa.mPref.mComponent,
flags | PackageManager.GET_DISABLED_COMPONENTS, userId);
- if (DEBUG_PREFERRED) {
- Log.v(TAG, "Got preferred activity:");
+ if (DEBUG_PREFERRED || debug) {
+ Slog.v(TAG, "Found preferred activity:");
if (ai != null) {
- ai.dump(new LogPrinter(Log.VERBOSE, TAG), " ");
+ ai.dump(new LogPrinter(Log.VERBOSE, TAG, Log.LOG_ID_SYSTEM), " ");
} else {
- Log.v(TAG, " null");
+ Slog.v(TAG, " null");
}
}
if (ai == null) {
@@ -2775,7 +2768,7 @@ public class PackageManagerService extends IPackageManager.Stub {
if (removeMatches) {
pir.removeFilter(pa);
if (DEBUG_PREFERRED) {
- Log.v(TAG, "Removing match " + pa.mPref.mComponent);
+ Slog.v(TAG, "Removing match " + pa.mPref.mComponent);
}
break;
}
@@ -2788,7 +2781,7 @@ public class PackageManagerService extends IPackageManager.Stub {
Slog.i(TAG, "Result set changed, dropping preferred activity for "
+ intent + " type " + resolvedType);
if (DEBUG_PREFERRED) {
- Log.v(TAG, "Removing preferred activity since set changed "
+ Slog.v(TAG, "Removing preferred activity since set changed "
+ pa.mPref.mComponent);
}
pir.removeFilter(pa);
@@ -2801,6 +2794,8 @@ public class PackageManagerService extends IPackageManager.Stub {
}
// Yay! Either the set matched or we're looking for the last chosen
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "Returning preferred activity: "
+ + ri.activityInfo.packageName + "/" + ri.activityInfo.name);
mSettings.writePackageRestrictionsLPr(userId);
return ri;
}
@@ -2808,6 +2803,7 @@ public class PackageManagerService extends IPackageManager.Stub {
}
mSettings.writePackageRestrictionsLPr(userId);
}
+ if (DEBUG_PREFERRED || debug) Slog.v(TAG, "No preferred activity to return");
return null;
}
@@ -9886,7 +9882,7 @@ public class PackageManagerService extends IPackageManager.Stub {
List<ResolveInfo> list = queryIntentActivities(intent, null,
PackageManager.GET_META_DATA, callingUserId);
ResolveInfo preferred = findPreferredActivity(intent, null, 0, list, 0,
- true, false, callingUserId);
+ true, false, false, callingUserId);
allHomeCandidates.clear();
if (list != null) {
diff --git a/services/java/com/android/server/pm/PreferredActivity.java b/services/java/com/android/server/pm/PreferredActivity.java
index 963cbe4..f93ba2f 100644
--- a/services/java/com/android/server/pm/PreferredActivity.java
+++ b/services/java/com/android/server/pm/PreferredActivity.java
@@ -71,4 +71,10 @@ class PreferredActivity extends IntentFilter implements PreferredComponent.Callb
}
return true;
}
+
+ @Override
+ public String toString() {
+ return "PreferredActivity{0x" + Integer.toHexString(System.identityHashCode(this))
+ + " " + mPref.mComponent.flattenToShortString() + "}";
+ }
}
diff --git a/services/java/com/android/server/wifi/WifiService.java b/services/java/com/android/server/wifi/WifiService.java
index a604d3f..f93a45b 100644
--- a/services/java/com/android/server/wifi/WifiService.java
+++ b/services/java/com/android/server/wifi/WifiService.java
@@ -455,9 +455,7 @@ public final class WifiService extends IWifiManager.Stub {
private void resolveBatchedScannersLocked() {
BatchedScanSettings setting = new BatchedScanSettings();
- setting.scanIntervalSec = BatchedScanSettings.DEFAULT_INTERVAL_SEC;
int responsibleUid = 0;
- setting.channelSet = new ArrayList<String>();
if (mBatchedScanners.size() == 0) {
mWifiStateMachine.setBatchedScanSettings(null, 0);
@@ -472,7 +470,7 @@ public final class WifiService extends IWifiManager.Stub {
}
if (s.maxApPerScan != BatchedScanSettings.UNSPECIFIED &&
(setting.maxApPerScan == BatchedScanSettings.UNSPECIFIED ||
- s.maxApPerScan > setting.maxApPerScan)) {
+ s.maxApPerScan > setting.maxApPerScan)) {
setting.maxApPerScan = s.maxApPerScan;
}
if (s.scanIntervalSec != BatchedScanSettings.UNSPECIFIED &&
@@ -481,31 +479,25 @@ public final class WifiService extends IWifiManager.Stub {
responsibleUid = r.uid;
}
if (s.maxApForDistance != BatchedScanSettings.UNSPECIFIED &&
- s.maxApForDistance > setting.maxApForDistance) {
+ (setting.maxApForDistance == BatchedScanSettings.UNSPECIFIED ||
+ s.maxApForDistance > setting.maxApForDistance)) {
setting.maxApForDistance = s.maxApForDistance;
}
- if (s.channelSet != null) {
- for (String i : s.channelSet) {
- if (setting.channelSet.contains(i) == false) setting.channelSet.add(i);
+ if (s.channelSet != null && s.channelSet.size() != 0) {
+ if (setting.channelSet == null || setting.channelSet.size() != 0) {
+ if (setting.channelSet == null) setting.channelSet = new ArrayList<String>();
+ for (String i : s.channelSet) {
+ if (setting.channelSet.contains(i) == false) setting.channelSet.add(i);
+ }
+ } // else, ignore the constraint - we already use all channels
+ } else {
+ if (setting.channelSet == null || setting.channelSet.size() != 0) {
+ setting.channelSet = new ArrayList<String>();
}
}
}
- if (setting.channelSet.size() == 0) setting.channelSet = null;
- if (setting.scanIntervalSec < BatchedScanSettings.MIN_INTERVAL_SEC) {
- setting.scanIntervalSec = BatchedScanSettings.MIN_INTERVAL_SEC;
- }
- if (setting.maxScansPerBatch == BatchedScanSettings.UNSPECIFIED) {
- setting.maxScansPerBatch = BatchedScanSettings.DEFAULT_SCANS_PER_BATCH;
- }
- if (setting.maxApPerScan == BatchedScanSettings.UNSPECIFIED) {
- setting.maxApPerScan = BatchedScanSettings.DEFAULT_AP_PER_SCAN;
- }
- if (setting.scanIntervalSec == BatchedScanSettings.UNSPECIFIED) {
- setting.scanIntervalSec = BatchedScanSettings.DEFAULT_INTERVAL_SEC;
- }
- if (setting.maxApForDistance == BatchedScanSettings.UNSPECIFIED) {
- setting.maxApForDistance = BatchedScanSettings.DEFAULT_AP_FOR_DISTANCE;
- }
+
+ setting.constrain();
mWifiStateMachine.setBatchedScanSettings(setting, responsibleUid);
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index d063db5..e4f5c7c 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -754,9 +754,9 @@ public class WindowManagerService extends IWindowManager.Stub
mBatteryStats = BatteryStatsService.getService();
mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
mAppOps.startWatchingMode(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, null,
- new AppOpsManager.Callback() {
+ new AppOpsManager.OnOpChangedInternalListener() {
@Override
- public void opChanged(int op, String packageName) {
+ public void onOpChanged(int op, String packageName) {
updateAppOpsState();
}
}