diff options
Diffstat (limited to 'core/java')
32 files changed, 511 insertions, 398 deletions
diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index b74c824..014a7af 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -1061,6 +1061,10 @@ public abstract class ActionBar { return false; } + /** @hide */ + public void setWindowTitle(CharSequence title) { + } + /** * Listener interface for ActionBar navigation events. * diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 9b7cc1c..c80eeb9 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -4145,10 +4145,9 @@ public class Activity extends ContextThemeWrapper intent.prepareToLeaveProcess(); result = ActivityManagerNative.getDefault() .startActivity(mMainThread.getApplicationThread(), getBasePackageName(), - intent, intent.resolveTypeIfNeeded(getContentResolver()), - mToken, mEmbeddedID, requestCode, - ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null, - options); + intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken, + mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED, + null, options); } catch (RemoteException e) { // Empty } @@ -5039,9 +5038,9 @@ public class Activity extends ContextThemeWrapper win.setTitleColor(color); } } - } - if (mActionBar != null) { - mActionBar.setTitle(title); + if (mActionBar != null) { + mActionBar.setWindowTitle(title); + } } } diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 586e7d4..ffb9c95 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -67,6 +67,8 @@ public class ActivityManager { private static String TAG = "ActivityManager"; private static boolean localLOGV = false; + private static int gMaxRecentTasks = -1; + private final Context mContext; private final Handler mHandler; @@ -193,13 +195,6 @@ public class ActivityManager { public static final int START_FLAG_OPENGL_TRACES = 1<<2; /** - * Flag for IActivityManaqer.startActivity: if the app is being - * launched for profiling, automatically stop the profiler once done. - * @hide - */ - public static final int START_FLAG_AUTO_STOP_PROFILER = 1<<3; - - /** * Result for IActivityManaqer.broadcastIntent: success! * @hide */ @@ -449,7 +444,7 @@ public class ActivityManager { // Really brain dead right now -- just take this from the configured // vm heap size, and assume it is in megabytes and thus ends with "m". String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); - return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); + return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length() - 1)); } /** @@ -480,6 +475,33 @@ public class ActivityManager { } /** + * Return the maximum number of recents entries that we will maintain and show. + * @hide + */ + static public int getMaxRecentTasksStatic() { + if (gMaxRecentTasks < 0) { + return gMaxRecentTasks = isLowRamDeviceStatic() ? 50 : 100; + } + return gMaxRecentTasks; + } + + /** + * Return the default limit on the number of recents that an app can make. + * @hide + */ + static public int getDefaultAppRecentsLimitStatic() { + return getMaxRecentTasksStatic() / 6; + } + + /** + * Return the maximum limit on the number of recents that an app can make. + * @hide + */ + static public int getMaxAppRecentsLimitStatic() { + return getMaxRecentTasksStatic() / 2; + } + + /** * Information you can set and retrieve about the current activity within the recent task list. */ public static class TaskDescription implements Parcelable { @@ -1191,13 +1213,13 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { if (mainThumbnail != null) { dest.writeInt(1); - mainThumbnail.writeToParcel(dest, 0); + mainThumbnail.writeToParcel(dest, flags); } else { dest.writeInt(0); } if (thumbnailFileDescriptor != null) { dest.writeInt(1); - thumbnailFileDescriptor.writeToParcel(dest, 0); + thumbnailFileDescriptor.writeToParcel(dest, flags); } else { dest.writeInt(0); } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 36e8892..1f7e450 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -17,6 +17,7 @@ package android.app; import android.app.ActivityManager.StackInfo; +import android.app.ProfilerInfo; import android.content.ComponentName; import android.content.IIntentReceiver; import android.content.IIntentSender; @@ -132,14 +133,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM String resultWho = data.readString(); int requestCode = data.readInt(); int startFlags = data.readInt(); - String profileFile = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int result = startActivity(app, callingPackage, intent, resolvedType, - resultTo, resultWho, requestCode, startFlags, - profileFile, profileFd, options); + resultTo, resultWho, requestCode, startFlags, profilerInfo, options); reply.writeNoException(); reply.writeInt(result); return true; @@ -157,15 +156,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM String resultWho = data.readString(); int requestCode = data.readInt(); int startFlags = data.readInt(); - String profileFile = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); int result = startActivityAsUser(app, callingPackage, intent, resolvedType, - resultTo, resultWho, requestCode, startFlags, - profileFile, profileFd, options, userId); + resultTo, resultWho, requestCode, startFlags, profilerInfo, options, userId); reply.writeNoException(); reply.writeInt(result); return true; @@ -183,14 +180,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM String resultWho = data.readString(); int requestCode = data.readInt(); int startFlags = data.readInt(); - String profileFile = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? data.readFileDescriptor() : null; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int result = startActivityAsCaller(app, callingPackage, intent, resolvedType, - resultTo, resultWho, requestCode, startFlags, - profileFile, profileFd, options); + resultTo, resultWho, requestCode, startFlags, profilerInfo, options); reply.writeNoException(); reply.writeInt(result); return true; @@ -208,15 +203,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM String resultWho = data.readString(); int requestCode = data.readInt(); int startFlags = data.readInt(); - String profileFile = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); WaitResult result = startActivityAndWait(app, callingPackage, intent, resolvedType, - resultTo, resultWho, requestCode, startFlags, - profileFile, profileFd, options, userId); + resultTo, resultWho, requestCode, startFlags, profilerInfo, options, userId); reply.writeNoException(); result.writeToParcel(reply, 0); return true; @@ -284,15 +277,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM IVoiceInteractor interactor = IVoiceInteractor.Stub.asInterface( data.readStrongBinder()); int startFlags = data.readInt(); - String profileFile = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); - int result = startVoiceActivity(callingPackage, callingPid, callingUid, - intent, resolvedType, session, interactor, startFlags, - profileFile, profileFd, options, userId); + int result = startVoiceActivity(callingPackage, callingPid, callingUid, intent, + resolvedType, session, interactor, startFlags, profilerInfo, options, userId); reply.writeNoException(); reply.writeInt(result); return true; @@ -1401,8 +1392,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder app = data.readStrongBinder(); String tag = data.readString(); + boolean system = data.readInt() != 0; ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data); - boolean res = handleApplicationWtf(app, tag, ci); + boolean res = handleApplicationWtf(app, tag, system, ci); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; @@ -1468,22 +1460,21 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM config.writeToParcel(reply, 0); return true; } - + case PROFILE_CONTROL_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String process = data.readString(); int userId = data.readInt(); boolean start = data.readInt() != 0; int profileType = data.readInt(); - String path = data.readString(); - ParcelFileDescriptor fd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; - boolean res = profileControl(process, userId, start, path, fd, profileType); + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; + boolean res = profileControl(process, userId, start, profilerInfo, profileType); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; } - + case SHUTDOWN_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); boolean res = shutdown(data.readInt()); @@ -2343,8 +2334,7 @@ class ActivityManagerProxy implements IActivityManager public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, - int startFlags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options) throws RemoteException { + int startFlags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -2356,10 +2346,9 @@ class ActivityManagerProxy implements IActivityManager data.writeString(resultWho); data.writeInt(requestCode); data.writeInt(startFlags); - data.writeString(profileFile); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -2379,8 +2368,8 @@ class ActivityManagerProxy implements IActivityManager public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, - int startFlags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { + int startFlags, ProfilerInfo profilerInfo, Bundle options, + int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -2392,10 +2381,9 @@ class ActivityManagerProxy implements IActivityManager data.writeString(resultWho); data.writeInt(requestCode); data.writeInt(startFlags); - data.writeString(profileFile); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -2415,8 +2403,7 @@ class ActivityManagerProxy implements IActivityManager } public int startActivityAsCaller(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, - int startFlags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options) throws RemoteException { + int startFlags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -2428,10 +2415,9 @@ class ActivityManagerProxy implements IActivityManager data.writeString(resultWho); data.writeInt(requestCode); data.writeInt(startFlags); - data.writeString(profileFile); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -2450,8 +2436,8 @@ class ActivityManagerProxy implements IActivityManager } public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, - int requestCode, int startFlags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { + int requestCode, int startFlags, ProfilerInfo profilerInfo, Bundle options, + int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -2463,10 +2449,9 @@ class ActivityManagerProxy implements IActivityManager data.writeString(resultWho); data.writeInt(requestCode); data.writeInt(startFlags); - data.writeString(profileFile); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -2550,8 +2535,8 @@ class ActivityManagerProxy implements IActivityManager } public int startVoiceActivity(String callingPackage, int callingPid, int callingUid, Intent intent, String resolvedType, IVoiceInteractionSession session, - IVoiceInteractor interactor, int startFlags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { + IVoiceInteractor interactor, int startFlags, ProfilerInfo profilerInfo, + Bundle options, int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -2563,10 +2548,9 @@ class ActivityManagerProxy implements IActivityManager data.writeStrongBinder(session.asBinder()); data.writeStrongBinder(interactor.asBinder()); data.writeInt(startFlags); - data.writeString(profileFile); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -4086,7 +4070,7 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); } - public boolean handleApplicationWtf(IBinder app, String tag, + public boolean handleApplicationWtf(IBinder app, String tag, boolean system, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException { Parcel data = Parcel.obtain(); @@ -4094,6 +4078,7 @@ class ActivityManagerProxy implements IActivityManager data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(app); data.writeString(tag); + data.writeInt(system ? 1 : 0); crashInfo.writeToParcel(data, 0); mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0); reply.readException(); @@ -4189,9 +4174,9 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); return res; } - + public boolean profileControl(String process, int userId, boolean start, - String path, ParcelFileDescriptor fd, int profileType) throws RemoteException + ProfilerInfo profilerInfo, int profileType) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); @@ -4200,10 +4185,9 @@ class ActivityManagerProxy implements IActivityManager data.writeInt(userId); data.writeInt(start ? 1 : 0); data.writeInt(profileType); - data.writeString(path); - if (fd != null) { + if (profilerInfo != null) { data.writeInt(1); - fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -4214,7 +4198,7 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); return res; } - + public boolean shutdown(int timeout) throws RemoteException { Parcel data = Parcel.obtain(); diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 0356093..d70e5df 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -124,6 +124,7 @@ import libcore.io.EventLogger; import libcore.io.IoUtils; import dalvik.system.CloseGuard; +import dalvik.system.VMDebug; import dalvik.system.VMRuntime; final class RemoteServiceException extends AndroidRuntimeException { @@ -282,9 +283,7 @@ public final class ActivityThread { Configuration createdConfig; ActivityClientRecord nextIdle; - String profileFile; - ParcelFileDescriptor profileFd; - boolean autoStopProfiler; + ProfilerInfo profilerInfo; ActivityInfo activityInfo; CompatibilityInfo compatInfo; @@ -436,9 +435,7 @@ public final class ActivityThread { CompatibilityInfo compatInfo; /** Initial values for {@link Profiler}. */ - String initProfileFile; - ParcelFileDescriptor initProfileFd; - boolean initAutoStopProfiler; + ProfilerInfo initProfilerInfo; public String toString() { return "AppBindData{appInfo=" + appInfo + "}"; @@ -448,10 +445,12 @@ public final class ActivityThread { static final class Profiler { String profileFile; ParcelFileDescriptor profileFd; + int samplingInterval; boolean autoStopProfiler; boolean profiling; boolean handlingProfiling; - public void setProfiler(String file, ParcelFileDescriptor fd) { + public void setProfiler(ProfilerInfo profilerInfo) { + ParcelFileDescriptor fd = profilerInfo.profileFd; if (profiling) { if (fd != null) { try { @@ -469,16 +468,18 @@ public final class ActivityThread { // Ignore } } - profileFile = file; + profileFile = profilerInfo.profileFile; profileFd = fd; + samplingInterval = profilerInfo.samplingInterval; + autoStopProfiler = profilerInfo.autoStopProfiler; } public void startProfiling() { if (profileFd == null || profiling) { return; } try { - Debug.startMethodTracing(profileFile, profileFd.getFileDescriptor(), - 8 * 1024 * 1024, 0); + VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(), + 8 * 1024 * 1024, 0, samplingInterval != 0, samplingInterval); profiling = true; } catch (RuntimeException e) { Slog.w(TAG, "Profiling failed on path " + profileFile); @@ -527,11 +528,6 @@ public final class ActivityThread { String who; } - static final class ProfilerControlData { - String path; - ParcelFileDescriptor fd; - } - static final class DumpHeapData { String path; ParcelFileDescriptor fd; @@ -612,7 +608,7 @@ public final class ActivityThread { IVoiceInteractor voiceInteractor, int procState, Bundle state, PersistableBundle persistentState, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward, - String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) { + ProfilerInfo profilerInfo) { updateProcessState(procState, false); @@ -633,9 +629,7 @@ public final class ActivityThread { r.startsNotResumed = notResumed; r.isForward = isForward; - r.profileFile = profileName; - r.profileFd = profileFd; - r.autoStopProfiler = autoStopProfiler; + r.profilerInfo = profilerInfo; updatePendingConfiguration(curConfig); @@ -742,11 +736,10 @@ public final class ActivityThread { sendMessage(H.STOP_SERVICE, token); } - public final void bindApplication(String processName, - ApplicationInfo appInfo, List<ProviderInfo> providers, - ComponentName instrumentationName, String profileFile, - ParcelFileDescriptor profileFd, boolean autoStopProfiler, - Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher, + public final void bindApplication(String processName, ApplicationInfo appInfo, + List<ProviderInfo> providers, ComponentName instrumentationName, + ProfilerInfo profilerInfo, Bundle instrumentationArgs, + IInstrumentationWatcher instrumentationWatcher, IUiAutomationConnection instrumentationUiConnection, int debugMode, boolean enableOpenGlTrace, boolean isRestrictedBackupMode, boolean persistent, Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, @@ -810,9 +803,7 @@ public final class ActivityThread { data.persistent = persistent; data.config = config; data.compatInfo = compatInfo; - data.initProfileFile = profileFile; - data.initProfileFd = profileFd; - data.initAutoStopProfiler = false; + data.initProfilerInfo = profilerInfo; sendMessage(H.BIND_APPLICATION, data); } @@ -878,12 +869,8 @@ public final class ActivityThread { sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED, token); } - public void profilerControl(boolean start, String path, ParcelFileDescriptor fd, - int profileType) { - ProfilerControlData pcd = new ProfilerControlData(); - pcd.path = path; - pcd.fd = fd; - sendMessage(H.PROFILER_CONTROL, pcd, start ? 1 : 0, profileType); + public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) { + sendMessage(H.PROFILER_CONTROL, profilerInfo, start ? 1 : 0, profileType); } public void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd) { @@ -1417,7 +1404,7 @@ public final class ActivityThread { Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); break; case PROFILER_CONTROL: - handleProfilerControl(msg.arg1 != 0, (ProfilerControlData)msg.obj, msg.arg2); + handleProfilerControl(msg.arg1 != 0, (ProfilerInfo)msg.obj, msg.arg2); break; case CREATE_BACKUP_AGENT: Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backupCreateAgent"); @@ -2354,10 +2341,9 @@ public final class ActivityThread { unscheduleGcIdler(); mSomeActivitiesChanged = true; - if (r.profileFd != null) { - mProfiler.setProfiler(r.profileFile, r.profileFd); + if (r.profilerInfo != null) { + mProfiler.setProfiler(r.profilerInfo); mProfiler.startProfiling(); - mProfiler.autoStopProfiler = r.autoStopProfiler; } // Make sure we are running with the most recent config. @@ -4118,22 +4104,21 @@ public final class ActivityThread { mSomeActivitiesChanged = true; } - final void handleProfilerControl(boolean start, ProfilerControlData pcd, int profileType) { + final void handleProfilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) { if (start) { try { switch (profileType) { - default: - mProfiler.setProfiler(pcd.path, pcd.fd); - mProfiler.autoStopProfiler = false; + default: + mProfiler.setProfiler(profilerInfo); mProfiler.startProfiling(); break; } } catch (RuntimeException e) { - Slog.w(TAG, "Profiling failed on path " + pcd.path + Slog.w(TAG, "Profiling failed on path " + profilerInfo.profileFile + " -- can the process access this path?"); } finally { try { - pcd.fd.close(); + profilerInfo.profileFd.close(); } catch (IOException e) { Slog.w(TAG, "Failure closing profile fd", e); } @@ -4265,9 +4250,12 @@ public final class ActivityThread { mCompatConfiguration = new Configuration(data.config); mProfiler = new Profiler(); - mProfiler.profileFile = data.initProfileFile; - mProfiler.profileFd = data.initProfileFd; - mProfiler.autoStopProfiler = data.initAutoStopProfiler; + if (data.initProfilerInfo != null) { + mProfiler.profileFile = data.initProfilerInfo.profileFile; + mProfiler.profileFd = data.initProfilerInfo.profileFd; + mProfiler.samplingInterval = data.initProfilerInfo.samplingInterval; + mProfiler.autoStopProfiler = data.initProfilerInfo.autoStopProfiler; + } // send up app name; do this *before* waiting for debugger Process.setArgV0(data.processName); @@ -4282,7 +4270,7 @@ public final class ActivityThread { HardwareRenderer.disable(false); } } - + if (mProfiler.profileFd != null) { mProfiler.startProfiling(); } diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index 52b69e1..63e8707 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -129,7 +129,7 @@ public abstract class ApplicationThreadNative extends Binder scheduleSendResult(b, ri); return true; } - + case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -148,17 +148,13 @@ public abstract class ApplicationThreadNative extends Binder List<Intent> pi = data.createTypedArrayList(Intent.CREATOR); boolean notResumed = data.readInt() != 0; boolean isForward = data.readInt() != 0; - String profileName = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; - boolean autoStopProfiler = data.readInt() != 0; - scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, - voiceInteractor, procState, state, persistentState, - ri, pi, notResumed, isForward, profileName, profileFd, - autoStopProfiler); + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; + scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, voiceInteractor, + procState, state, persistentState, ri, pi, notResumed, isForward, profilerInfo); return true; } - + case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -274,10 +270,8 @@ public abstract class ApplicationThreadNative extends Binder data.createTypedArrayList(ProviderInfo.CREATOR); ComponentName testName = (data.readInt() != 0) ? new ComponentName(data) : null; - String profileName = data.readString(); - ParcelFileDescriptor profileFd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; - boolean autoStopProfiler = data.readInt() != 0; + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; Bundle testArgs = data.readBundle(); IBinder binder = data.readStrongBinder(); IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder); @@ -292,11 +286,9 @@ public abstract class ApplicationThreadNative extends Binder CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data); HashMap<String, IBinder> services = data.readHashMap(null); Bundle coreSettings = data.readBundle(); - bindApplication(packageName, info, - providers, testName, profileName, profileFd, autoStopProfiler, - testArgs, testWatcher, uiAutomationConnection, testMode, - openGlTrace, restrictedBackupMode, persistent, config, compatInfo, - services, coreSettings); + bindApplication(packageName, info, providers, testName, profilerInfo, testArgs, + testWatcher, uiAutomationConnection, testMode, openGlTrace, + restrictedBackupMode, persistent, config, compatInfo, services, coreSettings); return true; } @@ -403,7 +395,7 @@ public abstract class ApplicationThreadNative extends Binder scheduleLowMemory(); return true; } - + case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -411,19 +403,18 @@ public abstract class ApplicationThreadNative extends Binder scheduleActivityConfigurationChanged(b); return true; } - + case PROFILER_CONTROL_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); boolean start = data.readInt() != 0; int profileType = data.readInt(); - String path = data.readString(); - ParcelFileDescriptor fd = data.readInt() != 0 - ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null; - profilerControl(start, path, fd, profileType); + ProfilerInfo profilerInfo = data.readInt() != 0 + ? ProfilerInfo.CREATOR.createFromParcel(data) : null; + profilerControl(start, profilerInfo, profileType); return true; } - + case SET_SCHEDULING_GROUP_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -774,8 +765,7 @@ class ApplicationThreadProxy implements IApplicationThread { IVoiceInteractor voiceInteractor, int procState, Bundle state, PersistableBundle persistentState, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward, - String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) - throws RemoteException { + ProfilerInfo profilerInfo) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); intent.writeToParcel(data, 0); @@ -792,14 +782,12 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeTypedList(pendingNewIntents); data.writeInt(notResumed ? 1 : 0); data.writeInt(isForward ? 1 : 0); - data.writeString(profileName); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } - data.writeInt(autoStopProfiler ? 1 : 0); mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); @@ -959,9 +947,8 @@ class ApplicationThreadProxy implements IApplicationThread { } public final void bindApplication(String packageName, ApplicationInfo info, - List<ProviderInfo> providers, ComponentName testName, String profileName, - ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs, - IInstrumentationWatcher testWatcher, + List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo, + Bundle testArgs, IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection, int debugMode, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, @@ -977,14 +964,12 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(1); testName.writeToParcel(data, 0); } - data.writeString(profileName); - if (profileFd != null) { + if (profilerInfo != null) { data.writeInt(1); - profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } - data.writeInt(autoStopProfiler ? 1 : 0); data.writeBundle(testArgs); data.writeStrongInterface(testWatcher); data.writeStrongInterface(uiAutomationConnection); @@ -1111,7 +1096,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public final void scheduleActivityConfigurationChanged( IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); @@ -1121,17 +1106,16 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - - public void profilerControl(boolean start, String path, - ParcelFileDescriptor fd, int profileType) throws RemoteException { + + public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) + throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeInt(start ? 1 : 0); data.writeInt(profileType); - data.writeString(path); - if (fd != null) { + if (profilerInfo != null) { data.writeInt(1); - fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); + profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } else { data.writeInt(0); } @@ -1139,7 +1123,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public void setSchedulingGroup(int group) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); @@ -1148,7 +1132,7 @@ class ApplicationThreadProxy implements IApplicationThread { IBinder.FLAG_ONEWAY); data.recycle(); } - + public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); @@ -1157,9 +1141,8 @@ class ApplicationThreadProxy implements IApplicationThread { mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); - } - + public void scheduleCrash(String msg) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); @@ -1167,7 +1150,6 @@ class ApplicationThreadProxy implements IApplicationThread { mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null, IBinder.FLAG_ONEWAY); data.recycle(); - } public void dumpHeap(boolean managed, String path, diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index fb5a8f5..91a0aed 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1247,7 +1247,7 @@ class ContextImpl extends Context { ActivityManagerNative.getDefault().startActivityAsUser( mMainThread.getApplicationThread(), getBasePackageName(), intent, intent.resolveTypeIfNeeded(getContentResolver()), - null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, options, + null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, user.getIdentifier()); } catch (RemoteException re) { } diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 57c4b71..99428e8 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -61,22 +61,19 @@ import java.util.List; * {@hide} */ public interface IActivityManager extends IInterface { - public int startActivity(IApplicationThread caller, String callingPackage, - Intent intent, String resolvedType, IBinder resultTo, String resultWho, - int requestCode, int flags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options) throws RemoteException; - public int startActivityAsUser(IApplicationThread caller, String callingPackage, - Intent intent, String resolvedType, IBinder resultTo, String resultWho, - int requestCode, int flags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException; + public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, + String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags, + ProfilerInfo profilerInfo, Bundle options) throws RemoteException; + public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent, + String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags, + ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException; public int startActivityAsCaller(IApplicationThread caller, String callingPackage, - Intent intent, String resolvedType, IBinder resultTo, String resultWho, - int requestCode, int flags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options) throws RemoteException; + Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, + int flags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException; public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, - int requestCode, int flags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException; + int requestCode, int flags, ProfilerInfo profilerInfo, Bundle options, + int userId) throws RemoteException; public int startActivityWithConfig(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, Configuration newConfig, @@ -87,8 +84,8 @@ public interface IActivityManager extends IInterface { int flagsMask, int flagsValues, Bundle options) throws RemoteException; public int startVoiceActivity(String callingPackage, int callingPid, int callingUid, Intent intent, String resolvedType, IVoiceInteractionSession session, - IVoiceInteractor interactor, int flags, String profileFile, - ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException; + IVoiceInteractor interactor, int flags, ProfilerInfo profilerInfo, Bundle options, + int userId) throws RemoteException; public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent, Bundle options) throws RemoteException; public int startActivityFromRecents(int taskId, Bundle options) throws RemoteException; @@ -269,7 +266,7 @@ public interface IActivityManager extends IInterface { // Special low-level communication with activity manager. public void handleApplicationCrash(IBinder app, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException; - public boolean handleApplicationWtf(IBinder app, String tag, + public boolean handleApplicationWtf(IBinder app, String tag, boolean system, ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException; // A StrictMode violation to be handled. The violationMask is a @@ -296,13 +293,13 @@ public interface IActivityManager extends IInterface { throws RemoteException; // Get device configuration public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException; - + // Turn on/off profiling in a particular process. public boolean profileControl(String process, int userId, boolean start, - String path, ParcelFileDescriptor fd, int profileType) throws RemoteException; - + ProfilerInfo profilerInfo, int profileType) throws RemoteException; + public boolean shutdown(int timeout) throws RemoteException; - + public void stopAppSwitches() throws RemoteException; public void resumeAppSwitches() throws RemoteException; diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index 01b6fdf..a7546d9 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -62,8 +62,7 @@ public interface IApplicationThread extends IInterface { IVoiceInteractor voiceInteractor, int procState, Bundle state, PersistableBundle persistentState, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, boolean notResumed, boolean isForward, - String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) - throws RemoteException; + ProfilerInfo profilerInfo) throws RemoteException; void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<Intent> pendingNewIntents, int configChanges, boolean notResumed, Configuration config) throws RemoteException; @@ -94,10 +93,9 @@ public interface IApplicationThread extends IInterface { static final int DEBUG_ON = 1; static final int DEBUG_WAIT = 2; void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers, - ComponentName testName, String profileName, ParcelFileDescriptor profileFd, - boolean autoStopProfiler, Bundle testArguments, IInstrumentationWatcher testWatcher, - IUiAutomationConnection uiAutomationConnection, int debugMode, - boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, + ComponentName testName, ProfilerInfo profilerInfo, Bundle testArguments, + IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection, + int debugMode, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, Bundle coreSettings) throws RemoteException; void scheduleExit() throws RemoteException; @@ -117,7 +115,7 @@ public interface IApplicationThread extends IInterface { boolean sticky, int sendingUser, int processState) throws RemoteException; void scheduleLowMemory() throws RemoteException; void scheduleActivityConfigurationChanged(IBinder token) throws RemoteException; - void profilerControl(boolean start, String path, ParcelFileDescriptor fd, int profileType) + void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) throws RemoteException; void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd) throws RemoteException; diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index bc71bad..ba3a234 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -1481,7 +1481,7 @@ public class Instrumentation { .startActivity(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mEmbeddedID : null, - requestCode, 0, null, null, options); + requestCode, 0, null, options); checkStartActivityResult(result, intent); } catch (RemoteException e) { } @@ -1598,7 +1598,7 @@ public class Instrumentation { .startActivity(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mWho : null, - requestCode, 0, null, null, options); + requestCode, 0, null, options); checkStartActivityResult(result, intent); } catch (RemoteException e) { } @@ -1658,7 +1658,7 @@ public class Instrumentation { .startActivityAsUser(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mEmbeddedID : null, - requestCode, 0, null, null, options, user.getIdentifier()); + requestCode, 0, null, options, user.getIdentifier()); checkStartActivityResult(result, intent); } catch (RemoteException e) { } @@ -1695,7 +1695,7 @@ public class Instrumentation { .startActivityAsCaller(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mEmbeddedID : null, - requestCode, 0, null, null, options); + requestCode, 0, null, options); checkStartActivityResult(result, intent); } catch (RemoteException e) { } diff --git a/core/java/android/app/ProfilerInfo.java b/core/java/android/app/ProfilerInfo.java new file mode 100644 index 0000000..cea7c3c --- /dev/null +++ b/core/java/android/app/ProfilerInfo.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2014 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 android.app; + +import android.os.Parcel; +import android.os.Parcelable; +import android.os.ParcelFileDescriptor; + +/** + * System private API for passing profiler settings. + * + * {@hide} + */ +public class ProfilerInfo implements Parcelable { + + /* Name of profile output file. */ + public final String profileFile; + + /* File descriptor for profile output file, can be null. */ + public ParcelFileDescriptor profileFd; + + /* Indicates sample profiling when nonzero, interval in microseconds. */ + public final int samplingInterval; + + /* Automatically stop the profiler when the app goes idle. */ + public final boolean autoStopProfiler; + + public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop) { + profileFile = filename; + profileFd = fd; + samplingInterval = interval; + autoStopProfiler = autoStop; + } + + public int describeContents() { + if (profileFd != null) { + return profileFd.describeContents(); + } else { + return 0; + } + } + + public void writeToParcel(Parcel out, int flags) { + out.writeString(profileFile); + if (profileFd != null) { + out.writeInt(1); + profileFd.writeToParcel(out, flags); + } else { + out.writeInt(0); + } + out.writeInt(samplingInterval); + out.writeInt(autoStopProfiler ? 1 : 0); + } + + public static final Parcelable.Creator<ProfilerInfo> CREATOR = + new Parcelable.Creator<ProfilerInfo>() { + public ProfilerInfo createFromParcel(Parcel in) { + return new ProfilerInfo(in); + } + + public ProfilerInfo[] newArray(int size) { + return new ProfilerInfo[size]; + } + }; + + private ProfilerInfo(Parcel in) { + profileFile = in.readString(); + profileFd = in.readInt() != 0 ? ParcelFileDescriptor.CREATOR.createFromParcel(in) : null; + samplingInterval = in.readInt(); + autoStopProfiler = in.readInt() != 0; + } +} diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index b17309f..26c72a5 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -1374,7 +1374,7 @@ public class DevicePolicyManager { * @param admin The name of the admin component to check, or null to aggregate * all admins. * @return time in milliseconds for the given admin or the minimum value (strictest) of - * all admins if admin is null. + * all admins if admin is null. Returns 0 if there are no restrictions. */ public long getMaximumTimeToLock(ComponentName admin) { return getMaximumTimeToLock(admin, UserHandle.myUserId()); @@ -1885,7 +1885,7 @@ public class DevicePolicyManager { * security exception will be thrown. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. - * @param disabled Whether or not screen capture should be disabled. + * @param disabled Whether screen capture is disabled or not. */ public void setScreenCaptureDisabled(ComponentName admin, boolean disabled) { if (mService != null) { @@ -1920,6 +1920,42 @@ public class DevicePolicyManager { } /** + * Called by a device owner to set whether auto time is required. If auto time is + * required the user cannot set the date and time, but has to use network date and time. + * + * <p>Note: if auto time is required the user can still manually set the time zone. + * + * <p>The calling device admin must be a device owner. If it is not, a security exception will + * be thrown. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param required Whether auto time is set required or not. + */ + public void setAutoTimeRequired(ComponentName admin, boolean required) { + if (mService != null) { + try { + mService.setAutoTimeRequired(admin, UserHandle.myUserId(), required); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + } + + /** + * @return true if auto time is required. + */ + public boolean getAutoTimeRequired() { + if (mService != null) { + try { + return mService.getAutoTimeRequired(); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return false; + } + + /** * Called by an application that is administering the device to disable keyguard customizations, * such as widgets. After setting this, keyguard features will be disabled according to the * provided feature list. @@ -3157,6 +3193,20 @@ public class DevicePolicyManager { /** * Called by device owners to update {@link Settings.Global} settings. Validation that the value * of the setting is in the correct form for the setting type should be performed by the caller. + * <p>The settings that can be updated with this method are: + * <ul> + * <li>{@link Settings.Global#ADB_ENABLED}</li> + * <li>{@link Settings.Global#AUTO_TIME}</li> + * <li>{@link Settings.Global#AUTO_TIME_ZONE}</li> + * <li>{@link Settings.Global#BLUETOOTH_ON}</li> + * <li>{@link Settings.Global#DATA_ROAMING}</li> + * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li> + * <li>{@link Settings.Global#MODE_RINGER}</li> + * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li> + * <li>{@link Settings.Global#USB_MASS_STORAGE_ENABLED}</li> + * <li>{@link Settings.Global#WIFI_ON}</li> + * <li>{@link Settings.Global#WIFI_SLEEP_POLICY}</li> + * </ul> * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. @@ -3176,7 +3226,11 @@ public class DevicePolicyManager { * Called by profile or device owners to update {@link Settings.Secure} settings. Validation * that the value of the setting is in the correct form for the setting type should be performed * by the caller. - * + * <p>The settings that can be updated with this method are: + * <ul> + * <li>{@link Settings.Secure#DEFAULT_INPUT_METHOD}</li> + * <li>{@link Settings.Secure#SKIP_FIRST_USE_HINTS}</li> + * </ul> * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. * @param value The value to update the setting to. diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 1e17bb6..23f36fb 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -186,4 +186,7 @@ interface IDevicePolicyManager { boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName); boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName); List<String> getCrossProfileWidgetProviders(in ComponentName admin); + + void setAutoTimeRequired(in ComponentName who, int userHandle, boolean required); + boolean getAutoTimeRequired(); } diff --git a/core/java/android/app/backup/WallpaperBackupHelper.java b/core/java/android/app/backup/WallpaperBackupHelper.java index 9e8ab2c..0567500 100644 --- a/core/java/android/app/backup/WallpaperBackupHelper.java +++ b/core/java/android/app/backup/WallpaperBackupHelper.java @@ -141,13 +141,13 @@ public class WallpaperBackupHelper extends FileBackupHelperBase implements Backu if (widthRatio > 0 && widthRatio < 1.33 && heightRatio > 0 && heightRatio < 1.33) { // sufficiently close to our resolution; go ahead and use it - if (DEBUG) Slog.d(TAG, "wallpaper dimension match; using"); + Slog.d(TAG, "Applying restored wallpaper image."); f.renameTo(new File(WALLPAPER_IMAGE)); // TODO: spin a service to copy the restored image to sd/usb storage, // since it does not exist anywhere other than the private wallpaper // file. } else { - if (DEBUG) Slog.d(TAG, "dimensions too far off: wr=" + widthRatio + Slog.i(TAG, "Dimensions too far off; using default wallpaper. wr=" + widthRatio + " hr=" + heightRatio); f.delete(); } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index b09d3ac..6d40dcf 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -25,6 +25,7 @@ import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NOT_APK; import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES; import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION; +import android.app.ActivityManager; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; @@ -3077,7 +3078,7 @@ public class PackageParser { ActivityInfo.DOCUMENT_LAUNCH_NONE); a.info.maxRecents = sa.getInt( com.android.internal.R.styleable.AndroidManifestActivity_maxRecents, - 15); + ActivityManager.getDefaultAppRecentsLimitStatic()); a.info.screenOrientation = sa.getInt( com.android.internal.R.styleable.AndroidManifestActivity_screenOrientation, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); diff --git a/core/java/android/database/ContentObserver.java b/core/java/android/database/ContentObserver.java index e4fbc28..5f01e30 100644 --- a/core/java/android/database/ContentObserver.java +++ b/core/java/android/database/ContentObserver.java @@ -18,6 +18,7 @@ package android.database; import android.net.Uri; import android.os.Handler; +import android.os.UserHandle; /** * Receives call backs for changes to content. @@ -130,6 +131,21 @@ public abstract class ContentObserver { } /** + * Dispatches a change notification to the observer. Includes the changed + * content Uri when available and also the user whose content changed. + * + * @param selfChange True if this is a self-change notification. + * @param uri The Uri of the changed content, or null if unknown. + * @param userId The user whose content changed. Can be either a specific + * user or {@link UserHandle#USER_ALL}. + * + * @hide + */ + public void onChange(boolean selfChange, Uri uri, int userId) { + onChange(selfChange, uri); + } + + /** * Dispatches a change notification to the observer. * <p> * If a {@link Handler} was supplied to the {@link ContentObserver} constructor, @@ -159,25 +175,45 @@ public abstract class ContentObserver { * @param uri The Uri of the changed content, or null if unknown. */ public final void dispatchChange(boolean selfChange, Uri uri) { + dispatchChange(selfChange, uri, UserHandle.getCallingUserId()); + } + + /** + * Dispatches a change notification to the observer. Includes the changed + * content Uri when available and also the user whose content changed. + * <p> + * If a {@link Handler} was supplied to the {@link ContentObserver} constructor, + * then a call to the {@link #onChange} method is posted to the handler's message queue. + * Otherwise, the {@link #onChange} method is invoked immediately on this thread. + * </p> + * + * @param selfChange True if this is a self-change notification. + * @param uri The Uri of the changed content, or null if unknown. + * @param userId The user whose content changed. + */ + private void dispatchChange(boolean selfChange, Uri uri, int userId) { if (mHandler == null) { - onChange(selfChange, uri); + onChange(selfChange, uri, userId); } else { - mHandler.post(new NotificationRunnable(selfChange, uri)); + mHandler.post(new NotificationRunnable(selfChange, uri, userId)); } } + private final class NotificationRunnable implements Runnable { private final boolean mSelfChange; private final Uri mUri; + private final int mUserId; - public NotificationRunnable(boolean selfChange, Uri uri) { + public NotificationRunnable(boolean selfChange, Uri uri, int userId) { mSelfChange = selfChange; mUri = uri; + mUserId = userId; } @Override public void run() { - ContentObserver.this.onChange(mSelfChange, mUri); + ContentObserver.this.onChange(mSelfChange, mUri, mUserId); } } @@ -189,10 +225,10 @@ public abstract class ContentObserver { } @Override - public void onChange(boolean selfChange, Uri uri) { + public void onChange(boolean selfChange, Uri uri, int userId) { ContentObserver contentObserver = mContentObserver; if (contentObserver != null) { - contentObserver.dispatchChange(selfChange, uri); + contentObserver.dispatchChange(selfChange, uri, userId); } } diff --git a/core/java/android/database/CursorToBulkCursorAdaptor.java b/core/java/android/database/CursorToBulkCursorAdaptor.java index 7dcfae2..02eddf2 100644 --- a/core/java/android/database/CursorToBulkCursorAdaptor.java +++ b/core/java/android/database/CursorToBulkCursorAdaptor.java @@ -17,9 +17,7 @@ package android.database; import android.net.Uri; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; +import android.os.*; /** @@ -33,7 +31,7 @@ import android.os.RemoteException; * * {@hide} */ -public final class CursorToBulkCursorAdaptor extends BulkCursorNative +public final class CursorToBulkCursorAdaptor extends BulkCursorNative implements IBinder.DeathRecipient { private static final String TAG = "Cursor"; @@ -66,7 +64,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative // Do nothing, the far side is dead } } - + public boolean unlinkToDeath(DeathRecipient recipient) { return mRemote.asBinder().unlinkToDeath(recipient, 0); } @@ -80,7 +78,7 @@ public final class CursorToBulkCursorAdaptor extends BulkCursorNative @Override public void onChange(boolean selfChange, Uri uri) { try { - mRemote.onChange(selfChange, uri); + mRemote.onChange(selfChange, uri, android.os.Process.myUid()); } catch (RemoteException ex) { // Do nothing, the far side is dead } diff --git a/core/java/android/database/IContentObserver.aidl b/core/java/android/database/IContentObserver.aidl index 13aff05..22dc9fe 100644 --- a/core/java/android/database/IContentObserver.aidl +++ b/core/java/android/database/IContentObserver.aidl @@ -2,16 +2,16 @@ ** ** Copyright 2007, 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 +** 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 +** 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 +** 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. */ @@ -29,5 +29,5 @@ interface IContentObserver * observed. selfUpdate is true if the update was caused by a call to * commit on the cursor that is being observed. */ - oneway void onChange(boolean selfUpdate, in Uri uri); + oneway void onChange(boolean selfUpdate, in Uri uri, int userId); } diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 4f35b16..27473e3 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -36,7 +36,6 @@ import android.database.Cursor; import android.database.DatabaseUtils; import android.graphics.Rect; import android.net.Uri; -import android.net.Uri.Builder; import android.os.RemoteException; import android.text.TextUtils; import android.util.DisplayMetrics; @@ -1622,15 +1621,15 @@ public final class ContactsContract { * * @hide */ - public static long CORP_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30 + public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30 /** - * Return TRUE if a contact ID is from the contacts provider on the corp profile. + * Return TRUE if a contact ID is from the contacts provider on the enterprise profile. * * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact. */ - public static boolean isCorpContactId(long contactId) { - return (contactId >= CORP_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); + public static boolean isEnterpriseContactId(long contactId) { + return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID); } /** @@ -2229,6 +2228,11 @@ public final class ContactsContract { * type. For applications that need to be aware of the data set, this can * be used instead of account type to distinguish sets of data. This is * never intended to be used for specifying accounts. + * <p> + * This column does *not* escape forward slashes in the account type or the data set. + * If this is an issue, consider using + * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and + * {@link ContactsContract.RawContacts#DATA_SET} directly. */ public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set"; @@ -2272,6 +2276,8 @@ public final class ContactsContract { * The default value is "0" * </p> * <p>Type: INTEGER</p> + * + * @hide */ public static final String NAME_VERIFIED = "name_verified"; @@ -5023,7 +5029,8 @@ public final class ContactsContract { * </li> * <li> * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact - * is from the corp profile, use {@link ContactsContract.Contacts#isCorpContactId(long)}. + * is from the corp profile, use + * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}. * </li> * </ul> * <p> @@ -8066,6 +8073,21 @@ public final class ContactsContract { } /** + * Pins a contact at a provided position, or unpins a contact. + * + * @param contentResolver to perform the pinning operation on. + * @param pinnedPosition the position to pin the contact at. To unpin a contact, use + * {@link PinnedPositions#UNPINNED}. + */ + public static void pin( + ContentResolver contentResolver, long contactId, int pinnedPosition) { + final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId)); + final ContentValues values = new ContentValues(); + values.put(Contacts.PINNED, pinnedPosition); + contentResolver.update(uri, values, null, null); + } + + /** * Default value for the pinned position of an unpinned contact. */ public static final int UNPINNED = 0; @@ -8097,19 +8119,19 @@ public final class ContactsContract { * @hide */ @Deprecated - public static final String EXTRA_TARGET_RECT = "target_rect"; + public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT"; /** * Extra used to specify size of pivot dialog. * @hide */ - public static final String EXTRA_MODE = "mode"; + public static final String EXTRA_MODE = "android.provider.extra.MODE"; /** * Extra used to indicate a list of specific MIME-types to exclude and not display in the * QuickContacts dialog. Stored as a {@link String} array. */ - public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; + public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; /** * Small QuickContact mode, usually presented with minimal actions. diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java index 2b81072..a9b3571 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -96,12 +96,12 @@ public final class Log { * @hide */ public interface TerribleFailureHandler { - void onTerribleFailure(String tag, TerribleFailure what); + void onTerribleFailure(String tag, TerribleFailure what, boolean system); } private static TerribleFailureHandler sWtfHandler = new TerribleFailureHandler() { - public void onTerribleFailure(String tag, TerribleFailure what) { - RuntimeInit.wtf(tag, what); + public void onTerribleFailure(String tag, TerribleFailure what, boolean system) { + RuntimeInit.wtf(tag, what, system); } }; @@ -253,7 +253,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int wtf(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, false); + return wtf(LOG_ID_MAIN, tag, msg, null, false, false); } /** @@ -262,7 +262,7 @@ public final class Log { * @hide */ public static int wtfStack(String tag, String msg) { - return wtf(LOG_ID_MAIN, tag, msg, null, true); + return wtf(LOG_ID_MAIN, tag, msg, null, true, false); } /** @@ -272,7 +272,7 @@ public final class Log { * @param tr An exception to log. */ public static int wtf(String tag, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false); + return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false, false); } /** @@ -283,14 +283,15 @@ public final class Log { * @param tr An exception to log. May be null. */ public static int wtf(String tag, String msg, Throwable tr) { - return wtf(LOG_ID_MAIN, tag, msg, tr, false); + return wtf(LOG_ID_MAIN, tag, msg, tr, false, false); } - static int wtf(int logId, String tag, String msg, Throwable tr, boolean localStack) { + static int wtf(int logId, String tag, String msg, Throwable tr, boolean localStack, + boolean system) { TerribleFailure what = new TerribleFailure(msg, tr); int bytes = println_native(logId, ASSERT, tag, msg + '\n' + getStackTraceString(localStack ? what : tr)); - sWtfHandler.onTerribleFailure(tag, what); + sWtfHandler.onTerribleFailure(tag, what, system); return bytes; } diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java index b25d80f..7a5fd50 100644 --- a/core/java/android/util/Slog.java +++ b/core/java/android/util/Slog.java @@ -74,19 +74,19 @@ public final class Slog { } public static int wtf(String tag, String msg) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true); } public static int wtfStack(String tag, String msg) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true); } public static int wtf(String tag, Throwable tr) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true); } public static int wtf(String tag, String msg, Throwable tr) { - return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false); + return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true); } public static int println(int priority, String tag, String msg) { diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java index 50341fc..3af214d 100644 --- a/core/java/android/view/ThreadedRenderer.java +++ b/core/java/android/view/ThreadedRenderer.java @@ -99,15 +99,13 @@ public class ThreadedRenderer extends HardwareRenderer { private boolean mRootNodeNeedsUpdate; ThreadedRenderer(Context context, boolean translucent) { - final TypedArray a = context.obtainStyledAttributes( - null, R.styleable.Lighting, R.attr.lightingStyle, 0); + final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Lighting, 0, 0); mLightY = a.getDimension(R.styleable.Lighting_lightY, 0); mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0); mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0); - mAmbientShadowAlpha = Math.round( - 255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0)); - mSpotShadowAlpha = Math.round( - 255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0)); + mAmbientShadowAlpha = + (int) (255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0) + 0.5f); + mSpotShadowAlpha = (int) (255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0) + 0.5f); a.recycle(); long rootNodePtr = nCreateRootRenderNode(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 6f58582..2d58ecf 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15110,7 +15110,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final AccessibilityNodeInfo virtualView = viewRoot.getAccessibilityFocusedVirtualView(); if (virtualView != null) { - virtualView.getBoundsInParent(bounds); + virtualView.getBoundsInScreen(bounds); + final int[] offset = mAttachInfo.mTmpLocation; + getLocationOnScreen(offset); + bounds.offset(-offset[0], -offset[1]); } else { bounds.set(0, 0, mRight - mLeft, mBottom - mTop); } diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index 49d47fe..7df1fa3 100644 --- a/core/java/android/widget/DatePickerCalendarDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -16,9 +16,6 @@ package android.widget; -import android.animation.Keyframe; -import android.animation.ObjectAnimator; -import android.animation.PropertyValuesHolder; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Configuration; @@ -60,10 +57,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i private static final int DEFAULT_START_YEAR = 1900; private static final int DEFAULT_END_YEAR = 2100; - private static final int PULSE_ANIMATOR_DURATION = 544; - private static final int ANIMATION_DURATION = 300; - private static final int ANIMATION_DELAY = 650; private static final int MONTH_INDEX = 0; private static final int DAY_INDEX = 1; @@ -73,8 +67,13 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i private SimpleDateFormat mDayFormat = new SimpleDateFormat("d", Locale.getDefault()); private TextView mDayOfWeekView; - private LinearLayout mDateLayout; + + /** Layout that contains the current month, day, and year. */ + private LinearLayout mMonthDayYearLayout; + + /** Clickable layout that contains the current day and year. */ private LinearLayout mMonthAndDayLayout; + private TextView mHeaderMonthTextView; private TextView mHeaderDayOfMonthTextView; private TextView mHeaderYearTextView; @@ -93,8 +92,6 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i private DatePicker.OnDateChangedListener mDateChangedListener; - private boolean mDelayAnimation = true; - private int mCurrentView = UNINITIALIZED; private Calendar mCurrentDate; @@ -112,7 +109,6 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mMinDate = getCalendarForLocale(mMinDate, locale); mMaxDate = getCalendarForLocale(mMaxDate, locale); mTempDate = getCalendarForLocale(mMaxDate, locale); - mCurrentDate = getCalendarForLocale(mCurrentDate, locale); mMinDate.set(DEFAULT_START_YEAR, 1, 1); @@ -129,7 +125,12 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mDelegator.addView(mainView); mDayOfWeekView = (TextView) mainView.findViewById(R.id.date_picker_header); - mDateLayout = (LinearLayout) mainView.findViewById(R.id.day_picker_selector_layout); + + // Layout that contains the current date and day name header. + final LinearLayout dateLayout = (LinearLayout) mainView.findViewById( + R.id.day_picker_selector_layout); + mMonthDayYearLayout = (LinearLayout) mainView.findViewById( + R.id.date_picker_month_day_year_layout); mMonthAndDayLayout = (LinearLayout) mainView.findViewById( R.id.date_picker_month_and_day_layout); mMonthAndDayLayout.setOnClickListener(this); @@ -156,7 +157,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i R.styleable.DatePicker_headerSelectedTextColor, defaultHighlightColor); final int headerBackgroundColor = a.getColor(R.styleable.DatePicker_headerBackgroundColor, Color.TRANSPARENT); - mDateLayout.setBackgroundColor(headerBackgroundColor); + dateLayout.setBackgroundColor(headerBackgroundColor); final int monthTextAppearanceResId = a.getResourceId( R.styleable.DatePicker_headerMonthTextAppearance, -1); @@ -189,6 +190,10 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mYearPickerView = new YearPickerView(mContext); mYearPickerView.init(this); + final int yearSelectedCircleColor = a.getColor(R.styleable.DatePicker_yearListSelectorColor, + defaultHighlightColor); + mYearPickerView.setYearSelectedCircleColor(yearSelectedCircleColor); + final ColorStateList calendarTextColor = a.getColorStateList( R.styleable.DatePicker_calendarTextColor); final int calendarSelectedTextColor = a.getColor( @@ -205,10 +210,12 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mAnimator.addView(mDayPickerView); mAnimator.addView(mYearPickerView); mAnimator.setDateMillis(mCurrentDate.getTimeInMillis()); - Animation animation = new AlphaAnimation(0.0f, 1.0f); + + final Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(ANIMATION_DURATION); mAnimator.setInAnimation(animation); - Animation animation2 = new AlphaAnimation(1.0f, 0.0f); + + final Animation animation2 = new AlphaAnimation(1.0f, 0.0f); animation2.setDuration(ANIMATION_DURATION); mAnimator.setOutAnimation(animation2); @@ -276,30 +283,28 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mDayOfWeekView.setText(mCurrentDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault())); } - final String bestDateTimePattern = - DateFormat.getBestDateTimePattern(mCurrentLocale, "yMMMd"); // Compute indices of Month, Day and Year views - int[] viewIndices = getMonthDayYearIndexes(bestDateTimePattern); - - // Restart from a clean state - mMonthAndDayLayout.removeAllViews(); - mDateLayout.removeView(mHeaderYearTextView); + final String bestDateTimePattern = + DateFormat.getBestDateTimePattern(mCurrentLocale, "yMMMd"); + final int[] viewIndices = getMonthDayYearIndexes(bestDateTimePattern); - // Position the Year View at the correct location + // Position the Year and MonthAndDay views within the header. + mMonthDayYearLayout.removeAllViews(); if (viewIndices[YEAR_INDEX] == 0) { - mDateLayout.addView(mHeaderYearTextView, 1); + mMonthDayYearLayout.addView(mHeaderYearTextView); + mMonthDayYearLayout.addView(mMonthAndDayLayout); } else { - mDateLayout.addView(mHeaderYearTextView, 2); + mMonthDayYearLayout.addView(mMonthAndDayLayout); + mMonthDayYearLayout.addView(mHeaderYearTextView); } - // Position Day and Month Views + // Position Day and Month views within the MonthAndDay view. + mMonthAndDayLayout.removeAllViews(); if (viewIndices[MONTH_INDEX] > viewIndices[DAY_INDEX]) { - // Day View is first mMonthAndDayLayout.addView(mHeaderDayOfMonthTextView); mMonthAndDayLayout.addView(mHeaderMonthTextView); } else { - // Month View is first mMonthAndDayLayout.addView(mHeaderMonthTextView); mMonthAndDayLayout.addView(mHeaderDayOfMonthTextView); } @@ -329,12 +334,6 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i switch (viewIndex) { case MONTH_AND_DAY_VIEW: - ObjectAnimator pulseAnimator = getPulseAnimator(mMonthAndDayLayout, 0.9f, - 1.05f); - if (mDelayAnimation) { - pulseAnimator.setStartDelay(ANIMATION_DELAY); - mDelayAnimation = false; - } mDayPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayLayout.setSelected(true); @@ -342,19 +341,13 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); mCurrentView = viewIndex; } - pulseAnimator.start(); - int flags = DateUtils.FORMAT_SHOW_DATE; - String dayString = DateUtils.formatDateTime(mContext, millis, flags); + final int flags = DateUtils.FORMAT_SHOW_DATE; + final String dayString = DateUtils.formatDateTime(mContext, millis, flags); mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString); mAnimator.announceForAccessibility(mSelectDay); break; case YEAR_VIEW: - pulseAnimator = getPulseAnimator(mHeaderYearTextView, 0.85f, 1.1f); - if (mDelayAnimation) { - pulseAnimator.setStartDelay(ANIMATION_DELAY); - mDelayAnimation = false; - } mYearPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayLayout.setSelected(false); @@ -362,9 +355,8 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i mAnimator.setDisplayedChild(YEAR_VIEW); mCurrentView = viewIndex; } - pulseAnimator.start(); - CharSequence yearString = mYearFormat.format(millis); + final CharSequence yearString = mYearFormat.format(millis); mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString); mAnimator.announceForAccessibility(mSelectYear); break; @@ -789,25 +781,4 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate i } }; } - - /** - * Render an animator to pulsate a view in place. - * @param labelToAnimate the view to pulsate. - * @return The animator object. Use .start() to begin. - */ - public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, - float increaseRatio) { - Keyframe k0 = Keyframe.ofFloat(0f, 1f); - Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); - Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); - Keyframe k3 = Keyframe.ofFloat(1f, 1f); - - PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, k0, k1, k2, k3); - PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, k0, k1, k2, k3); - ObjectAnimator pulseAnimator = - ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); - pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); - - return pulseAnimator; - } } diff --git a/core/java/android/widget/DayPickerView.java b/core/java/android/widget/DayPickerView.java index c44bd46..ca4095e 100644 --- a/core/java/android/widget/DayPickerView.java +++ b/core/java/android/widget/DayPickerView.java @@ -73,11 +73,6 @@ class DayPickerView extends ListView implements AbsListView.OnScrollListener, private ScrollStateRunnable mScrollStateChangedRunnable = new ScrollStateRunnable(this); - public DayPickerView(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - public DayPickerView(Context context, DatePickerController controller) { super(context); init(); diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java index ae44047..8917f39 100644 --- a/core/java/android/widget/TimePickerClockDelegate.java +++ b/core/java/android/widget/TimePickerClockDelegate.java @@ -18,7 +18,6 @@ package android.widget; import android.content.Context; import android.content.res.Configuration; -import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Parcel; import android.os.Parcelable; @@ -34,6 +33,7 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import com.android.internal.R; +import java.text.DateFormatSymbols; import java.util.Calendar; import java.util.Locale; @@ -149,7 +149,7 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate { mAmPmStrings = getAmPmStrings(context); // am/pm - View amPmView = mDelegator.findViewById(R.id.amPm); + final View amPmView = mDelegator.findViewById(R.id.amPm); if (amPmView instanceof Button) { mAmPmSpinner = null; mAmPmSpinnerInput = null; diff --git a/core/java/android/widget/TimePickerSpinnerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java index dd1bf4f..6169d2e 100644 --- a/core/java/android/widget/TimePickerSpinnerDelegate.java +++ b/core/java/android/widget/TimePickerSpinnerDelegate.java @@ -16,9 +16,6 @@ package android.widget; -import android.animation.Keyframe; -import android.animation.ObjectAnimator; -import android.animation.PropertyValuesHolder; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Configuration; @@ -43,6 +40,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.R; +import java.text.DateFormatSymbols; import java.util.ArrayList; import java.util.Calendar; import java.util.Locale; @@ -73,12 +71,6 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im private static final int HOURS_IN_HALF_DAY = 12; - // Delay in ms before starting the pulse animation - private static final int PULSE_ANIMATOR_DELAY = 300; - - // Duration in ms of the pulse animation - private static final int PULSE_ANIMATOR_DURATION = 544; - private TextView mHourView; private TextView mMinuteView; private TextView mAmPmTextView; @@ -98,7 +90,6 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im private String mDoublePlaceholderText; private String mDeletedKeyFormat; private boolean mInKbMode; - private boolean mIsTimeValid = true; private ArrayList<Integer> mTypedTimes = new ArrayList<Integer>(); private Node mLegalTimesTree; private int mAmKeyCode; @@ -215,14 +206,14 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im mHourView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - setCurrentItemShowing(HOUR_INDEX, true, false, true); + setCurrentItemShowing(HOUR_INDEX, true, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - setCurrentItemShowing(MINUTE_INDEX, true, false, true); + setCurrentItemShowing(MINUTE_INDEX, true, true); tryVibrate(); } }); @@ -245,7 +236,7 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im private void updateRadialPicker(int index) { mRadialTimePickerView.initialize(mInitialHourOfDay, mInitialMinute, mIs24HourView); - setCurrentItemShowing(index, false, true, true); + setCurrentItemShowing(index, false, true); } private int computeMaxWidthOfNumbers(int max) { @@ -633,7 +624,7 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im updateHeaderHour(newValue, false); String announcement = String.format("%d", newValue); if (mAllowAutoAdvance && autoAdvance) { - setCurrentItemShowing(MINUTE_INDEX, true, true, false); + setCurrentItemShowing(MINUTE_INDEX, true, false); announcement += ". " + mSelectMinutes; } else { mRadialTimePickerView.setContentDescription( @@ -753,11 +744,9 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im /** * Show either Hours or Minutes. */ - private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate, - boolean announce) { + private void setCurrentItemShowing(int index, boolean animateCircle, boolean announce) { mRadialTimePickerView.setCurrentItemShowing(index, animateCircle); - TextView labelToAnimate; if (index == HOUR_INDEX) { int hours = mRadialTimePickerView.getCurrentHour(); if (!mIs24HourView) { @@ -767,24 +756,16 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im if (announce) { mRadialTimePickerView.announceForAccessibility(mSelectHours); } - labelToAnimate = mHourView; } else { int minutes = mRadialTimePickerView.getCurrentMinute(); mRadialTimePickerView.setContentDescription(mMinutePickerDescription + ": " + minutes); if (announce) { mRadialTimePickerView.announceForAccessibility(mSelectMinutes); } - labelToAnimate = mMinuteView; } mHourView.setSelected(index == HOUR_INDEX); mMinuteView.setSelected(index == MINUTE_INDEX); - - ObjectAnimator pulseAnimator = getPulseAnimator(labelToAnimate, 0.85f, 1.1f); - if (delayLabelAnimate) { - pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY); - } - pulseAnimator.start(); } /** @@ -980,7 +961,7 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im if (!mIs24HourView) { updateAmPmDisplay(hour < 12 ? AM : PM); } - setCurrentItemShowing(mRadialTimePickerView.getCurrentItemShowing(), true, true, true); + setCurrentItemShowing(mRadialTimePickerView.getCurrentItemShowing(), true, true); onValidationChanged(true); } else { boolean[] enteredZeros = {false, false}; @@ -1289,26 +1270,4 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im return false; } } - - /** - * Render an animator to pulsate a view in place. - * - * @param labelToAnimate the view to pulsate. - * @return The animator object. Use .start() to begin. - */ - private static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, - float increaseRatio) { - final Keyframe k0 = Keyframe.ofFloat(0f, 1f); - final Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); - final Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); - final Keyframe k3 = Keyframe.ofFloat(1f, 1f); - - PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, k0, k1, k2, k3); - PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, k0, k1, k2, k3); - ObjectAnimator pulseAnimator = - ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); - pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); - - return pulseAnimator; - } } diff --git a/core/java/android/widget/YearPickerView.java b/core/java/android/widget/YearPickerView.java index 94c21dc..2bf07f9 100644 --- a/core/java/android/widget/YearPickerView.java +++ b/core/java/android/widget/YearPickerView.java @@ -70,15 +70,6 @@ class YearPickerView extends ListView implements AdapterView.OnItemClickListener R.dimen.datepicker_year_picker_padding_top); setPadding(0, paddingTop, 0, 0); - // Use Theme attributes if possible - final TypedArray a = context.obtainStyledAttributes( - attrs, R.styleable.DatePicker, defStyleAttr, defStyleRes); - final int colorResId = a.getResourceId(R.styleable.DatePicker_yearListSelectorColor, - R.color.datepicker_default_circle_background_color_holo_light); - mYearSelectedCircleColor = res.getColor(colorResId); - - a.recycle(); - setOnItemClickListener(this); setDividerHeight(0); } diff --git a/core/java/com/android/internal/app/ToolbarActionBar.java b/core/java/com/android/internal/app/ToolbarActionBar.java index 13eb182..abe8a9f 100644 --- a/core/java/com/android/internal/app/ToolbarActionBar.java +++ b/core/java/com/android/internal/app/ToolbarActionBar.java @@ -226,6 +226,11 @@ public class ToolbarActionBar extends ActionBar { } @Override + public void setWindowTitle(CharSequence title) { + mDecorToolbar.setWindowTitle(title); + } + + @Override public void setSubtitle(CharSequence subtitle) { mDecorToolbar.setSubtitle(subtitle); } diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java index b58e1db..a8f7bb3 100644 --- a/core/java/com/android/internal/app/WindowDecorActionBar.java +++ b/core/java/com/android/internal/app/WindowDecorActionBar.java @@ -431,6 +431,11 @@ public class WindowDecorActionBar extends ActionBar implements mDecorToolbar.setTitle(title); } + @Override + public void setWindowTitle(CharSequence title) { + mDecorToolbar.setWindowTitle(title); + } + public void setSubtitle(CharSequence subtitle) { mDecorToolbar.setSubtitle(subtitle); } diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index d35fce4..29ccb6a 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -338,10 +338,10 @@ public class RuntimeInit { * @param tag to record with the error * @param t exception describing the error site and conditions */ - public static void wtf(String tag, Throwable t) { + public static void wtf(String tag, Throwable t, boolean system) { try { if (ActivityManagerNative.getDefault().handleApplicationWtf( - mApplicationObject, tag, new ApplicationErrorReport.CrashInfo(t))) { + mApplicationObject, tag, system, new ApplicationErrorReport.CrashInfo(t))) { // The Activity Manager has already written us off -- now exit. Process.killProcess(Process.myPid()); System.exit(10); diff --git a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java index 5da5ae9..250bbac 100644 --- a/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java +++ b/core/java/com/android/internal/widget/ToolbarWidgetWrapper.java @@ -162,6 +162,8 @@ public class ToolbarWidgetWrapper implements DecorToolbar { } a.recycle(); + } else { + mDisplayOpts = detectDisplayOptions(); } if (TextUtils.isEmpty(mToolbar.getNavigationContentDescription())) { @@ -181,6 +183,15 @@ public class ToolbarWidgetWrapper implements DecorToolbar { }); } + private int detectDisplayOptions() { + int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | + ActionBar.DISPLAY_USE_LOGO; + if (mToolbar.getNavigationIcon() != null) { + opts |= ActionBar.DISPLAY_HOME_AS_UP; + } + return opts; + } + @Override public ViewGroup getViewGroup() { return mToolbar; |
