diff options
91 files changed, 2186 insertions, 2161 deletions
diff --git a/api/current.txt b/api/current.txt index a123620..91e5ddd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -10665,7 +10665,7 @@ package android.location { method public float getAccuracy(); method public double getAltitude(); method public float getBearing(); - method public long getElapsedRealtimeNano(); + method public long getElapsedRealtimeNanos(); method public android.os.Bundle getExtras(); method public double getLatitude(); method public double getLongitude(); @@ -10685,7 +10685,7 @@ package android.location { method public void setAccuracy(float); method public void setAltitude(double); method public void setBearing(float); - method public void setElapsedRealtimeNano(long); + method public void setElapsedRealtimeNanos(long); method public void setExtras(android.os.Bundle); method public void setLatitude(double); method public void setLongitude(double); @@ -12745,14 +12745,12 @@ package android.net { method public static javax.net.ssl.SSLSocketFactory getDefault(int, android.net.SSLSessionCache); method public java.lang.String[] getDefaultCipherSuites(); method public static org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int, android.net.SSLSessionCache); - method public static org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int, int, android.net.SSLSessionCache); method public static javax.net.ssl.SSLSocketFactory getInsecure(int, android.net.SSLSessionCache); method public byte[] getNpnSelectedProtocol(java.net.Socket); method public java.lang.String[] getSupportedCipherSuites(); method public void setHostname(java.net.Socket, java.lang.String); method public void setKeyManagers(javax.net.ssl.KeyManager[]); method public void setNpnProtocols(byte[][]); - method public void setSoWriteTimeout(java.net.Socket, int) throws java.net.SocketException; method public void setTrustManagers(javax.net.ssl.TrustManager[]); method public void setUseSessionTickets(java.net.Socket, boolean); } @@ -16576,7 +16574,7 @@ package android.os { public final class SystemClock { method public static long currentThreadTimeMillis(); method public static long elapsedRealtime(); - method public static long elapsedRealtimeNano(); + method public static long elapsedRealtimeNanos(); method public static boolean setCurrentTimeMillis(long); method public static void sleep(long); method public static long uptimeMillis(); @@ -18919,7 +18917,7 @@ package android.provider { field public static final deprecated java.lang.String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS = "wifi_watchdog_background_check_timeout_ms"; field public static final deprecated java.lang.String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT = "wifi_watchdog_initial_ignored_ping_count"; field public static final deprecated java.lang.String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks"; - field public static final java.lang.String WIFI_WATCHDOG_ON = "wifi_watchdog_on"; + field public static final deprecated java.lang.String WIFI_WATCHDOG_ON = "wifi_watchdog_on"; field public static final deprecated java.lang.String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count"; field public static final deprecated java.lang.String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms"; field public static final deprecated java.lang.String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms"; diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index bc9e74e..396b32f 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -804,8 +804,9 @@ public class Am { ParcelFileDescriptor fd = null; try { - fd = ParcelFileDescriptor.open( - new File(heapFile), + File file = new File(heapFile); + file.delete(); + fd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE | ParcelFileDescriptor.MODE_READ_WRITE); diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 9b08493..9874b0b 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1509,9 +1509,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case DUMP_HEAP_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String process = data.readString(); + int userId = data.readInt(); boolean managed = data.readInt() != 0; String path = data.readString(); - int userId = data.readInt(); ParcelFileDescriptor fd = data.readInt() != 0 ? data.readFileDescriptor() : null; boolean res = dumpHeap(process, userId, managed, path, fd); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index d4b204f..6638433 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2711,7 +2711,7 @@ public final class ActivityThread { r.activity.performResume(); EventLog.writeEvent(LOG_ON_RESUME_CALLED, - r.activity.getComponentName().getClassName()); + UserHandle.myUserId(), r.activity.getComponentName().getClassName()); r.paused = false; r.stopped = false; @@ -2979,7 +2979,8 @@ public final class ActivityThread { // Now we are idle. r.activity.mCalled = false; mInstrumentation.callActivityOnPause(r.activity); - EventLog.writeEvent(LOG_ON_PAUSE_CALLED, r.activity.getComponentName().getClassName()); + EventLog.writeEvent(LOG_ON_PAUSE_CALLED, UserHandle.myUserId(), + r.activity.getComponentName().getClassName()); if (!r.activity.mCalled) { throw new SuperNotCalledException( "Activity " + r.intent.getComponent().toShortString() + @@ -3364,7 +3365,7 @@ public final class ActivityThread { try { r.activity.mCalled = false; mInstrumentation.callActivityOnPause(r.activity); - EventLog.writeEvent(LOG_ON_PAUSE_CALLED, + EventLog.writeEvent(LOG_ON_PAUSE_CALLED, UserHandle.myUserId(), r.activity.getComponentName().getClassName()); if (!r.activity.mCalled) { throw new SuperNotCalledException( diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java index 96814b7..1b1d341 100644 --- a/core/java/android/app/BackStackRecord.java +++ b/core/java/android/app/BackStackRecord.java @@ -20,6 +20,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; +import android.util.LogWriter; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -94,11 +95,12 @@ final class BackStackState implements Parcelable { public BackStackRecord instantiate(FragmentManagerImpl fm) { BackStackRecord bse = new BackStackRecord(fm); int pos = 0; + int num = 0; while (pos < mOps.length) { BackStackRecord.Op op = new BackStackRecord.Op(); op.cmd = mOps[pos++]; if (FragmentManagerImpl.DEBUG) Log.v(FragmentManagerImpl.TAG, - "BSE " + bse + " set base fragment #" + mOps[pos]); + "Instantiate " + bse + " op #" + num + " base fragment #" + mOps[pos]); int findex = mOps[pos++]; if (findex >= 0) { Fragment f = fm.mActive.get(findex); @@ -115,12 +117,13 @@ final class BackStackState implements Parcelable { op.removed = new ArrayList<Fragment>(N); for (int i=0; i<N; i++) { if (FragmentManagerImpl.DEBUG) Log.v(FragmentManagerImpl.TAG, - "BSE " + bse + " set remove fragment #" + mOps[pos]); + "Instantiate " + bse + " set remove fragment #" + mOps[pos]); Fragment r = fm.mActive.get(mOps[pos++]); op.removed.add(r); } } bse.addOp(op); + num++; } bse.mTransition = mTransition; bse.mTransitionStyle = mTransitionStyle; @@ -168,7 +171,7 @@ final class BackStackState implements Parcelable { */ final class BackStackRecord extends FragmentTransaction implements FragmentManager.BackStackEntry, Runnable { - static final String TAG = "BackStackEntry"; + static final String TAG = FragmentManagerImpl.TAG; final FragmentManagerImpl mManager; @@ -206,46 +209,69 @@ final class BackStackRecord extends FragmentTransaction implements boolean mAllowAddToBackStack = true; String mName; boolean mCommitted; - int mIndex; + int mIndex = -1; int mBreadCrumbTitleRes; CharSequence mBreadCrumbTitleText; int mBreadCrumbShortTitleRes; CharSequence mBreadCrumbShortTitleText; - public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { - writer.print(prefix); writer.print("mName="); writer.print(mName); - writer.print(" mIndex="); writer.print(mIndex); - writer.print(" mCommitted="); writer.println(mCommitted); - if (mTransition != FragmentTransaction.TRANSIT_NONE) { - writer.print(prefix); writer.print("mTransition=#"); - writer.print(Integer.toHexString(mTransition)); - writer.print(" mTransitionStyle=#"); - writer.println(Integer.toHexString(mTransitionStyle)); - } - if (mEnterAnim != 0 || mExitAnim !=0) { - writer.print(prefix); writer.print("mEnterAnim=#"); - writer.print(Integer.toHexString(mEnterAnim)); - writer.print(" mExitAnim=#"); - writer.println(Integer.toHexString(mExitAnim)); - } - if (mPopEnterAnim != 0 || mPopExitAnim !=0) { - writer.print(prefix); writer.print("mPopEnterAnim=#"); - writer.print(Integer.toHexString(mPopEnterAnim)); - writer.print(" mPopExitAnim=#"); - writer.println(Integer.toHexString(mPopExitAnim)); + @Override + public String toString() { + StringBuilder sb = new StringBuilder(128); + sb.append("BackStackEntry{"); + sb.append(Integer.toHexString(System.identityHashCode(this))); + if (mIndex >= 0) { + sb.append(" #"); + sb.append(mIndex); } - if (mBreadCrumbTitleRes != 0 || mBreadCrumbTitleText != null) { - writer.print(prefix); writer.print("mBreadCrumbTitleRes=#"); - writer.print(Integer.toHexString(mBreadCrumbTitleRes)); - writer.print(" mBreadCrumbTitleText="); - writer.println(mBreadCrumbTitleText); + if (mName != null) { + sb.append(" "); + sb.append(mName); } - if (mBreadCrumbShortTitleRes != 0 || mBreadCrumbShortTitleText != null) { - writer.print(prefix); writer.print("mBreadCrumbShortTitleRes=#"); - writer.print(Integer.toHexString(mBreadCrumbShortTitleRes)); - writer.print(" mBreadCrumbShortTitleText="); - writer.println(mBreadCrumbShortTitleText); + sb.append("}"); + return sb.toString(); + } + + public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { + dump(prefix, writer, true); + } + + void dump(String prefix, PrintWriter writer, boolean full) { + if (full) { + writer.print(prefix); writer.print("mName="); writer.print(mName); + writer.print(" mIndex="); writer.print(mIndex); + writer.print(" mCommitted="); writer.println(mCommitted); + if (mTransition != FragmentTransaction.TRANSIT_NONE) { + writer.print(prefix); writer.print("mTransition=#"); + writer.print(Integer.toHexString(mTransition)); + writer.print(" mTransitionStyle=#"); + writer.println(Integer.toHexString(mTransitionStyle)); + } + if (mEnterAnim != 0 || mExitAnim !=0) { + writer.print(prefix); writer.print("mEnterAnim=#"); + writer.print(Integer.toHexString(mEnterAnim)); + writer.print(" mExitAnim=#"); + writer.println(Integer.toHexString(mExitAnim)); + } + if (mPopEnterAnim != 0 || mPopExitAnim !=0) { + writer.print(prefix); writer.print("mPopEnterAnim=#"); + writer.print(Integer.toHexString(mPopEnterAnim)); + writer.print(" mPopExitAnim=#"); + writer.println(Integer.toHexString(mPopExitAnim)); + } + if (mBreadCrumbTitleRes != 0 || mBreadCrumbTitleText != null) { + writer.print(prefix); writer.print("mBreadCrumbTitleRes=#"); + writer.print(Integer.toHexString(mBreadCrumbTitleRes)); + writer.print(" mBreadCrumbTitleText="); + writer.println(mBreadCrumbTitleText); + } + if (mBreadCrumbShortTitleRes != 0 || mBreadCrumbShortTitleText != null) { + writer.print(prefix); writer.print("mBreadCrumbShortTitleRes=#"); + writer.print(Integer.toHexString(mBreadCrumbShortTitleRes)); + writer.print(" mBreadCrumbShortTitleText="); + writer.println(mBreadCrumbShortTitleText); + } } if (mHead != null) { @@ -254,21 +280,34 @@ final class BackStackRecord extends FragmentTransaction implements Op op = mHead; int num = 0; while (op != null) { - writer.print(prefix); writer.print(" Op #"); writer.print(num); - writer.println(":"); - writer.print(innerPrefix); writer.print("cmd="); writer.print(op.cmd); - writer.print(" fragment="); writer.println(op.fragment); - if (op.enterAnim != 0 || op.exitAnim != 0) { - writer.print(prefix); writer.print("enterAnim=#"); - writer.print(Integer.toHexString(op.enterAnim)); - writer.print(" exitAnim=#"); - writer.println(Integer.toHexString(op.exitAnim)); + String cmdStr; + switch (op.cmd) { + case OP_NULL: cmdStr="NULL"; break; + case OP_ADD: cmdStr="ADD"; break; + case OP_REPLACE: cmdStr="REPLACE"; break; + case OP_REMOVE: cmdStr="REMOVE"; break; + case OP_HIDE: cmdStr="HIDE"; break; + case OP_SHOW: cmdStr="SHOW"; break; + case OP_DETACH: cmdStr="DETACH"; break; + case OP_ATTACH: cmdStr="ATTACH"; break; + default: cmdStr="cmd=" + op.cmd; break; } - if (op.popEnterAnim != 0 || op.popExitAnim != 0) { - writer.print(prefix); writer.print("popEnterAnim=#"); - writer.print(Integer.toHexString(op.popEnterAnim)); - writer.print(" popExitAnim=#"); - writer.println(Integer.toHexString(op.popExitAnim)); + writer.print(prefix); writer.print(" Op #"); writer.print(num); + writer.print(": "); writer.print(cmdStr); + writer.print(" "); writer.println(op.fragment); + if (full) { + if (op.enterAnim != 0 || op.exitAnim != 0) { + writer.print(innerPrefix); writer.print("enterAnim=#"); + writer.print(Integer.toHexString(op.enterAnim)); + writer.print(" exitAnim=#"); + writer.println(Integer.toHexString(op.exitAnim)); + } + if (op.popEnterAnim != 0 || op.popExitAnim != 0) { + writer.print(innerPrefix); writer.print("popEnterAnim=#"); + writer.print(Integer.toHexString(op.popEnterAnim)); + writer.print(" popExitAnim=#"); + writer.println(Integer.toHexString(op.popExitAnim)); + } } if (op.removed != null && op.removed.size() > 0) { for (int i=0; i<op.removed.size(); i++) { @@ -276,14 +315,17 @@ final class BackStackRecord extends FragmentTransaction implements if (op.removed.size() == 1) { writer.print("Removed: "); } else { - writer.println("Removed:"); - writer.print(innerPrefix); writer.print(" #"); writer.print(num); + if (i == 0) { + writer.println("Removed:"); + } + writer.print(innerPrefix); writer.print(" #"); writer.print(i); writer.print(": "); } writer.println(op.removed.get(i)); } } op = op.next; + num++; } } } @@ -538,7 +580,12 @@ final class BackStackRecord extends FragmentTransaction implements int commitInternal(boolean allowStateLoss) { if (mCommitted) throw new IllegalStateException("commit already called"); - if (FragmentManagerImpl.DEBUG) Log.v(TAG, "Commit: " + this); + if (FragmentManagerImpl.DEBUG) { + Log.v(TAG, "Commit: " + this); + LogWriter logw = new LogWriter(Log.VERBOSE, TAG); + PrintWriter pw = new PrintWriter(logw); + dump(" ", null, pw, null); + } mCommitted = true; if (mAddToBackStack) { mIndex = mManager.allocBackStackIndex(this); @@ -641,7 +688,12 @@ final class BackStackRecord extends FragmentTransaction implements } public void popFromBackStack(boolean doStateMove) { - if (FragmentManagerImpl.DEBUG) Log.v(TAG, "popFromBackStack: " + this); + if (FragmentManagerImpl.DEBUG) { + Log.v(TAG, "popFromBackStack: " + this); + LogWriter logw = new LogWriter(Log.VERBOSE, TAG); + PrintWriter pw = new PrintWriter(logw); + dump(" ", null, pw, null); + } bumpBackStackNesting(-1); diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index aad5487..e983299 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -22,6 +22,7 @@ import android.animation.AnimatorListenerAdapter; import android.content.res.Configuration; import android.content.res.TypedArray; import android.os.Bundle; +import android.os.Debug; import android.os.Handler; import android.os.Looper; import android.os.Parcel; @@ -771,9 +772,9 @@ final class FragmentManagerImpl extends FragmentManager { void moveToState(Fragment f, int newState, int transit, int transitionStyle, boolean keepActive) { - //if (DEBUG) Log.v(TAG, "moveToState: " + f - // + " oldState=" + f.mState + " newState=" + newState - // + " mRemoving=" + f.mRemoving + " Callers=" + Debug.getCallers(5)); + if (DEBUG && false) Log.v(TAG, "moveToState: " + f + + " oldState=" + f.mState + " newState=" + newState + + " mRemoving=" + f.mRemoving + " Callers=" + Debug.getCallers(5)); // Fragments that are not currently added will sit in the onCreate() state. if ((!f.mAdded || f.mDetached) && newState > Fragment.CREATED) { @@ -1112,6 +1113,9 @@ final class FragmentManagerImpl extends FragmentManager { if (DEBUG) Log.v(TAG, "add: " + fragment); makeActive(fragment); if (!fragment.mDetached) { + if (mAdded.contains(fragment)) { + throw new IllegalStateException("Fragment already added: " + fragment); + } mAdded.add(fragment); fragment.mAdded = true; fragment.mRemoving = false; @@ -1128,6 +1132,14 @@ final class FragmentManagerImpl extends FragmentManager { if (DEBUG) Log.v(TAG, "remove: " + fragment + " nesting=" + fragment.mBackStackNesting); final boolean inactive = !fragment.isInBackStack(); if (!fragment.mDetached || inactive) { + if (false) { + // Would be nice to catch a bad remove here, but we need + // time to test this to make sure we aren't crashes cases + // where it is not a problem. + if (!mAdded.contains(fragment)) { + throw new IllegalStateException("Fragment not added: " + fragment); + } + } if (mAdded != null) { mAdded.remove(fragment); } @@ -1200,6 +1212,7 @@ final class FragmentManagerImpl extends FragmentManager { if (fragment.mAdded) { // We are not already in back stack, so need to remove the fragment. if (mAdded != null) { + if (DEBUG) Log.v(TAG, "remove from detach: " + fragment); mAdded.remove(fragment); } if (fragment.mHasMenu && fragment.mMenuVisible) { @@ -1219,6 +1232,10 @@ final class FragmentManagerImpl extends FragmentManager { if (mAdded == null) { mAdded = new ArrayList<Fragment>(); } + if (mAdded.contains(fragment)) { + throw new IllegalStateException("Fragment already added: " + fragment); + } + if (DEBUG) Log.v(TAG, "add from attach: " + fragment); mAdded.add(fragment); fragment.mAdded = true; if (fragment.mHasMenu && fragment.mMenuVisible) { @@ -1717,19 +1734,18 @@ final class FragmentManagerImpl extends FragmentManager { FragmentState fs = fms.mActive[i]; if (fs != null) { Fragment f = fs.instantiate(mActivity, mParent); - if (DEBUG) Log.v(TAG, "restoreAllState: adding #" + i + ": " + f); + if (DEBUG) Log.v(TAG, "restoreAllState: active #" + i + ": " + f); mActive.add(f); // Now that the fragment is instantiated (or came from being // retained above), clear mInstance in case we end up re-restoring // from this FragmentState again. fs.mInstance = null; } else { - if (DEBUG) Log.v(TAG, "restoreAllState: adding #" + i + ": (null)"); mActive.add(null); if (mAvailIndices == null) { mAvailIndices = new ArrayList<Integer>(); } - if (DEBUG) Log.v(TAG, "restoreAllState: adding avail #" + i); + if (DEBUG) Log.v(TAG, "restoreAllState: avail #" + i); mAvailIndices.add(i); } } @@ -1760,7 +1776,10 @@ final class FragmentManagerImpl extends FragmentManager { "No instantiated fragment for index #" + fms.mAdded[i])); } f.mAdded = true; - if (DEBUG) Log.v(TAG, "restoreAllState: making added #" + i + ": " + f); + if (DEBUG) Log.v(TAG, "restoreAllState: added #" + i + ": " + f); + if (mAdded.contains(f)) { + throw new IllegalStateException("Already added!"); + } mAdded.add(f); } } else { @@ -1772,8 +1791,13 @@ final class FragmentManagerImpl extends FragmentManager { mBackStack = new ArrayList<BackStackRecord>(fms.mBackStack.length); for (int i=0; i<fms.mBackStack.length; i++) { BackStackRecord bse = fms.mBackStack[i].instantiate(this); - if (DEBUG) Log.v(TAG, "restoreAllState: adding bse #" + i + if (DEBUG) { + Log.v(TAG, "restoreAllState: back stack #" + i + " (index " + bse.mIndex + "): " + bse); + LogWriter logw = new LogWriter(Log.VERBOSE, TAG); + PrintWriter pw = new PrintWriter(logw); + bse.dump(" ", pw, false); + } mBackStack.add(bse); if (bse.mIndex >= 0) { setBackStackIndex(bse.mIndex, bse); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index ac36cf7..201b43f 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -178,7 +178,7 @@ public abstract class Context { * Flag for {@link #bindService}: indicates that the client application * binding to this service considers the service to be more important than * the app itself. When set, the platform will try to have the out of - * memory kill the app before it kills the service it is bound to, though + * memory killer kill the app before it kills the service it is bound to, though * this is not guaranteed to be the case. */ public static final int BIND_ABOVE_CLIENT = 0x0008; @@ -219,6 +219,19 @@ public abstract class Context { public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080; /** + * @hide An idea that is not yet implemented. + * Flag for {@link #bindService}: If binding from an activity, consider + * this service to be visible like the binding activity is. That is, + * it will be treated as something more important to keep around than + * invisible background activities. This will impact the number of + * recent activities the user can switch between without having them + * restart. There is no guarantee this will be respected, as the system + * tries to balance such requests from one app vs. the importantance of + * keeping other apps around. + */ + public static final int BIND_VISIBLE = 0x0100; + + /** * Flag for {@link #bindService}: Don't consider the bound service to be * visible, even if the caller is visible. * @hide diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 4257e0e..4999a2d 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -203,6 +203,12 @@ public class SyncManager implements OnAccountsUpdateListener { } }; + private BroadcastReceiver mAccountsUpdatedReceiver = new BroadcastReceiver() { + public void onReceive(Context context, Intent intent) { + onAccountsUpdated(null); + } + }; + private final PowerManager mPowerManager; // Use this as a random offset to seed all periodic syncs @@ -456,8 +462,11 @@ public class SyncManager implements OnAccountsUpdateListener { }); if (!factoryTest) { - AccountManager.get(mContext).addOnAccountsUpdatedListener(SyncManager.this, - mSyncHandler, false /* updateImmediately */); + // Register for account list updates for all users + mContext.registerReceiverAsUser(mAccountsUpdatedReceiver, + UserHandle.ALL, + new IntentFilter(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION), + null, null); // do this synchronously to ensure we have the accounts before this call returns onAccountsUpdated(null); } diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index 58a0f13..28e320b 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -46,9 +46,7 @@ public final class DisplayManager { * The status is provided as a {@link WifiDisplayStatus} object in the * {@link #EXTRA_WIFI_DISPLAY_STATUS} extra. * </p><p> - * This broadcast is only sent to registered receivers with the - * {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} permission and can - * only be sent by the system. + * This broadcast is only sent to registered receivers and can only be sent by the system. * </p> * @hide */ @@ -163,6 +161,9 @@ public final class DisplayManager { * <p> * Automatically remembers the display after a successful connection, if not * already remembered. + * </p><p> + * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY} to connect + * to unknown displays. No permissions are required to connect to already known displays. * </p> * * @param deviceAddress The MAC address of the device to which we should connect. @@ -187,6 +188,8 @@ public final class DisplayManager { * The display must already be remembered for this call to succeed. In other words, * we must already have successfully connected to the display at least once and then * not forgotten it. + * </p><p> + * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to rename. @@ -202,6 +205,8 @@ public final class DisplayManager { * Forgets a previously remembered Wifi display. * <p> * Automatically disconnects from the display if currently connected to it. + * </p><p> + * Requires {@link android.Manifest.permission#CONFIGURE_WIFI_DISPLAY}. * </p> * * @param deviceAddress The MAC address of the device to forget. diff --git a/core/java/android/hardware/display/IDisplayManager.aidl b/core/java/android/hardware/display/IDisplayManager.aidl index 4b6fb53..79aad78 100644 --- a/core/java/android/hardware/display/IDisplayManager.aidl +++ b/core/java/android/hardware/display/IDisplayManager.aidl @@ -28,13 +28,14 @@ interface IDisplayManager { void registerCallback(in IDisplayManagerCallback callback); - // Requires CONFIGURE_WIFI_DISPLAY permission. + // No permissions required. void scanWifiDisplays(); - // Requires CONFIGURE_WIFI_DISPLAY permission. + // Requires CONFIGURE_WIFI_DISPLAY permission to connect to an unknown device. + // No permissions required to connect to a known device. void connectWifiDisplay(String address); - // Requires CONFIGURE_WIFI_DISPLAY permission. + // No permissions required. void disconnectWifiDisplay(); // Requires CONFIGURE_WIFI_DISPLAY permission. @@ -43,6 +44,6 @@ interface IDisplayManager { // Requires CONFIGURE_WIFI_DISPLAY permission. void forgetWifiDisplay(String address); - // Requires CONFIGURE_WIFI_DISPLAY permission. + // No permissions required. WifiDisplayStatus getWifiDisplayStatus(); } diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java index 42fb5c3..846443d 100644 --- a/core/java/android/net/SSLCertificateSocketFactory.java +++ b/core/java/android/net/SSLCertificateSocketFactory.java @@ -90,7 +90,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { private byte[] mNpnProtocols = null; private final int mHandshakeTimeoutMillis; - private final int mWriteTimeoutMillis; private final SSLClientSessionCache mSessionCache; private final boolean mSecure; @@ -101,21 +100,12 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { } private SSLCertificateSocketFactory( - int handshakeTimeoutMillis, - int writeTimeoutMillis, - SSLSessionCache cache, - boolean secure) { + int handshakeTimeoutMillis, SSLSessionCache cache, boolean secure) { mHandshakeTimeoutMillis = handshakeTimeoutMillis; - mWriteTimeoutMillis = writeTimeoutMillis; mSessionCache = cache == null ? null : cache.mSessionCache; mSecure = secure; } - private SSLCertificateSocketFactory( - int handshakeTimeoutMillis, SSLSessionCache cache, boolean secure) { - this(handshakeTimeoutMillis, 0, cache, secure); - } - /** * Returns a new socket factory instance with an optional handshake timeout. * @@ -172,24 +162,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { } /** - * Returns a socket factory (also named SSLSocketFactory, but in a different - * namespace) for use with the Apache HTTP stack. - * - * @param handshakeTimeoutMillis to use for SSL connection handshake, or 0 - * for none. The socket timeout is reset to 0 after the handshake. - * @param writeTimeoutMillis the desired write timeout in milliseconds or 0 for none. - * @param cache The {@link SSLSessionCache} to use, or null for no cache. - * @return a new SocketFactory with the specified parameters - */ - public static org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory( - int handshakeTimeoutMillis, - int writeTimeoutMillis, - SSLSessionCache cache) { - return new org.apache.http.conn.ssl.SSLSocketFactory(new SSLCertificateSocketFactory( - handshakeTimeoutMillis, writeTimeoutMillis, cache, true)); - } - - /** * Verify the hostname of the certificate used by the other end of a * connected socket. You MUST call this if you did not supply a hostname * to {@link #createSocket()}. It is harmless to call this method @@ -376,8 +348,10 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { * To take effect, this option must be set before the blocking method was called. * * @param socket a socket created by this factory. - * @param writeTimeoutMilliseconds the desired write timeout in milliseconds. + * @param timeout the desired write timeout in milliseconds. * @throws IllegalArgumentException if the socket was not created by this factory. + * + * @hide */ public void setSoWriteTimeout(Socket socket, int writeTimeoutMilliseconds) throws SocketException { @@ -404,7 +378,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { OpenSSLSocketImpl s = (OpenSSLSocketImpl) getDelegate().createSocket(k, host, port, close); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); if (mSecure) { verifyHostname(s, host); } @@ -424,7 +397,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { OpenSSLSocketImpl s = (OpenSSLSocketImpl) getDelegate().createSocket(); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); return s; } @@ -442,7 +414,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { addr, port, localAddr, localPort); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); return s; } @@ -458,7 +429,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { OpenSSLSocketImpl s = (OpenSSLSocketImpl) getDelegate().createSocket(addr, port); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); return s; } @@ -475,7 +445,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { host, port, localAddr, localPort); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); if (mSecure) { verifyHostname(s, host); } @@ -493,7 +462,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { OpenSSLSocketImpl s = (OpenSSLSocketImpl) getDelegate().createSocket(host, port); s.setNpnProtocols(mNpnProtocols); s.setHandshakeTimeout(mHandshakeTimeoutMillis); - s.setSoWriteTimeout(mWriteTimeoutMillis); if (mSecure) { verifyHostname(s, host); } diff --git a/core/java/android/net/http/AndroidHttpClient.java b/core/java/android/net/http/AndroidHttpClient.java index 8169a94..c534e58 100644 --- a/core/java/android/net/http/AndroidHttpClient.java +++ b/core/java/android/net/http/AndroidHttpClient.java @@ -16,16 +16,7 @@ package android.net.http; -import android.content.ContentResolver; -import android.content.Context; -import android.net.SSLCertificateSocketFactory; -import android.net.SSLSessionCache; -import android.os.Looper; -import android.util.Base64; -import android.util.Log; - import com.android.internal.http.HttpDateTime; - import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -34,18 +25,18 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; +import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ByteArrayEntity; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.protocol.ClientContext; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.params.HttpClientParams; -import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.entity.AbstractHttpEntity; -import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.RequestWrapper; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; @@ -53,17 +44,25 @@ import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.params.HttpProtocolParams; -import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.BasicHttpProcessor; import org.apache.http.protocol.HttpContext; +import org.apache.http.protocol.BasicHttpContext; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.ByteArrayOutputStream; import java.io.OutputStream; -import java.net.URI; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; +import java.net.URI; + +import android.content.Context; +import android.content.ContentResolver; +import android.net.SSLCertificateSocketFactory; +import android.net.SSLSessionCache; +import android.os.Looper; +import android.util.Base64; +import android.util.Log; /** * Implementation of the Apache {@link DefaultHttpClient} that is configured with @@ -135,7 +134,7 @@ public final class AndroidHttpClient implements HttpClient { PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register(new Scheme("https", SSLCertificateSocketFactory.getHttpSocketFactory( - SOCKET_OPERATION_TIMEOUT, SOCKET_OPERATION_TIMEOUT, sessionCache), 443)); + SOCKET_OPERATION_TIMEOUT, sessionCache), 443)); ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry); diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index 7aee644..eec19cb 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -34,6 +34,7 @@ interface IPowerManager void userActivity(long time, int event, int flags); void wakeUp(long time); void goToSleep(long time, int reason); + void nap(long time); boolean isScreenOn(); void reboot(String reason); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index cc2c002..58372f4 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -426,7 +426,7 @@ public final class PowerManager { * </p> * * @param when The time of the user activity, in the {@link SystemClock#uptimeMillis()} - * time base. This timestamp is used to correctly order the user activity with + * time base. This timestamp is used to correctly order the user activity request with * other power management functions. It should be set * to the timestamp of the input event that caused the user activity. * @param noChangeLights If true, does not cause the keyboard backlight to turn on @@ -457,7 +457,7 @@ public final class PowerManager { * * @param time The time when the request to go to sleep was issued, in the * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly - * order the user activity with other power management functions. It should be set + * order the go to sleep request with other power management functions. It should be set * to the timestamp of the input event that caused the request to go to sleep. * * @see #userActivity @@ -481,7 +481,7 @@ public final class PowerManager { * * @param time The time when the request to wake up was issued, in the * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly - * order the user activity with other power management functions. It should be set + * order the wake up request with other power management functions. It should be set * to the timestamp of the input event that caused the request to wake up. * * @see #userActivity @@ -495,6 +495,34 @@ public final class PowerManager { } /** + * Forces the device to start napping. + * <p> + * If the device is currently awake, starts dreaming, otherwise does nothing. + * When the dream ends or if the dream cannot be started, the device will + * either wake up or go to sleep depending on whether there has been recent + * user activity. + * </p><p> + * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission. + * </p> + * + * @param time The time when the request to nap was issued, in the + * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly + * order the nap request with other power management functions. It should be set + * to the timestamp of the input event that caused the request to nap. + * + * @see #wakeUp + * @see #goToSleep + * + * @hide + */ + public void nap(long time) { + try { + mService.nap(time); + } catch (RemoteException e) { + } + } + + /** * Sets the brightness of the backlights (screen, keyboard, button). * <p> * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission. diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java index a54c25b..c9adf45 100644 --- a/core/java/android/os/SystemClock.java +++ b/core/java/android/os/SystemClock.java @@ -50,7 +50,7 @@ package android.os; * interval does not span device sleep. Most methods that accept a * timestamp value currently expect the {@link #uptimeMillis} clock. * - * <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNano} + * <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNanos} * return the time since the system was booted, and include deep sleep. * This clock is guaranteed to be monotonic, and continues to tick even * when the CPU is in power saving modes, so is the recommend basis @@ -157,7 +157,7 @@ public final class SystemClock { * * @return elapsed nanoseconds since boot. */ - public static native long elapsedRealtimeNano(); + public static native long elapsedRealtimeNanos(); /** * Returns milliseconds running in the current thread. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 965e488..0d980c0 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3054,6 +3054,7 @@ public final class Settings { /** * @deprecated Use {@link android.provider.Settings.Global#DATA_ROAMING} instead */ + @Deprecated public static final String DATA_ROAMING = Global.DATA_ROAMING; /** @@ -3215,27 +3216,6 @@ public final class Settings { "lock_screen_owner_info_enabled"; /** - * @deprecated Use {@link android.provider.Settings.Global#DISPLAY_SIZE_FORCED} instead - * @hide - */ - @Deprecated - public static final String DISPLAY_SIZE_FORCED = Global.DISPLAY_SIZE_FORCED; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DISPLAY_DENSITY_FORCED} instead - * @hide - */ - @Deprecated - public static final String DISPLAY_DENSITY_FORCED = Global.DISPLAY_DENSITY_FORCED; - - /** - * @deprecated Use {@link android.provider.Settings.Global#ASSISTED_GPS_ENABLED} instead - * @hide - */ - @Deprecated - public static final String ASSISTED_GPS_ENABLED = Global.ASSISTED_GPS_ENABLED; - - /** * The Logging ID (a unique 64-bit value) as a hex string. * Used as a pseudonymous identifier for logging. * @deprecated This identifier is poorly initialized and has @@ -3251,44 +3231,6 @@ public final class Settings { public static final String NETWORK_PREFERENCE = Global.NETWORK_PREFERENCE; /** - * @deprecated Use {@link android.provider.Settings.Global#TETHER_SUPPORTED} instead - * @hide - */ - @Deprecated - public static final String TETHER_SUPPORTED = Global.TETHER_SUPPORTED; - - /** - * @deprecated Use {@link android.provider.Settings.Global#TETHER_DUN_REQUIRED} instead - * @hide - */ - @Deprecated - public static final String TETHER_DUN_REQUIRED = Global.TETHER_DUN_REQUIRED; - - /** - * @deprecated Use {@link android.provider.Settings.Global#TETHER_DUN_REQUIRED} instead - * @hide - */ - @Deprecated - public static final String TETHER_DUN_APN = Global.TETHER_DUN_APN; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DATA_ACTIVITY_TIMEOUT_MOBILE} - * instead - * @hide - */ - @Deprecated - public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = - Global.DATA_ACTIVITY_TIMEOUT_MOBILE; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DATA_ACTIVITY_TIMEOUT_MOBILE} - * instead - * @hide - */ - @Deprecated - public static final String DATA_ACTIVITY_TIMEOUT_WIFI = Global.DATA_ACTIVITY_TIMEOUT_WIFI; - - /** * No longer supported. */ public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled"; @@ -3304,13 +3246,6 @@ public final class Settings { public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url"; /** - * @deprecated Use {@link android.provider.Settings.Global#SAMPLING_PROFILER_MS} instead - * @hide - */ - @Deprecated - public static final String SAMPLING_PROFILER_MS = Global.SAMPLING_PROFILER_MS; - - /** * Settings classname to launch when Settings is clicked from All * Applications. Needed because of user testing between the old * and new Settings apps. @@ -3562,14 +3497,6 @@ public final class Settings { @Deprecated public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON; - /** - * @deprecated Use {@link android.provider.Settings.Global#WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON} - * instead. - * {@hide} - */ - @Deprecated - public static final String WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON = - Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON; /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY} @@ -3580,15 +3507,6 @@ public final class Settings { Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY; /** - * @deprecated Use {@link android.provider.Settings.Global#WIFI_COUNTRY_CODE} - * instead. - * @hide - */ - @Deprecated - public static final String WIFI_COUNTRY_CODE = Global.WIFI_COUNTRY_CODE; - - - /** * @deprecated Use {@link android.provider.Settings.Global#WIFI_NUM_OPEN_NETWORKS_KEPT} * instead. */ @@ -3604,39 +3522,6 @@ public final class Settings { public static final String WIFI_ON = Global.WIFI_ON; /** - * Used to save the Wifi_ON state prior to tethering. - * This state will be checked to restore Wifi after - * the user turns off tethering. - * - * @hide - * @deprecated Use {@link android.provider.Settings.Global#WIFI_SAVED_STATE} - * instead. - */ - @Deprecated - public static final String WIFI_SAVED_STATE = Global.WIFI_SAVED_STATE; - - /** - * AP SSID - * - * @hide - */ - public static final String WIFI_AP_SSID = "wifi_ap_ssid"; - - /** - * AP security - * - * @hide - */ - public static final String WIFI_AP_SECURITY = "wifi_ap_security"; - - /** - * AP passphrase - * - * @hide - */ - public static final String WIFI_AP_PASSWD = "wifi_ap_passwd"; - - /** * The acceptable packet loss percentage (range 0 - 100) before trying * another AP on the same network. * @deprecated This setting is not used. @@ -3700,8 +3585,9 @@ public final class Settings { public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks"; /** - * Whether the Wi-Fi watchdog is enabled. + * @deprecated Use {@link android.provider.Settings.Global#WIFI_WATCHDOG_ON} instead */ + @Deprecated public static final String WIFI_WATCHDOG_ON = "wifi_watchdog_on"; /** @@ -3733,66 +3619,6 @@ public final class Settings { public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms"; /** - * ms delay before rechecking an 'online' wifi connection when it is thought to be unstable. - * @deprecated This setting is not used. - * @hide - */ - @Deprecated - public static final String WIFI_WATCHDOG_ARP_CHECK_INTERVAL_MS = - "wifi_watchdog_arp_interval_ms"; - - /** - * ms delay interval between rssi polling when the signal is known to be weak - * @deprecated This setting is not used. - * @hide - */ - @Deprecated - public static final String WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS = - "wifi_watchdog_rssi_fetch_interval_ms"; - - /** - * Number of ARP pings per check. - * @deprecated This setting is not used. - * @hide - */ - @Deprecated - public static final String WIFI_WATCHDOG_NUM_ARP_PINGS = "wifi_watchdog_num_arp_pings"; - - /** - * Minimum number of responses to the arp pings to consider the test 'successful'. - * @deprecated This setting is not used. - * @hide - */ - @Deprecated - public static final String WIFI_WATCHDOG_MIN_ARP_RESPONSES = - "wifi_watchdog_min_arp_responses"; - - /** - * Timeout on ARP pings - * @deprecated This setting is not used. - * @hide - */ - @Deprecated - public static final String WIFI_WATCHDOG_ARP_PING_TIMEOUT_MS = - "wifi_watchdog_arp_ping_timeout_ms"; - - /** - * Setting to turn off poor network avoidance on Wi-Fi. Feature is enabled by default and - * the setting needs to be set to 0 to disable it. - * @hide - */ - public static final String WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED = - "wifi_watchdog_poor_network_test_enabled"; - - /** - * Setting to turn on suspend optimizations at screen off on Wi-Fi. Enabled by default and - * needs to be set to 0 to disable it. - * @hide - */ - public static final String WIFI_SUSPEND_OPTIMIZATIONS_ENABLED = - "wifi_suspend_optimizations_enabled"; - - /** * @deprecated Use * {@link android.provider.Settings.Global#WIFI_MAX_DHCP_RETRY_COUNT} instead */ @@ -3800,22 +3626,6 @@ public final class Settings { public static final String WIFI_MAX_DHCP_RETRY_COUNT = Global.WIFI_MAX_DHCP_RETRY_COUNT; /** - * The operational wifi frequency band - * Set to one of {@link WifiManager#WIFI_FREQUENCY_BAND_AUTO}, - * {@link WifiManager#WIFI_FREQUENCY_BAND_5GHZ} or - * {@link WifiManager#WIFI_FREQUENCY_BAND_2GHZ} - * - * @hide - */ - public static final String WIFI_FREQUENCY_BAND = "wifi_frequency_band"; - - /** - * The Wi-Fi peer-to-peer device name - * @hide - */ - public static final String WIFI_P2P_DEVICE_NAME = "wifi_p2p_device_name"; - - /** * Setting to turn off captive portal detection. Feature is enabled by default and * the setting needs to be set to 0 to disable it. * @hide @@ -3834,6 +3644,7 @@ public final class Settings { * @deprecated Use * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead */ + @Deprecated public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS; @@ -3858,27 +3669,6 @@ public final class Settings { = "allowed_geolocation_origins"; /** - * @deprecated Use {@link android.provider.Settings.Global#MOBILE_DATA} instead - * @hide - */ - @Deprecated - public static final String MOBILE_DATA = Global.MOBILE_DATA; - - /** - * @deprecated Use {@link android.provider.Settings.Global#CDMA_ROAMING_MODE} instead - * @hide - */ - @Deprecated - public static final String CDMA_ROAMING_MODE = Global.CDMA_ROAMING_MODE; - - /** - * @deprecated Use {@link android.provider.Settings.Global#CDMA_ROAMING_MODE} instead - * @hide - */ - @Deprecated - public static final String CDMA_SUBSCRIPTION_MODE = Global.CDMA_SUBSCRIPTION_MODE; - - /** * The preferred network mode 7 = Global * 6 = EvDo only * 5 = CDMA w/o EvDo @@ -3902,14 +3692,6 @@ public final class Settings { public static final String PREFERRED_TTY_MODE = "preferred_tty_mode"; - - /** - * @deprecated Use {@link android.provider.Settings.Global#CDMA_CELL_BROADCAST_SMS} instead - * @hide - */ - @Deprecated - public static final String CDMA_CELL_BROADCAST_SMS = Global.CDMA_CELL_BROADCAST_SMS; - /** * The cdma subscription 0 = Subscription from RUIM, when available * 1 = Subscription from NV @@ -3982,133 +3764,6 @@ public final class Settings { public static final String LAST_SETUP_SHOWN = "last_setup_shown"; /** - * How frequently (in seconds) to check the memory status of the - * device. - * @hide - */ - public static final String MEMCHECK_INTERVAL = "memcheck_interval"; - - /** - * Max frequency (in seconds) to log memory check stats, in realtime - * seconds. This allows for throttling of logs when the device is - * running for large amounts of time. - * @hide - */ - public static final String MEMCHECK_LOG_REALTIME_INTERVAL = - "memcheck_log_realtime_interval"; - - /** - * Boolean indicating whether rebooting due to system memory checks - * is enabled. - * @hide - */ - public static final String MEMCHECK_SYSTEM_ENABLED = "memcheck_system_enabled"; - - /** - * How many bytes the system process must be below to avoid scheduling - * a soft reboot. This reboot will happen when it is next determined - * to be a good time. - * @hide - */ - public static final String MEMCHECK_SYSTEM_SOFT_THRESHOLD = "memcheck_system_soft"; - - /** - * How many bytes the system process must be below to avoid scheduling - * a hard reboot. This reboot will happen immediately. - * @hide - */ - public static final String MEMCHECK_SYSTEM_HARD_THRESHOLD = "memcheck_system_hard"; - - /** - * How many bytes the phone process must be below to avoid scheduling - * a soft restart. This restart will happen when it is next determined - * to be a good time. - * @hide - */ - public static final String MEMCHECK_PHONE_SOFT_THRESHOLD = "memcheck_phone_soft"; - - /** - * How many bytes the phone process must be below to avoid scheduling - * a hard restart. This restart will happen immediately. - * @hide - */ - public static final String MEMCHECK_PHONE_HARD_THRESHOLD = "memcheck_phone_hard"; - - /** - * Boolean indicating whether restarting the phone process due to - * memory checks is enabled. - * @hide - */ - public static final String MEMCHECK_PHONE_ENABLED = "memcheck_phone_enabled"; - - /** - * First time during the day it is okay to kill processes - * or reboot the device due to low memory situations. This number is - * in seconds since midnight. - * @hide - */ - public static final String MEMCHECK_EXEC_START_TIME = "memcheck_exec_start_time"; - - /** - * Last time during the day it is okay to kill processes - * or reboot the device due to low memory situations. This number is - * in seconds since midnight. - * @hide - */ - public static final String MEMCHECK_EXEC_END_TIME = "memcheck_exec_end_time"; - - /** - * How long the screen must have been off in order to kill processes - * or reboot. This number is in seconds. A value of -1 means to - * entirely disregard whether the screen is on. - * @hide - */ - public static final String MEMCHECK_MIN_SCREEN_OFF = "memcheck_min_screen_off"; - - /** - * How much time there must be until the next alarm in order to kill processes - * or reboot. This number is in seconds. Note: this value must be - * smaller than {@link #MEMCHECK_RECHECK_INTERVAL} or else it will - * always see an alarm scheduled within its time. - * @hide - */ - public static final String MEMCHECK_MIN_ALARM = "memcheck_min_alarm"; - - /** - * How frequently to check whether it is a good time to restart things, - * if the device is in a bad state. This number is in seconds. Note: - * this value must be larger than {@link #MEMCHECK_MIN_ALARM} or else - * the alarm to schedule the recheck will always appear within the - * minimum "do not execute now" time. - * @hide - */ - public static final String MEMCHECK_RECHECK_INTERVAL = "memcheck_recheck_interval"; - - /** - * How frequently (in DAYS) to reboot the device. If 0, no reboots - * will occur. - * @hide - */ - public static final String REBOOT_INTERVAL = "reboot_interval"; - - /** - * First time during the day it is okay to force a reboot of the - * device (if REBOOT_INTERVAL is set). This number is - * in seconds since midnight. - * @hide - */ - public static final String REBOOT_START_TIME = "reboot_start_time"; - - /** - * The window of time (in seconds) after each REBOOT_INTERVAL in which - * a reboot can be executed. If 0, a reboot will always be executed at - * exactly the given time. Otherwise, it will only be executed if - * the device is idle within the window. - * @hide - */ - public static final String REBOOT_WINDOW = "reboot_window"; - - /** * Threshold values for the duration and level of a discharge cycle, under * which we log discharge cycle info. * @hide @@ -4128,13 +3783,6 @@ public final class Settings { public static final String SEND_ACTION_APP_ERROR = "send_action_app_error"; /** - * @deprecated Use {@link android.provider.Settings.Global#WTF_IS_FATAL} instead - * @hide - */ - @Deprecated - public static final String WTF_IS_FATAL = Global.WTF_IS_FATAL; - - /** * Maximum age of entries kept by {@link com.android.internal.os.IDropBoxManagerService}. * @hide */ @@ -4239,121 +3887,6 @@ public final class Settings { public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS; /** - * The interval in milliseconds to issue wake up scans when wifi needs - * to connect. This is necessary to connect to an access point when - * device is on the move and the screen is off. - * @hide - * @deprecated Use {@link android.provider.Settings.Global#WIFI_FRAMEWORK_SCAN_INTERVAL_MS} - * instead. - */ - @Deprecated - public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS = - Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS; - - /** - * The interval in milliseconds to scan as used by the wifi supplicant - * @hide - * @deprecated Use {@link android.provider.Settings.Global#WIFI_SUPPLICANT_SCAN_INTERVAL_MS} - * instead. - */ - @Deprecated - public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS = - Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_POLL_INTERVAL_MS} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_POLL_INTERVAL_MS = - Global.PDP_WATCHDOG_POLL_INTERVAL_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_LONG_POLL_INTERVAL_MS} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_LONG_POLL_INTERVAL_MS = - Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS = - Global.PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_TRIGGER_PACKET_COUNT} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_TRIGGER_PACKET_COUNT = - Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_ERROR_POLL_COUNT} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_ERROR_POLL_COUNT = - Global.PDP_WATCHDOG_ERROR_POLL_COUNT; - - /** - * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT} - * instead. - * @hide - */ - @Deprecated - public static final String PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT = - Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS} - * instead. - * @hide - */ - @Deprecated - public static final String DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS = - Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS} - * instead. - * @hide - */ - @Deprecated - public static final String DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS = - Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#GPRS_REGISTER_CHECK_PERIOD_MS} - * instead. - * @hide - */ - @Deprecated - public static final String GPRS_REGISTER_CHECK_PERIOD_MS = - Global.GPRS_REGISTER_CHECK_PERIOD_MS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#NITZ_UPDATE_SPACING} instead - * @hide - */ - public static final String NITZ_UPDATE_SPACING = Global.NITZ_UPDATE_SPACING; - - /** - * @deprecated Use {@link android.provider.Settings.Global#NITZ_UPDATE_SPACING} instead - * @hide - */ - public static final String NITZ_UPDATE_DIFF = Global.NITZ_UPDATE_DIFF; - - /** * The maximum reconnect delay for short network outages or when the network is suspended * due to phone use. * @hide @@ -4362,20 +3895,6 @@ public final class Settings { "sync_max_retry_delay_in_seconds"; /** - * @deprecated Use {@link Settings.Global#SMS_OUTGOING_CHECK_INTERVAL_MS} instead. - * @hide - */ - public static final String SMS_OUTGOING_CHECK_INTERVAL_MS = - Global.SMS_OUTGOING_CHECK_INTERVAL_MS; - - /** - * @deprecated Use {@link Settings.Global#SMS_OUTGOING_CHECK_MAX_COUNT} instead. - * @hide - */ - public static final String SMS_OUTGOING_CHECK_MAX_COUNT = - Global.SMS_OUTGOING_CHECK_MAX_COUNT; - - /** * The global search provider chosen by the user (if multiple global * search providers are installed). This will be the provider returned * by {@link SearchManager#getGlobalSearchActivity()} if it's still @@ -4610,72 +4129,6 @@ public final class Settings { public static final String DEFAULT_INSTALL_LOCATION = "default_install_location"; /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_POLLING_SEC} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_POLLING_SEC = Global.THROTTLE_POLLING_SEC; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_THRESHOLD_BYTES} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_THRESHOLD_BYTES = Global.THROTTLE_THRESHOLD_BYTES; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_VALUE_KBITSPS} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_VALUE_KBITSPS = Global.THROTTLE_VALUE_KBITSPS; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_VALUE_KBITSPS} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_RESET_DAY = Global.THROTTLE_RESET_DAY; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_NOTIFICATION_TYPE} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_NOTIFICATION_TYPE = Global.THROTTLE_NOTIFICATION_TYPE; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_HELP_URI} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_HELP_URI = Global.THROTTLE_HELP_URI; - - /** - * @deprecated Use {@link android.provider.Settings.Global#THROTTLE_MAX_NTP_CACHE_AGE_SEC} instead - * @hide - */ - @Deprecated - public static final String THROTTLE_MAX_NTP_CACHE_AGE_SEC = - Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DOWNLOAD_MAX_BYTES_OVER_MOBILE} instead - * @hide - */ - @Deprecated - public static final String DOWNLOAD_MAX_BYTES_OVER_MOBILE = - Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE; - - /** - * @deprecated Use {@link android.provider.Settings.Global#DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE} instead - * @hide - */ - @Deprecated - public static final String DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE = - Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE; - - /** * ms during which to consume extra events related to Inet connection condition * after a transtion to fully-connected * @hide @@ -4692,30 +4145,6 @@ public final class Settings { "inet_condition_debounce_down_delay"; /** - * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DATA_SERVICE_URL} instead - * @hide - */ - @Deprecated - public static final String SETUP_PREPAID_DATA_SERVICE_URL = - Global.SETUP_PREPAID_DATA_SERVICE_URL; - - /** - * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DETECTION_TARGET_URL} instead - * @hide - */ - @Deprecated - public static final String SETUP_PREPAID_DETECTION_TARGET_URL = - Global.SETUP_PREPAID_DETECTION_TARGET_URL; - - /** - * @deprecated Use {@link android.provider.Settings.Global#SETUP_PREPAID_DETECTION_REDIR_HOST} instead - * @hide - */ - @Deprecated - public static final String SETUP_PREPAID_DETECTION_REDIR_HOST = - Global.SETUP_PREPAID_DETECTION_REDIR_HOST; - - /** * Whether screensavers are enabled. * @hide */ @@ -4750,131 +4179,11 @@ public final class Settings { */ public static final String SCREENSAVER_DEFAULT_COMPONENT = "screensaver_default_component"; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_ENABLED = Global.NETSTATS_ENABLED; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_POLL_INTERVAL = Global.NETSTATS_POLL_INTERVAL; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_TIME_CACHE_MAX_AGE = Global.NETSTATS_TIME_CACHE_MAX_AGE; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_GLOBAL_ALERT_BYTES = Global.NETSTATS_GLOBAL_ALERT_BYTES; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_SAMPLE_ENABLED = Global.NETSTATS_SAMPLE_ENABLED; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_REPORT_XT_OVER_DEV = Global.NETSTATS_REPORT_XT_OVER_DEV; - - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_DEV_BUCKET_DURATION = Global.NETSTATS_DEV_BUCKET_DURATION; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_DEV_PERSIST_BYTES = Global.NETSTATS_DEV_PERSIST_BYTES; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_DEV_ROTATE_AGE = Global.NETSTATS_DEV_ROTATE_AGE; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_DEV_DELETE_AGE = Global.NETSTATS_DEV_DELETE_AGE; - - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_BUCKET_DURATION = Global.NETSTATS_UID_BUCKET_DURATION; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_PERSIST_BYTES = Global.NETSTATS_UID_PERSIST_BYTES; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_ROTATE_AGE = Global.NETSTATS_UID_ROTATE_AGE; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_DELETE_AGE = Global.NETSTATS_UID_DELETE_AGE; - - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_TAG_BUCKET_DURATION = Global.NETSTATS_UID_TAG_BUCKET_DURATION; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_TAG_PERSIST_BYTES = Global.NETSTATS_UID_TAG_PERSIST_BYTES; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_TAG_ROTATE_AGE = Global.NETSTATS_UID_TAG_ROTATE_AGE; - /** @deprecated The NETSTATS_* symbols live in Settings.Global.* now - * {@hide} */ - @Deprecated - public static final String NETSTATS_UID_TAG_DELETE_AGE = Global.NETSTATS_UID_TAG_DELETE_AGE; - - /** Preferred NTP server. {@hide} - * @deprecated moved to Settings.Global */ - public static final String NTP_SERVER = Global.NTP_SERVER; - - /** Timeout in milliseconds to wait for NTP server. {@hide} - * @deprecated moved to Settings.Global */ - public static final String NTP_TIMEOUT = Global.NTP_TIMEOUT; - - /** Autofill server address (Used in WebView/browser). - * @deprecated moved to Settings.Global - * {@hide} */ - public static final String WEB_AUTOFILL_QUERY_URL = Global.WEB_AUTOFILL_QUERY_URL; - - /** - * Whether the package manager should send package verification broadcasts for verifiers to - * review apps prior to installation. - * @deprecated moved to Settings.Global - * 1 = request apps to be verified prior to installation, if a verifier exists. - * 0 = do not verify apps before installation - * {@hide} - */ - @Deprecated - public static final String PACKAGE_VERIFIER_ENABLE = "package_verifier_enable"; - - /** Timeout for package verification. - * @deprecated moved to Settings.Global - * {@hide} */ - @Deprecated - public static final String PACKAGE_VERIFIER_TIMEOUT = "verifier_timeout"; - - /** Default response code for package verification. - * @deprecated moved to Settings.Global - * {@hide} */ - @Deprecated - public static final String PACKAGE_VERIFIER_DEFAULT_RESPONSE = "verifier_default_response"; - /** {@hide} */ public static final String READ_EXTERNAL_STORAGE_ENFORCED_DEFAULT = "read_external_storage_enforced_default"; /** - * Duration in milliseconds before pre-authorized URIs for the contacts - * provider should expire. - * @hide - */ - public static final String CONTACTS_PREAUTH_URI_EXPIRATION = - "contacts_preauth_uri_expiration"; - - /** * This are the settings to be backed up. * * NOTE: Settings are backed up and restored in the order they appear diff --git a/core/java/android/service/dreams/Dream.java b/core/java/android/service/dreams/Dream.java index 473414c..590acfa 100644 --- a/core/java/android/service/dreams/Dream.java +++ b/core/java/android/service/dreams/Dream.java @@ -72,6 +72,12 @@ public class Dream extends Service implements Window.Callback { private final String TAG = Dream.class.getSimpleName() + "[" + getClass().getSimpleName() + "]"; /** + * The name of the dream manager service. + * @hide + */ + public static final String DREAM_SERVICE = "dreams"; + + /** * Used with {@link Intent#ACTION_MAIN} to declare the necessary intent-filter for a dream. * * @see Dream @@ -499,7 +505,7 @@ public class Dream extends Service implements Window.Callback { // end public api private void loadSandman() { - mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService("dreams")); + mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService(DREAM_SERVICE)); } private final void attach(IBinder windowToken) { @@ -584,7 +590,7 @@ public class Dream extends Service implements Window.Callback { mFinished = true; if (mSandman != null) { - mSandman.awakenSelf(mWindowToken); + mSandman.finishSelf(mWindowToken); } else { Slog.w(TAG, "No dream manager found"); } diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl index bd1c524..1c1b390 100644 --- a/core/java/android/service/dreams/IDreamManager.aidl +++ b/core/java/android/service/dreams/IDreamManager.aidl @@ -30,5 +30,5 @@ interface IDreamManager { ComponentName getDefaultDreamComponent(); void testDream(in ComponentName componentName); boolean isDreaming(); - void awakenSelf(in IBinder token); + void finishSelf(in IBinder token); }
\ No newline at end of file diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index 123ce2a..b0a2711 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -314,7 +314,7 @@ public class ScaleGestureDetector { } } - final boolean configChanged = + final boolean configChanged = action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_POINTER_DOWN; final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP; @@ -344,7 +344,7 @@ public class ScaleGestureDetector { if (skipIndex == i) continue; // Average touch major and touch minor and convert the resulting diameter into a radius. - final float touchSize = getAdjustedTouchHistory(event.getPointerId(i)); + final float touchSize = getAdjustedTouchHistory(event.getPointerId(i)) / 2; devSumX += Math.abs(event.getX(i) - focusX) + touchSize; devSumY += Math.abs(event.getY(i) - focusY) + touchSize; } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 87396fb..7ca8322 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -789,6 +789,7 @@ public class ImageView extends View { if (resizeWidth) { int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) + pleft + pright; + widthSize = resolveAdjustedSize(newWidth, mMaxWidth, widthMeasureSpec); if (newWidth <= widthSize) { widthSize = newWidth; done = true; @@ -799,6 +800,7 @@ public class ImageView extends View { if (!done && resizeHeight) { int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) + ptop + pbottom; + heightSize = resolveAdjustedSize(newHeight, mMaxHeight, heightMeasureSpec); if (newHeight <= heightSize) { heightSize = newHeight; } diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index bffbe11..4ad0819 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -436,9 +436,10 @@ public class ResolverActivity extends AlertActivity implements AdapterView.OnIte if (mBaseResolveList != null) { mCurrentResolveList = mBaseResolveList; } else { - mCurrentResolveList = mPm.queryIntentActivities( + mCurrentResolveList = mPm.queryIntentActivitiesAsUser( mIntent, PackageManager.MATCH_DEFAULT_ONLY - | (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0)); + | (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0), + UserHandle.getUserId(mLaunchedFromUid)); // Filter out any activities that the launched uid does not // have permission for. We don't do this when we have an explicit // list of resolved activities, because that only happens when diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp index 78f989a..5c135ee 100644 --- a/core/jni/android_os_SystemClock.cpp +++ b/core/jni/android_os_SystemClock.cpp @@ -137,7 +137,7 @@ static JNINativeMethod gMethods[] = { (void*) android_os_SystemClock_currentThreadTimeMicro }, { "currentTimeMicro", "()J", (void*) android_os_SystemClock_currentTimeMicro }, - { "elapsedRealtimeNano", "()J", + { "elapsedRealtimeNanos", "()J", (void*) android_os_SystemClock_elapsedRealtimeNano }, }; int register_android_os_SystemClock(JNIEnv* env) diff --git a/core/res/res/values-sw600dp/bools.xml b/core/res/res/values-sw600dp/bools.xml index b8db31f..751b997 100644 --- a/core/res/res/values-sw600dp/bools.xml +++ b/core/res/res/values-sw600dp/bools.xml @@ -16,4 +16,5 @@ <resources> <bool name="target_honeycomb_needs_options_menu">false</bool> + <bool name="show_ongoing_ime_switcher">false</bool> </resources> diff --git a/core/res/res/values-w720dp/bools.xml b/core/res/res/values-w720dp/bools.xml index cd595ad..352c319 100644 --- a/core/res/res/values-w720dp/bools.xml +++ b/core/res/res/values-w720dp/bools.xml @@ -16,5 +16,4 @@ <resources> <bool name="action_bar_expanded_action_views_exclusive">false</bool> - <bool name="show_ongoing_ime_switcher">true</bool> </resources> diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java b/graphics/java/android/renderscript/ScriptIntrinsicBlend.java index 13c03af..65c69c0 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicBlend.java @@ -36,17 +36,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @return ScriptIntrinsicBlend */ public static ScriptIntrinsicBlend create(RenderScript rs, Element e) { - int id = rs.nScriptIntrinsicCreate(6, e.getID(rs)); + // 7 comes from RS_SCRIPT_INTRINSIC_ID_BLEND in rsDefines.h + int id = rs.nScriptIntrinsicCreate(7, e.getID(rs)); return new ScriptIntrinsicBlend(id, rs); } private void blend(int id, Allocation ain, Allocation aout) { - if (ain.getElement() != Element.U8_4(mRS)) { - throw new RSIllegalArgumentException("Input not of expected format."); + if (!ain.getElement().isCompatible(Element.U8_4(mRS))) { + throw new RSIllegalArgumentException("Input is not of expected format."); } - if (aout.getElement() != Element.U8_4(mRS)) { - throw new RSIllegalArgumentException("Output not of expected format."); + if (!aout.getElement().isCompatible(Element.U8_4(mRS))) { + throw new RSIllegalArgumentException("Output is not of expected format."); } forEach(id, ain, aout, null); } diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp index 5b1b57d..f0b5553 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -81,6 +81,7 @@ Program::Program(const ProgramDescription& description, const char* vertex, cons if (mInitialized) { transform = addUniform("transform"); + projection = addUniform("projection"); } } @@ -152,18 +153,20 @@ GLuint Program::buildShader(const char* source, GLenum type) { void Program::set(const mat4& projectionMatrix, const mat4& modelViewMatrix, const mat4& transformMatrix, bool offset) { - mat4 t(projectionMatrix); + mat4 p(projectionMatrix); if (offset) { // offset screenspace xy by an amount that compensates for typical precision // issues in GPU hardware that tends to paint hor/vert lines in pixels shifted // up and to the left. // This offset value is based on an assumption that some hardware may use as // little as 12.4 precision, so we offset by slightly more than 1/16. - t.translate(.375, .375, 0); + p.translate(.375, .375, 0); } - t.multiply(transformMatrix); + + mat4 t(transformMatrix); t.multiply(modelViewMatrix); + glUniformMatrix4fv(projection, 1, GL_FALSE, &p.data[0]); glUniformMatrix4fv(transform, 1, GL_FALSE, &t.data[0]); } diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h index b1cb446..7e3aacf 100644 --- a/libs/hwui/Program.h +++ b/libs/hwui/Program.h @@ -374,6 +374,11 @@ public: */ int transform; + /** + * Name of the projection uniform. + */ + int projection; + protected: /** * Adds an attribute with the specified name. diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 7bc2b37..f536ade 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -48,6 +48,7 @@ const char* gVS_Header_Attributes_AAVertexShapeParameters = const char* gVS_Header_Uniforms_TextureTransform = "uniform mat4 mainTextureTransform;\n"; const char* gVS_Header_Uniforms = + "uniform mat4 projection;\n" \ "uniform mat4 transform;\n"; const char* gVS_Header_Uniforms_IsPoint = "uniform mediump float pointSize;\n"; @@ -104,28 +105,28 @@ const char* gVS_Main_OutTransformedTexCoords = const char* gVS_Main_OutGradient[6] = { // Linear " linear = vec2((screenSpace * position).x, 0.5);\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", " linear = (screenSpace * position).x;\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", // Circular " circular = (screenSpace * position).xy;\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", " circular = (screenSpace * position).xy;\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", // Sweep " sweep = (screenSpace * position).xy;\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", " sweep = (screenSpace * position).xy;\n" - " ditherTexCoords = (gl_Position * ditherSize).xy;\n", + " ditherTexCoords = (transform * position).xy * ditherSize;\n", }; const char* gVS_Main_OutBitmapTexCoords = " outBitmapTexCoords = (textureTransform * position).xy * textureDimension;\n"; const char* gVS_Main_OutPointBitmapTexCoords = " outPointBitmapTexCoords = (textureTransform * position).xy * textureDimension;\n"; const char* gVS_Main_Position = - " gl_Position = transform * position;\n"; + " gl_Position = projection * transform * position;\n"; const char* gVS_Main_PointSize = " gl_PointSize = pointSize;\n"; const char* gVS_Main_AALine = diff --git a/location/java/android/location/Location.java b/location/java/android/location/Location.java index 672e378..f057ebc 100644 --- a/location/java/android/location/Location.java +++ b/location/java/android/location/Location.java @@ -71,7 +71,7 @@ public class Location implements Parcelable { private String mProvider; private long mTime = 0; - private long mElapsedRealtimeNano = 0; + private long mElapsedRealtimeNanos = 0; private double mLatitude = 0.0; private double mLongitude = 0.0; private boolean mHasAltitude = false; @@ -120,7 +120,7 @@ public class Location implements Parcelable { public void set(Location l) { mProvider = l.mProvider; mTime = l.mTime; - mElapsedRealtimeNano = l.mElapsedRealtimeNano; + mElapsedRealtimeNanos = l.mElapsedRealtimeNanos; mLatitude = l.mLatitude; mLongitude = l.mLongitude; mHasAltitude = l.mHasAltitude; @@ -140,7 +140,7 @@ public class Location implements Parcelable { public void reset() { mProvider = null; mTime = 0; - mElapsedRealtimeNano = 0; + mElapsedRealtimeNanos = 0; mLatitude = 0; mLongitude = 0; mHasAltitude = false; @@ -485,7 +485,7 @@ public class Location implements Parcelable { * * <p>Note that the UTC time on a device is not monotonic: it * can jump forwards or backwards unpredictably. So always use - * {@link #getElapsedRealtimeNano} when calculating time deltas. + * {@link #getElapsedRealtimeNanos} when calculating time deltas. * * <p>On the other hand, {@link #getTime} is useful for presenting * a human readable time to the user, or for carefully comparing @@ -515,7 +515,7 @@ public class Location implements Parcelable { * Return the time of this fix, in elapsed real-time since system boot. * * <p>This value can be reliably compared to - * {@link android.os.SystemClock#elapsedRealtimeNano}, + * {@link android.os.SystemClock#elapsedRealtimeNanos}, * to calculate the age of a fix and to compare Location fixes. This * is reliable because elapsed real-time is guaranteed monotonic for * each system boot and continues to increment even when the system @@ -526,8 +526,8 @@ public class Location implements Parcelable { * * @return elapsed real-time of fix, in nanoseconds since system boot. */ - public long getElapsedRealtimeNano() { - return mElapsedRealtimeNano; + public long getElapsedRealtimeNanos() { + return mElapsedRealtimeNanos; } /** @@ -535,8 +535,8 @@ public class Location implements Parcelable { * * @param time elapsed real-time of fix, in nanoseconds since system boot. */ - public void setElapsedRealtimeNano(long time) { - mElapsedRealtimeNano = time; + public void setElapsedRealtimeNanos(long time) { + mElapsedRealtimeNanos = time; } /** @@ -772,7 +772,7 @@ public class Location implements Parcelable { if (mProvider == null) return false; if (!mHasAccuracy) return false; if (mTime == 0) return false; - if (mElapsedRealtimeNano == 0) return false; + if (mElapsedRealtimeNanos == 0) return false; return true; } @@ -792,7 +792,7 @@ public class Location implements Parcelable { mAccuracy = 100.0f; } if (mTime == 0) mTime = System.currentTimeMillis(); - if (mElapsedRealtimeNano == 0) mElapsedRealtimeNano = SystemClock.elapsedRealtimeNano(); + if (mElapsedRealtimeNanos == 0) mElapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos(); } /** @@ -832,11 +832,11 @@ public class Location implements Parcelable { if (mTime == 0) { s.append(" t=?!?"); } - if (mElapsedRealtimeNano == 0) { + if (mElapsedRealtimeNanos == 0) { s.append(" et=?!?"); } else { s.append(" et="); - TimeUtils.formatDuration(mElapsedRealtimeNano / 1000000L, s); + TimeUtils.formatDuration(mElapsedRealtimeNanos / 1000000L, s); } if (mHasAltitude) s.append(" alt=").append(mAltitude); if (mHasSpeed) s.append(" vel=").append(mSpeed); @@ -860,7 +860,7 @@ public class Location implements Parcelable { String provider = in.readString(); Location l = new Location(provider); l.mTime = in.readLong(); - l.mElapsedRealtimeNano = in.readLong(); + l.mElapsedRealtimeNanos = in.readLong(); l.mLatitude = in.readDouble(); l.mLongitude = in.readDouble(); l.mHasAltitude = in.readInt() != 0; @@ -890,7 +890,7 @@ public class Location implements Parcelable { public void writeToParcel(Parcel parcel, int flags) { parcel.writeString(mProvider); parcel.writeLong(mTime); - parcel.writeLong(mElapsedRealtimeNano); + parcel.writeLong(mElapsedRealtimeNanos); parcel.writeDouble(mLatitude); parcel.writeDouble(mLongitude); parcel.writeInt(mHasAltitude ? 1 : 0); diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 5b3c9e2..4ad8fd0 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -1186,7 +1186,7 @@ public class LocationManager { * Get the last known location. * * <p>This location could be very old so use - * {@link Location#getElapsedRealtimeNano} to calculate its age. It can + * {@link Location#getElapsedRealtimeNanos} to calculate its age. It can * also return null if no previous location is available. * * <p>Always returns immediately. diff --git a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java index b83521a..2cf795d 100644 --- a/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java +++ b/packages/FusedLocation/src/com/android/location/fused/FusionEngine.java @@ -215,7 +215,7 @@ public class FusionEngine implements LocationListener { } private static double weighAge(Location loc) { - long ageSeconds = SystemClock.elapsedRealtimeNano() - loc.getElapsedRealtimeNano(); + long ageSeconds = SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos(); ageSeconds /= 1000000000L; if (ageSeconds < 0) ageSeconds = 0; return Math.exp(-ageSeconds * AGE_DECAY_CONSTANT_S); @@ -266,7 +266,7 @@ public class FusionEngine implements LocationListener { // fused time - now fused.setTime(System.currentTimeMillis()); - fused.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano()); + fused.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); // fuse altitude if (mGpsLocation.hasAltitude() && !mNetworkLocation.hasAltitude() && diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 8275b25..dc4213e 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -472,7 +472,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { String value = mContext.getResources().getBoolean(R.bool.assisted_gps_enabled) ? "1" : "0"; db.execSQL("INSERT OR IGNORE INTO secure(name,value) values('" + - Settings.Secure.ASSISTED_GPS_ENABLED + "','" + value + "');"); + Settings.Global.ASSISTED_GPS_ENABLED + "','" + value + "');"); db.setTransactionSuccessful(); } finally { db.endTransaction(); @@ -1190,7 +1190,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { try { stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)" + " VALUES(?,?);"); - loadBooleanSetting(stmt, Settings.Secure.PACKAGE_VERIFIER_ENABLE, + loadBooleanSetting(stmt, Settings.Global.PACKAGE_VERIFIER_ENABLE, R.bool.def_package_verifier_enable); db.setTransactionSuccessful(); } finally { @@ -1300,9 +1300,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { db.beginTransaction(); try { String[] settingsToMove = { - Settings.Secure.PACKAGE_VERIFIER_ENABLE, - Settings.Secure.PACKAGE_VERIFIER_TIMEOUT, - Settings.Secure.PACKAGE_VERIFIER_DEFAULT_RESPONSE + Settings.Global.PACKAGE_VERIFIER_ENABLE, + Settings.Global.PACKAGE_VERIFIER_TIMEOUT, + Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE }; moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); @@ -1319,9 +1319,9 @@ public class DatabaseHelper extends SQLiteOpenHelper { db.beginTransaction(); try { String[] settingsToMove = { - Settings.Secure.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS, - Settings.Secure.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS, - Settings.Secure.GPRS_REGISTER_CHECK_PERIOD_MS + Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS, + Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS, + Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS }; moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true); diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 6d8b08f..2c0bf75 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -110,94 +110,94 @@ public class SettingsProvider extends ContentProvider { // table, shared across all users // These must match Settings.Secure.MOVED_TO_GLOBAL sSecureGlobalKeys = new HashSet<String>(); - sSecureGlobalKeys.add(Settings.Secure.ADB_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.ASSISTED_GPS_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.BLUETOOTH_ON); - sSecureGlobalKeys.add(Settings.Secure.CDMA_CELL_BROADCAST_SMS); - sSecureGlobalKeys.add(Settings.Secure.CDMA_ROAMING_MODE); - sSecureGlobalKeys.add(Settings.Secure.CDMA_SUBSCRIPTION_MODE); - sSecureGlobalKeys.add(Settings.Secure.DATA_ACTIVITY_TIMEOUT_MOBILE); - sSecureGlobalKeys.add(Settings.Secure.DATA_ACTIVITY_TIMEOUT_WIFI); - sSecureGlobalKeys.add(Settings.Secure.DATA_ROAMING); - sSecureGlobalKeys.add(Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.DEVICE_PROVISIONED); - sSecureGlobalKeys.add(Settings.Secure.DISPLAY_DENSITY_FORCED); - sSecureGlobalKeys.add(Settings.Secure.DISPLAY_SIZE_FORCED); - sSecureGlobalKeys.add(Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE); - sSecureGlobalKeys.add(Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE); - sSecureGlobalKeys.add(Settings.Secure.INSTALL_NON_MARKET_APPS); - sSecureGlobalKeys.add(Settings.Secure.MOBILE_DATA); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_DEV_BUCKET_DURATION); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_DEV_DELETE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_DEV_PERSIST_BYTES); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_DEV_ROTATE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_GLOBAL_ALERT_BYTES); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_POLL_INTERVAL); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_REPORT_XT_OVER_DEV); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_SAMPLE_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_TIME_CACHE_MAX_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_BUCKET_DURATION); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_DELETE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_PERSIST_BYTES); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_ROTATE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_TAG_BUCKET_DURATION); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_TAG_DELETE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_TAG_PERSIST_BYTES); - sSecureGlobalKeys.add(Settings.Secure.NETSTATS_UID_TAG_ROTATE_AGE); - sSecureGlobalKeys.add(Settings.Secure.NETWORK_PREFERENCE); - sSecureGlobalKeys.add(Settings.Secure.NITZ_UPDATE_DIFF); - sSecureGlobalKeys.add(Settings.Secure.NITZ_UPDATE_SPACING); - sSecureGlobalKeys.add(Settings.Secure.NTP_SERVER); - sSecureGlobalKeys.add(Settings.Secure.NTP_TIMEOUT); - sSecureGlobalKeys.add(Settings.Secure.PDP_WATCHDOG_ERROR_POLL_COUNT); - sSecureGlobalKeys.add(Settings.Secure.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS); - sSecureGlobalKeys.add(Settings.Secure.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT); - sSecureGlobalKeys.add(Settings.Secure.PDP_WATCHDOG_POLL_INTERVAL_MS); - sSecureGlobalKeys.add(Settings.Secure.PDP_WATCHDOG_TRIGGER_PACKET_COUNT); - sSecureGlobalKeys.add(Settings.Secure.SAMPLING_PROFILER_MS); - sSecureGlobalKeys.add(Settings.Secure.SETUP_PREPAID_DATA_SERVICE_URL); - sSecureGlobalKeys.add(Settings.Secure.SETUP_PREPAID_DETECTION_REDIR_HOST); - sSecureGlobalKeys.add(Settings.Secure.SETUP_PREPAID_DETECTION_TARGET_URL); - sSecureGlobalKeys.add(Settings.Secure.TETHER_DUN_APN); - sSecureGlobalKeys.add(Settings.Secure.TETHER_DUN_REQUIRED); - sSecureGlobalKeys.add(Settings.Secure.TETHER_SUPPORTED); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_HELP_URI); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_NOTIFICATION_TYPE); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_POLLING_SEC); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_RESET_DAY); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_THRESHOLD_BYTES); - sSecureGlobalKeys.add(Settings.Secure.THROTTLE_VALUE_KBITSPS); - sSecureGlobalKeys.add(Settings.Secure.USB_MASS_STORAGE_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.USE_GOOGLE_MAIL); - sSecureGlobalKeys.add(Settings.Secure.WEB_AUTOFILL_QUERY_URL); - sSecureGlobalKeys.add(Settings.Secure.WIFI_COUNTRY_CODE); - sSecureGlobalKeys.add(Settings.Secure.WIFI_FRAMEWORK_SCAN_INTERVAL_MS); - sSecureGlobalKeys.add(Settings.Secure.WIFI_FREQUENCY_BAND); - sSecureGlobalKeys.add(Settings.Secure.WIFI_IDLE_MS); - sSecureGlobalKeys.add(Settings.Secure.WIFI_MAX_DHCP_RETRY_COUNT); - sSecureGlobalKeys.add(Settings.Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS); - sSecureGlobalKeys.add(Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON); - sSecureGlobalKeys.add(Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY); - sSecureGlobalKeys.add(Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT); - sSecureGlobalKeys.add(Settings.Secure.WIFI_ON); - sSecureGlobalKeys.add(Settings.Secure.WIFI_P2P_DEVICE_NAME); - sSecureGlobalKeys.add(Settings.Secure.WIFI_SAVED_STATE); - sSecureGlobalKeys.add(Settings.Secure.WIFI_SUPPLICANT_SCAN_INTERVAL_MS); - sSecureGlobalKeys.add(Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.WIFI_WATCHDOG_NUM_ARP_PINGS); - sSecureGlobalKeys.add(Settings.Secure.WIFI_WATCHDOG_ON); - sSecureGlobalKeys.add(Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED); - sSecureGlobalKeys.add(Settings.Secure.WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS); - sSecureGlobalKeys.add(Settings.Secure.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON); - sSecureGlobalKeys.add(Settings.Secure.PACKAGE_VERIFIER_ENABLE); - sSecureGlobalKeys.add(Settings.Secure.PACKAGE_VERIFIER_TIMEOUT); - sSecureGlobalKeys.add(Settings.Secure.PACKAGE_VERIFIER_DEFAULT_RESPONSE); - sSecureGlobalKeys.add(Settings.Secure.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS); - sSecureGlobalKeys.add(Settings.Secure.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS); - sSecureGlobalKeys.add(Settings.Secure.GPRS_REGISTER_CHECK_PERIOD_MS); - sSecureGlobalKeys.add(Settings.Secure.WTF_IS_FATAL); + sSecureGlobalKeys.add(Settings.Global.ADB_ENABLED); + sSecureGlobalKeys.add(Settings.Global.ASSISTED_GPS_ENABLED); + sSecureGlobalKeys.add(Settings.Global.BLUETOOTH_ON); + sSecureGlobalKeys.add(Settings.Global.CDMA_CELL_BROADCAST_SMS); + sSecureGlobalKeys.add(Settings.Global.CDMA_ROAMING_MODE); + sSecureGlobalKeys.add(Settings.Global.CDMA_SUBSCRIPTION_MODE); + sSecureGlobalKeys.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE); + sSecureGlobalKeys.add(Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI); + sSecureGlobalKeys.add(Settings.Global.DATA_ROAMING); + sSecureGlobalKeys.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED); + sSecureGlobalKeys.add(Settings.Global.DEVICE_PROVISIONED); + sSecureGlobalKeys.add(Settings.Global.DISPLAY_DENSITY_FORCED); + sSecureGlobalKeys.add(Settings.Global.DISPLAY_SIZE_FORCED); + sSecureGlobalKeys.add(Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE); + sSecureGlobalKeys.add(Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE); + sSecureGlobalKeys.add(Settings.Global.INSTALL_NON_MARKET_APPS); + sSecureGlobalKeys.add(Settings.Global.MOBILE_DATA); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_DEV_BUCKET_DURATION); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_DEV_DELETE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_DEV_PERSIST_BYTES); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_DEV_ROTATE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_ENABLED); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_POLL_INTERVAL); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_REPORT_XT_OVER_DEV); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_SAMPLE_ENABLED); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_BUCKET_DURATION); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_DELETE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_PERSIST_BYTES); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_ROTATE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_TAG_DELETE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES); + sSecureGlobalKeys.add(Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE); + sSecureGlobalKeys.add(Settings.Global.NETWORK_PREFERENCE); + sSecureGlobalKeys.add(Settings.Global.NITZ_UPDATE_DIFF); + sSecureGlobalKeys.add(Settings.Global.NITZ_UPDATE_SPACING); + sSecureGlobalKeys.add(Settings.Global.NTP_SERVER); + sSecureGlobalKeys.add(Settings.Global.NTP_TIMEOUT); + sSecureGlobalKeys.add(Settings.Global.PDP_WATCHDOG_ERROR_POLL_COUNT); + sSecureGlobalKeys.add(Settings.Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS); + sSecureGlobalKeys.add(Settings.Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT); + sSecureGlobalKeys.add(Settings.Global.PDP_WATCHDOG_POLL_INTERVAL_MS); + sSecureGlobalKeys.add(Settings.Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT); + sSecureGlobalKeys.add(Settings.Global.SAMPLING_PROFILER_MS); + sSecureGlobalKeys.add(Settings.Global.SETUP_PREPAID_DATA_SERVICE_URL); + sSecureGlobalKeys.add(Settings.Global.SETUP_PREPAID_DETECTION_REDIR_HOST); + sSecureGlobalKeys.add(Settings.Global.SETUP_PREPAID_DETECTION_TARGET_URL); + sSecureGlobalKeys.add(Settings.Global.TETHER_DUN_APN); + sSecureGlobalKeys.add(Settings.Global.TETHER_DUN_REQUIRED); + sSecureGlobalKeys.add(Settings.Global.TETHER_SUPPORTED); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_HELP_URI); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_NOTIFICATION_TYPE); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_POLLING_SEC); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_RESET_DAY); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_THRESHOLD_BYTES); + sSecureGlobalKeys.add(Settings.Global.THROTTLE_VALUE_KBITSPS); + sSecureGlobalKeys.add(Settings.Global.USB_MASS_STORAGE_ENABLED); + sSecureGlobalKeys.add(Settings.Global.USE_GOOGLE_MAIL); + sSecureGlobalKeys.add(Settings.Global.WEB_AUTOFILL_QUERY_URL); + sSecureGlobalKeys.add(Settings.Global.WIFI_COUNTRY_CODE); + sSecureGlobalKeys.add(Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS); + sSecureGlobalKeys.add(Settings.Global.WIFI_FREQUENCY_BAND); + sSecureGlobalKeys.add(Settings.Global.WIFI_IDLE_MS); + sSecureGlobalKeys.add(Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT); + sSecureGlobalKeys.add(Settings.Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS); + sSecureGlobalKeys.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON); + sSecureGlobalKeys.add(Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY); + sSecureGlobalKeys.add(Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT); + sSecureGlobalKeys.add(Settings.Global.WIFI_ON); + sSecureGlobalKeys.add(Settings.Global.WIFI_P2P_DEVICE_NAME); + sSecureGlobalKeys.add(Settings.Global.WIFI_SAVED_STATE); + sSecureGlobalKeys.add(Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS); + sSecureGlobalKeys.add(Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED); + sSecureGlobalKeys.add(Settings.Global.WIFI_WATCHDOG_NUM_ARP_PINGS); + sSecureGlobalKeys.add(Settings.Global.WIFI_WATCHDOG_ON); + sSecureGlobalKeys.add(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED); + sSecureGlobalKeys.add(Settings.Global.WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS); + sSecureGlobalKeys.add(Settings.Global.WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON); + sSecureGlobalKeys.add(Settings.Global.PACKAGE_VERIFIER_ENABLE); + sSecureGlobalKeys.add(Settings.Global.PACKAGE_VERIFIER_TIMEOUT); + sSecureGlobalKeys.add(Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE); + sSecureGlobalKeys.add(Settings.Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS); + sSecureGlobalKeys.add(Settings.Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS); + sSecureGlobalKeys.add(Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS); + sSecureGlobalKeys.add(Settings.Global.WTF_IS_FATAL); // Keys from the 'system' table now moved to 'global' // These must match Settings.System.MOVED_TO_GLOBAL diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_close_off.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_close_off.9.png Binary files differindex bc6462b..0c301ab 100644 --- a/packages/SystemUI/res/drawable-hdpi/status_bar_close_off.9.png +++ b/packages/SystemUI/res/drawable-hdpi/status_bar_close_off.9.png diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_close_on.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_close_on.9.png Binary files differindex f4e28ae..ec0424a 100644 --- a/packages/SystemUI/res/drawable-hdpi/status_bar_close_on.9.png +++ b/packages/SystemUI/res/drawable-hdpi/status_bar_close_on.9.png diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_close_off.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_close_off.9.png Binary files differindex 4f5bba5..5c577cb 100644 --- a/packages/SystemUI/res/drawable-mdpi/status_bar_close_off.9.png +++ b/packages/SystemUI/res/drawable-mdpi/status_bar_close_off.9.png diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_close_on.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_close_on.9.png Binary files differindex ef7afb8..7efb502 100644 --- a/packages/SystemUI/res/drawable-mdpi/status_bar_close_on.9.png +++ b/packages/SystemUI/res/drawable-mdpi/status_bar_close_on.9.png diff --git a/packages/SystemUI/res/drawable-xhdpi/status_bar_close_off.9.png b/packages/SystemUI/res/drawable-xhdpi/status_bar_close_off.9.png Binary files differindex e243e50..98d0cfb 100644 --- a/packages/SystemUI/res/drawable-xhdpi/status_bar_close_off.9.png +++ b/packages/SystemUI/res/drawable-xhdpi/status_bar_close_off.9.png diff --git a/packages/SystemUI/res/drawable-xhdpi/status_bar_close_on.9.png b/packages/SystemUI/res/drawable-xhdpi/status_bar_close_on.9.png Binary files differindex cdad949..17f4169 100644 --- a/packages/SystemUI/res/drawable-xhdpi/status_bar_close_on.9.png +++ b/packages/SystemUI/res/drawable-xhdpi/status_bar_close_on.9.png diff --git a/packages/SystemUI/src/com/android/systemui/Somnambulator.java b/packages/SystemUI/src/com/android/systemui/Somnambulator.java index 89d4ef7..bd87238 100644 --- a/packages/SystemUI/src/com/android/systemui/Somnambulator.java +++ b/packages/SystemUI/src/com/android/systemui/Somnambulator.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.content.Intent; import android.os.RemoteException; import android.os.ServiceManager; +import android.service.dreams.Dream; import android.service.dreams.IDreamManager; import android.util.Slog; @@ -45,7 +46,7 @@ public class Somnambulator extends Activity { setResult(RESULT_OK, resultIntent); } else { IDreamManager somnambulist = IDreamManager.Stub.asInterface( - ServiceManager.checkService("dreams")); + ServiceManager.checkService(Dream.DREAM_SERVICE)); if (somnambulist != null) { try { Slog.v("Somnambulator", "Dreaming by user request."); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index e6aa632..d72632f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -45,6 +45,7 @@ import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; +import android.service.dreams.Dream; import android.service.dreams.IDreamManager; import android.util.DisplayMetrics; import android.util.Log; @@ -262,7 +263,7 @@ public class PhoneStatusBar extends BaseStatusBar { .getDefaultDisplay(); mDreamManager = IDreamManager.Stub.asInterface( - ServiceManager.checkService("dreams")); + ServiceManager.checkService(Dream.DREAM_SERVICE)); super.start(); // calls createAndAddWindows() diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index ceb17c7..891cac7 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -1509,8 +1509,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { // which is where we store the value and maybe make this // asynchronous. enforceAccessPermission(); - boolean retVal = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.MOBILE_DATA, 1) == 1; + boolean retVal = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.MOBILE_DATA, 1) == 1; if (VDBG) log("getMobileDataEnabled returning " + retVal); return retVal; } diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java index 8ad5a91..4a8bf72 100644 --- a/services/java/com/android/server/DockObserver.java +++ b/services/java/com/android/server/DockObserver.java @@ -16,9 +16,6 @@ package com.android.server; -import static android.provider.Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK; -import static android.provider.Settings.Secure.SCREENSAVER_ENABLED; - import android.content.ContentResolver; import android.content.Context; import android.content.Intent; @@ -27,16 +24,12 @@ import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Handler; -import android.os.Looper; import android.os.Message; -import android.os.RemoteException; -import android.os.ServiceManager; import android.os.PowerManager; import android.os.SystemClock; import android.os.UEventObserver; import android.os.UserHandle; import android.provider.Settings; -import android.service.dreams.IDreamManager; import android.util.Log; import android.util.Slog; @@ -48,14 +41,10 @@ import java.io.FileReader; */ final class DockObserver extends UEventObserver { private static final String TAG = DockObserver.class.getSimpleName(); - private static final boolean LOG = false; private static final String DOCK_UEVENT_MATCH = "DEVPATH=/devices/virtual/switch/dock"; private static final String DOCK_STATE_PATH = "/sys/class/switch/dock/state"; - private static final int DEFAULT_SCREENSAVER_ENABLED = 1; - private static final int DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK = 1; - private static final int MSG_DOCK_STATE_CHANGED = 0; private final Object mLock = new Object(); @@ -66,11 +55,16 @@ final class DockObserver extends UEventObserver { private boolean mSystemReady; private final Context mContext; + private final PowerManager mPowerManager; + private final PowerManager.WakeLock mWakeLock; public DockObserver(Context context) { mContext = context; - init(); // set initial status + mPowerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); + mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); + + init(); // set initial status startObserving(DOCK_UEVENT_MATCH); } @@ -87,17 +81,9 @@ final class DockObserver extends UEventObserver { mPreviousDockState = mDockState; mDockState = newState; if (mSystemReady) { - // Don't force screen on when undocking from the desk dock. - // The change in power state will do this anyway. - // FIXME - we should be configurable. - if ((mPreviousDockState != Intent.EXTRA_DOCK_STATE_DESK - && mPreviousDockState != Intent.EXTRA_DOCK_STATE_LE_DESK - && mPreviousDockState != Intent.EXTRA_DOCK_STATE_HE_DESK) || - mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) { - PowerManager pm = - (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); - pm.wakeUp(SystemClock.uptimeMillis()); - } + // Wake up immediately when docked or undocked. + mPowerManager.wakeUp(SystemClock.uptimeMillis()); + updateLocked(); } } @@ -138,6 +124,7 @@ final class DockObserver extends UEventObserver { } private void updateLocked() { + mWakeLock.acquire(); mHandler.sendEmptyMessage(MSG_DOCK_STATE_CHANGED); } @@ -145,8 +132,8 @@ final class DockObserver extends UEventObserver { synchronized (mLock) { Slog.i(TAG, "Dock state changed: " + mDockState); + // Skip the dock intent if not yet provisioned. final ContentResolver cr = mContext.getContentResolver(); - if (Settings.Global.getInt(cr, Settings.Global.DEVICE_PROVISIONED, 0) == 0) { Slog.i(TAG, "Device not provisioned, skipping dock broadcast"); @@ -158,16 +145,8 @@ final class DockObserver extends UEventObserver { intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra(Intent.EXTRA_DOCK_STATE, mDockState); - // Check if this is Bluetooth Dock - // TODO(BT): Get Dock address. - // String address = null; - // if (address != null) { - // intent.putExtra(BluetoothDevice.EXTRA_DEVICE, - // BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address)); - // } - - // User feedback to confirm dock connection. Particularly - // useful for flaky contact pins... + // Play a sound to provide feedback to confirm dock connection. + // Particularly useful for flaky contact pins... if (Settings.Global.getInt(cr, Settings.Global.DOCK_SOUNDS_ENABLED, 1) == 1) { String whichSound = null; @@ -204,42 +183,14 @@ final class DockObserver extends UEventObserver { } } - IDreamManager mgr = IDreamManager.Stub.asInterface(ServiceManager.getService("dreams")); - if (mgr != null) { - // dreams feature enabled - boolean undocked = mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED; - if (undocked) { - try { - if (mgr.isDreaming()) { - mgr.awaken(); - } - } catch (RemoteException e) { - Slog.w(TAG, "Unable to awaken!", e); - } - } else { - if (isScreenSaverEnabled(mContext) && isScreenSaverActivatedOnDock(mContext)) { - try { - mgr.dream(); - } catch (RemoteException e) { - Slog.w(TAG, "Unable to dream!", e); - } - } - } - } else { - // dreams feature not enabled, send legacy intent - mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); - } - } - } + // Send the dock event intent. + // There are many components in the system watching for this so as to + // adjust audio routing, screen orientation, etc. + mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); - private static boolean isScreenSaverEnabled(Context context) { - return Settings.Secure.getInt(context.getContentResolver(), - SCREENSAVER_ENABLED, DEFAULT_SCREENSAVER_ENABLED) != 0; - } - - private static boolean isScreenSaverActivatedOnDock(Context context) { - return Settings.Secure.getInt(context.getContentResolver(), - SCREENSAVER_ACTIVATE_ON_DOCK, DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK) != 0; + // Release the wake lock that was acquired when the message was posted. + mWakeLock.release(); + } } private final Handler mHandler = new Handler(true /*async*/) { diff --git a/services/java/com/android/server/DreamController.java b/services/java/com/android/server/DreamController.java deleted file mode 100644 index 498e581..0000000 --- a/services/java/com/android/server/DreamController.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2012 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.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Binder; -import android.os.Handler; -import android.os.IBinder; -import android.os.RemoteException; -import android.os.IBinder.DeathRecipient; -import android.service.dreams.IDreamService; -import android.util.Slog; -import android.view.IWindowManager; -import android.view.WindowManager; -import android.view.WindowManagerGlobal; - -import com.android.internal.util.DumpUtils; - -import java.io.PrintWriter; -import java.util.NoSuchElementException; - -/** - * Internal controller for starting and stopping the current dream and managing related state. - * - * Assumes all operations (except {@link #dump}) are called from a single thread. - */ -final class DreamController { - private static final boolean DEBUG = true; - private static final String TAG = DreamController.class.getSimpleName(); - - public interface Listener { - void onDreamStopped(boolean wasTest); - } - - private final Context mContext; - private final IWindowManager mIWindowManager; - private final DeathRecipient mDeathRecipient; - private final ServiceConnection mServiceConnection; - private final Listener mListener; - - private Handler mHandler; - - private ComponentName mCurrentDreamComponent; - private IDreamService mCurrentDream; - private Binder mCurrentDreamToken; - private boolean mCurrentDreamIsTest; - - public DreamController(Context context, DeathRecipient deathRecipient, - ServiceConnection serviceConnection, Listener listener) { - mContext = context; - mDeathRecipient = deathRecipient; - mServiceConnection = serviceConnection; - mListener = listener; - mIWindowManager = WindowManagerGlobal.getWindowManagerService(); - } - - public void setHandler(Handler handler) { - mHandler = handler; - } - - public void dump(PrintWriter pw) { - if (mHandler== null || pw == null) { - return; - } - DumpUtils.dumpAsync(mHandler, new DumpUtils.Dump() { - @Override - public void dump(PrintWriter pw) { - pw.print(" component="); pw.println(mCurrentDreamComponent); - pw.print(" token="); pw.println(mCurrentDreamToken); - pw.print(" dream="); pw.println(mCurrentDream); - } - }, pw, 200); - } - - public void start(ComponentName dream, boolean isTest) { - if (DEBUG) Slog.v(TAG, String.format("start(%s,%s)", dream, isTest)); - - if (mCurrentDreamComponent != null ) { - if (dream.equals(mCurrentDreamComponent) && isTest == mCurrentDreamIsTest) { - if (DEBUG) Slog.v(TAG, "Dream is already started: " + dream); - return; - } - // stop the current dream before starting a new one - stop(); - } - - mCurrentDreamComponent = dream; - mCurrentDreamIsTest = isTest; - mCurrentDreamToken = new Binder(); - - try { - if (DEBUG) Slog.v(TAG, "Adding window token: " + mCurrentDreamToken - + " for window type: " + WindowManager.LayoutParams.TYPE_DREAM); - mIWindowManager.addWindowToken(mCurrentDreamToken, - WindowManager.LayoutParams.TYPE_DREAM); - } catch (RemoteException e) { - Slog.w(TAG, "Unable to add window token."); - stop(); - return; - } - - Intent intent = new Intent(Intent.ACTION_MAIN) - .setComponent(mCurrentDreamComponent) - .addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) - .putExtra("android.dreams.TEST", mCurrentDreamIsTest); - - if (!mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE)) { - Slog.w(TAG, "Unable to bind service"); - stop(); - return; - } - if (DEBUG) Slog.v(TAG, "Bound service"); - } - - public void attach(ComponentName name, IBinder dream) { - if (DEBUG) Slog.v(TAG, String.format("attach(%s,%s)", name, dream)); - mCurrentDream = IDreamService.Stub.asInterface(dream); - - boolean linked = linkDeathRecipient(dream); - if (!linked) { - stop(); - return; - } - - try { - if (DEBUG) Slog.v(TAG, "Attaching with token:" + mCurrentDreamToken); - mCurrentDream.attach(mCurrentDreamToken); - } catch (Throwable ex) { - Slog.w(TAG, "Unable to send window token to dream:" + ex); - stop(); - } - } - - public void stop() { - if (DEBUG) Slog.v(TAG, "stop()"); - - if (mCurrentDream != null) { - unlinkDeathRecipient(mCurrentDream.asBinder()); - - if (DEBUG) Slog.v(TAG, "Unbinding: " + mCurrentDreamComponent + " service: " + mCurrentDream); - mContext.unbindService(mServiceConnection); - } - if (mCurrentDreamToken != null) { - removeWindowToken(mCurrentDreamToken); - } - - final boolean wasTest = mCurrentDreamIsTest; - mCurrentDream = null; - mCurrentDreamToken = null; - mCurrentDreamComponent = null; - mCurrentDreamIsTest = false; - - if (mListener != null && mHandler != null) { - mHandler.post(new Runnable(){ - @Override - public void run() { - mListener.onDreamStopped(wasTest); - }}); - } - } - - public void stopSelf(IBinder token) { - if (DEBUG) Slog.v(TAG, String.format("stopSelf(%s)", token)); - if (token == null || token != mCurrentDreamToken) { - Slog.w(TAG, "Stop requested for non-current dream token: " + token); - } else { - stop(); - } - } - - private void removeWindowToken(IBinder token) { - if (DEBUG) Slog.v(TAG, "Removing window token: " + token); - try { - mIWindowManager.removeWindowToken(token); - } catch (Throwable e) { - Slog.w(TAG, "Error removing window token", e); - } - } - - private boolean linkDeathRecipient(IBinder dream) { - if (DEBUG) Slog.v(TAG, "Linking death recipient"); - try { - dream.linkToDeath(mDeathRecipient, 0); - return true; - } catch (RemoteException e) { - Slog.w(TAG, "Unable to link death recipient", e); - return false; - } - } - - private void unlinkDeathRecipient(IBinder dream) { - if (DEBUG) Slog.v(TAG, "Unlinking death recipient"); - try { - dream.unlinkToDeath(mDeathRecipient, 0); - } catch (NoSuchElementException e) { - // we tried - } - } - -}
\ No newline at end of file diff --git a/services/java/com/android/server/DreamManagerService.java b/services/java/com/android/server/DreamManagerService.java deleted file mode 100644 index b02ea7f..0000000 --- a/services/java/com/android/server/DreamManagerService.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (C) 2012 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 static android.provider.Settings.Secure.SCREENSAVER_COMPONENTS; -import static android.provider.Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT; - -import android.app.ActivityManagerNative; -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.ServiceConnection; -import android.content.pm.PackageManager; -import android.os.Binder; -import android.os.Bundle; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.os.RemoteException; -import android.os.UserHandle; -import android.provider.Settings; -import android.service.dreams.Dream; -import android.service.dreams.IDreamManager; -import android.util.Slog; -import android.util.SparseArray; - -import java.io.FileDescriptor; -import java.io.PrintWriter; - -/** - * Service api for managing dreams. - * - * @hide - */ -public final class DreamManagerService - extends IDreamManager.Stub - implements ServiceConnection { - private static final boolean DEBUG = true; - private static final String TAG = DreamManagerService.class.getSimpleName(); - - private static final Intent mDreamingStartedIntent = new Intent(Dream.ACTION_DREAMING_STARTED) - .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); - private static final Intent mDreamingStoppedIntent = new Intent(Dream.ACTION_DREAMING_STOPPED) - .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); - - private final Object mLock = new Object(); - private final DreamController mController; - private final DreamControllerHandler mHandler; - private final Context mContext; - - private final CurrentUserManager mCurrentUserManager = new CurrentUserManager(); - - private final DeathRecipient mAwakenOnBinderDeath = new DeathRecipient() { - @Override - public void binderDied() { - if (DEBUG) Slog.v(TAG, "binderDied()"); - awaken(); - } - }; - - private final DreamController.Listener mControllerListener = new DreamController.Listener() { - @Override - public void onDreamStopped(boolean wasTest) { - synchronized(mLock) { - setDreamingLocked(false, wasTest); - } - }}; - - private boolean mIsDreaming; - - public DreamManagerService(Context context) { - if (DEBUG) Slog.v(TAG, "DreamManagerService startup"); - mContext = context; - mController = new DreamController(context, mAwakenOnBinderDeath, this, mControllerListener); - mHandler = new DreamControllerHandler(mController); - mController.setHandler(mHandler); - } - - public void systemReady() { - mCurrentUserManager.init(mContext); - - if (DEBUG) Slog.v(TAG, "Ready to dream!"); - } - - @Override - protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); - - pw.println("Dreamland:"); - mController.dump(pw); - mCurrentUserManager.dump(pw); - } - - // begin IDreamManager api - @Override - public ComponentName[] getDreamComponents() { - checkPermission(android.Manifest.permission.READ_DREAM_STATE); - int userId = UserHandle.getCallingUserId(); - - final long ident = Binder.clearCallingIdentity(); - try { - return getDreamComponentsForUser(userId); - } finally { - Binder.restoreCallingIdentity(ident); - } - } - - @Override - public void setDreamComponents(ComponentName[] componentNames) { - checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); - int userId = UserHandle.getCallingUserId(); - - final long ident = Binder.clearCallingIdentity(); - try { - Settings.Secure.putStringForUser(mContext.getContentResolver(), - SCREENSAVER_COMPONENTS, - componentsToString(componentNames), - userId); - } finally { - Binder.restoreCallingIdentity(ident); - } - } - - @Override - public ComponentName getDefaultDreamComponent() { - checkPermission(android.Manifest.permission.READ_DREAM_STATE); - int userId = UserHandle.getCallingUserId(); - - final long ident = Binder.clearCallingIdentity(); - try { - String name = Settings.Secure.getStringForUser(mContext.getContentResolver(), - SCREENSAVER_DEFAULT_COMPONENT, - userId); - return name == null ? null : ComponentName.unflattenFromString(name); - } finally { - Binder.restoreCallingIdentity(ident); - } - - } - - @Override - public boolean isDreaming() { - checkPermission(android.Manifest.permission.READ_DREAM_STATE); - - return mIsDreaming; - } - - @Override - public void dream() { - checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); - - final long ident = Binder.clearCallingIdentity(); - try { - if (DEBUG) Slog.v(TAG, "Dream now"); - ComponentName[] dreams = getDreamComponentsForUser(mCurrentUserManager.getCurrentUserId()); - ComponentName firstDream = dreams != null && dreams.length > 0 ? dreams[0] : null; - if (firstDream != null) { - mHandler.requestStart(firstDream, false /*isTest*/); - synchronized (mLock) { - setDreamingLocked(true, false /*isTest*/); - } - } - } finally { - Binder.restoreCallingIdentity(ident); - } - } - - @Override - public void testDream(ComponentName dream) { - checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); - - final long ident = Binder.clearCallingIdentity(); - try { - if (DEBUG) Slog.v(TAG, "Test dream name=" + dream); - if (dream != null) { - mHandler.requestStart(dream, true /*isTest*/); - synchronized (mLock) { - setDreamingLocked(true, true /*isTest*/); - } - } - } finally { - Binder.restoreCallingIdentity(ident); - } - - } - - @Override - public void awaken() { - checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); - - final long ident = Binder.clearCallingIdentity(); - try { - if (DEBUG) Slog.v(TAG, "Wake up"); - mHandler.requestStop(); - } finally { - Binder.restoreCallingIdentity(ident); - } - } - - @Override - public void awakenSelf(IBinder token) { - // requires no permission, called by Dream from an arbitrary process - - final long ident = Binder.clearCallingIdentity(); - try { - if (DEBUG) Slog.v(TAG, "Wake up from dream: " + token); - if (token != null) { - mHandler.requestStopSelf(token); - } - } finally { - Binder.restoreCallingIdentity(ident); - } - } - // end IDreamManager api - - // begin ServiceConnection - @Override - public void onServiceConnected(ComponentName name, IBinder dream) { - if (DEBUG) Slog.v(TAG, "Service connected: " + name + " binder=" + - dream + " thread=" + Thread.currentThread().getId()); - mHandler.requestAttach(name, dream); - } - - @Override - public void onServiceDisconnected(ComponentName name) { - if (DEBUG) Slog.v(TAG, "Service disconnected: " + name); - // Only happens in exceptional circumstances, awaken just to be safe - awaken(); - } - // end ServiceConnection - - private void checkPermission(String permission) { - if (PackageManager.PERMISSION_GRANTED != mContext.checkCallingOrSelfPermission(permission)) { - throw new SecurityException("Access denied to process: " + Binder.getCallingPid() - + ", must have permission " + permission); - } - } - - private void setDreamingLocked(boolean isDreaming, boolean isTest) { - boolean wasDreaming = mIsDreaming; - if (!isTest) { - if (!wasDreaming && isDreaming) { - if (DEBUG) Slog.v(TAG, "Firing ACTION_DREAMING_STARTED"); - mContext.sendBroadcast(mDreamingStartedIntent); - } else if (wasDreaming && !isDreaming) { - if (DEBUG) Slog.v(TAG, "Firing ACTION_DREAMING_STOPPED"); - mContext.sendBroadcast(mDreamingStoppedIntent); - } - } - mIsDreaming = isDreaming; - } - - private ComponentName[] getDreamComponentsForUser(int userId) { - String names = Settings.Secure.getStringForUser(mContext.getContentResolver(), - SCREENSAVER_COMPONENTS, - userId); - return names == null ? null : componentsFromString(names); - } - - private static String componentsToString(ComponentName[] componentNames) { - StringBuilder names = new StringBuilder(); - if (componentNames != null) { - for (ComponentName componentName : componentNames) { - if (names.length() > 0) { - names.append(','); - } - names.append(componentName.flattenToString()); - } - } - return names.toString(); - } - - private static ComponentName[] componentsFromString(String names) { - String[] namesArray = names.split(","); - ComponentName[] componentNames = new ComponentName[namesArray.length]; - for (int i = 0; i < namesArray.length; i++) { - componentNames[i] = ComponentName.unflattenFromString(namesArray[i]); - } - return componentNames; - } - - /** - * Keeps track of the current user, since dream() uses the current user's configuration. - */ - private static class CurrentUserManager { - private final Object mLock = new Object(); - private int mCurrentUserId; - - public void init(Context context) { - IntentFilter filter = new IntentFilter(); - filter.addAction(Intent.ACTION_USER_SWITCHED); - context.registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (Intent.ACTION_USER_SWITCHED.equals(action)) { - synchronized(mLock) { - mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); - if (DEBUG) Slog.v(TAG, "userId " + mCurrentUserId + " is in the house"); - } - } - }}, filter); - try { - synchronized (mLock) { - mCurrentUserId = ActivityManagerNative.getDefault().getCurrentUser().id; - } - } catch (RemoteException e) { - Slog.w(TAG, "Couldn't get current user ID; guessing it's 0", e); - } - } - - public void dump(PrintWriter pw) { - pw.print(" user="); pw.println(getCurrentUserId()); - } - - public int getCurrentUserId() { - synchronized(mLock) { - return mCurrentUserId; - } - } - } - - /** - * Handler for asynchronous operations performed by the dream manager. - * - * Ensures operations to {@link DreamController} are single-threaded. - */ - private static final class DreamControllerHandler extends Handler { - private final DreamController mController; - private final Runnable mStopRunnable = new Runnable() { - @Override - public void run() { - mController.stop(); - }}; - - public DreamControllerHandler(DreamController controller) { - super(true /*async*/); - mController = controller; - } - - public void requestStart(final ComponentName name, final boolean isTest) { - post(new Runnable(){ - @Override - public void run() { - mController.start(name, isTest); - }}); - } - - public void requestAttach(final ComponentName name, final IBinder dream) { - post(new Runnable(){ - @Override - public void run() { - mController.attach(name, dream); - }}); - } - - public void requestStopSelf(final IBinder token) { - post(new Runnable(){ - @Override - public void run() { - mController.stopSelf(token); - }}); - } - - public void requestStop() { - post(mStopRunnable); - } - - } - -} diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 578e602..a0c1552 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -17,17 +17,14 @@ package com.android.server; import android.app.PendingIntent; -import android.content.ContentQueryMap; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.database.ContentObserver; -import android.database.Cursor; import android.location.Address; import android.location.Criteria; import android.location.GeocoderParams; @@ -41,7 +38,6 @@ import android.location.Location; import android.location.LocationManager; import android.location.LocationProvider; import android.location.LocationRequest; -import android.net.ConnectivityManager; import android.os.Binder; import android.os.Bundle; import android.os.Handler; @@ -55,7 +51,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.provider.Settings; -import android.provider.Settings.NameValueTable; import android.util.Log; import android.util.Slog; @@ -80,8 +75,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Observable; -import java.util.Observer; import java.util.Set; /** @@ -1343,7 +1336,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run // Check whether sufficient time has passed long minTime = record.mRequest.getFastestInterval(); - long delta = (loc.getElapsedRealtimeNano() - lastLoc.getElapsedRealtimeNano()) / 1000000L; + long delta = (loc.getElapsedRealtimeNanos() - lastLoc.getElapsedRealtimeNanos()) / 1000000L; if (delta < minTime - MAX_PROVIDER_SCHEDULING_JITTER_MS) { return false; } diff --git a/services/java/com/android/server/ServiceWatcher.java b/services/java/com/android/server/ServiceWatcher.java index 0dfaa05..e99949b 100644 --- a/services/java/com/android/server/ServiceWatcher.java +++ b/services/java/com/android/server/ServiceWatcher.java @@ -170,7 +170,7 @@ public class ServiceWatcher implements ServiceConnection { } if (D) Log.d(mTag, "binding " + packageName + " (version " + version + ")"); mContext.bindService(intent, this, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND - | Context.BIND_ALLOW_OOM_MANAGEMENT); + | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_NOT_VISIBLE); } private boolean isSignatureMatch(Signature[] signatures) { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index eeab757..738e19b 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -38,6 +38,7 @@ import android.os.StrictMode; import android.os.SystemClock; import android.os.SystemProperties; import android.server.search.SearchManagerService; +import android.service.dreams.Dream; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; @@ -51,6 +52,7 @@ import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.am.ActivityManagerService; import com.android.server.am.BatteryStatsService; import com.android.server.display.DisplayManagerService; +import com.android.server.dreams.DreamManagerService; import com.android.server.input.InputManagerService; import com.android.server.net.NetworkPolicyManagerService; import com.android.server.net.NetworkStatsService; @@ -738,8 +740,8 @@ class ServerThread extends Thread { try { Slog.i(TAG, "Dreams Service"); // Dreams (interactive idle-time views, a/k/a screen savers) - dreamy = new DreamManagerService(context); - ServiceManager.addService("dreams", dreamy); + dreamy = new DreamManagerService(context, wmHandler); + ServiceManager.addService(Dream.DREAM_SERVICE, dreamy); } catch (Throwable e) { reportWtf("starting DreamManagerService", e); } @@ -810,7 +812,7 @@ class ServerThread extends Thread { context.getResources().updateConfiguration(config, metrics); try { - power.systemReady(twilight); + power.systemReady(twilight, dreamy); } catch (Throwable e) { reportWtf("making Power Manager Service ready", e); } diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java index f36d73a..75eb3c4 100644 --- a/services/java/com/android/server/ThrottleService.java +++ b/services/java/com/android/server/ThrottleService.java @@ -211,20 +211,20 @@ public class ThrottleService extends IThrottleManager.Stub { void register(Context context) { ContentResolver resolver = context.getContentResolver(); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_POLLING_SEC), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_THRESHOLD_BYTES), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_VALUE_KBITSPS), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_RESET_DAY), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_NOTIFICATION_TYPE), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_HELP_URI), false, this); - resolver.registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_POLLING_SEC), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_THRESHOLD_BYTES), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_VALUE_KBITSPS), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_RESET_DAY), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_NOTIFICATION_TYPE), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_HELP_URI), false, this); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC), false, this); } void unregister(Context context) { @@ -297,8 +297,8 @@ public class ThrottleService extends IThrottleManager.Stub { public String getHelpUri() { enforceAccessPermission(); - return Settings.Secure.getString(mContext.getContentResolver(), - Settings.Secure.THROTTLE_HELP_URI); + return Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.THROTTLE_HELP_URI); } // TODO - fetch for the iface @@ -436,18 +436,18 @@ public class ThrottleService extends IThrottleManager.Stub { int pollingPeriod = mContext.getResources().getInteger( R.integer.config_datause_polling_period_sec); - mPolicyPollPeriodSec = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_POLLING_SEC, pollingPeriod); + mPolicyPollPeriodSec = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_POLLING_SEC, pollingPeriod); // TODO - remove testing stuff? long defaultThreshold = mContext.getResources().getInteger( R.integer.config_datause_threshold_bytes); int defaultValue = mContext.getResources().getInteger( R.integer.config_datause_throttle_kbitsps); - long threshold = Settings.Secure.getLong(mContext.getContentResolver(), - Settings.Secure.THROTTLE_THRESHOLD_BYTES, defaultThreshold); - int value = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_VALUE_KBITSPS, defaultValue); + long threshold = Settings.Global.getLong(mContext.getContentResolver(), + Settings.Global.THROTTLE_THRESHOLD_BYTES, defaultThreshold); + int value = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_VALUE_KBITSPS, defaultValue); mPolicyThreshold.set(threshold); mPolicyThrottleValue.set(value); @@ -456,14 +456,14 @@ public class ThrottleService extends IThrottleManager.Stub { mPolicyThreshold.set(TESTING_THRESHOLD); } - mPolicyResetDay = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_RESET_DAY, -1); + mPolicyResetDay = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_RESET_DAY, -1); if (mPolicyResetDay == -1 || ((mPolicyResetDay < 1) || (mPolicyResetDay > 28))) { Random g = new Random(); mPolicyResetDay = 1 + g.nextInt(28); // 1-28 - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_RESET_DAY, mPolicyResetDay); + Settings.Global.putInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_RESET_DAY, mPolicyResetDay); } if (mIface == null) { mPolicyThreshold.set(0); @@ -471,11 +471,11 @@ public class ThrottleService extends IThrottleManager.Stub { int defaultNotificationType = mContext.getResources().getInteger( R.integer.config_datause_notification_type); - mPolicyNotificationsAllowedMask = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_NOTIFICATION_TYPE, defaultNotificationType); + mPolicyNotificationsAllowedMask = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_NOTIFICATION_TYPE, defaultNotificationType); - final int maxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, + final int maxNtpCacheAgeSec = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.THROTTLE_MAX_NTP_CACHE_AGE_SEC, (int) (MAX_NTP_CACHE_AGE / 1000)); mMaxNtpCacheAge = maxNtpCacheAgeSec * 1000; diff --git a/services/java/com/android/server/TwilightService.java b/services/java/com/android/server/TwilightService.java index a7bce54..154de1c 100644 --- a/services/java/com/android/server/TwilightService.java +++ b/services/java/com/android/server/TwilightService.java @@ -147,7 +147,7 @@ public final class TwilightService { } // if new location is older than the current one, the device hasn't moved. - if (to.getElapsedRealtimeNano() < from.getElapsedRealtimeNano()) { + if (to.getElapsedRealtimeNanos() < from.getElapsedRealtimeNanos()) { return false; } @@ -428,8 +428,8 @@ public final class TwilightService { mLocationManager.getLastKnownLocation(providers.next()); // pick the most recent location if (location == null || (lastKnownLocation != null && - location.getElapsedRealtimeNano() < - lastKnownLocation.getElapsedRealtimeNano())) { + location.getElapsedRealtimeNanos() < + lastKnownLocation.getElapsedRealtimeNanos())) { location = lastKnownLocation; } } @@ -447,7 +447,7 @@ public final class TwilightService { location.setLatitude(0); location.setAccuracy(417000.0f); location.setTime(System.currentTimeMillis()); - location.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano()); + location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); if (DEBUG) { Slog.d(TAG, "Estimated location from timezone: " + location); diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java index 85a6e41..3b8caba 100644 --- a/services/java/com/android/server/UiModeManagerService.java +++ b/services/java/com/android/server/UiModeManagerService.java @@ -17,6 +17,7 @@ package com.android.server; import android.app.Activity; +import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.IUiModeManager; import android.app.Notification; @@ -24,7 +25,6 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.app.StatusBarManager; import android.app.UiModeManager; -import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -39,6 +39,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; +import android.service.dreams.Dream; +import android.service.dreams.IDreamManager; import android.util.Slog; import java.io.FileDescriptor; @@ -56,6 +58,9 @@ class UiModeManagerService extends IUiModeManager.Stub { private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true; private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = true; + private static final int DEFAULT_SCREENSAVER_ENABLED = 1; + private static final int DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK = 1; + private final Context mContext; private final TwilightService mTwilightService; private final Handler mHandler = new Handler(); @@ -110,72 +115,10 @@ class UiModeManagerService extends IUiModeManager.Stub { return; } - final int enableFlags = intent.getIntExtra("enableFlags", 0); - final int disableFlags = intent.getIntExtra("disableFlags", 0); - + final int enableFlags = intent.getIntExtra("enableFlags", 0); + final int disableFlags = intent.getIntExtra("disableFlags", 0); synchronized (mLock) { - // Launch a dock activity - String category = null; - if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { - // Only launch car home when car mode is enabled and the caller - // has asked us to switch to it. - if (ENABLE_LAUNCH_CAR_DOCK_APP - && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { - category = Intent.CATEGORY_CAR_DOCK; - } - } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(intent.getAction())) { - // Only launch car home when desk mode is enabled and the caller - // has asked us to switch to it. Currently re-using the car - // mode flag since we don't have a formal API for "desk mode". - if (ENABLE_LAUNCH_DESK_DOCK_APP - && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { - category = Intent.CATEGORY_DESK_DOCK; - } - } else { - // Launch the standard home app if requested. - if ((disableFlags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { - category = Intent.CATEGORY_HOME; - } - } - - if (LOG) { - Slog.v(TAG, String.format( - "Handling broadcast result for action %s: enable=0x%08x disable=0x%08x category=%s", - intent.getAction(), enableFlags, disableFlags, category)); - } - - if (category != null) { - // This is the new activity that will serve as home while - // we are in care mode. - Intent homeIntent = buildHomeIntent(category); - - // Now we are going to be careful about switching the - // configuration and starting the activity -- we need to - // do this in a specific order under control of the - // activity manager, to do it cleanly. So compute the - // new config, but don't set it yet, and let the - // activity manager take care of both the start and config - // change. - Configuration newConfig = null; - if (mHoldingConfiguration) { - mHoldingConfiguration = false; - updateConfigurationLocked(false); - newConfig = mConfiguration; - } - try { - ActivityManagerNative.getDefault().startActivityWithConfig( - null, homeIntent, null, null, null, 0, 0, - newConfig, null, UserHandle.USER_CURRENT); - mHoldingConfiguration = false; - } catch (RemoteException e) { - Slog.w(TAG, e.getCause()); - } - } - - if (mHoldingConfiguration) { - mHoldingConfiguration = false; - updateConfigurationLocked(true); - } + updateAfterBroadcastLocked(intent.getAction(), enableFlags, disableFlags); } } }; @@ -335,9 +278,8 @@ class UiModeManagerService extends IUiModeManager.Stub { } } - final void updateConfigurationLocked(boolean sendIt) { - int uiMode = mTelevision ? Configuration.UI_MODE_TYPE_TELEVISION - : mDefaultUiModeType; + final void updateConfigurationLocked() { + int uiMode = mTelevision ? Configuration.UI_MODE_TYPE_TELEVISION : mDefaultUiModeType; if (mCarModeEnabled) { uiMode = Configuration.UI_MODE_TYPE_CAR; } else if (isDeskDockState(mDockState)) { @@ -365,17 +307,19 @@ class UiModeManagerService extends IUiModeManager.Stub { } mCurUiMode = uiMode; - - if (!mHoldingConfiguration && uiMode != mSetUiMode) { - mSetUiMode = uiMode; + if (!mHoldingConfiguration) { mConfiguration.uiMode = uiMode; + } + } - if (sendIt) { - try { - ActivityManagerNative.getDefault().updateConfiguration(mConfiguration); - } catch (RemoteException e) { - Slog.w(TAG, "Failure communicating with activity manager", e); - } + final void sendConfigurationLocked() { + if (mSetUiMode != mConfiguration.uiMode) { + mSetUiMode = mConfiguration.uiMode; + + try { + ActivityManagerNative.getDefault().updateConfiguration(mConfiguration); + } catch (RemoteException e) { + Slog.w(TAG, "Failure communicating with activity manager", e); } } } @@ -434,43 +378,38 @@ class UiModeManagerService extends IUiModeManager.Stub { intent.putExtra("disableFlags", disableFlags); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, mResultReceiver, null, Activity.RESULT_OK, null, null); + // Attempting to make this transition a little more clean, we are going // to hold off on doing a configuration change until we have finished // the broadcast and started the home activity. mHoldingConfiguration = true; + updateConfigurationLocked(); } else { - Intent homeIntent = null; + String category = null; if (mCarModeEnabled) { if (ENABLE_LAUNCH_CAR_DOCK_APP - && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { - homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK); + && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + category = Intent.CATEGORY_CAR_DOCK; } } else if (isDeskDockState(mDockState)) { if (ENABLE_LAUNCH_DESK_DOCK_APP - && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { - homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK); + && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + category = Intent.CATEGORY_DESK_DOCK; } } else { - if ((disableFlags&UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { - homeIntent = buildHomeIntent(Intent.CATEGORY_HOME); + if ((disableFlags & UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { + category = Intent.CATEGORY_HOME; } } if (LOG) { Slog.v(TAG, "updateLocked: null action, mDockState=" - + mDockState +", firing homeIntent: " + homeIntent); + + mDockState +", category=" + category); } - if (homeIntent != null) { - try { - mContext.startActivityAsUser(homeIntent, UserHandle.CURRENT); - } catch (ActivityNotFoundException e) { - } - } + sendConfigurationAndStartDreamOrDockAppLocked(category); } - updateConfigurationLocked(true); - // keep screen on when charging and in car mode boolean keepScreenOn = mCharging && ((mCarModeEnabled && mCarModeKeepsScreenOn) || @@ -487,6 +426,101 @@ class UiModeManagerService extends IUiModeManager.Stub { } } + private void updateAfterBroadcastLocked(String action, int enableFlags, int disableFlags) { + // Launch a dock activity + String category = null; + if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(action)) { + // Only launch car home when car mode is enabled and the caller + // has asked us to switch to it. + if (ENABLE_LAUNCH_CAR_DOCK_APP + && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + category = Intent.CATEGORY_CAR_DOCK; + } + } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(action)) { + // Only launch car home when desk mode is enabled and the caller + // has asked us to switch to it. Currently re-using the car + // mode flag since we don't have a formal API for "desk mode". + if (ENABLE_LAUNCH_DESK_DOCK_APP + && (enableFlags & UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + category = Intent.CATEGORY_DESK_DOCK; + } + } else { + // Launch the standard home app if requested. + if ((disableFlags & UiModeManager.DISABLE_CAR_MODE_GO_HOME) != 0) { + category = Intent.CATEGORY_HOME; + } + } + + if (LOG) { + Slog.v(TAG, String.format( + "Handling broadcast result for action %s: enable=0x%08x, disable=0x%08x, " + + "category=%s", + action, enableFlags, disableFlags, category)); + } + + sendConfigurationAndStartDreamOrDockAppLocked(category); + } + + private void sendConfigurationAndStartDreamOrDockAppLocked(String category) { + // Update the configuration but don't send it yet. + mHoldingConfiguration = false; + updateConfigurationLocked(); + + // Start the dock app, if there is one. + boolean dockAppStarted = false; + if (category != null) { + // Now we are going to be careful about switching the + // configuration and starting the activity -- we need to + // do this in a specific order under control of the + // activity manager, to do it cleanly. So compute the + // new config, but don't set it yet, and let the + // activity manager take care of both the start and config + // change. + Intent homeIntent = buildHomeIntent(category); + try { + int result = ActivityManagerNative.getDefault().startActivityWithConfig( + null, homeIntent, null, null, null, 0, 0, + mConfiguration, null, UserHandle.USER_CURRENT); + if (result >= ActivityManager.START_SUCCESS) { + dockAppStarted = true; + } else if (result != ActivityManager.START_INTENT_NOT_RESOLVED) { + Slog.e(TAG, "Could not start dock app: " + homeIntent + + ", startActivityWithConfig result " + result); + } + } catch (RemoteException ex) { + Slog.e(TAG, "Could not start dock app: " + homeIntent, ex); + } + } + + // Send the new configuration. + sendConfigurationLocked(); + + // If we did not start a dock app, then start dreaming if supported. + if (category != null && !dockAppStarted + && isScreenSaverEnabled() && isScreenSaverActivatedOnDock()) { + Slog.i(TAG, "Activating dream while docked."); + try { + IDreamManager dreamManagerService = IDreamManager.Stub.asInterface( + ServiceManager.getService(Dream.DREAM_SERVICE)); + dreamManagerService.dream(); + } catch (RemoteException ex) { + Slog.e(TAG, "Could not start dream when docked.", ex); + } + } + } + + private boolean isScreenSaverEnabled() { + return Settings.Secure.getIntForUser(mContext.getContentResolver(), + Settings.Secure.SCREENSAVER_ENABLED, DEFAULT_SCREENSAVER_ENABLED, + UserHandle.USER_CURRENT) != 0; + } + + private boolean isScreenSaverActivatedOnDock() { + return Settings.Secure.getIntForUser(mContext.getContentResolver(), + Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, + DEFAULT_SCREENSAVER_ACTIVATED_ON_DOCK, UserHandle.USER_CURRENT) != 0; + } + private void adjustStatusBarCarModeLocked() { if (mStatusBarManager == null) { mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE); diff --git a/services/java/com/android/server/Watchdog.java b/services/java/com/android/server/Watchdog.java index 9edfad6..9dbe503 100644 --- a/services/java/com/android/server/Watchdog.java +++ b/services/java/com/android/server/Watchdog.java @@ -33,7 +33,6 @@ import android.os.Process; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; -import android.provider.Settings; import android.util.EventLog; import android.util.Log; import android.util.Slog; @@ -118,9 +117,7 @@ public class Watchdog extends Thread { case MONITOR: { // See if we should force a reboot. int rebootInterval = mReqRebootInterval >= 0 - ? mReqRebootInterval : Settings.Secure.getInt( - mResolver, Settings.Secure.REBOOT_INTERVAL, - REBOOT_DEFAULT_INTERVAL); + ? mReqRebootInterval : REBOOT_DEFAULT_INTERVAL; if (mRebootInterval != rebootInterval) { mRebootInterval = rebootInterval; // We have been running long enough that a reboot can @@ -226,9 +223,7 @@ public class Watchdog extends Thread { void checkReboot(boolean fromAlarm) { int rebootInterval = mReqRebootInterval >= 0 ? mReqRebootInterval - : Settings.Secure.getInt( - mResolver, Settings.Secure.REBOOT_INTERVAL, - REBOOT_DEFAULT_INTERVAL); + : REBOOT_DEFAULT_INTERVAL; mRebootInterval = rebootInterval; if (rebootInterval <= 0) { // No reboot interval requested. @@ -238,17 +233,11 @@ public class Watchdog extends Thread { } long rebootStartTime = mReqRebootStartTime >= 0 ? mReqRebootStartTime - : Settings.Secure.getLong( - mResolver, Settings.Secure.REBOOT_START_TIME, - REBOOT_DEFAULT_START_TIME); + : REBOOT_DEFAULT_START_TIME; long rebootWindowMillis = (mReqRebootWindow >= 0 ? mReqRebootWindow - : Settings.Secure.getLong( - mResolver, Settings.Secure.REBOOT_WINDOW, - REBOOT_DEFAULT_WINDOW)) * 1000; + : REBOOT_DEFAULT_WINDOW) * 1000; long recheckInterval = (mReqRecheckInterval >= 0 ? mReqRecheckInterval - : Settings.Secure.getLong( - mResolver, Settings.Secure.MEMCHECK_RECHECK_INTERVAL, - MEMCHECK_DEFAULT_RECHECK_INTERVAL)) * 1000; + : MEMCHECK_DEFAULT_RECHECK_INTERVAL) * 1000; retrieveBrutalityAmount(); @@ -325,13 +314,9 @@ public class Watchdog extends Thread { */ void retrieveBrutalityAmount() { mMinScreenOff = (mReqMinScreenOff >= 0 ? mReqMinScreenOff - : Settings.Secure.getInt( - mResolver, Settings.Secure.MEMCHECK_MIN_SCREEN_OFF, - MEMCHECK_DEFAULT_MIN_SCREEN_OFF)) * 1000; + : MEMCHECK_DEFAULT_MIN_SCREEN_OFF) * 1000; mMinAlarm = (mReqMinNextAlarm >= 0 ? mReqMinNextAlarm - : Settings.Secure.getInt( - mResolver, Settings.Secure.MEMCHECK_MIN_ALARM, - MEMCHECK_DEFAULT_MIN_ALARM)) * 1000; + : MEMCHECK_DEFAULT_MIN_ALARM) * 1000; } /** diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java index 0c0f00c..1269433 100644 --- a/services/java/com/android/server/am/ActiveServices.java +++ b/services/java/com/android/server/am/ActiveServices.java @@ -44,7 +44,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; -import android.content.pm.UserInfo; import android.os.Binder; import android.os.IBinder; import android.os.Message; @@ -391,7 +390,7 @@ public class ActiveServices { if (r.isForeground) { r.isForeground = false; if (r.app != null) { - mAm.updateLruProcessLocked(r.app, false, true); + mAm.updateLruProcessLocked(r.app, false); updateServiceForegroundLocked(r.app, true); } } @@ -760,7 +759,8 @@ public class ActiveServices { int N = mPendingServices.size(); for (int i=0; i<N; i++) { ServiceRecord pr = mPendingServices.get(i); - if (pr.name.equals(name)) { + if (pr.serviceInfo.applicationInfo.uid == sInfo.applicationInfo.uid + && pr.name.equals(name)) { mPendingServices.remove(i); i--; N--; @@ -942,7 +942,7 @@ public class ActiveServices { Slog.w(TAG, "Scheduling restart of crashed service " + r.shortName + " in " + r.restartDelay + "ms"); EventLog.writeEvent(EventLogTags.AM_SCHEDULE_SERVICE_RESTART, - r.shortName, r.restartDelay); + r.userId, r.shortName, r.restartDelay); return canceled; } @@ -1083,14 +1083,14 @@ public class ActiveServices { app.services.add(r); bumpServiceExecutingLocked(r, "create"); - mAm.updateLruProcessLocked(app, true, true); + mAm.updateLruProcessLocked(app, true); boolean created = false; try { mAm.mStringBuilder.setLength(0); r.intent.getIntent().toShortString(mAm.mStringBuilder, true, false, true, false); EventLog.writeEvent(EventLogTags.AM_CREATE_SERVICE, - System.identityHashCode(r), r.shortName, + r.userId, System.identityHashCode(r), r.shortName, mAm.mStringBuilder.toString(), r.app.pid); synchronized (r.stats.getBatteryStats()) { r.stats.startLaunchedLocked(); @@ -1240,7 +1240,7 @@ public class ActiveServices { if (DEBUG_SERVICE) Slog.v(TAG, "Bringing down " + r + " " + r.intent); EventLog.writeEvent(EventLogTags.AM_DESTROY_SERVICE, - System.identityHashCode(r), r.shortName, + r.userId, System.identityHashCode(r), r.shortName, (r.app != null) ? r.app.pid : -1); mServiceMap.removeServiceByName(r.name, r.userId); @@ -1664,7 +1664,7 @@ public class ActiveServices { Slog.w(TAG, "Service crashed " + sr.crashCount + " times, stopping: " + sr); EventLog.writeEvent(EventLogTags.AM_SERVICE_CRASHED_TOO_MUCH, - sr.crashCount, sr.shortName, app.pid); + sr.userId, sr.crashCount, sr.shortName, app.pid); bringDownServiceLocked(sr, true); } else if (!allowRestart) { bringDownServiceLocked(sr, true); diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index b266bd4..0221245 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -1369,7 +1369,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (mSelf.mPidsSelfLocked) { mSelf.mPidsSelfLocked.put(app.pid, app); } - mSelf.updateLruProcessLocked(app, true, true); + mSelf.updateLruProcessLocked(app, true); } } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException( @@ -1805,8 +1805,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } - private final void updateLruProcessInternalLocked(ProcessRecord app, - boolean updateActivityTime, int bestPos) { + private final void updateLruProcessInternalLocked(ProcessRecord app, int bestPos) { // put it on the LRU to keep track of when it should be exited. int lrui = mLruProcesses.indexOf(app); if (lrui >= 0) mLruProcesses.remove(lrui); @@ -1817,9 +1816,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.lruSeq = mLruSeq; // compute the new weight for this process. - if (updateActivityTime) { - app.lastActivityTime = SystemClock.uptimeMillis(); - } + app.lastActivityTime = SystemClock.uptimeMillis(); if (app.activities.size() > 0) { // If this process has activities, we more strongly want to keep // it around. @@ -1863,24 +1860,22 @@ public final class ActivityManagerService extends ActivityManagerNative if (cr.binding != null && cr.binding.service != null && cr.binding.service.app != null && cr.binding.service.app.lruSeq != mLruSeq) { - updateLruProcessInternalLocked(cr.binding.service.app, - updateActivityTime, i+1); + updateLruProcessInternalLocked(cr.binding.service.app, i+1); } } } 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) { - updateLruProcessInternalLocked(cpr.proc, - updateActivityTime, i+1); + updateLruProcessInternalLocked(cpr.proc, i+1); } } } final void updateLruProcessLocked(ProcessRecord app, - boolean oomAdj, boolean updateActivityTime) { + boolean oomAdj) { mLruSeq++; - updateLruProcessInternalLocked(app, updateActivityTime, 0); + updateLruProcessInternalLocked(app, 0); //Slog.i(TAG, "Putting proc to front: " + app.processName); if (oomAdj) { @@ -1981,7 +1976,8 @@ public final class ActivityManagerService extends ActivityManagerNative + "/" + info.processName); mProcessCrashTimes.remove(info.processName, info.uid); if (mBadProcesses.get(info.processName, info.uid) != null) { - EventLog.writeEvent(EventLogTags.AM_PROC_GOOD, info.uid, + EventLog.writeEvent(EventLogTags.AM_PROC_GOOD, + UserHandle.getUserId(info.uid), info.uid, info.processName); mBadProcesses.remove(info.processName, info.uid); if (app != null) { @@ -2129,7 +2125,8 @@ public final class ActivityManagerService extends ActivityManagerNative } } - EventLog.writeEvent(EventLogTags.AM_PROC_START, startResult.pid, uid, + EventLog.writeEvent(EventLogTags.AM_PROC_START, + UserHandle.getUserId(uid), startResult.pid, uid, app.processName, hostingType, hostingNameStr != null ? hostingNameStr : ""); @@ -2946,7 +2943,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (!r.finishing) { Slog.w(TAG, "Force removing " + r + ": app died, no saved state"); EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY, - System.identityHashCode(r), + r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName, "proc died without state saved"); } @@ -3037,7 +3034,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.i(TAG, "Process " + app.processName + " (pid " + pid + ") has died."); } - EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.pid, app.processName); + EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.userId, app.pid, app.processName); if (localLOGV) Slog.v( TAG, "Dying app: " + app + ", pid: " + pid + ", thread: " + thread.asBinder()); @@ -3086,7 +3083,7 @@ public final class ActivityManagerService extends ActivityManagerNative // A new process has already been started. Slog.i(TAG, "Process " + app.processName + " (pid " + pid + ") has died and restarted (pid " + app.pid + ")."); - EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.pid, app.processName); + EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.userId, app.pid, app.processName); } else if (DEBUG_PROCESSES) { Slog.d(TAG, "Received spurious death notification for thread " + thread.asBinder()); @@ -3321,8 +3318,8 @@ public final class ActivityManagerService extends ActivityManagerNative app.notResponding = true; // Log the ANR to the event log. - EventLog.writeEvent(EventLogTags.AM_ANR, app.pid, app.processName, app.info.flags, - annotation); + EventLog.writeEvent(EventLogTags.AM_ANR, app.userId, app.pid, + app.processName, app.info.flags, annotation); // Dump thread traces as quickly as we can, starting with "interesting" processes. firstPids.add(app.pid); @@ -3408,7 +3405,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) { Slog.w(TAG, "Killing " + app + ": background ANR"); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "background ANR"); Process.killProcessQuiet(app.pid); return; @@ -4077,8 +4074,8 @@ public final class ActivityManagerService extends ActivityManagerNative if (gone) { Slog.w(TAG, "Process " + app + " failed to attach"); - EventLog.writeEvent(EventLogTags.AM_PROCESS_START_TIMEOUT, pid, app.uid, - app.processName); + EventLog.writeEvent(EventLogTags.AM_PROCESS_START_TIMEOUT, app.userId, + pid, app.uid, app.processName); mProcessNames.remove(app.processName, app.uid); mIsolatedProcesses.remove(app.uid); if (mHeavyWeightProcess == app) { @@ -4090,7 +4087,7 @@ public final class ActivityManagerService extends ActivityManagerNative checkAppInLaunchingProvidersLocked(app, true); // Take care of any services that are waiting for the process. mServices.processStartTimedOutLocked(app); - EventLog.writeEvent(EventLogTags.AM_KILL, pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, pid, app.processName, app.setAdj, "start timeout"); Process.killProcessQuiet(pid); if (mBackupTarget != null && mBackupTarget.app.pid == pid) { @@ -4166,7 +4163,7 @@ public final class ActivityManagerService extends ActivityManagerNative return false; } - EventLog.writeEvent(EventLogTags.AM_PROC_BOUND, app.pid, app.processName); + EventLog.writeEvent(EventLogTags.AM_PROC_BOUND, app.userId, app.pid, app.processName); app.thread = thread; app.curAdj = app.setAdj = -100; @@ -4244,7 +4241,7 @@ public final class ActivityManagerService extends ActivityManagerNative enableOpenGlTrace, isRestrictedBackupMode || !normalMode, app.persistent, new Configuration(mConfiguration), app.compat, getCommonServicesLocked(), mCoreSettingsObserver.getCoreSettingsLocked()); - updateLruProcessLocked(app, false, true); + updateLruProcessLocked(app, false); app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis(); } catch (Exception e) { // todo: Yikes! What should we do? For now we will try to @@ -5914,7 +5911,7 @@ public final class ActivityManagerService extends ActivityManagerNative ProcessRecord pr = procs.get(i); if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) { Slog.i(TAG, "Killing " + pr.toShortString() + ": remove task"); - EventLog.writeEvent(EventLogTags.AM_KILL, pr.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, pr.userId, pr.pid, pr.processName, pr.setAdj, "remove task"); pr.killedBackground = true; Process.killProcessQuiet(pr.pid); @@ -6442,7 +6439,7 @@ public final class ActivityManagerService extends ActivityManagerNative // make sure to count it as being accessed and thus // back up on the LRU list. This is good because // content providers are often expensive to start. - updateLruProcessLocked(cpr.proc, false, true); + updateLruProcessLocked(cpr.proc, false); } } @@ -6630,6 +6627,7 @@ public final class ActivityManagerService extends ActivityManagerNative + cpi.applicationInfo.uid + " for provider " + name + ": launching app became null"); EventLog.writeEvent(EventLogTags.AM_PROVIDER_LOST_PROCESS, + UserHandle.getUserId(cpi.applicationInfo.uid), cpi.applicationInfo.packageName, cpi.applicationInfo.uid, name); return null; @@ -7013,7 +7011,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (isolated) { mIsolatedProcesses.put(app.uid, app); } - updateLruProcessLocked(app, true, true); + updateLruProcessLocked(app, true); } // This package really, really can not be stopped. @@ -7499,7 +7497,7 @@ public final class ActivityManagerService extends ActivityManagerNative int adj = proc.setAdj; if (adj >= worstType && !proc.killedBackground) { Slog.w(TAG, "Killing " + proc + " (adj " + adj + "): " + reason); - EventLog.writeEvent(EventLogTags.AM_KILL, proc.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, proc.userId, proc.pid, proc.processName, adj, reason); killed = true; proc.killedBackground = true; @@ -7535,8 +7533,8 @@ public final class ActivityManagerService extends ActivityManagerNative final int adj = proc.setAdj; if (adj > belowAdj && !proc.killedBackground) { Slog.w(TAG, "Killing " + proc + " (adj " + adj + "): " + reason); - EventLog.writeEvent( - EventLogTags.AM_KILL, proc.pid, proc.processName, adj, reason); + EventLog.writeEvent(EventLogTags.AM_KILL, proc.userId, + proc.pid, proc.processName, adj, reason); killed = true; proc.killedBackground = true; Process.killProcessQuiet(pid); @@ -7953,7 +7951,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (app.pid > 0 && app.pid != MY_PID) { handleAppCrashLocked(app); Slog.i(ActivityManagerService.TAG, "Killing " + app + ": user's request"); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "user's request after error"); Process.killProcessQuiet(app.pid); } @@ -7978,7 +7976,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, "Process " + app.info.processName + " has crashed too many times: killing!"); EventLog.writeEvent(EventLogTags.AM_PROCESS_CRASHED_TOO_MUCH, - app.info.processName, app.uid); + app.userId, app.info.processName, app.uid); for (int i=mMainStack.mHistory.size()-1; i>=0; i--) { ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); if (r.app == app) { @@ -7993,7 +7991,7 @@ public final class ActivityManagerService extends ActivityManagerNative // explicitly does so... but for persistent process, we really // need to keep it running. If a persistent process is actually // repeatedly crashing, then badness for everyone. - EventLog.writeEvent(EventLogTags.AM_PROC_BAD, app.uid, + EventLog.writeEvent(EventLogTags.AM_PROC_BAD, app.userId, app.uid, app.info.processName); if (!app.isolated) { // XXX We don't have a way to mark isolated processes @@ -8106,7 +8104,7 @@ public final class ActivityManagerService extends ActivityManagerNative : (r == null ? "unknown" : r.processName); EventLog.writeEvent(EventLogTags.AM_CRASH, Binder.getCallingPid(), - processName, + UserHandle.getUserId(Binder.getCallingUid()), processName, r == null ? -1 : r.info.flags, crashInfo.exceptionClassName, crashInfo.exceptionMessage, @@ -8304,7 +8302,8 @@ public final class ActivityManagerService extends ActivityManagerNative final String processName = app == null ? "system_server" : (r == null ? "unknown" : r.processName); - EventLog.writeEvent(EventLogTags.AM_WTF, Binder.getCallingPid(), + EventLog.writeEvent(EventLogTags.AM_WTF, + UserHandle.getUserId(Binder.getCallingUid()), Binder.getCallingPid(), processName, r == null ? -1 : r.info.flags, tag, crashInfo.exceptionMessage); @@ -10067,6 +10066,7 @@ public final class ActivityManagerService extends ActivityManagerNative pw.print(" "); pw.print("oom: max="); pw.print(r.maxAdj); pw.print(" hidden="); pw.print(r.hiddenAdj); + pw.print(" client="); pw.print(r.clientHiddenAdj); pw.print(" empty="); pw.print(r.emptyAdj); pw.print(" curRaw="); pw.print(r.curRawAdj); pw.print(" setRaw="); pw.print(r.setRawAdj); @@ -10591,7 +10591,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.i(TAG, "Kill " + capp.processName + " (pid " + capp.pid + "): provider " + cpr.info.name + " in dying process " + (proc != null ? proc.processName : "??")); - EventLog.writeEvent(EventLogTags.AM_KILL, capp.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, capp.userId, capp.pid, capp.processName, capp.setAdj, "dying provider " + cpr.name.toShortString()); Process.killProcessQuiet(capp.pid); @@ -11514,8 +11514,9 @@ public final class ActivityManagerService extends ActivityManagerNative * Prevent non-system code (defined here to be non-persistent * processes) from sending protected broadcasts. */ - if (callingUid == Process.SYSTEM_UID || callingUid == Process.PHONE_UID - || callingUid == Process.SHELL_UID || callingUid == Process.BLUETOOTH_UID || + int callingAppId = UserHandle.getAppId(callingUid); + if (callingAppId == Process.SYSTEM_UID || callingAppId == Process.PHONE_UID + || callingAppId == Process.SHELL_UID || callingAppId == Process.BLUETOOTH_UID || callingUid == 0) { // Always okay. } else if (callerApp == null || !callerApp.persistent) { @@ -12466,7 +12467,7 @@ public final class ActivityManagerService extends ActivityManagerNative return null; } - private final int computeOomAdjLocked(ProcessRecord app, int hiddenAdj, + private final int computeOomAdjLocked(ProcessRecord app, int hiddenAdj, int clientHiddenAdj, int emptyAdj, ProcessRecord TOP_APP, boolean recursed, boolean doingAll) { if (mAdjSeq == app.adjSeq) { // This adjustment has already been computed. If we are calling @@ -12474,8 +12475,13 @@ public final class ActivityManagerService extends ActivityManagerNative // an earlier hidden adjustment that isn't really for us... if // so, use the new hidden adjustment. if (!recursed && app.hidden) { - app.curAdj = app.curRawAdj = app.nonStoppingAdj = - app.hasActivities ? hiddenAdj : emptyAdj; + if (app.hasActivities) { + app.curAdj = app.curRawAdj = app.nonStoppingAdj = hiddenAdj; + } else if (app.hasClientActivities) { + app.curAdj = app.curRawAdj = app.nonStoppingAdj = clientHiddenAdj; + } else { + app.curAdj = app.curRawAdj = app.nonStoppingAdj = emptyAdj; + } } return app.curRawAdj; } @@ -12491,6 +12497,7 @@ public final class ActivityManagerService extends ActivityManagerNative app.adjTarget = null; app.empty = false; app.hidden = false; + app.hasClientActivities = false; final int activitiesSize = app.activities.size(); @@ -12572,7 +12579,7 @@ public final class ActivityManagerService extends ActivityManagerNative adj = hiddenAdj; schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; app.hidden = true; - app.adjType = "bg-activities"; + app.adjType = "bg-act"; } boolean hasStoppingActivities = false; @@ -12614,11 +12621,16 @@ public final class ActivityManagerService extends ActivityManagerNative } if (adj == hiddenAdj && !app.hasActivities) { - // Whoops, this process is completely empty as far as we know - // at this point. - adj = emptyAdj; - app.empty = true; - app.adjType = "bg-empty"; + if (app.hasClientActivities) { + adj = clientHiddenAdj; + app.adjType = "bg-client-act"; + } else { + // Whoops, this process is completely empty as far as we know + // at this point. + adj = emptyAdj; + app.empty = true; + app.adjType = "bg-empty"; + } } if (adj > ProcessList.PERCEPTIBLE_APP_ADJ) { @@ -12626,13 +12638,13 @@ public final class ActivityManagerService extends ActivityManagerNative // The user is aware of this app, so make it visible. adj = ProcessList.PERCEPTIBLE_APP_ADJ; app.hidden = false; - app.adjType = "foreground-service"; + app.adjType = "fg-service"; schedGroup = Process.THREAD_GROUP_DEFAULT; } else if (app.forcingToForeground != null) { // The user is aware of this app, so make it visible. adj = ProcessList.PERCEPTIBLE_APP_ADJ; app.hidden = false; - app.adjType = "force-foreground"; + app.adjType = "force-fg"; app.adjSource = app.forcingToForeground; schedGroup = Process.THREAD_GROUP_DEFAULT; } @@ -12754,6 +12766,14 @@ public final class ActivityManagerService extends ActivityManagerNative myHiddenAdj = ProcessList.VISIBLE_APP_ADJ; } } + int myClientHiddenAdj = clientHiddenAdj; + if (myClientHiddenAdj > client.clientHiddenAdj) { + if (client.clientHiddenAdj >= ProcessList.VISIBLE_APP_ADJ) { + myClientHiddenAdj = client.clientHiddenAdj; + } else { + myClientHiddenAdj = ProcessList.VISIBLE_APP_ADJ; + } + } int myEmptyAdj = emptyAdj; if (myEmptyAdj > client.emptyAdj) { if (client.emptyAdj >= ProcessList.VISIBLE_APP_ADJ) { @@ -12763,7 +12783,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } clientAdj = computeOomAdjLocked(client, myHiddenAdj, - myEmptyAdj, TOP_APP, true, doingAll); + myClientHiddenAdj, myEmptyAdj, TOP_APP, true, doingAll); String adjType = null; if ((cr.flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { // Not doing bind OOM management, so treat @@ -12792,6 +12812,19 @@ public final class ActivityManagerService extends ActivityManagerNative clientAdj = adj; } } + } else if ((cr.flags&Context.BIND_AUTO_CREATE) != 0) { + if ((cr.flags&Context.BIND_NOT_VISIBLE) == 0) { + // If this connection is keeping the service + // created, then we want to try to better follow + // its memory management semantics for activities. + // That is, if it is sitting in the background + // LRU list as a hidden process (with activities), + // we don't want the service it is connected to + // to go into the empty LRU and quickly get killed, + // because I'll we'll do is just end up restarting + // the service. + app.hasClientActivities |= client.hasActivities; + } } if (adj > clientAdj) { // If this process has recently shown UI, and @@ -12843,8 +12876,8 @@ public final class ActivityManagerService extends ActivityManagerNative } } } + final ActivityRecord a = cr.activity; if ((cr.flags&Context.BIND_ADJUST_WITH_ACTIVITY) != 0) { - ActivityRecord a = cr.activity; if (a != null && adj > ProcessList.FOREGROUND_APP_ADJ && (a.visible || a.state == ActivityState.RESUMED || a.state == ActivityState.PAUSING)) { @@ -12902,6 +12935,14 @@ public final class ActivityManagerService extends ActivityManagerNative myHiddenAdj = ProcessList.FOREGROUND_APP_ADJ; } } + int myClientHiddenAdj = clientHiddenAdj; + if (myClientHiddenAdj > client.clientHiddenAdj) { + if (client.clientHiddenAdj >= ProcessList.FOREGROUND_APP_ADJ) { + myClientHiddenAdj = client.clientHiddenAdj; + } else { + myClientHiddenAdj = ProcessList.FOREGROUND_APP_ADJ; + } + } int myEmptyAdj = emptyAdj; if (myEmptyAdj > client.emptyAdj) { if (client.emptyAdj > ProcessList.FOREGROUND_APP_ADJ) { @@ -12911,7 +12952,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } int clientAdj = computeOomAdjLocked(client, myHiddenAdj, - myEmptyAdj, TOP_APP, true, doingAll); + myClientHiddenAdj, myEmptyAdj, TOP_APP, true, doingAll); if (adj > clientAdj) { if (app.hasShownUi && app != mHomeProcess && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) { @@ -13301,7 +13342,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, "Excessive wake lock in " + app.processName + " (pid " + app.pid + "): held " + wtimeUsed + " during " + realtimeSince); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "excessive wake lock"); Process.killProcessQuiet(app.pid); } else if (doCpuKills && uptimeSince > 0 @@ -13313,7 +13354,7 @@ public final class ActivityManagerService extends ActivityManagerNative Slog.w(TAG, "Excessive CPU in " + app.processName + " (pid " + app.pid + "): used " + cputimeUsed + " during " + uptimeSince); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "excessive cpu"); Process.killProcessQuiet(app.pid); } else { @@ -13325,8 +13366,9 @@ public final class ActivityManagerService extends ActivityManagerNative } private final boolean updateOomAdjLocked(ProcessRecord app, int hiddenAdj, - int emptyAdj, ProcessRecord TOP_APP, boolean doingAll) { + int clientHiddenAdj, int emptyAdj, ProcessRecord TOP_APP, boolean doingAll) { app.hiddenAdj = hiddenAdj; + app.clientHiddenAdj = clientHiddenAdj; app.emptyAdj = emptyAdj; if (app.thread == null) { @@ -13337,7 +13379,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean success = true; - computeOomAdjLocked(app, hiddenAdj, emptyAdj, TOP_APP, false, doingAll); + computeOomAdjLocked(app, hiddenAdj, clientHiddenAdj, emptyAdj, TOP_APP, false, doingAll); if (app.curRawAdj != app.setRawAdj) { if (wasKeeping && !app.keeping) { @@ -13374,7 +13416,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (app.waitingToKill != null && app.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) { Slog.i(TAG, "Killing " + app.toShortString() + ": " + app.waitingToKill); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, app.waitingToKill); app.killedBackground = true; Process.killProcessQuiet(app.pid); @@ -13424,8 +13466,8 @@ public final class ActivityManagerService extends ActivityManagerNative mAdjSeq++; - boolean success = updateOomAdjLocked(app, app.hiddenAdj, app.emptyAdj, - TOP_APP, false); + boolean success = updateOomAdjLocked(app, app.hiddenAdj, app.clientHiddenAdj, + app.emptyAdj, TOP_APP, false); final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; if (nowHidden != wasHidden) { @@ -13439,6 +13481,7 @@ public final class ActivityManagerService extends ActivityManagerNative final void updateOomAdjLocked() { final ActivityRecord TOP_ACT = resumedAppLocked(); final ProcessRecord TOP_APP = TOP_ACT != null ? TOP_ACT.app : null; + final long oldTime = SystemClock.uptimeMillis() - ProcessList.MAX_EMPTY_TIME; if (false) { RuntimeException e = new RuntimeException(); @@ -13449,20 +13492,40 @@ public final class ActivityManagerService extends ActivityManagerNative mAdjSeq++; mNewNumServiceProcs = 0; + final int emptyProcessLimit; + final int hiddenProcessLimit; + if (mProcessLimit <= 0) { + emptyProcessLimit = hiddenProcessLimit = 0; + } else if (mProcessLimit == 1) { + emptyProcessLimit = 1; + hiddenProcessLimit = 0; + } else { + emptyProcessLimit = (mProcessLimit*2)/3; + hiddenProcessLimit = mProcessLimit - emptyProcessLimit; + } + // Let's determine how many processes we have running vs. // how many slots we have for background processes; we may want // to put multiple processes in a slot of there are enough of // them. int numSlots = (ProcessList.HIDDEN_APP_MAX_ADJ - ProcessList.HIDDEN_APP_MIN_ADJ + 1) / 2; - int emptyFactor = (mLruProcesses.size()-mNumNonHiddenProcs-mNumHiddenProcs)/numSlots; + int numEmptyProcs = mLruProcesses.size()-mNumNonHiddenProcs-mNumHiddenProcs; + if (numEmptyProcs > hiddenProcessLimit) { + // If there are more empty processes than our limit on hidden + // processes, then use the hidden process limit for the factor. + // This ensures that the really old empty processes get pushed + // down to the bottom, so if we are running low on memory we will + // have a better chance at keeping around more hidden processes + // instead of a gazillion empty processes. + numEmptyProcs = hiddenProcessLimit; + } + int emptyFactor = numEmptyProcs/numSlots; if (emptyFactor < 1) emptyFactor = 1; int hiddenFactor = (mNumHiddenProcs > 0 ? mNumHiddenProcs : 1)/numSlots; if (hiddenFactor < 1) hiddenFactor = 1; int stepHidden = 0; int stepEmpty = 0; - final int emptyProcessLimit = mProcessLimit > 1 ? mProcessLimit / 2 : mProcessLimit; - final int hiddenProcessLimit = mProcessLimit > 1 ? mProcessLimit / 2 : mProcessLimit; int numHidden = 0; int numEmpty = 0; int numTrimming = 0; @@ -13477,11 +13540,12 @@ public final class ActivityManagerService extends ActivityManagerNative int nextHiddenAdj = curHiddenAdj+1; int curEmptyAdj = ProcessList.HIDDEN_APP_MIN_ADJ; int nextEmptyAdj = curEmptyAdj+2; + int curClientHiddenAdj = curEmptyAdj; while (i > 0) { i--; ProcessRecord app = mLruProcesses.get(i); //Slog.i(TAG, "OOM " + app + ": cur hidden=" + curHiddenAdj); - updateOomAdjLocked(app, curHiddenAdj, curEmptyAdj, TOP_APP, true); + updateOomAdjLocked(app, curHiddenAdj, curClientHiddenAdj, curEmptyAdj, TOP_APP, true); if (!app.killedBackground) { if (app.curRawAdj == curHiddenAdj && app.hasActivities) { // This process was assigned as a hidden process... step the @@ -13496,17 +13560,31 @@ public final class ActivityManagerService extends ActivityManagerNative if (nextHiddenAdj > ProcessList.HIDDEN_APP_MAX_ADJ) { nextHiddenAdj = ProcessList.HIDDEN_APP_MAX_ADJ; } + if (curClientHiddenAdj <= curHiddenAdj) { + curClientHiddenAdj = curHiddenAdj + 1; + if (curClientHiddenAdj > ProcessList.HIDDEN_APP_MAX_ADJ) { + curClientHiddenAdj = ProcessList.HIDDEN_APP_MAX_ADJ; + } + } } } numHidden++; if (numHidden > hiddenProcessLimit) { Slog.i(TAG, "No longer want " + app.processName + " (pid " + app.pid + "): hidden #" + numHidden); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "too many background"); app.killedBackground = true; Process.killProcessQuiet(app.pid); } + } else if (app.curRawAdj == curHiddenAdj && app.hasClientActivities) { + // This process has a client that has activities. We will have + // given it the current hidden adj; here we will just leave it + // without stepping the hidden adj. + curClientHiddenAdj++; + if (curClientHiddenAdj > ProcessList.HIDDEN_APP_MAX_ADJ) { + curClientHiddenAdj = ProcessList.HIDDEN_APP_MAX_ADJ; + } } else { if (app.curRawAdj == curEmptyAdj || app.curRawAdj == curHiddenAdj) { // This process was assigned as an empty process... step the @@ -13525,15 +13603,28 @@ public final class ActivityManagerService extends ActivityManagerNative } else if (app.curRawAdj < ProcessList.HIDDEN_APP_MIN_ADJ) { mNumNonHiddenProcs++; } - if (app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ) { - numEmpty++; - if (numEmpty > emptyProcessLimit) { + if (app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ + && !app.hasClientActivities) { + if (numEmpty > ProcessList.TRIM_EMPTY_APPS + && app.lastActivityTime < oldTime) { Slog.i(TAG, "No longer want " + app.processName - + " (pid " + app.pid + "): empty #" + numEmpty); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, - app.processName, app.setAdj, "too many background"); + + " (pid " + app.pid + "): empty for " + + ((oldTime+ProcessList.MAX_EMPTY_TIME-app.lastActivityTime) + / 1000) + "s"); + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, + app.processName, app.setAdj, "old background process"); app.killedBackground = true; Process.killProcessQuiet(app.pid); + } else { + numEmpty++; + if (numEmpty > emptyProcessLimit) { + Slog.i(TAG, "No longer want " + app.processName + + " (pid " + app.pid + "): empty #" + numEmpty); + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, + app.processName, app.setAdj, "too many background"); + app.killedBackground = true; + Process.killProcessQuiet(app.pid); + } } } } @@ -13546,7 +13637,7 @@ public final class ActivityManagerService extends ActivityManagerNative // left sitting around after no longer needed. Slog.i(TAG, "Isolated process " + app.processName + " (pid " + app.pid + ") no longer needed"); - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "isolated not needed"); app.killedBackground = true; Process.killProcessQuiet(app.pid); @@ -13567,8 +13658,8 @@ public final class ActivityManagerService extends ActivityManagerNative // are managing to keep around is less than half the maximum we desire; // if we are keeping a good number around, we'll let them use whatever // memory they want. - if (numHidden <= (ProcessList.MAX_HIDDEN_APPS/4) - && numEmpty <= (ProcessList.MAX_HIDDEN_APPS/4)) { + if (numHidden <= ProcessList.TRIM_HIDDEN_APPS + && numEmpty <= ProcessList.TRIM_EMPTY_APPS) { final int numHiddenAndEmpty = numHidden + numEmpty; final int N = mLruProcesses.size(); int factor = numTrimming/3; @@ -13578,9 +13669,9 @@ public final class ActivityManagerService extends ActivityManagerNative if (factor < minFactor) factor = minFactor; int step = 0; int fgTrimLevel; - if (numHiddenAndEmpty <= (ProcessList.MAX_HIDDEN_APPS/5)) { + if (numHiddenAndEmpty <= ProcessList.TRIM_CRITICAL_THRESHOLD) { fgTrimLevel = ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL; - } else if (numHiddenAndEmpty <= (ProcessList.MAX_HIDDEN_APPS/3)) { + } else if (numHiddenAndEmpty <= ProcessList.TRIM_LOW_THRESHOLD) { fgTrimLevel = ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW; } else { fgTrimLevel = ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE; @@ -13700,7 +13791,7 @@ public final class ActivityManagerService extends ActivityManagerNative + (app.thread != null ? app.thread.asBinder() : null) + ")\n"); if (app.pid > 0 && app.pid != MY_PID) { - EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, app.pid, app.processName, app.setAdj, "empty"); Process.killProcessQuiet(app.pid); } else { diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index 7ff5748..6cd86fd 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -746,8 +746,8 @@ final class ActivityRecord { final long totalTime = stack.mInitialStartTime != 0 ? (curTime - stack.mInitialStartTime) : thisTime; if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) { - EventLog.writeEvent(EventLogTags.ACTIVITY_LAUNCH_TIME, - System.identityHashCode(this), shortComponentName, + EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME, + userId, System.identityHashCode(this), shortComponentName, thisTime, totalTime); StringBuilder sb = service.mStringBuilder; sb.setLength(0); @@ -923,6 +923,8 @@ final class ActivityRecord { StringBuilder sb = new StringBuilder(128); sb.append("ActivityRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" u"); + sb.append(userId); sb.append(' '); sb.append(intent.getComponent().flattenToShortString()); sb.append('}'); diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index 1707ff0..2d445274 100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -638,7 +638,7 @@ final class ActivityStack { if (idx < 0) { app.activities.add(r); } - mService.updateLruProcessLocked(app, true, true); + mService.updateLruProcessLocked(app, true); try { if (app.thread == null) { @@ -656,7 +656,7 @@ final class ActivityStack { + " andResume=" + andResume); if (andResume) { EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY, - System.identityHashCode(r), + r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName); } if (r.isHomeActivity) { @@ -951,7 +951,7 @@ final class ActivityStack { if (DEBUG_PAUSE) Slog.v(TAG, "Enqueueing pending pause: " + prev); try { EventLog.writeEvent(EventLogTags.AM_PAUSE_ACTIVITY, - System.identityHashCode(prev), + prev.userId, System.identityHashCode(prev), prev.shortComponentName); prev.app.thread.schedulePauseActivity(prev.appToken, prev.finishing, userLeaving, prev.configChangeFlags); @@ -1040,7 +1040,7 @@ final class ActivityStack { completePauseLocked(); } else { EventLog.writeEvent(EventLogTags.AM_FAILED_TO_PAUSE, - System.identityHashCode(r), r.shortComponentName, + r.userId, System.identityHashCode(r), r.shortComponentName, mPausingActivity != null ? mPausingActivity.shortComponentName : "(none)"); } @@ -1505,7 +1505,7 @@ final class ActivityStack { if (next.app != null && next.app.thread != null) { // No reason to do full oom adj update here; we'll let that // happen whenever it needs to later. - mService.updateLruProcessLocked(next.app, false, true); + mService.updateLruProcessLocked(next.app, false); } startPausingLocked(userLeaving, false); return true; @@ -1641,7 +1641,7 @@ final class ActivityStack { if (mMainStack) { mService.addRecentTaskLocked(next.task); } - mService.updateLruProcessLocked(next.app, true, true); + mService.updateLruProcessLocked(next.app, true); updateLRUListLocked(next); // Have the window manager re-evaluate the orientation of @@ -1699,7 +1699,7 @@ final class ActivityStack { } EventLog.writeEvent(EventLogTags.AM_RESUME_ACTIVITY, - System.identityHashCode(next), + next.userId, System.identityHashCode(next), next.task.taskId, next.shortComponentName); next.sleeping = false; @@ -2967,7 +2967,7 @@ final class ActivityStack { intent, r.getUriPermissionsLocked()); if (newTask) { - EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, r.task.taskId); + EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, r.userId, r.task.taskId); } logStartActivity(EventLogTags.AM_CREATE_ACTIVITY, r, r.task); startActivityLocked(r, newTask, doResume, keepCurTransition, options); @@ -3700,7 +3700,7 @@ final class ActivityStack { r.makeFinishing(); EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY, - System.identityHashCode(r), + r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName, reason); if (index < (mHistory.size()-1)) { ActivityRecord next = mHistory.get(index+1); @@ -3996,7 +3996,7 @@ final class ActivityStack { TAG, "Removing activity from " + reason + ": token=" + r + ", app=" + (r.app != null ? r.app.processName : "(null)")); EventLog.writeEvent(EventLogTags.AM_DESTROY_ACTIVITY, - System.identityHashCode(r), + r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName, reason); boolean removedFromHistory = false; @@ -4228,7 +4228,7 @@ final class ActivityStack { } finishTaskMoveLocked(task); - EventLog.writeEvent(EventLogTags.AM_TASK_TO_FRONT, task); + EventLog.writeEvent(EventLogTags.AM_TASK_TO_FRONT, tr.userId, task); } private final void finishTaskMoveLocked(int task) { @@ -4448,7 +4448,7 @@ final class ActivityStack { private final void logStartActivity(int tag, ActivityRecord r, TaskRecord task) { EventLog.writeEvent(tag, - System.identityHashCode(r), task.taskId, + r.userId, System.identityHashCode(r), task.taskId, r.shortComponentName, r.intent.getAction(), r.intent.getType(), r.intent.getDataString(), r.intent.getFlags()); @@ -4590,7 +4590,7 @@ final class ActivityStack { + " with results=" + results + " newIntents=" + newIntents + " andResume=" + andResume); EventLog.writeEvent(andResume ? EventLogTags.AM_RELAUNCH_RESUME_ACTIVITY - : EventLogTags.AM_RELAUNCH_ACTIVITY, System.identityHashCode(r), + : EventLogTags.AM_RELAUNCH_ACTIVITY, r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName); r.startFreezingScreenLocked(r.app, 0); diff --git a/services/java/com/android/server/am/BroadcastFilter.java b/services/java/com/android/server/am/BroadcastFilter.java index 07440b5..c631b6e 100644 --- a/services/java/com/android/server/am/BroadcastFilter.java +++ b/services/java/com/android/server/am/BroadcastFilter.java @@ -64,6 +64,8 @@ class BroadcastFilter extends IntentFilter { StringBuilder sb = new StringBuilder(); sb.append("BroadcastFilter{"); sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" u"); + sb.append(owningUserId); sb.append(' '); sb.append(receiverList); sb.append('}'); diff --git a/services/java/com/android/server/am/BroadcastQueue.java b/services/java/com/android/server/am/BroadcastQueue.java index b0af081..9f27994 100644 --- a/services/java/com/android/server/am/BroadcastQueue.java +++ b/services/java/com/android/server/am/BroadcastQueue.java @@ -209,7 +209,7 @@ public class BroadcastQueue { r.receiver = app.thread.asBinder(); r.curApp = app; app.curReceiver = r; - mService.updateLruProcessLocked(app, true, true); + mService.updateLruProcessLocked(app, true); // Tell the application to launch this receiver. r.intent.setComponent(r.curComponent); @@ -930,22 +930,22 @@ public class BroadcastQueue { if (curReceiver instanceof BroadcastFilter) { BroadcastFilter bf = (BroadcastFilter) curReceiver; EventLog.writeEvent(EventLogTags.AM_BROADCAST_DISCARD_FILTER, - System.identityHashCode(r), + bf.owningUserId, System.identityHashCode(r), r.intent.getAction(), r.nextReceiver - 1, System.identityHashCode(bf)); } else { + ResolveInfo ri = (ResolveInfo)curReceiver; EventLog.writeEvent(EventLogTags.AM_BROADCAST_DISCARD_APP, - System.identityHashCode(r), - r.intent.getAction(), - r.nextReceiver - 1, - ((ResolveInfo)curReceiver).toString()); + UserHandle.getUserId(ri.activityInfo.applicationInfo.uid), + System.identityHashCode(r), r.intent.getAction(), + r.nextReceiver - 1, ri.toString()); } } else { Slog.w(TAG, "Discarding broadcast before first receiver is invoked: " + r); EventLog.writeEvent(EventLogTags.AM_BROADCAST_DISCARD_APP, - System.identityHashCode(r), + -1, System.identityHashCode(r), r.intent.getAction(), r.nextReceiver, "NONE"); diff --git a/services/java/com/android/server/am/BroadcastRecord.java b/services/java/com/android/server/am/BroadcastRecord.java index ca6d5f7..85ec328 100644 --- a/services/java/com/android/server/am/BroadcastRecord.java +++ b/services/java/com/android/server/am/BroadcastRecord.java @@ -194,6 +194,6 @@ class BroadcastRecord extends Binder { public String toString() { return "BroadcastRecord{" + Integer.toHexString(System.identityHashCode(this)) - + " " + intent.getAction() + "}"; + + " u" + userId + " " + intent.getAction() + "}"; } } diff --git a/services/java/com/android/server/am/ConnectionRecord.java b/services/java/com/android/server/am/ConnectionRecord.java index 5b3ff8d..4ed3c31 100644 --- a/services/java/com/android/server/am/ConnectionRecord.java +++ b/services/java/com/android/server/am/ConnectionRecord.java @@ -62,6 +62,8 @@ class ConnectionRecord { StringBuilder sb = new StringBuilder(128); sb.append("ConnectionRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" u"); + sb.append(binding.client.userId); sb.append(' '); if ((flags&Context.BIND_AUTO_CREATE) != 0) { sb.append("CR "); @@ -70,7 +72,7 @@ class ConnectionRecord { sb.append("DBG "); } if ((flags&Context.BIND_NOT_FOREGROUND) != 0) { - sb.append("NOTFG "); + sb.append("!FG "); } if ((flags&Context.BIND_ABOVE_CLIENT) != 0) { sb.append("ABCLT "); @@ -88,7 +90,10 @@ class ConnectionRecord { sb.append("ACT "); } if ((flags&Context.BIND_NOT_VISIBLE) != 0) { - sb.append("NOTVIS "); + sb.append("!VIS "); + } + if ((flags&Context.BIND_VISIBLE) != 0) { + sb.append("VIS "); } if (serviceDead) { sb.append("DEAD "); diff --git a/services/java/com/android/server/am/ContentProviderRecord.java b/services/java/com/android/server/am/ContentProviderRecord.java index de306b5..8fb6a93 100644 --- a/services/java/com/android/server/am/ContentProviderRecord.java +++ b/services/java/com/android/server/am/ContentProviderRecord.java @@ -25,6 +25,7 @@ import android.os.IBinder; import android.os.IBinder.DeathRecipient; import android.os.Process; import android.os.RemoteException; +import android.os.UserHandle; import android.util.Slog; import java.io.PrintWriter; @@ -199,6 +200,8 @@ class ContentProviderRecord { StringBuilder sb = new StringBuilder(128); sb.append("ContentProviderRecord{"); sb.append(Integer.toHexString(System.identityHashCode(this))); + sb.append(" u"); + sb.append(UserHandle.getUserId(uid)); sb.append(' '); sb.append(name.flattenToShortString()); sb.append('}'); diff --git a/services/java/com/android/server/am/EventLogTags.logtags b/services/java/com/android/server/am/EventLogTags.logtags index a579f44..6ee7507 100644 --- a/services/java/com/android/server/am/EventLogTags.logtags +++ b/services/java/com/android/server/am/EventLogTags.logtags @@ -14,72 +14,72 @@ option java_package com.android.server.am # google3/googledata/wireless/android/provisioning/gservices.config !! # # An activity is being finished: -30001 am_finish_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) +30001 am_finish_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) # A task is being brought to the front of the screen: -30002 am_task_to_front (Task|1|5) +30002 am_task_to_front (User|1|5),(Task|1|5) # An existing activity is being given a new intent: -30003 am_new_intent (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) +30003 am_new_intent (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) # A new task is being created: -30004 am_create_task (Task ID|1|5) +30004 am_create_task (User|1|5),(Task ID|1|5) # A new activity is being created in an existing task: -30005 am_create_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) +30005 am_create_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Action|3),(MIME Type|3),(URI|3),(Flags|1|5) # An activity has been resumed into the foreground but was not already running: -30006 am_restart_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +30006 am_restart_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) # An activity has been resumed and is now in the foreground: -30007 am_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +30007 am_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) # Application Not Responding -30008 am_anr (pid|1|5),(Package Name|3),(Flags|1|5),(reason|3) +30008 am_anr (User|1|5),(pid|1|5),(Package Name|3),(Flags|1|5),(reason|3) # Activity launch time -30009 activity_launch_time (Token|1|5),(Component Name|3),(time|2|3) +30009 am_activity_launch_time (User|1|5),(Token|1|5),(Component Name|3),(time|2|3) # Application process bound to work -30010 am_proc_bound (PID|1|5),(Process Name|3) +30010 am_proc_bound (User|1|5),(PID|1|5),(Process Name|3) # Application process died -30011 am_proc_died (PID|1|5),(Process Name|3) +30011 am_proc_died (User|1|5),(PID|1|5),(Process Name|3) # The Activity Manager failed to pause the given activity. -30012 am_failed_to_pause (Token|1|5),(Wanting to pause|3),(Currently pausing|3) +30012 am_failed_to_pause (User|1|5),(Token|1|5),(Wanting to pause|3),(Currently pausing|3) # Attempting to pause the current activity -30013 am_pause_activity (Token|1|5),(Component Name|3) +30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3) # Application process has been started -30014 am_proc_start (PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) +30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) # An application process has been marked as bad -30015 am_proc_bad (UID|1|5),(Process Name|3) +30015 am_proc_bad (User|1|5),(UID|1|5),(Process Name|3) # An application process that was bad is now marked as good -30016 am_proc_good (UID|1|5),(Process Name|3) +30016 am_proc_good (User|1|5),(UID|1|5),(Process Name|3) # Reporting to applications that memory is low 30017 am_low_memory (Num Processes|1|1) # An activity is being destroyed: -30018 am_destroy_activity (Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) +30018 am_destroy_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3),(Reason|3) # An activity has been relaunched, resumed, and is now in the foreground: -30019 am_relaunch_resume_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +30019 am_relaunch_resume_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) # An activity has been relaunched: -30020 am_relaunch_activity (Token|1|5),(Task ID|1|5),(Component Name|3) +30020 am_relaunch_activity (User|1|5),(Token|1|5),(Task ID|1|5),(Component Name|3) # The activity's onPause has been called. -30021 am_on_paused_called (Component Name|3) +30021 am_on_paused_called (User|1|5),(Component Name|3) # The activity's onResume has been called. -30022 am_on_resume_called (Component Name|3) +30022 am_on_resume_called (User|1|5),(Component Name|3) # Kill a process to reclaim memory. -30023 am_kill (PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3) +30023 am_kill (User|1|5),(PID|1|5),(Process Name|3),(OomAdj|1|5),(Reason|3) # Discard an undelivered serialized broadcast (timeout/ANR/crash) -30024 am_broadcast_discard_filter (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5) -30025 am_broadcast_discard_app (Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3) +30024 am_broadcast_discard_filter (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(BroadcastFilter|1|5) +30025 am_broadcast_discard_app (User|1|5),(Broadcast|1|5),(Action|3),(Receiver Number|1|1),(App|3) # A service is being created -30030 am_create_service (Service Record|1|5),(Name|3),(Intent|3),(PID|1|5) +30030 am_create_service (User|1|5),(Service Record|1|5),(Name|3),(Intent|3),(PID|1|5) # A service is being destroyed -30031 am_destroy_service (Service Record|1|5),(Name|3),(PID|1|5) +30031 am_destroy_service (User|1|5),(Service Record|1|5),(Name|3),(PID|1|5) # A process has crashed too many times, it is being cleared -30032 am_process_crashed_too_much (Name|3),(PID|1|5) +30032 am_process_crashed_too_much (User|1|5),(Name|3),(PID|1|5) # An unknown process is trying to attach to the activity manager 30033 am_drop_process (PID|1|5) # A service has crashed too many times, it is being stopped -30034 am_service_crashed_too_much (Crash Count|1|1),(Component Name|3),(PID|1|5) +30034 am_service_crashed_too_much (User|1|5),(Crash Count|1|1),(Component Name|3),(PID|1|5) # A service is going to be restarted after its process went away -30035 am_schedule_service_restart (Component Name|3),(Time|2|3) +30035 am_schedule_service_restart (User|1|5),(Component Name|3),(Time|2|3) # A client was waiting for a content provider, but its process was lost -30036 am_provider_lost_process (Package Name|3),(UID|1|5),(Name|3) +30036 am_provider_lost_process (User|1|5),(Package Name|3),(UID|1|5),(Name|3) # The activity manager gave up on a new process taking too long to start -30037 am_process_start_timeout (PID|1|5),(UID|1|5),(Process Name|3) +30037 am_process_start_timeout (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3) # Unhandled exception -30039 am_crash (PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5) +30039 am_crash (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Exception|3),(Message|3),(File|3),(Line|1|5) # Log.wtf() called -30040 am_wtf (PID|1|5),(Process Name|3),(Flags|1|5),(Tag|3),(Message|3) +30040 am_wtf (User|1|5),(PID|1|5),(Process Name|3),(Flags|1|5),(Tag|3),(Message|3) diff --git a/services/java/com/android/server/am/ProcessList.java b/services/java/com/android/server/am/ProcessList.java index afc060e..9e25e30 100644 --- a/services/java/com/android/server/am/ProcessList.java +++ b/services/java/com/android/server/am/ProcessList.java @@ -101,7 +101,24 @@ class ProcessList { // The maximum number of hidden processes we will keep around before // killing them; this is just a control to not let us go too crazy with // keeping around processes on devices with large amounts of RAM. - static final int MAX_HIDDEN_APPS = 15; + static final int MAX_HIDDEN_APPS = 24; + + // We allow empty processes to stick around for at most 30 minutes. + static final long MAX_EMPTY_TIME = 30*60*1000; + + // The number of hidden at which we don't consider it necessary to do + // memory trimming. + static final int TRIM_HIDDEN_APPS = 3; + + // The number of empty apps at which we don't consider it necessary to do + // memory trimming. + static final int TRIM_EMPTY_APPS = 3; + + // Threshold of number of hidden+empty where we consider memory critical. + static final int TRIM_CRITICAL_THRESHOLD = 3; + + // Threshold of number of hidden+empty where we consider memory critical. + static final int TRIM_LOW_THRESHOLD = 5; // We put empty content processes after any hidden processes that have // been idle for less than 15 seconds. diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java index d372422..652fdb5 100644 --- a/services/java/com/android/server/am/ProcessRecord.java +++ b/services/java/com/android/server/am/ProcessRecord.java @@ -61,6 +61,7 @@ class ProcessRecord { long lruWeight; // Weight for ordering in LRU list int maxAdj; // Maximum OOM adjustment for this process int hiddenAdj; // If hidden, this is the adjustment to use + int clientHiddenAdj; // If empty but hidden client, this is the adjustment to use int emptyAdj; // If empty, this is the adjustment to use int curRawAdj; // Current OOM unlimited adjustment for this process int setRawAdj; // Last set OOM unlimited adjustment for this process @@ -75,6 +76,7 @@ class ProcessRecord { boolean keeping; // Actively running code so don't kill due to that? boolean setIsForeground; // Running foreground UI when last set? boolean hasActivities; // Are there any activities running in this process? + boolean hasClientActivities; // Are there any client services with activities? boolean foregroundServices; // Running any services that are foreground? boolean foregroundActivities; // Running any activities that are foreground? boolean systemNoUi; // This is a system process, but not currently showing UI. @@ -188,8 +190,7 @@ class ProcessRecord { instrumentationInfo.dump(new PrintWriterPrinter(pw), prefix + " "); } } - pw.print(prefix); pw.print("thread="); pw.print(thread); - pw.print(" curReceiver="); pw.println(curReceiver); + pw.print(prefix); pw.print("thread="); pw.println(thread); pw.print(prefix); pw.print("pid="); pw.print(pid); pw.print(" starting="); pw.print(starting); pw.print(" lastPss="); pw.println(lastPss); pw.print(prefix); pw.print("lastActivityTime="); @@ -201,6 +202,7 @@ class ProcessRecord { pw.print(" empty="); pw.println(empty); pw.print(prefix); pw.print("oom: max="); pw.print(maxAdj); pw.print(" hidden="); pw.print(hiddenAdj); + pw.print(" client="); pw.print(clientHiddenAdj); pw.print(" empty="); pw.print(emptyAdj); pw.print(" curRaw="); pw.print(curRawAdj); pw.print(" setRaw="); pw.print(setRawAdj); @@ -211,18 +213,27 @@ class ProcessRecord { pw.print(" setSchedGroup="); pw.print(setSchedGroup); pw.print(" systemNoUi="); pw.print(systemNoUi); pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel); - pw.print(prefix); pw.print("hasShownUi="); pw.print(hasShownUi); - pw.print(" pendingUiClean="); pw.print(pendingUiClean); - pw.print(" hasAboveClient="); pw.println(hasAboveClient); - pw.print(prefix); pw.print("setIsForeground="); pw.print(setIsForeground); - pw.print(" foregroundServices="); pw.print(foregroundServices); - pw.print(" forcingToForeground="); pw.println(forcingToForeground); - pw.print(prefix); pw.print("persistent="); pw.print(persistent); - pw.print(" removed="); pw.print(removed); - pw.print(" hasActivities="); pw.print(hasActivities); - pw.print(" foregroundActivities="); pw.println(foregroundActivities); pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq); pw.print(" lruSeq="); pw.println(lruSeq); + if (hasShownUi || pendingUiClean || hasAboveClient) { + pw.print(prefix); pw.print("hasShownUi="); pw.print(hasShownUi); + pw.print(" pendingUiClean="); pw.print(pendingUiClean); + pw.print(" hasAboveClient="); pw.println(hasAboveClient); + } + if (setIsForeground || foregroundServices || forcingToForeground != null) { + pw.print(prefix); pw.print("setIsForeground="); pw.print(setIsForeground); + pw.print(" foregroundServices="); pw.print(foregroundServices); + pw.print(" forcingToForeground="); pw.println(forcingToForeground); + } + if (persistent || removed) { + pw.print(prefix); pw.print("persistent="); pw.print(persistent); + pw.print(" removed="); pw.println(removed); + } + if (hasActivities || hasClientActivities || foregroundActivities) { + pw.print(prefix); pw.print("hasActivities="); pw.print(hasActivities); + pw.print(" hasClientActivities="); pw.print(hasClientActivities); + pw.print(" foregroundActivities="); pw.println(foregroundActivities); + } if (!keeping) { long wtime; synchronized (batteryStats.getBatteryStats()) { @@ -231,10 +242,10 @@ class ProcessRecord { } long timeUsed = wtime - lastWakeTime; pw.print(prefix); pw.print("lastWakeTime="); pw.print(lastWakeTime); - pw.print(" time used="); + pw.print(" timeUsed="); TimeUtils.formatDuration(timeUsed, pw); pw.println(""); pw.print(prefix); pw.print("lastCpuTime="); pw.print(lastCpuTime); - pw.print(" time used="); + pw.print(" timeUsed="); TimeUtils.formatDuration(curCpuTime-lastCpuTime, pw); pw.println(""); } pw.print(prefix); pw.print("lastRequestedGc="); @@ -299,6 +310,9 @@ class ProcessRecord { pw.print(prefix); pw.print(" - "); pw.println(conProviders.get(i).toShortString()); } } + if (curReceiver != null) { + pw.print(prefix); pw.print("curReceiver="); pw.println(curReceiver); + } if (receivers.size() > 0) { pw.print(prefix); pw.println("Receivers:"); for (ReceiverList rl : receivers) { @@ -318,7 +332,7 @@ class ProcessRecord { pkgList.add(_info.packageName); thread = _thread; maxAdj = ProcessList.HIDDEN_APP_MAX_ADJ; - hiddenAdj = emptyAdj = ProcessList.HIDDEN_APP_MIN_ADJ; + hiddenAdj = clientHiddenAdj = emptyAdj = ProcessList.HIDDEN_APP_MIN_ADJ; curRawAdj = setRawAdj = -100; curAdj = setAdj = -100; persistent = false; diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java index 7055fdc..84e824a 100644 --- a/services/java/com/android/server/am/ServiceRecord.java +++ b/services/java/com/android/server/am/ServiceRecord.java @@ -425,6 +425,7 @@ class ServiceRecord extends Binder { StringBuilder sb = new StringBuilder(128); sb.append("ServiceRecord{") .append(Integer.toHexString(System.identityHashCode(this))) + .append(" u").append(userId) .append(' ').append(shortName).append('}'); return stringName = sb.toString(); } diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java index 85f3b56..f348cb6 100644 --- a/services/java/com/android/server/display/DisplayManagerService.java +++ b/services/java/com/android/server/display/DisplayManagerService.java @@ -352,11 +352,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void scanWifiDisplays() { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } - final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { @@ -371,19 +366,16 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void connectWifiDisplay(String address) { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } if (address == null) { throw new IllegalArgumentException("address must not be null"); } + final boolean trusted = canCallerConfigureWifiDisplay(); final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { if (mWifiDisplayAdapter != null) { - mWifiDisplayAdapter.requestConnectLocked(address); + mWifiDisplayAdapter.requestConnectLocked(address, trusted); } } } finally { @@ -393,11 +385,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void disconnectWifiDisplay() { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } - final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { @@ -412,13 +399,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void renameWifiDisplay(String address, String alias) { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } if (address == null) { throw new IllegalArgumentException("address must not be null"); } + if (!canCallerConfigureWifiDisplay()) { + throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + + "rename a wifi display."); + } final long token = Binder.clearCallingIdentity(); try { @@ -434,13 +421,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public void forgetWifiDisplay(String address) { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } if (address == null) { throw new IllegalArgumentException("address must not be null"); } + if (!canCallerConfigureWifiDisplay()) { + throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission to " + + "forget a wifi display."); + } final long token = Binder.clearCallingIdentity(); try { @@ -456,11 +443,6 @@ public final class DisplayManagerService extends IDisplayManager.Stub { @Override // Binder call public WifiDisplayStatus getWifiDisplayStatus() { - if (mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Requires CONFIGURE_WIFI_DISPLAY permission"); - } - final long token = Binder.clearCallingIdentity(); try { synchronized (mSyncRoot) { @@ -475,6 +457,11 @@ public final class DisplayManagerService extends IDisplayManager.Stub { } } + private boolean canCallerConfigureWifiDisplay() { + return mContext.checkCallingPermission(android.Manifest.permission.CONFIGURE_WIFI_DISPLAY) + == PackageManager.PERMISSION_GRANTED; + } + private void registerDefaultDisplayAdapter() { // Register default display adapter. synchronized (mSyncRoot) { diff --git a/services/java/com/android/server/display/WifiDisplayAdapter.java b/services/java/com/android/server/display/WifiDisplayAdapter.java index 1d50ded..4a89be7 100644 --- a/services/java/com/android/server/display/WifiDisplayAdapter.java +++ b/services/java/com/android/server/display/WifiDisplayAdapter.java @@ -27,6 +27,7 @@ import android.hardware.display.WifiDisplayStatus; import android.media.RemoteDisplay; import android.os.Handler; import android.os.IBinder; +import android.util.Slog; import android.view.Surface; import java.io.PrintWriter; @@ -121,7 +122,17 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } - public void requestConnectLocked(final String address) { + public void requestConnectLocked(final String address, final boolean trusted) { + if (!trusted) { + synchronized (getSyncRoot()) { + if (!isRememberedDisplayLocked(address)) { + Slog.w(TAG, "Ignoring request by an untrusted client to connect to " + + "an unknown wifi display: " + address); + return; + } + } + } + getHandler().post(new Runnable() { @Override public void run() { @@ -132,6 +143,15 @@ final class WifiDisplayAdapter extends DisplayAdapter { }); } + private boolean isRememberedDisplayLocked(String address) { + for (WifiDisplay display : mRememberedDisplays) { + if (display.getDeviceAddress().equals(address)) { + return true; + } + } + return false; + } + public void requestDisconnectLocked() { getHandler().post(new Runnable() { @Override @@ -241,10 +261,8 @@ final class WifiDisplayAdapter extends DisplayAdapter { getWifiDisplayStatusLocked()); } - // Send protected broadcast about wifi display status to receivers that - // have the required permission. - getContext().sendBroadcast(intent, - android.Manifest.permission.CONFIGURE_WIFI_DISPLAY); + // Send protected broadcast about wifi display status to registered receivers. + getContext().sendBroadcast(intent); } }; diff --git a/services/java/com/android/server/dreams/DreamController.java b/services/java/com/android/server/dreams/DreamController.java new file mode 100644 index 0000000..81c80187 --- /dev/null +++ b/services/java/com/android/server/dreams/DreamController.java @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2012 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.dreams; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.RemoteException; +import android.os.IBinder.DeathRecipient; +import android.service.dreams.Dream; +import android.service.dreams.IDreamService; +import android.util.Slog; +import android.view.IWindowManager; +import android.view.WindowManager; +import android.view.WindowManagerGlobal; + +import java.io.PrintWriter; +import java.util.NoSuchElementException; + +/** + * Internal controller for starting and stopping the current dream and managing related state. + * + * Assumes all operations are called from the dream handler thread. + */ +final class DreamController { + private static final String TAG = "DreamController"; + + private final Context mContext; + private final Handler mHandler; + private final Listener mListener; + private final IWindowManager mIWindowManager; + + private final Intent mDreamingStartedIntent = new Intent(Dream.ACTION_DREAMING_STARTED) + .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); + private final Intent mDreamingStoppedIntent = new Intent(Dream.ACTION_DREAMING_STOPPED) + .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); + + private DreamRecord mCurrentDream; + + public DreamController(Context context, Handler handler, Listener listener) { + mContext = context; + mHandler = handler; + mListener = listener; + mIWindowManager = WindowManagerGlobal.getWindowManagerService(); + } + + public void dump(PrintWriter pw) { + pw.println("Dreamland:"); + if (mCurrentDream != null) { + pw.println(" mCurrentDream:"); + pw.println(" mToken=" + mCurrentDream.mToken); + pw.println(" mName=" + mCurrentDream.mName); + pw.println(" mIsTest=" + mCurrentDream.mIsTest); + pw.println(" mUserId=" + mCurrentDream.mUserId); + pw.println(" mBound=" + mCurrentDream.mBound); + pw.println(" mService=" + mCurrentDream.mService); + pw.println(" mSentStartBroadcast=" + mCurrentDream.mSentStartBroadcast); + } else { + pw.println(" mCurrentDream: null"); + } + } + + public void startDream(Binder token, ComponentName name, boolean isTest, int userId) { + stopDream(); + + Slog.i(TAG, "Starting dream: name=" + name + ", isTest=" + isTest + ", userId=" + userId); + + mCurrentDream = new DreamRecord(token, name, isTest, userId); + + try { + mIWindowManager.addWindowToken(token, WindowManager.LayoutParams.TYPE_DREAM); + } catch (RemoteException ex) { + Slog.e(TAG, "Unable to add window token for dream.", ex); + stopDream(); + return; + } + + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Dream.CATEGORY_DREAM); + intent.setComponent(name); + intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + try { + if (!mContext.bindService(intent, mCurrentDream, + Context.BIND_AUTO_CREATE, userId)) { + Slog.e(TAG, "Unable to bind dream service: " + intent); + stopDream(); + return; + } + } catch (SecurityException ex) { + Slog.e(TAG, "Unable to bind dream service: " + intent, ex); + stopDream(); + return; + } + + mCurrentDream.mBound = true; + } + + public void stopDream() { + if (mCurrentDream == null) { + return; + } + + final DreamRecord oldDream = mCurrentDream; + mCurrentDream = null; + Slog.i(TAG, "Stopping dream: name=" + oldDream.mName + + ", isTest=" + oldDream.mIsTest + ", userId=" + oldDream.mUserId); + + if (oldDream.mSentStartBroadcast) { + mContext.sendBroadcast(mDreamingStoppedIntent); + } + + if (oldDream.mService != null) { + // TODO: It would be nice to tell the dream that it's being stopped so that + // it can shut down nicely before we yank its window token out from under it. + try { + oldDream.mService.asBinder().unlinkToDeath(oldDream, 0); + } catch (NoSuchElementException ex) { + // don't care + } + oldDream.mService = null; + } + + if (oldDream.mBound) { + mContext.unbindService(oldDream); + } + + try { + mIWindowManager.removeWindowToken(oldDream.mToken); + } catch (RemoteException ex) { + Slog.w(TAG, "Error removing window token for dream.", ex); + } + + mHandler.post(new Runnable() { + @Override + public void run() { + mListener.onDreamStopped(oldDream.mToken); + } + }); + } + + private void attach(IDreamService service) { + try { + service.asBinder().linkToDeath(mCurrentDream, 0); + service.attach(mCurrentDream.mToken); + } catch (RemoteException ex) { + Slog.e(TAG, "The dream service died unexpectedly.", ex); + stopDream(); + return; + } + + mCurrentDream.mService = service; + + if (!mCurrentDream.mIsTest) { + mContext.sendBroadcast(mDreamingStartedIntent); + mCurrentDream.mSentStartBroadcast = true; + } + } + + /** + * Callback interface to be implemented by the {@link DreamManagerService}. + */ + public interface Listener { + void onDreamStopped(Binder token); + } + + private final class DreamRecord implements DeathRecipient, ServiceConnection { + public final Binder mToken; + public final ComponentName mName; + public final boolean mIsTest; + public final int mUserId; + + public boolean mBound; + public IDreamService mService; + public boolean mSentStartBroadcast; + + public DreamRecord(Binder token, ComponentName name, + boolean isTest, int userId) { + mToken = token; + mName = name; + mIsTest = isTest; + mUserId = userId; + } + + // May be called on any thread. + @Override + public void binderDied() { + mHandler.post(new Runnable() { + @Override + public void run() { + mService = null; + if (mCurrentDream == DreamRecord.this) { + stopDream(); + } + } + }); + } + + // May be called on any thread. + @Override + public void onServiceConnected(ComponentName name, final IBinder service) { + mHandler.post(new Runnable() { + @Override + public void run() { + if (mCurrentDream == DreamRecord.this && mService == null) { + attach(IDreamService.Stub.asInterface(service)); + } + } + }); + } + + // May be called on any thread. + @Override + public void onServiceDisconnected(ComponentName name) { + mHandler.post(new Runnable() { + @Override + public void run() { + mService = null; + if (mCurrentDream == DreamRecord.this) { + stopDream(); + } + } + }); + } + } +}
\ No newline at end of file diff --git a/services/java/com/android/server/dreams/DreamManagerService.java b/services/java/com/android/server/dreams/DreamManagerService.java new file mode 100644 index 0000000..1f40176 --- /dev/null +++ b/services/java/com/android/server/dreams/DreamManagerService.java @@ -0,0 +1,383 @@ +/* + * Copyright (C) 2012 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.dreams; + +import com.android.internal.util.DumpUtils; + +import android.app.ActivityManager; +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.Looper; +import android.os.PowerManager; +import android.os.SystemClock; +import android.os.UserHandle; +import android.provider.Settings; +import android.service.dreams.IDreamManager; +import android.util.Slog; + +import java.io.FileDescriptor; +import java.io.PrintWriter; + +import libcore.util.Objects; + +/** + * Service api for managing dreams. + * + * @hide + */ +public final class DreamManagerService extends IDreamManager.Stub { + private static final boolean DEBUG = true; + private static final String TAG = "DreamManagerService"; + + private final Object mLock = new Object(); + + private final Context mContext; + private final DreamHandler mHandler; + private final DreamController mController; + private final PowerManager mPowerManager; + + private Binder mCurrentDreamToken; + private ComponentName mCurrentDreamName; + private int mCurrentDreamUserId; + private boolean mCurrentDreamIsTest; + + public DreamManagerService(Context context, Handler mainHandler) { + mContext = context; + mHandler = new DreamHandler(mainHandler.getLooper()); + mController = new DreamController(context, mHandler, mControllerListener); + + mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); + } + + public void systemReady() { + mContext.registerReceiver(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + synchronized (mLock) { + stopDreamLocked(); + } + } + }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler); + } + + @Override + protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG); + + pw.println("DREAM MANAGER (dumpsys dreams)"); + pw.println(); + + pw.println("mCurrentDreamToken=" + mCurrentDreamToken); + pw.println("mCurrentDreamName=" + mCurrentDreamName); + pw.println("mCurrentDreamUserId=" + mCurrentDreamUserId); + pw.println("mCurrentDreamIsTest=" + mCurrentDreamIsTest); + pw.println(); + + DumpUtils.dumpAsync(mHandler, new DumpUtils.Dump() { + @Override + public void dump(PrintWriter pw) { + mController.dump(pw); + } + }, pw, 200); + } + + @Override // Binder call + public ComponentName[] getDreamComponents() { + checkPermission(android.Manifest.permission.READ_DREAM_STATE); + + final int userId = UserHandle.getCallingUserId(); + final long ident = Binder.clearCallingIdentity(); + try { + return getDreamComponentsForUser(userId); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public void setDreamComponents(ComponentName[] componentNames) { + checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); + + final int userId = UserHandle.getCallingUserId(); + final long ident = Binder.clearCallingIdentity(); + try { + Settings.Secure.putStringForUser(mContext.getContentResolver(), + Settings.Secure.SCREENSAVER_COMPONENTS, + componentsToString(componentNames), + userId); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public ComponentName getDefaultDreamComponent() { + checkPermission(android.Manifest.permission.READ_DREAM_STATE); + + final int userId = UserHandle.getCallingUserId(); + final long ident = Binder.clearCallingIdentity(); + try { + String name = Settings.Secure.getStringForUser(mContext.getContentResolver(), + Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT, + userId); + return name == null ? null : ComponentName.unflattenFromString(name); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public boolean isDreaming() { + checkPermission(android.Manifest.permission.READ_DREAM_STATE); + + synchronized (mLock) { + return mCurrentDreamToken != null && !mCurrentDreamIsTest; + } + } + + @Override // Binder call + public void dream() { + checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); + + final long ident = Binder.clearCallingIdentity(); + try { + // Ask the power manager to nap. It will eventually call back into + // startDream() if/when it is appropriate to start dreaming. + // Because napping could cause the screen to turn off immediately if the dream + // cannot be started, we keep one eye open and gently poke user activity. + long time = SystemClock.uptimeMillis(); + mPowerManager.userActivity(time, true /*noChangeLights*/); + mPowerManager.nap(time); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public void testDream(ComponentName dream) { + checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); + + if (dream == null) { + throw new IllegalArgumentException("dream must not be null"); + } + + final int callingUserId = UserHandle.getCallingUserId(); + final int currentUserId = ActivityManager.getCurrentUser(); + if (callingUserId != currentUserId) { + // This check is inherently prone to races but at least it's something. + Slog.w(TAG, "Aborted attempt to start a test dream while a different " + + " user is active: callingUserId=" + callingUserId + + ", currentUserId=" + currentUserId); + return; + } + final long ident = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + startDreamLocked(dream, true /*isTest*/, callingUserId); + } + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public void awaken() { + checkPermission(android.Manifest.permission.WRITE_DREAM_STATE); + + final long ident = Binder.clearCallingIdentity(); + try { + // Treat an explicit request to awaken as user activity so that the + // device doesn't immediately go to sleep if the timeout expired, + // for example when being undocked. + long time = SystemClock.uptimeMillis(); + mPowerManager.userActivity(time, false /*noChangeLights*/); + stopDream(); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override // Binder call + public void finishSelf(IBinder token) { + // Requires no permission, called by Dream from an arbitrary process. + if (token == null) { + throw new IllegalArgumentException("token must not be null"); + } + + final long ident = Binder.clearCallingIdentity(); + try { + if (DEBUG) { + Slog.d(TAG, "Dream finished: " + token); + } + + // Note that a dream finishing and self-terminating is not + // itself considered user activity. If the dream is ending because + // the user interacted with the device then user activity will already + // have been poked so the device will stay awake a bit longer. + // If the dream is ending on its own for other reasons and no wake + // locks are held and the user activity timeout has expired then the + // device may simply go to sleep. + synchronized (mLock) { + if (mCurrentDreamToken == token) { + stopDreamLocked(); + } + } + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + /** + * Called by the power manager to start a dream. + */ + public void startDream() { + int userId = ActivityManager.getCurrentUser(); + ComponentName dream = chooseDreamForUser(userId); + if (dream != null) { + synchronized (mLock) { + startDreamLocked(dream, false /*isTest*/, userId); + } + } + } + + /** + * Called by the power manager to stop a dream. + */ + public void stopDream() { + synchronized (mLock) { + stopDreamLocked(); + } + } + + private ComponentName chooseDreamForUser(int userId) { + ComponentName[] dreams = getDreamComponentsForUser(userId); + return dreams != null && dreams.length != 0 ? dreams[0] : null; + } + + private ComponentName[] getDreamComponentsForUser(int userId) { + String names = Settings.Secure.getStringForUser(mContext.getContentResolver(), + Settings.Secure.SCREENSAVER_COMPONENTS, + userId); + return names == null ? null : componentsFromString(names); + } + + private void startDreamLocked(final ComponentName name, + final boolean isTest, final int userId) { + if (Objects.equal(mCurrentDreamName, name) + && mCurrentDreamIsTest == isTest + && mCurrentDreamUserId == userId) { + return; + } + + stopDreamLocked(); + + Slog.i(TAG, "Entering dreamland."); + + final Binder newToken = new Binder(); + mCurrentDreamToken = newToken; + mCurrentDreamName = name; + mCurrentDreamIsTest = isTest; + mCurrentDreamUserId = userId; + + mHandler.post(new Runnable() { + @Override + public void run() { + mController.startDream(newToken, name, isTest, userId); + } + }); + } + + private void stopDreamLocked() { + if (mCurrentDreamToken != null) { + Slog.i(TAG, "Leaving dreamland."); + + cleanupDreamLocked(); + + mHandler.post(new Runnable() { + @Override + public void run() { + mController.stopDream(); + } + }); + } + } + + private void cleanupDreamLocked() { + mCurrentDreamToken = null; + mCurrentDreamName = null; + mCurrentDreamIsTest = false; + mCurrentDreamUserId = 0; + } + + private void checkPermission(String permission) { + if (mContext.checkCallingOrSelfPermission(permission) + != PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Access denied to process: " + Binder.getCallingPid() + + ", must have permission " + permission); + } + } + + private static String componentsToString(ComponentName[] componentNames) { + StringBuilder names = new StringBuilder(); + if (componentNames != null) { + for (ComponentName componentName : componentNames) { + if (names.length() > 0) { + names.append(','); + } + names.append(componentName.flattenToString()); + } + } + return names.toString(); + } + + private static ComponentName[] componentsFromString(String names) { + String[] namesArray = names.split(","); + ComponentName[] componentNames = new ComponentName[namesArray.length]; + for (int i = 0; i < namesArray.length; i++) { + componentNames[i] = ComponentName.unflattenFromString(namesArray[i]); + } + return componentNames; + } + + private final DreamController.Listener mControllerListener = new DreamController.Listener() { + @Override + public void onDreamStopped(Binder token) { + synchronized (mLock) { + if (mCurrentDreamToken == token) { + cleanupDreamLocked(); + } + } + } + }; + + /** + * Handler for asynchronous operations performed by the dream manager. + * Ensures operations to {@link DreamController} are single-threaded. + */ + private final class DreamHandler extends Handler { + public DreamHandler(Looper looper) { + super(looper, null, true /*async*/); + } + } +} diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java index 28870a2..84adb83 100755 --- a/services/java/com/android/server/location/GpsLocationProvider.java +++ b/services/java/com/android/server/location/GpsLocationProvider.java @@ -1029,7 +1029,7 @@ public class GpsLocationProvider implements LocationProviderInterface { mLocation.setTime(timestamp); // It would be nice to push the elapsed real-time timestamp // further down the stack, but this is still useful - mLocation.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano()); + mLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } if ((flags & LOCATION_HAS_ALTITUDE) == LOCATION_HAS_ALTITUDE) { mLocation.setAltitude(altitude); diff --git a/services/java/com/android/server/location/LocationBasedCountryDetector.java b/services/java/com/android/server/location/LocationBasedCountryDetector.java index 38871d7..03db621 100755 --- a/services/java/com/android/server/location/LocationBasedCountryDetector.java +++ b/services/java/com/android/server/location/LocationBasedCountryDetector.java @@ -115,8 +115,8 @@ public class LocationBasedCountryDetector extends CountryDetectorBase { Location lastKnownLocation = mLocationManager.getLastKnownLocation(provider); if (lastKnownLocation != null) { if (bestLocation == null || - bestLocation.getElapsedRealtimeNano() < - lastKnownLocation.getElapsedRealtimeNano()) { + bestLocation.getElapsedRealtimeNanos() < + lastKnownLocation.getElapsedRealtimeNanos()) { bestLocation = lastKnownLocation; } } diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 030eb5e..ad138e8 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -24,6 +24,7 @@ import com.android.server.TwilightService; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerService; import com.android.server.display.DisplayManagerService; +import com.android.server.dreams.DreamManagerService; import android.Manifest; import android.content.BroadcastReceiver; @@ -46,13 +47,11 @@ import android.os.Message; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; -import android.os.ServiceManager; import android.os.SystemClock; import android.os.UserHandle; import android.os.WorkSource; import android.provider.Settings; import android.service.dreams.Dream; -import android.service.dreams.IDreamManager; import android.util.EventLog; import android.util.Log; import android.util.Slog; @@ -100,14 +99,12 @@ public final class PowerManagerService extends IPowerManager.Stub private static final int DIRTY_STAY_ON = 1 << 7; // Dirty bit: battery state changed private static final int DIRTY_BATTERY_STATE = 1 << 8; - // Dirty bit: dream ended - private static final int DIRTY_DREAM_ENDED = 1 << 9; // Wakefulness: The device is asleep and can only be awoken by a call to wakeUp(). // The screen should be off or in the process of being turned off by the display controller. private static final int WAKEFULNESS_ASLEEP = 0; // Wakefulness: The device is fully awake. It can be put to sleep by a call to goToSleep(). - // When the user activity timeout expires, the device may start napping. + // When the user activity timeout expires, the device may start napping or go to sleep. private static final int WAKEFULNESS_AWAKE = 1; // Wakefulness: The device is napping. It is deciding whether to dream or go to sleep // but hasn't gotten around to it yet. It can be awoken by a call to wakeUp(), which @@ -149,7 +146,7 @@ public final class PowerManagerService extends IPowerManager.Stub private Notifier mNotifier; private DisplayPowerController mDisplayPowerController; private SettingsObserver mSettingsObserver; - private IDreamManager mDreamManager; + private DreamManagerService mDreamManager; private LightsService.Light mAttentionLight; private final Object mLock = new Object(); @@ -335,9 +332,10 @@ public final class PowerManagerService extends IPowerManager.Stub } } - public void systemReady(TwilightService twilight) { + public void systemReady(TwilightService twilight, DreamManagerService dreamManager) { synchronized (mLock) { mSystemReady = true; + mDreamManager = dreamManager; PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); mScreenBrightnessSettingMinimum = pm.getMinimumScreenBrightnessSetting(); @@ -365,10 +363,7 @@ public final class PowerManagerService extends IPowerManager.Stub mContext.registerReceiver(new BootCompletedReceiver(), filter, null, mHandler); filter = new IntentFilter(); - filter.addAction(Intent.ACTION_DOCK_EVENT); - mContext.registerReceiver(new DockReceiver(), filter, null, mHandler); - - filter = new IntentFilter(); + filter.addAction(Dream.ACTION_DREAMING_STARTED); filter.addAction(Dream.ACTION_DREAMING_STOPPED); mContext.registerReceiver(new DreamReceiver(), filter, null, mHandler); @@ -887,6 +882,47 @@ public final class PowerManagerService extends IPowerManager.Stub return true; } + @Override // Binder call + public void nap(long eventTime) { + if (eventTime > SystemClock.uptimeMillis()) { + throw new IllegalArgumentException("event time must not be in the future"); + } + + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); + + final long ident = Binder.clearCallingIdentity(); + try { + napInternal(eventTime); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + private void napInternal(long eventTime) { + synchronized (mLock) { + if (napNoUpdateLocked(eventTime)) { + updatePowerStateLocked(); + } + } + } + + private boolean napNoUpdateLocked(long eventTime) { + if (DEBUG_SPEW) { + Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime); + } + + if (eventTime < mLastWakeTime || mWakefulness != WAKEFULNESS_AWAKE + || !mBootCompleted || !mSystemReady) { + return false; + } + + Slog.i(TAG, "Nap time..."); + + mDirty |= DIRTY_WAKEFULNESS; + mWakefulness = WAKEFULNESS_NAPPING; + return true; + } + /** * Updates the global power state based on dirty bits recorded in mDirty. * @@ -1143,11 +1179,15 @@ public final class PowerManagerService extends IPowerManager.Stub | DIRTY_WAKEFULNESS | DIRTY_STAY_ON)) != 0) { if (mWakefulness == WAKEFULNESS_AWAKE && isItBedTimeYetLocked()) { if (DEBUG_SPEW) { - Slog.d(TAG, "updateWakefulnessLocked: Nap time..."); + Slog.d(TAG, "updateWakefulnessLocked: Bed time..."); + } + final long time = SystemClock.uptimeMillis(); + if (mDreamsActivateOnSleepSetting) { + changed = napNoUpdateLocked(time); + } else { + changed = goToSleepNoUpdateLocked(time, + PowerManager.GO_TO_SLEEP_REASON_TIMEOUT); } - mWakefulness = WAKEFULNESS_NAPPING; - mDirty |= DIRTY_WAKEFULNESS; - changed = true; } } return changed; @@ -1172,8 +1212,7 @@ public final class PowerManagerService extends IPowerManager.Stub | DIRTY_SETTINGS | DIRTY_IS_POWERED | DIRTY_STAY_ON - | DIRTY_BATTERY_STATE - | DIRTY_DREAM_ENDED)) != 0) { + | DIRTY_BATTERY_STATE)) != 0) { scheduleSandmanLocked(); } } @@ -1210,32 +1249,15 @@ public final class PowerManagerService extends IPowerManager.Stub } } - // Get the dream manager, if needed. - if (startDreaming && mDreamManager == null) { - mDreamManager = IDreamManager.Stub.asInterface( - ServiceManager.checkService("dreams")); - if (mDreamManager == null) { - Slog.w(TAG, "Unable to find IDreamManager."); - } - } - // Start dreaming if needed. // We only control the dream on the handler thread, so we don't need to worry about // concurrent attempts to start or stop the dream. boolean isDreaming = false; if (mDreamManager != null) { - try { - isDreaming = mDreamManager.isDreaming(); - if (startDreaming && !isDreaming) { - Slog.i(TAG, "Entering dreamland."); - mDreamManager.dream(); - isDreaming = mDreamManager.isDreaming(); - if (!isDreaming) { - Slog.i(TAG, "Could not enter dreamland. Sleep will be dreamless."); - } - } - } catch (RemoteException ex) { + if (startDreaming) { + mDreamManager.startDream(); } + isDreaming = mDreamManager.isDreaming(); } // Update dream state. @@ -1255,18 +1277,6 @@ public final class PowerManagerService extends IPowerManager.Stub if (!continueDreaming) { handleDreamFinishedLocked(); } - - // In addition to listening for the intent, poll the sandman periodically to detect - // when the dream has ended (as a watchdog only, ensuring our state is always correct). - if (mWakefulness == WAKEFULNESS_DREAMING - || mWakefulness == WAKEFULNESS_NAPPING) { - if (!mSandmanScheduled) { - mSandmanScheduled = true; - Message msg = mHandler.obtainMessage(MSG_SANDMAN); - msg.setAsynchronous(true); - mHandler.sendMessageDelayed(msg, 5000); - } - } } // Stop dreaming if needed. @@ -1274,26 +1284,22 @@ public final class PowerManagerService extends IPowerManager.Stub // If so, then the power manager will have posted another message to the handler // to take care of it later. if (mDreamManager != null) { - try { - if (!continueDreaming && isDreaming) { - Slog.i(TAG, "Leaving dreamland."); - mDreamManager.awaken(); - } - } catch (RemoteException ex) { + if (!continueDreaming) { + mDreamManager.stopDream(); } } } /** * Returns true if the device is allowed to dream in its current state, - * assuming there has been no recent user activity and no wake locks are held. + * assuming that there was either an explicit request to nap or the user activity + * timeout expired and no wake locks are held. */ private boolean canDreamLocked() { return mIsPowered && mDreamsSupportedConfig && mDreamsEnabledSetting - && mDreamsActivateOnSleepSetting - && !mBatteryService.isBatteryLow(); + && mDisplayPowerRequest.screenState != DisplayPowerRequest.SCREEN_STATE_OFF; } /** @@ -1313,7 +1319,6 @@ public final class PowerManagerService extends IPowerManager.Stub } } - /** * Updates the display power state asynchronously. * When the update is finished, mDisplayReady will be set to true. The display @@ -1494,15 +1499,6 @@ public final class PowerManagerService extends IPowerManager.Stub updatePowerStateLocked(); } - private void handleDockStateChangedLocked(int dockState) { - // TODO - } - - private void handleDreamEndedLocked() { - mDirty |= DIRTY_DREAM_ENDED; - updatePowerStateLocked(); - } - /** * Reboot the device immediately, passing 'reason' (may be null) * to the underlying __reboot system call. Should not return. @@ -1957,22 +1953,11 @@ public final class PowerManagerService extends IPowerManager.Stub } } - private final class DockReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - synchronized (mLock) { - int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, - Intent.EXTRA_DOCK_STATE_UNDOCKED); - handleDockStateChangedLocked(dockState); - } - } - } - private final class DreamReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { synchronized (mLock) { - handleDreamEndedLocked(); + scheduleSandmanLocked(); } } } diff --git a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java index afa0eec..569acee 100644 --- a/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/ThrottleServiceTest.java @@ -242,9 +242,9 @@ public class ThrottleServiceTest extends AndroidTestCase { */ public void setThrottlePolicy(long thresholdBytes, int valueKbitps, int resetDay) { final ContentResolver resolver = getContext().getContentResolver(); - Settings.Secure.putLong(resolver, Settings.Secure.THROTTLE_THRESHOLD_BYTES, thresholdBytes); - Settings.Secure.putInt(resolver, Settings.Secure.THROTTLE_VALUE_KBITSPS, valueKbitps); - Settings.Secure.putInt(resolver, Settings.Secure.THROTTLE_RESET_DAY, resetDay); + Settings.Global.putLong(resolver, Settings.Global.THROTTLE_THRESHOLD_BYTES, thresholdBytes); + Settings.Global.putInt(resolver, Settings.Global.THROTTLE_VALUE_KBITSPS, valueKbitps); + Settings.Global.putInt(resolver, Settings.Global.THROTTLE_RESET_DAY, resetDay); } /** @@ -252,9 +252,9 @@ public class ThrottleServiceTest extends AndroidTestCase { */ public void clearThrottlePolicy() { final ContentResolver resolver = getContext().getContentResolver(); - Settings.Secure.putString(resolver, Settings.Secure.THROTTLE_THRESHOLD_BYTES, null); - Settings.Secure.putString(resolver, Settings.Secure.THROTTLE_VALUE_KBITSPS, null); - Settings.Secure.putString(resolver, Settings.Secure.THROTTLE_RESET_DAY, null); + Settings.Global.putString(resolver, Settings.Global.THROTTLE_THRESHOLD_BYTES, null); + Settings.Global.putString(resolver, Settings.Global.THROTTLE_VALUE_KBITSPS, null); + Settings.Global.putString(resolver, Settings.Global.THROTTLE_RESET_DAY, null); } /** diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml index 9dfe4a1..15d075c 100644 --- a/tests/ActivityTests/AndroidManifest.xml +++ b/tests/ActivityTests/AndroidManifest.xml @@ -21,6 +21,8 @@ <uses-permission android:name="android.permission.REMOVE_TASKS" /> <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" /> + <uses-permission android:name="android.permission.MANAGE_USERS" /> <application android:label="ActivityTest"> <activity android:name="ActivityTestMain"> <intent-filter> @@ -31,6 +33,8 @@ <service android:name="SingleUserService" android:singleUser="true" android:exported="true"> </service> + <service android:name="ServiceUserTarget"> + </service> <receiver android:name="UserTarget"> </receiver> <receiver android:name="SingleUserReceiver" diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java index 2348e99..f0c3b22 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -16,6 +16,7 @@ package com.google.android.test.activity; +import java.util.ArrayList; import java.util.List; import android.app.Activity; @@ -31,6 +32,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.graphics.Bitmap; import android.widget.ImageView; import android.widget.LinearLayout; @@ -41,6 +43,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.content.Context; +import android.content.pm.UserInfo; import android.content.res.Configuration; import android.util.Log; @@ -51,6 +54,9 @@ public class ActivityTestMain extends Activity { ActivityManager mAm; Configuration mOverrideConfig; + int mSecondUser; + + ArrayList<ServiceConnection> mConnections = new ArrayList<ServiceConnection>(); class BroadcastResultReceiver extends BroadcastReceiver { @Override @@ -122,6 +128,15 @@ public class ActivityTestMain extends Activity { applyOverrideConfiguration(mOverrideConfig); } } + + UserManager um = (UserManager)getSystemService(Context.USER_SERVICE); + List<UserInfo> users = um.getUsers(); + mSecondUser = Integer.MAX_VALUE; + for (UserInfo ui : users) { + if (ui.id != 0 && mSecondUser > ui.id) { + mSecondUser = ui.id; + } + } } @Override @@ -148,7 +163,12 @@ public class ActivityTestMain extends Activity { Log.i(TAG, "Service disconnected " + name); } }; - bindService(intent, conn, Context.BIND_AUTO_CREATE); + if (bindService(intent, conn, Context.BIND_AUTO_CREATE)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } return true; } }); @@ -185,15 +205,70 @@ public class ActivityTestMain extends Activity { return true; } }); - menu.add("Send to user 1!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + menu.add("Send to user 0!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, UserTarget.class); + sendOrderedBroadcastAsUser(intent, new UserHandle(0), null, + new BroadcastResultReceiver(), + null, Activity.RESULT_OK, null, null); + return true; + } + }); + menu.add("Send to user " + mSecondUser + "!").setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ActivityTestMain.this, UserTarget.class); - sendOrderedBroadcastAsUser(intent, new UserHandle(1), null, + sendOrderedBroadcastAsUser(intent, new UserHandle(mSecondUser), null, new BroadcastResultReceiver(), null, Activity.RESULT_OK, null, null); return true; } }); + menu.add("Bind to user 0!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, ServiceUserTarget.class); + ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Log.i(TAG, "Service connected " + name + " " + service); + } + @Override + public void onServiceDisconnected(ComponentName name) { + Log.i(TAG, "Service disconnected " + name); + } + }; + if (bindService(intent, conn, Context.BIND_AUTO_CREATE, 0)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } + return true; + } + }); + menu.add("Bind to user " + mSecondUser + "!").setOnMenuItemClickListener( + new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + Intent intent = new Intent(ActivityTestMain.this, ServiceUserTarget.class); + ServiceConnection conn = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Log.i(TAG, "Service connected " + name + " " + service); + } + @Override + public void onServiceDisconnected(ComponentName name) { + Log.i(TAG, "Service disconnected " + name); + } + }; + if (bindService(intent, conn, Context.BIND_AUTO_CREATE, mSecondUser)) { + mConnections.add(conn); + } else { + Toast.makeText(ActivityTestMain.this, "Failed to bind", + Toast.LENGTH_LONG).show(); + } + return true; + } + }); menu.add("Density!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (mOverrideConfig == null) { @@ -226,6 +301,15 @@ public class ActivityTestMain extends Activity { } } + @Override + protected void onStop() { + super.onStop(); + for (ServiceConnection conn : mConnections) { + unbindService(conn); + } + mConnections.clear(); + } + private View scrollWrap(View view) { ScrollView scroller = new ScrollView(this); scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java b/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java new file mode 100644 index 0000000..a7474ec --- /dev/null +++ b/tests/ActivityTests/src/com/google/android/test/activity/ServiceUserTarget.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 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.google.android.test.activity; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import android.os.UserHandle; +import android.widget.Toast; + +public class ServiceUserTarget extends Service { + Binder mBinder = new Binder(); + + @Override + public void onCreate() { + super.onCreate(); + Toast.makeText(this, + "Service created as user " + UserHandle.myUserId(), + Toast.LENGTH_LONG).show(); + } + + @Override + public IBinder onBind(Intent intent) { + return mBinder; + } +} diff --git a/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java b/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java index c40582a..e9c340f 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/SingleUserService.java @@ -20,11 +20,21 @@ import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.IBinder; +import android.os.UserHandle; +import android.widget.Toast; public class SingleUserService extends Service { Binder mBinder = new Binder(); @Override + public void onCreate() { + super.onCreate(); + Toast.makeText(this, + "Service created as user " + UserHandle.myUserId(), + Toast.LENGTH_LONG).show(); + } + + @Override public IBinder onBind(Intent intent) { return mBinder; } diff --git a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml index 4715d6e..f0a2b92 100644 --- a/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml +++ b/tests/RenderScriptTests/ImageProcessing/res/layout/main.xml @@ -54,6 +54,10 @@ android:id="@+id/filterselection" android:layout_width="fill_parent" android:layout_height="wrap_content"/> + <Spinner + android:id="@+id/spinner1" + android:layout_width="fill_parent" + android:layout_height="wrap_content"/> <TextView android:id="@+id/slider1Text" android:layout_width="match_parent" diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java new file mode 100644 index 0000000..2920824 --- /dev/null +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blend.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2012 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.rs.image; + +import java.lang.Math; +import java.lang.Short; + +import android.renderscript.Allocation; +import android.renderscript.Element; +import android.renderscript.Matrix4f; +import android.renderscript.RenderScript; +import android.renderscript.Script; +import android.renderscript.ScriptC; +import android.renderscript.ScriptGroup; +import android.renderscript.ScriptIntrinsicBlend; +import android.renderscript.Type; +import android.util.Log; +import android.widget.SeekBar; +import android.widget.TextView; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.view.View; +import android.widget.Spinner; + +public class Blend extends TestBase { + private ScriptIntrinsicBlend mBlend; + private ScriptC_blend mBlendHelper; + private short image1Alpha = 128; + private short image2Alpha = 128; + + String mIntrinsicNames[]; + + private Allocation image1; + private Allocation image2; + private int currentIntrinsic = 0; + + private AdapterView.OnItemSelectedListener mIntrinsicSpinnerListener = + new AdapterView.OnItemSelectedListener() { + public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { + currentIntrinsic = pos; + runTest(); + act.updateDisplay(); + } + + public void onNothingSelected(AdapterView parent) { + + } + }; + + public void createTest(android.content.res.Resources res) { + mBlend = ScriptIntrinsicBlend.create(mRS, Element.U8_4(mRS)); + mBlendHelper = new ScriptC_blend(mRS); + mBlendHelper.set_alpha((short)128); + + image1 = Allocation.createTyped(mRS, mInPixelsAllocation.getType()); + image2 = Allocation.createTyped(mRS, mInPixelsAllocation2.getType()); + + mIntrinsicNames = new String[14]; + mIntrinsicNames[0] = "Source"; + mIntrinsicNames[1] = "Destination"; + mIntrinsicNames[2] = "Source Over"; + mIntrinsicNames[3] = "Destination Over"; + mIntrinsicNames[4] = "Source In"; + mIntrinsicNames[5] = "Destination In"; + mIntrinsicNames[6] = "Source Out"; + mIntrinsicNames[7] = "Destination Out"; + mIntrinsicNames[8] = "Source Atop"; + mIntrinsicNames[9] = "Destination Atop"; + mIntrinsicNames[10] = "XOR"; + mIntrinsicNames[11] = "Add"; + mIntrinsicNames[12] = "Subtract"; + mIntrinsicNames[13] = "Multiply"; + } + + public boolean onSpinner1Setup(Spinner s) { + s.setAdapter(new ArrayAdapter<String>( + act, R.layout.spinner_layout, mIntrinsicNames)); + s.setOnItemSelectedListener(mIntrinsicSpinnerListener); + return true; + } + + public boolean onBar1Setup(SeekBar b, TextView t) { + t.setText("Image 1 Alpha"); + b.setMax(255); + b.setProgress(image1Alpha); + return true; + } + + public void onBar1Changed(int progress) { + image1Alpha = (short)progress; + } + + public boolean onBar2Setup(SeekBar b, TextView t) { + t.setText("Image 2 Alpha"); + b.setMax(255); + b.setProgress(image2Alpha); + return true; + } + + public void onBar2Changed(int progress) { + image2Alpha = (short)progress; + } + + public void runTest() { + image1.copy2DRangeFrom(0, 0, mInPixelsAllocation.getType().getX(), mInPixelsAllocation.getType().getY(), mInPixelsAllocation, 0, 0); + image2.copy2DRangeFrom(0, 0, mInPixelsAllocation2.getType().getX(), mInPixelsAllocation2.getType().getY(), mInPixelsAllocation2, 0, 0); + + mBlendHelper.set_alpha(image1Alpha); + mBlendHelper.forEach_setImageAlpha(image1); + + mBlendHelper.set_alpha(image2Alpha); + mBlendHelper.forEach_setImageAlpha(image2); + + switch (currentIntrinsic) { + case 0: + mBlend.forEachSrc(image1, image2); + break; + case 1: + mBlend.forEachDst(image1, image2); + break; + case 2: + mBlend.forEachSrcOver(image1, image2); + break; + case 3: + mBlend.forEachDstOver(image1, image2); + break; + case 4: + mBlend.forEachSrcIn(image1, image2); + break; + case 5: + mBlend.forEachDstIn(image1, image2); + break; + case 6: + mBlend.forEachSrcOut(image1, image2); + break; + case 7: + mBlend.forEachDstOut(image1, image2); + break; + case 8: + mBlend.forEachSrcAtop(image1, image2); + break; + case 9: + mBlend.forEachDstAtop(image1, image2); + break; + case 10: + mBlend.forEachXor(image1, image2); + break; + case 11: + mBlend.forEachAdd(image1, image2); + break; + case 12: + mBlend.forEachSubtract(image1, image2); + break; + case 13: + mBlend.forEachMultiply(image1, image2); + break; + } + + mOutPixelsAllocation.copy2DRangeFrom(0, 0, image2.getType().getX(), image2.getType().getY(), image2, 0, 0); + } + +} diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java index a8462e6..db0ef78 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java @@ -55,9 +55,11 @@ public class ImageProcessingActivity extends Activity private final String RESULT_FILE = "image_processing_result.csv"; Bitmap mBitmapIn; + Bitmap mBitmapIn2; Bitmap mBitmapOut; String mTestNames[]; + private Spinner mSpinner; private SeekBar mBar1; private SeekBar mBar2; private SeekBar mBar3; @@ -81,6 +83,10 @@ public class ImageProcessingActivity extends Activity private TestBase mTest; + public void updateDisplay() { + mTest.updateBitmap(mBitmapOut); + mDisplayView.invalidate(); + } public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { @@ -98,8 +104,7 @@ public class ImageProcessingActivity extends Activity } mTest.runTest(); - mTest.updateBitmap(mBitmapOut); - mDisplayView.invalidate(); + updateDisplay(); } } @@ -110,6 +115,9 @@ public class ImageProcessingActivity extends Activity } void setupBars() { + mSpinner.setVisibility(View.VISIBLE); + mTest.onSpinner1Setup(mSpinner); + mBar1.setVisibility(View.VISIBLE); mText1.setVisibility(View.VISIBLE); mTest.onBar1Setup(mBar1, mText1); @@ -221,19 +229,21 @@ public class ImageProcessingActivity extends Activity case 27: mTest = new Mandelbrot(); break; + case 28: + mTest = new Blend(); + break; } - mTest.createBaseTest(this, mBitmapIn); + mTest.createBaseTest(this, mBitmapIn, mBitmapIn2); setupBars(); mTest.runTest(); - mTest.updateBitmap(mBitmapOut); - mDisplayView.invalidate(); + updateDisplay(); mBenchmarkResult.setText("Result: not run"); } void setupTests() { - mTestNames = new String[28]; + mTestNames = new String[29]; mTestNames[0] = "Levels Vec3 Relaxed"; mTestNames[1] = "Levels Vec4 Relaxed"; mTestNames[2] = "Levels Vec3 Full"; @@ -262,6 +272,7 @@ public class ImageProcessingActivity extends Activity mTestNames[25] = "Convolve 5x5"; mTestNames[26] = "Intrinsics Convolve 5x5"; mTestNames[27] = "Mandelbrot"; + mTestNames[28] = "Intrinsics Blend"; mTestSpinner.setAdapter(new ArrayAdapter<String>( this, R.layout.spinner_layout, mTestNames)); @@ -284,6 +295,7 @@ public class ImageProcessingActivity extends Activity setContentView(R.layout.main); mBitmapIn = loadBitmap(R.drawable.img1600x1067); + mBitmapIn2 = loadBitmap(R.drawable.img1600x1067b); mBitmapOut = loadBitmap(R.drawable.img1600x1067); mSurfaceView = (SurfaceView) findViewById(R.id.surface); @@ -291,6 +303,8 @@ public class ImageProcessingActivity extends Activity mDisplayView = (ImageView) findViewById(R.id.display); mDisplayView.setImageBitmap(mBitmapOut); + mSpinner = (Spinner) findViewById(R.id.spinner1); + mBar1 = (SeekBar) findViewById(R.id.slider1); mBar2 = (SeekBar) findViewById(R.id.slider2); mBar3 = (SeekBar) findViewById(R.id.slider3); diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java index 6885181..8009daa 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/TestBase.java @@ -36,14 +36,18 @@ import android.widget.TextView; import android.view.View; import android.util.Log; import java.lang.Math; +import android.widget.Spinner; public class TestBase { protected final String TAG = "Img"; protected RenderScript mRS; protected Allocation mInPixelsAllocation; + protected Allocation mInPixelsAllocation2; protected Allocation mOutPixelsAllocation; + protected ImageProcessingActivity act; + // Override to use UI elements public void onBar1Changed(int progress) { } @@ -84,11 +88,20 @@ public class TestBase { return false; } - public final void createBaseTest(ImageProcessingActivity act, Bitmap b) { + public boolean onSpinner1Setup(Spinner s) { + s.setVisibility(View.INVISIBLE); + return false; + } + + public final void createBaseTest(ImageProcessingActivity ipact, Bitmap b, Bitmap b2) { + act = ipact; mRS = RenderScript.create(act); mInPixelsAllocation = Allocation.createFromBitmap(mRS, b, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); + mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, b2, + Allocation.MipmapControl.MIPMAP_NONE, + Allocation.USAGE_SCRIPT); mOutPixelsAllocation = Allocation.createFromBitmap(mRS, b, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT); diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs new file mode 100644 index 0000000..87b56f7 --- /dev/null +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/blend.rs @@ -0,0 +1,24 @@ +// Copyright (C) 2011 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. + +#pragma version(1) +#pragma rs java_package_name(com.android.rs.image) + +uchar alpha = 0x0; + +void setImageAlpha(uchar4 *v_out, uint32_t x, uint32_t y) { + v_out->rgba = convert_uchar4((convert_uint4(v_out->rgba) * alpha) >> (uint4)8); + v_out->a = alpha; +} + diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java index 83fadcb..7662007 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java @@ -72,6 +72,7 @@ public class RSTestCore { unitTests.add(new UT_array_alloc(this, mRes, mCtx)); unitTests.add(new UT_kernel(this, mRes, mCtx)); unitTests.add(new UT_kernel_struct(this, mRes, mCtx)); + unitTests.add(new UT_bug_char(this, mRes, mCtx)); unitTests.add(new UT_clamp(this, mRes, mCtx)); unitTests.add(new UT_clamp_relaxed(this, mRes, mCtx)); unitTests.add(new UT_convert(this, mRes, mCtx)); diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java new file mode 100644 index 0000000..faf3a31 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_bug_char.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2012 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.rs.test; + +import android.content.Context; +import android.content.res.Resources; +import android.renderscript.*; +import android.util.Log; +import java.util.Arrays; + +public class UT_bug_char extends UnitTest { + private Resources mRes; + + protected UT_bug_char(RSTestCore rstc, Resources res, Context ctx) { + super(rstc, "Bug Char", ctx); + mRes = res; + } + + // packing functions + private Byte2 pack_b2(byte[] val) { + assert val.length == 2; + Log.i("bug_char", "pack_b2 " + val[0] + " " + val[1]); + return new Byte2(val[0], val[1]); + } + + private byte min(byte v1, byte v2) { + return v1 < v2 ? v1 : v2; + } + private byte[] min(byte[] v1, byte[] v2) { + assert v1.length == v2.length; + byte[] rv = new byte[v1.length]; + for (int i = 0; i < v1.length; ++i) + rv[i] = min(v1[i], v2[i]); + return rv; + } + + private void initializeValues(ScriptC_bug_char s) { + byte rand_sc1_0 = (byte)7; + byte[] rand_sc2_0 = new byte[2]; + rand_sc2_0[0] = 11; + rand_sc2_0[1] = 21; + Log.i("bug_char", "Generated sc2_0 to " + Arrays.toString(rand_sc2_0)); + byte rand_sc1_1 = (byte)10; + byte[] rand_sc2_1 = new byte[2]; + rand_sc2_1[0] = 13; + rand_sc2_1[1] = 15; + Log.i("bug_char", "Generated sc2_1 to " + Arrays.toString(rand_sc2_1)); + + s.set_rand_sc1_0(rand_sc1_0); + s.set_rand_sc2_0(pack_b2(rand_sc2_0)); + s.set_rand_sc1_1(rand_sc1_1); + s.set_rand_sc2_1(pack_b2(rand_sc2_1)); + // Set results for min + s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1)); + byte[] min_rand_sc2_raw = min(rand_sc2_0, rand_sc2_1); + Log.i("bug_char", "Generating min_rand_sc2_sc2 to " + + Arrays.toString(min_rand_sc2_raw)); + Byte2 min_rand_sc2 = pack_b2(min_rand_sc2_raw); + Log.i("bug_char", "Setting min_rand_sc2_sc2 to [" + min_rand_sc2.x + + ", " + min_rand_sc2.y + "]"); + s.set_min_rand_sc2_sc2(min_rand_sc2); + } + + public void run() { + RenderScript pRS = RenderScript.create(mCtx); + ScriptC_bug_char s = new ScriptC_bug_char(pRS, mRes, + R.raw.bug_char); + pRS.setMessageHandler(mRsMessage); + initializeValues(s); + s.invoke_bug_char_test(); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + } +} diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java index 40f7213..220509c 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_math_agree.java @@ -347,8 +347,6 @@ public class UT_math_agree extends UnitTest { long[] rand_sl2_1 = randvec_long(2); long[] rand_sl3_1 = randvec_long(3); long[] rand_sl4_1 = randvec_long(4); - // FIXME: generate signed char vectors once bug 6865598 is fixed - /* byte rand_sc1_0 = (byte)rand.nextInt(0x1 << 8); byte[] rand_sc2_0 = randvec_char(2); byte[] rand_sc3_0 = randvec_char(3); @@ -357,7 +355,6 @@ public class UT_math_agree extends UnitTest { byte[] rand_sc2_1 = randvec_char(2); byte[] rand_sc3_1 = randvec_char(3); byte[] rand_sc4_1 = randvec_char(4); - */ // TODO: generate unsigned long vectors // Set random vectors in renderscript code @@ -417,8 +414,6 @@ public class UT_math_agree extends UnitTest { s.set_rand_uc2_0(pack_s2(rand_uc2_0)); s.set_rand_uc3_0(pack_s3(rand_uc3_0)); s.set_rand_uc4_0(pack_s4(rand_uc4_0)); - // FIXME: set char input vectors once bug 6865598 is fixed - /* s.set_rand_sc1_0(rand_sc1_0); s.set_rand_sc2_0(pack_b2(rand_sc2_0)); s.set_rand_sc3_0(pack_b3(rand_sc3_0)); @@ -427,7 +422,6 @@ public class UT_math_agree extends UnitTest { s.set_rand_sc2_1(pack_b2(rand_sc2_1)); s.set_rand_sc3_1(pack_b3(rand_sc3_1)); s.set_rand_sc4_1(pack_b4(rand_sc4_1)); - */ // TODO: set unsigned long vectors // Set results for min @@ -459,13 +453,10 @@ public class UT_math_agree extends UnitTest { s.set_min_rand_sl2_sl2(pack_l2(min(rand_sl2_0, rand_sl2_1))); s.set_min_rand_sl3_sl3(pack_l3(min(rand_sl3_0, rand_sl3_1))); s.set_min_rand_sl4_sl4(pack_l4(min(rand_sl4_0, rand_sl4_1))); - // FIXME: set char min reference vectors once bug 6865598 is fixed - /* s.set_min_rand_sc1_sc1(min(rand_sc1_0, rand_sc1_1)); s.set_min_rand_sc2_sc2(pack_b2(min(rand_sc2_0, rand_sc2_1))); s.set_min_rand_sc3_sc3(pack_b3(min(rand_sc3_0, rand_sc3_1))); s.set_min_rand_sc4_sc4(pack_b4(min(rand_sc4_0, rand_sc4_1))); - */ // TODO: set results for unsigned long min // Set results for max @@ -497,13 +488,10 @@ public class UT_math_agree extends UnitTest { s.set_max_rand_sl2_sl2(pack_l2(max(rand_sl2_0, rand_sl2_1))); s.set_max_rand_sl3_sl3(pack_l3(max(rand_sl3_0, rand_sl3_1))); s.set_max_rand_sl4_sl4(pack_l4(max(rand_sl4_0, rand_sl4_1))); - // FIXME: set signed char max reference vectors once bug 6865598 is fixed - /* s.set_max_rand_sc1_sc1(max(rand_sc1_0, rand_sc1_1)); s.set_max_rand_sc2_sc2(pack_b2(max(rand_sc2_0, rand_sc2_1))); s.set_max_rand_sc3_sc3(pack_b3(max(rand_sc3_0, rand_sc3_1))); s.set_max_rand_sc4_sc4(pack_b4(max(rand_sc4_0, rand_sc4_1))); - */ // TODO: set results for unsigned long max diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs new file mode 100644 index 0000000..dcd7b72 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/bug_char.rs @@ -0,0 +1,47 @@ +#include "shared.rsh" + +char rand_sc1_0, rand_sc1_1; +char2 rand_sc2_0, rand_sc2_1; + +char min_rand_sc1_sc1; +char2 min_rand_sc2_sc2; + +static bool test_bug_char() { + bool failed = false; + + rsDebug("rand_sc2_0.x: ", rand_sc2_0.x); + rsDebug("rand_sc2_0.y: ", rand_sc2_0.y); + rsDebug("rand_sc2_1.x: ", rand_sc2_1.x); + rsDebug("rand_sc2_1.y: ", rand_sc2_1.y); + char temp_sc1; + char2 temp_sc2; + + temp_sc1 = min( rand_sc1_0, rand_sc1_1 ); + if (temp_sc1 != min_rand_sc1_sc1) { + rsDebug("temp_sc1", temp_sc1); + failed = true; + } + rsDebug("broken", 'y'); + + temp_sc2 = min( rand_sc2_0, rand_sc2_1 ); + if (temp_sc2.x != min_rand_sc2_sc2.x + || temp_sc2.y != min_rand_sc2_sc2.y) { + failed = true; + } + + + return failed; +} + +void bug_char_test() { + bool failed = false; + failed |= test_bug_char(); + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + } +} + diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs index 1adb036..5bfbb2b 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/math_agree.rs @@ -338,16 +338,13 @@ TEST_UL4_UL4(func) #define TEST_VEC_VEC_ALL(func) \ TEST_FN_FN_ALL(func) \ +TEST_SC_SC_ALL(func) \ TEST_UC_UC_ALL(func) \ TEST_SS_SS_ALL(func) \ TEST_US_US_ALL(func) \ TEST_SI_SI_ALL(func) \ TEST_UI_UI_ALL(func) -// FIXME: Add char tests back in once bug 6865598 is fixed -#if 0 -TEST_SC_SC_ALL(func) -#endif // TODO: add long types to ALL macro #if 0 TEST_SL_SL_ALL(func) \ diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java index 0c85204..0cf0f21 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java @@ -60,6 +60,11 @@ public class BridgePowerManager implements IPowerManager { } @Override + public void nap(long arg0) throws RemoteException { + // pass for now. + } + + @Override public void preventScreenOn(boolean arg0) throws RemoteException { // pass for now. } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index e7927ae..ab9db88 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -608,8 +608,8 @@ public class WifiStateMachine extends StateMachine { mPrimaryDeviceType = mContext.getResources().getString( R.string.config_wifi_p2p_device_type); - mUserWantsSuspendOpt.set(Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); + mUserWantsSuspendOpt.set(Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); mContext.registerReceiver( new BroadcastReceiver() { @@ -659,13 +659,13 @@ public class WifiStateMachine extends StateMachine { }, new IntentFilter(ACTION_DELAYED_DRIVER_STOP)); - mContext.getContentResolver().registerContentObserver(Settings.Secure.getUriFor( - Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED), false, + mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor( + Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED), false, new ContentObserver(getHandler()) { @Override public void onChange(boolean selfChange) { - mUserWantsSuspendOpt.set(Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); + mUserWantsSuspendOpt.set(Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); } }); @@ -1074,8 +1074,8 @@ public class WifiStateMachine extends StateMachine { */ public void setFrequencyBand(int band, boolean persist) { if (persist) { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.WIFI_FREQUENCY_BAND, + Settings.Global.putInt(mContext.getContentResolver(), + Settings.Global.WIFI_FREQUENCY_BAND, band); } sendMessage(obtainMessage(CMD_SET_FREQUENCY_BAND, band, 0)); @@ -1331,8 +1331,8 @@ public class WifiStateMachine extends StateMachine { * Set the frequency band from the system setting value, if any. */ private void setFrequencyBand() { - int band = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.WIFI_FREQUENCY_BAND, WifiManager.WIFI_FREQUENCY_BAND_AUTO); + int band = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.WIFI_FREQUENCY_BAND, WifiManager.WIFI_FREQUENCY_BAND_AUTO); setFrequencyBand(band, false); } diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java index 7fa6aac..4440145 100644 --- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java +++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java @@ -343,13 +343,13 @@ public class WifiWatchdogStateMachine extends StateMachine { // Watchdog is always enabled. Poor network detection can be seperately turned on/off // TODO: Remove this setting & clean up state machine since we always have // watchdog in an enabled state - putSettingsBoolean(contentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true); + putSettingsGlobalBoolean(contentResolver, Settings.Global.WIFI_WATCHDOG_ON, true); // disable poor network avoidance if (sWifiOnly) { logd("Disabling poor network avoidance for wi-fi only device"); - putSettingsBoolean(contentResolver, - Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, false); + putSettingsGlobalBoolean(contentResolver, + Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, false); } WifiWatchdogStateMachine wwsm = new WifiWatchdogStateMachine(context); @@ -402,7 +402,7 @@ public class WifiWatchdogStateMachine extends StateMachine { }; mContext.getContentResolver().registerContentObserver( - Settings.Secure.getUriFor(Settings.Secure.WIFI_WATCHDOG_ON), + Settings.Global.getUriFor(Settings.Global.WIFI_WATCHDOG_ON), false, contentObserver); } @@ -418,7 +418,7 @@ public class WifiWatchdogStateMachine extends StateMachine { }; mContext.getContentResolver().registerContentObserver( - Settings.Secure.getUriFor(Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED), + Settings.Global.getUriFor(Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED), false, contentObserver); } @@ -432,7 +432,8 @@ public class WifiWatchdogStateMachine extends StateMachine { } private boolean isWatchdogEnabled() { - boolean ret = getSettingsBoolean(mContentResolver, Settings.Secure.WIFI_WATCHDOG_ON, true); + boolean ret = getSettingsGlobalBoolean( + mContentResolver, Settings.Global.WIFI_WATCHDOG_ON, true); if (DBG) logd("Watchdog enabled " + ret); return ret; } @@ -440,8 +441,8 @@ public class WifiWatchdogStateMachine extends StateMachine { private void updateSettings() { if (DBG) logd("Updating secure settings"); - mPoorNetworkDetectionEnabled = getSettingsBoolean(mContentResolver, - Settings.Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, true); + mPoorNetworkDetectionEnabled = getSettingsGlobalBoolean(mContentResolver, + Settings.Global.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, true); } /** @@ -927,21 +928,6 @@ public class WifiWatchdogStateMachine extends StateMachine { } /** - * Convenience function for retrieving a single secure settings value - * as a string with a default value. - * - * @param cr The ContentResolver to access. - * @param name The name of the setting to retrieve. - * @param def Value to return if the setting is not defined. - * - * @return The setting's current value, or 'def' if it is not defined - */ - private static String getSettingsStr(ContentResolver cr, String name, String def) { - String v = Settings.Secure.getString(cr, name); - return v != null ? v : def; - } - - /** * Convenience function for retrieving a single secure settings value as a * boolean. Note that internally setting values are always stored as * strings; this function converts the string to a boolean for you. The @@ -954,8 +940,8 @@ public class WifiWatchdogStateMachine extends StateMachine { * @return The setting's current value, or 'def' if it is not defined or not * a valid boolean. */ - private static boolean getSettingsBoolean(ContentResolver cr, String name, boolean def) { - return Settings.Secure.getInt(cr, name, def ? 1 : 0) == 1; + private static boolean getSettingsGlobalBoolean(ContentResolver cr, String name, boolean def) { + return Settings.Global.getInt(cr, name, def ? 1 : 0) == 1; } /** @@ -970,8 +956,8 @@ public class WifiWatchdogStateMachine extends StateMachine { * @param value The new value for the setting. * @return true if the value was set, false on database errors */ - private static boolean putSettingsBoolean(ContentResolver cr, String name, boolean value) { - return Settings.Secure.putInt(cr, name, value ? 1 : 0); + private static boolean putSettingsGlobalBoolean(ContentResolver cr, String name, boolean value) { + return Settings.Global.putInt(cr, name, value ? 1 : 0); } private static void logd(String s) { diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java index 8f0d8f0..8670650 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java @@ -2039,8 +2039,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { } private String getPersistedDeviceName() { - String deviceName = Settings.Secure.getString(mContext.getContentResolver(), - Settings.Secure.WIFI_P2P_DEVICE_NAME); + String deviceName = Settings.Global.getString(mContext.getContentResolver(), + Settings.Global.WIFI_P2P_DEVICE_NAME); if (deviceName == null) { /* We use the 4 digits of the ANDROID_ID to have a friendly * default that has low likelihood of collision with a peer */ @@ -2062,8 +2062,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub { mThisDevice.deviceName = devName; mWifiNative.setP2pSsidPostfix("-" + mThisDevice.deviceName); - Settings.Secure.putString(mContext.getContentResolver(), - Settings.Secure.WIFI_P2P_DEVICE_NAME, devName); + Settings.Global.putString(mContext.getContentResolver(), + Settings.Global.WIFI_P2P_DEVICE_NAME, devName); sendThisDeviceChangedBroadcast(); return true; } |
