diff options
Diffstat (limited to 'core/java')
28 files changed, 199 insertions, 395 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 9968dbb..49f5099 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -3841,10 +3841,7 @@ public class Activity extends ContextThemeWrapper mStartedActivity = true; } - final View decor = mWindow != null ? mWindow.peekDecorView() : null; - if (decor != null) { - decor.cancelPendingInputEvents(); - } + cancelInputsAndStartExitTransition(options); // TODO Consider clearing/flushing other event sources and events for child windows. } else { if (options != null) { @@ -3855,6 +3852,18 @@ public class Activity extends ContextThemeWrapper mParent.startActivityFromChild(this, intent, requestCode); } } + } + + /** + * Cancels pending inputs and if an Activity Transition is to be run, starts the transition. + * + * @param options The ActivityOptions bundle used to start an Activity. + */ + private void cancelInputsAndStartExitTransition(Bundle options) { + final View decor = mWindow != null ? mWindow.peekDecorView() : null; + if (decor != null) { + decor.cancelPendingInputEvents(); + } if (options != null && !isTopOfTask()) { mActivityTransitionState.startExitOutTransition(this, options); } @@ -3872,9 +3881,6 @@ public class Activity extends ContextThemeWrapper */ public void startActivityForResultAsUser(Intent intent, int requestCode, @Nullable Bundle options, UserHandle user) { - if (options != null) { - mActivityTransitionState.startExitOutTransition(this, options); - } if (mParent != null) { throw new RuntimeException("Can't be called from a child"); } @@ -3896,10 +3902,7 @@ public class Activity extends ContextThemeWrapper mStartedActivity = true; } - final View decor = mWindow != null ? mWindow.peekDecorView() : null; - if (decor != null) { - decor.cancelPendingInputEvents(); - } + cancelInputsAndStartExitTransition(options); } /** @@ -3925,6 +3928,7 @@ public class Activity extends ContextThemeWrapper mToken, mEmbeddedID, -1, ar.getResultCode(), ar.getResultData()); } + cancelInputsAndStartExitTransition(options); } /** @@ -3948,6 +3952,7 @@ public class Activity extends ContextThemeWrapper mToken, mEmbeddedID, -1, ar.getResultCode(), ar.getResultData()); } + cancelInputsAndStartExitTransition(options); } /** @@ -4380,6 +4385,7 @@ public class Activity extends ContextThemeWrapper mToken, child.mEmbeddedID, requestCode, ar.getResultCode(), ar.getResultData()); } + cancelInputsAndStartExitTransition(options); } /** @@ -4431,9 +4437,6 @@ public class Activity extends ContextThemeWrapper @Override public void startActivityForResult( String who, Intent intent, int requestCode, @Nullable Bundle options) { - if (options != null) { - mActivityTransitionState.startExitOutTransition(this, options); - } Instrumentation.ActivityResult ar = mInstrumentation.execStartActivity( this, mMainThread.getApplicationThread(), mToken, who, @@ -4443,6 +4446,7 @@ public class Activity extends ContextThemeWrapper mToken, who, requestCode, ar.getResultCode(), ar.getResultData()); } + cancelInputsAndStartExitTransition(options); } /** diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index bde8f39..40eb799 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -17,6 +17,7 @@ package android.app; import android.annotation.NonNull; +import android.content.ComponentName; /** * Activity manager local system service interface. @@ -48,4 +49,10 @@ public abstract class ActivityManagerInternal { */ public abstract void release(); } + + /** + * Returns home activity for the specified user. + * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL} + */ + public abstract ComponentName getHomeActivityForUser(int userId); } diff --git a/core/java/android/app/ActivityTransitionCoordinator.java b/core/java/android/app/ActivityTransitionCoordinator.java index 968c956..fa81412 100644 --- a/core/java/android/app/ActivityTransitionCoordinator.java +++ b/core/java/android/app/ActivityTransitionCoordinator.java @@ -31,6 +31,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewGroupOverlay; import android.view.ViewParent; +import android.view.ViewRootImpl; import android.view.ViewTreeObserver; import android.view.Window; import android.widget.ImageView; @@ -187,11 +188,6 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { */ public static final int MSG_SHARED_ELEMENT_DESTINATION = 107; - /** - * Send the shared element positions. - */ - public static final int MSG_SEND_SHARED_ELEMENT_DESTINATION = 108; - private Window mWindow; final protected ArrayList<String> mAllSharedElementNames; final protected ArrayList<View> mSharedElements = new ArrayList<View>(); @@ -207,6 +203,8 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { new ArrayList<GhostViewListeners>(); private ArrayMap<View, Float> mOriginalAlphas = new ArrayMap<View, Float>(); private ArrayList<Matrix> mSharedElementParentMatrices; + private boolean mSharedElementTransitionComplete; + private boolean mViewsTransitionComplete; public ActivityTransitionCoordinator(Window window, ArrayList<String> allSharedElementNames, @@ -219,6 +217,11 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { } protected void viewsReady(ArrayMap<String, View> sharedElements) { + final View decor = getDecor(); + final ViewRootImpl viewRoot = decor == null ? null : decor.getViewRootImpl(); + if (viewRoot != null) { + viewRoot.setPausedForTransition(true); + } sharedElements.retainAll(mAllSharedElementNames); if (mListener != null) { mListener.onMapSharedElements(mAllSharedElementNames, sharedElements); @@ -878,6 +881,32 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver { } } + protected boolean isViewsTransitionComplete() { + return mViewsTransitionComplete; + } + + protected void viewsTransitionComplete() { + mViewsTransitionComplete = true; + startInputWhenTransitionsComplete(); + } + + protected void sharedElementTransitionComplete() { + mSharedElementTransitionComplete = true; + startInputWhenTransitionsComplete(); + } + private void startInputWhenTransitionsComplete() { + if (mViewsTransitionComplete && mSharedElementTransitionComplete) { + final View decor = getDecor(); + if (decor != null) { + final ViewRootImpl viewRoot = decor.getViewRootImpl(); + viewRoot.setPausedForTransition(false); + } + onTransitionsComplete(); + } + } + + protected void onTransitionsComplete() {} + protected class ContinueTransitionListener extends Transition.TransitionListenerAdapter { @Override public void onTransitionStart(Transition transition) { diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 5aa399b..7104185 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -606,7 +606,7 @@ public class AppOpsManager { UserManager.DISALLOW_CREATE_WINDOWS, //SYSTEM_ALERT_WINDOW null, //ACCESS_NOTIFICATIONS null, //CAMERA - null, //RECORD_AUDIO + UserManager.DISALLOW_RECORD_AUDIO, //RECORD_AUDIO null, //PLAY_AUDIO null, //READ_CLIPBOARD null, //WRITE_CLIPBOARD diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 90293a4..07eee12 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -1571,9 +1571,15 @@ final class ApplicationPackageManager extends PackageManager { final VolumeInfo currentVol = getPrimaryStorageCurrentVolume(); final List<VolumeInfo> vols = storage.getVolumes(); final List<VolumeInfo> candidates = new ArrayList<>(); - for (VolumeInfo vol : vols) { - if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) { - candidates.add(vol); + if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL, + storage.getPrimaryStorageUuid()) && currentVol != null) { + // TODO: support moving primary physical to emulated volume + candidates.add(currentVol); + } else { + for (VolumeInfo vol : vols) { + if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) { + candidates.add(vol); + } } } return candidates; @@ -1590,12 +1596,7 @@ final class ApplicationPackageManager extends PackageManager { return false; } - // We can move to public volumes on legacy devices - if ((vol.getType() == VolumeInfo.TYPE_PUBLIC) && vol.getDisk().isDefaultPrimary()) { - return true; - } - - // Otherwise we can move to any private volume + // We can move to any private volume return (vol.getType() == VolumeInfo.TYPE_PRIVATE); } diff --git a/core/java/android/app/EnterTransitionCoordinator.java b/core/java/android/app/EnterTransitionCoordinator.java index e84a8da..4db4be0 100644 --- a/core/java/android/app/EnterTransitionCoordinator.java +++ b/core/java/android/app/EnterTransitionCoordinator.java @@ -55,8 +55,6 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator { private boolean mWasOpaque; private boolean mAreViewsReady; private boolean mIsViewsTransitionStarted; - private boolean mIsViewsTransitionComplete; - private boolean mIsSharedElementTransitionComplete; private Transition mEnterViewsTransition; public EnterTransitionCoordinator(Activity activity, ResultReceiver resultReceiver, @@ -456,7 +454,7 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator { } } if (viewsTransition == null) { - viewTransitionComplete(); + viewsTransitionComplete(); } else { viewsTransition.forceVisibility(View.INVISIBLE, true); final ArrayList<View> transitioningViews = mTransitioningViews; @@ -474,7 +472,7 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator { public void onTransitionEnd(Transition transition) { mEnterViewsTransition = null; transition.removeListener(this); - viewTransitionComplete(); + viewsTransitionComplete(); super.onTransitionEnd(transition); } }); @@ -497,18 +495,9 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator { return transition; } - private void viewTransitionComplete() { - mIsViewsTransitionComplete = true; - if (mIsSharedElementTransitionComplete) { - moveSharedElementsFromOverlay(); - } - } - - private void sharedElementTransitionComplete() { - mIsSharedElementTransitionComplete = true; - if (mIsViewsTransitionComplete) { - moveSharedElementsFromOverlay(); - } + @Override + protected void onTransitionsComplete() { + moveSharedElementsFromOverlay(); } private void sharedElementTransitionStarted() { diff --git a/core/java/android/app/ExitTransitionCoordinator.java b/core/java/android/app/ExitTransitionCoordinator.java index 0f286fb..9ddebb0 100644 --- a/core/java/android/app/ExitTransitionCoordinator.java +++ b/core/java/android/app/ExitTransitionCoordinator.java @@ -46,8 +46,6 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { private static final String TAG = "ExitTransitionCoordinator"; private static final long MAX_WAIT_MS = 1000; - private boolean mExitComplete; - private Bundle mSharedElementBundle; private boolean mExitNotified; @@ -165,7 +163,7 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { @Override public void onTransitionEnd(Transition transition) { transition.removeListener(this); - if (mExitComplete) { + if (isViewsTransitionComplete()) { delayCancel(); } } @@ -310,14 +308,14 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { viewsTransition = configureTransition(getViewsTransition(), true); } if (viewsTransition == null) { - exitTransitionComplete(); + viewsTransitionComplete(); } else { final ArrayList<View> transitioningViews = mTransitioningViews; viewsTransition.addListener(new ContinueTransitionListener() { @Override public void onTransitionEnd(Transition transition) { transition.removeListener(this); - exitTransitionComplete(); + viewsTransitionComplete(); if (mIsHidden && transitioningViews != null) { showViews(transitioningViews, true); } @@ -373,19 +371,15 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { } } - private void exitTransitionComplete() { - mExitComplete = true; - notifyComplete(); - } - protected boolean isReadyToNotify() { return mSharedElementBundle != null && mResultReceiver != null && mIsBackgroundReady; } - private void sharedElementTransitionComplete() { + @Override + protected void sharedElementTransitionComplete() { mSharedElementBundle = mExitSharedElementBundle == null ? captureSharedElementState() : captureExitSharedElementsState(); - notifyComplete(); + super.sharedElementTransitionComplete(); } private Bundle captureExitSharedElementsState() { @@ -405,6 +399,11 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { return bundle; } + @Override + protected void onTransitionsComplete() { + notifyComplete(); + } + protected void notifyComplete() { if (isReadyToNotify()) { if (!mSharedElementNotified) { @@ -433,7 +432,7 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator { } private void notifyExitComplete() { - if (!mExitNotified && mExitComplete) { + if (!mExitNotified && isViewsTransitionComplete()) { mExitNotified = true; mResultReceiver.send(MSG_EXIT_TRANSITION_COMPLETE, null); mResultReceiver = null; // done talking diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 391131a..0d00908 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -55,7 +55,6 @@ import android.location.CountryDetector; import android.location.ICountryDetector; import android.location.ILocationManager; import android.location.LocationManager; -import android.media.AudioDevicesManager; import android.media.AudioManager; import android.media.MediaRouter; import android.media.midi.IMidiManager; @@ -701,13 +700,6 @@ final class SystemServiceRegistry { public RadioManager createService(ContextImpl ctx) { return new RadioManager(ctx); }}); - - registerService(Context.AUDIO_DEVICES_SERVICE, AudioDevicesManager.class, - new CachedServiceFetcher<AudioDevicesManager>() { - @Override - public AudioDevicesManager createService(ContextImpl ctx) { - return new AudioDevicesManager(ctx); - }}); } /** @@ -726,7 +718,7 @@ final class SystemServiceRegistry { } /** - * Gets the name of the system-level service that is represented by the specified class. + * Gets the name of the system-level service that is represented by the specified class. */ public static String getSystemServiceName(Class<?> serviceClass) { return SYSTEM_SERVICE_NAMES.get(serviceClass); diff --git a/core/java/android/app/usage/IUsageStatsManager.aidl b/core/java/android/app/usage/IUsageStatsManager.aidl index 23659e3..254408a 100644 --- a/core/java/android/app/usage/IUsageStatsManager.aidl +++ b/core/java/android/app/usage/IUsageStatsManager.aidl @@ -30,6 +30,6 @@ interface IUsageStatsManager { ParceledListSlice queryConfigurationStats(int bucketType, long beginTime, long endTime, String callingPackage); UsageEvents queryEvents(long beginTime, long endTime, String callingPackage); - void setAppIdle(String packageName, boolean idle, int userId); - boolean isAppIdle(String packageName, int userId); + void setAppInactive(String packageName, boolean inactive, int userId); + boolean isAppInactive(String packageName, int userId); } diff --git a/core/java/android/app/usage/UsageStatsManager.java b/core/java/android/app/usage/UsageStatsManager.java index 8a01d66..c74bbdd 100644 --- a/core/java/android/app/usage/UsageStatsManager.java +++ b/core/java/android/app/usage/UsageStatsManager.java @@ -220,15 +220,15 @@ public final class UsageStatsManager { } /** - * Returns whether the specified app is currently considered idle. This will be true if the + * Returns whether the specified app is currently considered inactive. This will be true if the * app hasn't been used directly or indirectly for a period of time defined by the system. This * could be of the order of several hours or days. * @param packageName The package name of the app to query - * @return whether the app is currently considered idle + * @return whether the app is currently considered inactive */ - public boolean isAppIdle(String packageName) { + public boolean isAppInactive(String packageName) { try { - return mService.isAppIdle(packageName, UserHandle.myUserId()); + return mService.isAppInactive(packageName, UserHandle.myUserId()); } catch (RemoteException e) { // fall through and return default } diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 8687c6b..6a98950 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -3133,16 +3133,6 @@ public abstract class Context { public static final String RADIO_SERVICE = "radio"; /** - * Use with {@link #getSystemService} to retrieve a - * {@link android.media.AudioDevicesManager} for handling device enumeration & notification. - * - * @see #getSystemService - * @see android.media.AudioDevicesManager - */ - public static final String AUDIO_DEVICES_SERVICE = "audio_devices_manager"; - - - /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. * diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index d0298cd..6f543a8 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2589,21 +2589,6 @@ public class Intent implements Parcelable, Cloneable { "android.intent.action.GET_RESTRICTION_ENTRIES"; /** - * @hide - * Activity to challenge the user for a PIN that was configured when setting up - * restrictions. Restrictions include blocking of apps and preventing certain user operations, - * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle). - * Launch the activity using - * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the - * result is {@link android.app.Activity#RESULT_OK} for a successful response to the - * challenge.<p/> - * Before launching this activity, make sure that there is a PIN in effect, by calling - * {@link android.os.UserManager#hasRestrictionsChallenge()}. - */ - public static final String ACTION_RESTRICTIONS_CHALLENGE = - "android.intent.action.RESTRICTIONS_CHALLENGE"; - - /** * Sent the first time a user is starting, to allow system apps to * perform one time initialization. (This will not be seen by third * party applications because a newly initialized user does not have any diff --git a/core/java/android/hardware/usb/IUsbManager.aidl b/core/java/android/hardware/usb/IUsbManager.aidl index 9bc967f..e4ab3f2 100644 --- a/core/java/android/hardware/usb/IUsbManager.aidl +++ b/core/java/android/hardware/usb/IUsbManager.aidl @@ -85,9 +85,6 @@ interface IUsbManager /* Sets the current USB function. */ void setCurrentFunction(String function, boolean makeDefault); - /* Sets the file path for USB mass storage backing file. */ - void setMassStorageBackingFile(String path); - /* Allow USB debugging from the attached host. If alwaysAllow is true, add the * the public key to list of host keys that the user has approved. */ diff --git a/core/java/android/hardware/usb/UsbManager.java b/core/java/android/hardware/usb/UsbManager.java index f283051..a45d4ca 100644 --- a/core/java/android/hardware/usb/UsbManager.java +++ b/core/java/android/hardware/usb/UsbManager.java @@ -410,28 +410,6 @@ public class UsbManager { } } - private static boolean propertyContainsFunction(String property, String function) { - String functions = SystemProperties.get(property, ""); - int index = functions.indexOf(function); - if (index < 0) return false; - if (index > 0 && functions.charAt(index - 1) != ',') return false; - int charAfter = index + function.length(); - if (charAfter < functions.length() && functions.charAt(charAfter) != ',') return false; - return true; - } - - /** - * Returns true if the specified USB function is currently enabled. - * - * @param function name of the USB function - * @return true if the USB function is enabled. - * - * {@hide} - */ - public boolean isFunctionEnabled(String function) { - return propertyContainsFunction("sys.usb.config", function); - } - /** * Returns the current default USB function. * @@ -465,19 +443,4 @@ public class UsbManager { Log.e(TAG, "RemoteException in setCurrentFunction", e); } } - - /** - * Sets the file path for USB mass storage backing file. - * - * @param path backing file path - * - * {@hide} - */ - public void setMassStorageBackingFile(String path) { - try { - mService.setMassStorageBackingFile(path); - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in setDefaultFunction", e); - } - } } diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index c2fd3c3..f212daf 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -45,13 +45,12 @@ interface IUserManager { Bundle getUserRestrictions(int userHandle); boolean hasUserRestriction(in String restrictionKey, int userHandle); void setUserRestrictions(in Bundle restrictions, int userHandle); + void setUserRestriction(String key, boolean value, int userId); + void setSystemControlledUserRestriction(String key, boolean value, int userId); void setApplicationRestrictions(in String packageName, in Bundle restrictions, int userHandle); Bundle getApplicationRestrictions(in String packageName); Bundle getApplicationRestrictionsForUser(in String packageName, int userHandle); - boolean setRestrictionsChallenge(in String newPin); - int checkRestrictionsChallenge(in String pin); - boolean hasRestrictionsChallenge(); void removeRestrictions(); void setDefaultGuestRestrictions(in Bundle restrictions); Bundle getDefaultGuestRestrictions(); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 44eb1ed..cc37d5e 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -412,6 +412,16 @@ public class UserManager { public static final String DISALLOW_SAFE_BOOT = "no_safe_boot"; /** + * Specifies if a user is not allowed to record audio. This restriction is always enabled for + * background users. The default value is <code>false</code>. + * + * @see #setUserRestrictions(Bundle) + * @see #getUserRestrictions() + * @hide + */ + public static final String DISALLOW_RECORD_AUDIO = "no_record_audio"; + + /** * Application restriction key that is used to indicate the pending arrival * of real restrictions for the app. * @@ -688,9 +698,11 @@ public class UserManager { */ @Deprecated public void setUserRestriction(String key, boolean value, UserHandle userHandle) { - Bundle bundle = getUserRestrictions(userHandle); - bundle.putBoolean(key, value); - setUserRestrictions(bundle, userHandle); + try { + mService.setUserRestriction(key, value, userHandle.getIdentifier()); + } catch (RemoteException re) { + Log.w(TAG, "Could not set user restriction", re); + } } /** @@ -744,7 +756,7 @@ public class UserManager { * @see #getSerialNumberForUser(UserHandle) */ public UserHandle getUserForSerialNumber(long serialNumber) { - int ident = getUserHandle((int)serialNumber); + int ident = getUserHandle((int) serialNumber); return ident >= 0 ? new UserHandle(ident) : null; } @@ -1252,49 +1264,10 @@ public class UserManager { * apps and requires the MANAGE_USERS permission. * @param newPin the PIN to use for challenge dialogs. * @return Returns true if the challenge PIN was set successfully. + * @deprecated The restrictions PIN functionality is no longer provided by the system. + * This method is preserved for backwards compatibility reasons and always returns false. */ public boolean setRestrictionsChallenge(String newPin) { - try { - return mService.setRestrictionsChallenge(newPin); - } catch (RemoteException re) { - Log.w(TAG, "Could not change restrictions pin"); - } - return false; - } - - /** - * @hide - * @param pin The PIN to verify, or null to get the number of milliseconds to wait for before - * allowing the user to enter the PIN. - * @return Returns a positive number (including zero) for how many milliseconds before - * you can accept another PIN, when the input is null or the input doesn't match the saved PIN. - * Returns {@link #PIN_VERIFICATION_SUCCESS} if the input matches the saved PIN. Returns - * {@link #PIN_VERIFICATION_FAILED_NOT_SET} if there is no PIN set. - */ - public int checkRestrictionsChallenge(String pin) { - try { - return mService.checkRestrictionsChallenge(pin); - } catch (RemoteException re) { - Log.w(TAG, "Could not check restrictions pin"); - } - return PIN_VERIFICATION_FAILED_INCORRECT; - } - - /** - * @hide - * Checks whether the user has restrictions that are PIN-protected. An application that - * participates in restrictions can check if the owner has requested a PIN challenge for - * any restricted operations. If there is a PIN in effect, the application should launch - * the PIN challenge activity {@link android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE}. - * @see android.content.Intent#ACTION_RESTRICTIONS_CHALLENGE - * @return whether a restrictions PIN is in effect. - */ - public boolean hasRestrictionsChallenge() { - try { - return mService.hasRestrictionsChallenge(); - } catch (RemoteException re) { - Log.w(TAG, "Could not change restrictions pin"); - } return false; } diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java index 68ad782..3781d40 100644 --- a/core/java/android/view/AccessibilityInteractionController.java +++ b/core/java/android/view/AccessibilityInteractionController.java @@ -586,7 +586,7 @@ final class AccessibilityInteractionController { } } - private void perfromAccessibilityActionUiThread(Message message) { + private void performAccessibilityActionUiThread(Message message) { final int flags = message.arg1; final int accessibilityViewId = message.arg2; @@ -602,7 +602,8 @@ final class AccessibilityInteractionController { boolean succeeded = false; try { - if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) { + if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null || + mViewRootImpl.mStopped || mViewRootImpl.mPausedForTransition) { return; } mViewRootImpl.mAttachInfo.mAccessibilityFetchFlags = flags; @@ -1146,7 +1147,7 @@ final class AccessibilityInteractionController { findAccessibilityNodeInfoByAccessibilityIdUiThread(message); } break; case MSG_PERFORM_ACCESSIBILITY_ACTION: { - perfromAccessibilityActionUiThread(message); + performAccessibilityActionUiThread(message); } break; case MSG_FIND_ACCESSIBILITY_NODE_INFOS_BY_VIEW_ID: { findAccessibilityNodeInfosByViewIdUiThread(message); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index ea1dadb..57c6cbf 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -174,6 +174,9 @@ public final class ViewRootImpl implements ViewParent, // so the window should no longer be active. boolean mStopped = false; + // Set to true to stop input during an Activity Transition. + boolean mPausedForTransition = false; + boolean mLastInCompatMode = false; SurfaceHolder.Callback2 mSurfaceHolderCallback; @@ -982,15 +985,25 @@ public final class ViewRootImpl implements ViewParent, return null; } - void setStopped(boolean stopped) { + void setWindowStopped(boolean stopped) { if (mStopped != stopped) { mStopped = stopped; - if (!stopped) { + if (!mStopped) { scheduleTraversals(); } } } + /** + * Block the input events during an Activity Transition. The KEYCODE_BACK event is allowed + * through to allow quick reversal of the Activity Transition. + * + * @param paused true to pause, false to resume. + */ + public void setPausedForTransition(boolean paused) { + mPausedForTransition = paused; + } + @Override public ViewParent getParent() { return null; @@ -3637,8 +3650,9 @@ public final class ViewRootImpl implements ViewParent, if (mView == null || !mAdded) { Slog.w(TAG, "Dropping event due to root view being removed: " + q.mEvent); return true; - } else if ((!mAttachInfo.mHasWindowFocus || mStopped) - && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { + } else if ((!mAttachInfo.mHasWindowFocus + && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) || mStopped + || (mPausedForTransition && !isBack(q.mEvent))) { // This is a focus event and the window doesn't currently have input focus or // has stopped. This could be an event that came back from the previous stage // but the window has lost focus or stopped in the meantime. @@ -3661,6 +3675,14 @@ public final class ViewRootImpl implements ViewParent, mNext.dump(prefix, writer); } } + + private boolean isBack(InputEvent event) { + if (event instanceof KeyEvent) { + return ((KeyEvent) event).getKeyCode() == KeyEvent.KEYCODE_BACK; + } else { + return false; + } + } } /** @@ -6228,7 +6250,7 @@ public final class ViewRootImpl implements ViewParent, @Override public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event) { - if (mView == null) { + if (mView == null || mStopped || mPausedForTransition) { return false; } // Intercept accessibility focus events fired by virtual nodes to keep diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index 57558ff..e7a7ba8 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -21,7 +21,6 @@ import android.app.ActivityManager; import android.content.ComponentCallbacks2; import android.content.Context; import android.content.res.Configuration; -import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; @@ -552,7 +551,7 @@ public final class WindowManagerGlobal { for (int i = 0; i < count; i++) { if (token == null || mParams.get(i).token == token) { ViewRootImpl root = mRoots.get(i); - root.setStopped(stopped); + root.setWindowStopped(stopped); } } } diff --git a/core/java/android/widget/CalendarViewLegacyDelegate.java b/core/java/android/widget/CalendarViewLegacyDelegate.java index 6ab3828..442fb33 100644 --- a/core/java/android/widget/CalendarViewLegacyDelegate.java +++ b/core/java/android/widget/CalendarViewLegacyDelegate.java @@ -713,7 +713,7 @@ class CalendarViewLegacyDelegate extends CalendarView.AbstractCalendarViewDelega for (int i = 1, count = mDayNamesHeader.getChildCount(); i < count; i++) { label = (TextView) mDayNamesHeader.getChildAt(i); if (mWeekDayTextAppearanceResId > -1) { - label.setTextAppearance(mContext, mWeekDayTextAppearanceResId); + label.setTextAppearance(mWeekDayTextAppearanceResId); } if (i < mDaysPerWeek + 1) { label.setText(mDayNamesShort[i - 1]); diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 78c418b..4fd85b6 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -2055,7 +2055,7 @@ public class Editor { shadowView.setText(text); shadowView.setTextColor(mTextView.getTextColors()); - shadowView.setTextAppearance(mTextView.getContext(), R.styleable.Theme_textAppearanceLarge); + shadowView.setTextAppearance(R.styleable.Theme_textAppearanceLarge); shadowView.setGravity(Gravity.CENTER); shadowView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, diff --git a/core/java/android/widget/Toolbar.java b/core/java/android/widget/Toolbar.java index 087406a..62d948d 100644 --- a/core/java/android/widget/Toolbar.java +++ b/core/java/android/widget/Toolbar.java @@ -590,7 +590,7 @@ public class Toolbar extends ViewGroup { mTitleTextView.setSingleLine(); mTitleTextView.setEllipsize(TextUtils.TruncateAt.END); if (mTitleTextAppearance != 0) { - mTitleTextView.setTextAppearance(context, mTitleTextAppearance); + mTitleTextView.setTextAppearance(mTitleTextAppearance); } if (mTitleTextColor != 0) { mTitleTextView.setTextColor(mTitleTextColor); @@ -644,7 +644,7 @@ public class Toolbar extends ViewGroup { mSubtitleTextView.setSingleLine(); mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END); if (mSubtitleTextAppearance != 0) { - mSubtitleTextView.setTextAppearance(context, mSubtitleTextAppearance); + mSubtitleTextView.setTextAppearance(mSubtitleTextAppearance); } if (mSubtitleTextColor != 0) { mSubtitleTextView.setTextColor(mSubtitleTextColor); @@ -670,7 +670,7 @@ public class Toolbar extends ViewGroup { public void setTitleTextAppearance(Context context, @StyleRes int resId) { mTitleTextAppearance = resId; if (mTitleTextView != null) { - mTitleTextView.setTextAppearance(context, resId); + mTitleTextView.setTextAppearance(resId); } } @@ -681,7 +681,7 @@ public class Toolbar extends ViewGroup { public void setSubtitleTextAppearance(Context context, @StyleRes int resId) { mSubtitleTextAppearance = resId; if (mSubtitleTextView != null) { - mSubtitleTextView.setTextAppearance(context, resId); + mSubtitleTextView.setTextAppearance(resId); } } diff --git a/core/java/com/android/internal/app/RestrictionsPinActivity.java b/core/java/com/android/internal/app/RestrictionsPinActivity.java deleted file mode 100644 index 66585c6..0000000 --- a/core/java/com/android/internal/app/RestrictionsPinActivity.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2013 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.internal.app; - -import android.content.Context; -import android.os.Bundle; -import android.os.UserManager; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -import com.android.internal.R; - -/** - * This activity is launched by Settings and other apps to either create a new PIN or - * challenge for an existing PIN. The PIN is maintained by UserManager. - */ -public class RestrictionsPinActivity extends AlertActivity - implements OnClickListener, TextWatcher, OnEditorActionListener { - - protected UserManager mUserManager; - protected boolean mHasRestrictionsPin; - - protected EditText mPinText; - protected TextView mPinErrorMessage; - private Button mOkButton; - private Button mCancelButton; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); - mHasRestrictionsPin = mUserManager.hasRestrictionsChallenge(); - initUi(); - setupAlert(); - } - - protected void initUi() { - AlertController.AlertParams ap = mAlertParams; - ap.mTitle = getString(R.string.restr_pin_enter_admin_pin); - LayoutInflater inflater = - (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - ap.mView = inflater.inflate(R.layout.restrictions_pin_challenge, null); - - mPinErrorMessage = (TextView) ap.mView.findViewById(R.id.pin_error_message); - mPinText = (EditText) ap.mView.findViewById(R.id.pin_text); - mOkButton = (Button) ap.mView.findViewById(R.id.pin_ok_button); - mCancelButton = (Button) ap.mView.findViewById(R.id.pin_cancel_button); - - mPinText.addTextChangedListener(this); - - mOkButton.setOnClickListener(this); - mCancelButton.setOnClickListener(this); - } - - protected boolean verifyingPin() { - return true; - } - - public void onResume() { - super.onResume(); - - setPositiveButtonState(false); - boolean hasPin = mUserManager.hasRestrictionsChallenge(); - if (hasPin) { - mPinErrorMessage.setVisibility(View.INVISIBLE); - mPinText.setOnEditorActionListener(this); - updatePinTimer(-1); - } else if (verifyingPin()) { - setResult(RESULT_OK); - finish(); - } - } - - protected void setPositiveButtonState(boolean enabled) { - mOkButton.setEnabled(enabled); - } - - private boolean updatePinTimer(int pinTimerMs) { - if (pinTimerMs < 0) { - pinTimerMs = mUserManager.checkRestrictionsChallenge(null); - } - boolean enableInput; - if (pinTimerMs >= 200) { - // Do the count down timer for less than a minute, otherwise just say try again later. - if (pinTimerMs <= 60000) { - final int seconds = (pinTimerMs + 200) / 1000; - final String formatString = getResources().getQuantityString( - R.plurals.restr_pin_countdown, - seconds); - mPinErrorMessage.setText(String.format(formatString, seconds)); - } else { - mPinErrorMessage.setText(R.string.restr_pin_try_later); - } - enableInput = false; - mPinErrorMessage.setVisibility(View.VISIBLE); - mPinText.setText(""); - mPinText.postDelayed(mCountdownRunnable, Math.min(1000, pinTimerMs)); - } else { - enableInput = true; - mPinErrorMessage.setText(R.string.restr_pin_incorrect); - } - mPinText.setEnabled(enableInput); - setPositiveButtonState(enableInput); - return enableInput; - } - - protected void performPositiveButtonAction() { - int result = mUserManager.checkRestrictionsChallenge(mPinText.getText().toString()); - if (result == UserManager.PIN_VERIFICATION_SUCCESS) { - setResult(RESULT_OK); - finish(); - } else if (result >= 0) { - mPinErrorMessage.setText(R.string.restr_pin_incorrect); - mPinErrorMessage.setVisibility(View.VISIBLE); - updatePinTimer(result); - mPinText.setText(""); - } - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - CharSequence pin = mPinText.getText(); - setPositiveButtonState(pin != null && pin.length() >= 4); - } - - @Override - public void afterTextChanged(Editable s) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - performPositiveButtonAction(); - return true; - } - - private Runnable mCountdownRunnable = new Runnable() { - public void run() { - if (updatePinTimer(-1)) { - // If we are no longer counting down, clear the message. - mPinErrorMessage.setVisibility(View.INVISIBLE); - } - } - }; - - @Override - public void onClick(View v) { - if (v == mOkButton) { - performPositiveButtonAction(); - } else if (v == mCancelButton) { - setResult(RESULT_CANCELED); - finish(); - } - } -} diff --git a/core/java/com/android/internal/logging/MetricsLogger.java b/core/java/com/android/internal/logging/MetricsLogger.java index 9277f9b..cf25cef 100644 --- a/core/java/com/android/internal/logging/MetricsLogger.java +++ b/core/java/com/android/internal/logging/MetricsLogger.java @@ -27,7 +27,6 @@ import android.view.View; */ public class MetricsLogger implements MetricsConstants { // These constants are temporary, they should migrate to MetricsConstants. - // next value is 148; public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144; public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145; @@ -38,6 +37,34 @@ public class MetricsLogger implements MetricsConstants { public static final int QS_BLUETOOTH_DETAILS = 150; public static final int QS_CAST_DETAILS = 151; public static final int QS_WIFI_DETAILS = 152; + public static final int QS_WIFI_TOGGLE = 153; + public static final int QS_BLUETOOTH_TOGGLE = 154; + public static final int QS_CELLULAR_TOGGLE = 155; + public static final int QS_SWITCH_USER = 156; + public static final int QS_CAST_SELECT = 157; + public static final int QS_CAST_DISCONNECT = 158; + public static final int ACTION_BLUETOOTH_TOGGLE = 159; + public static final int ACTION_BLUETOOTH_SCAN = 160; + public static final int ACTION_BLUETOOTH_RENAME = 161; + public static final int ACTION_BLUETOOTH_FILES = 162; + public static final int QS_DND_TIME = 163; + public static final int QS_DND_CONDITION_SELECT = 164; + public static final int QS_DND_ZEN_SELECT = 165; + public static final int QS_DND_TOGGLE = 166; + public static final int ACTION_ZEN_ALLOW_REMINDERS = 167; + public static final int ACTION_ZEN_ALLOW_EVENTS = 168; + public static final int ACTION_ZEN_ALLOW_MESSAGES = 169; + public static final int ACTION_ZEN_ALLOW_CALLS = 170; + public static final int ACTION_ZEN_ALLOW_REPEAT_CALLS = 171; + public static final int ACTION_ZEN_ADD_RULE = 172; + public static final int ACTION_ZEN_ADD_RULE_OK = 173; + public static final int ACTION_ZEN_DELETE_RULE = 174; + public static final int ACTION_ZEN_DELETE_RULE_OK = 175; + public static final int ACTION_ZEN_ENABLE_RULE = 176; + public static final int ACTION_AIRPLANE_TOGGLE = 177; + public static final int ACTION_CELL_DATA_TOGGLE = 178; + public static final int NOTIFICATION_ACCESS = 179; + public static final int NOTIFICATION_ZEN_MODE_ACCESS = 180; public static void visible(Context context, int category) throws IllegalArgumentException { if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) { @@ -71,6 +98,14 @@ public class MetricsLogger implements MetricsConstants { action(context, category, ""); } + public static void action(Context context, int category, int value) { + action(context, category, Integer.toString(value)); + } + + public static void action(Context context, int category, boolean value) { + action(context, category, Boolean.toString(value)); + } + public static void action(Context context, int category, String pkg) { if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) { throw new IllegalArgumentException("Must define metric category"); diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java index 2946456..106272b 100644 --- a/core/java/com/android/internal/widget/ActionBarContextView.java +++ b/core/java/com/android/internal/widget/ActionBarContextView.java @@ -192,10 +192,10 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title); mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle); if (mTitleStyleRes != 0) { - mTitleView.setTextAppearance(mContext, mTitleStyleRes); + mTitleView.setTextAppearance(mTitleStyleRes); } if (mSubtitleStyleRes != 0) { - mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + mSubtitleView.setTextAppearance(mSubtitleStyleRes); } } diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index 6b781c3..825e336 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -813,14 +813,14 @@ public class ActionBarView extends AbsActionBarView implements DecorToolbar { mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle); if (mTitleStyleRes != 0) { - mTitleView.setTextAppearance(mContext, mTitleStyleRes); + mTitleView.setTextAppearance(mTitleStyleRes); } if (mTitle != null) { mTitleView.setText(mTitle); } if (mSubtitleStyleRes != 0) { - mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes); + mSubtitleView.setTextAppearance(mSubtitleStyleRes); } if (mSubtitle != null) { mSubtitleView.setText(mSubtitle); diff --git a/core/java/com/android/internal/widget/FloatingToolbar.java b/core/java/com/android/internal/widget/FloatingToolbar.java index 3f7696f..f98fbfc 100644 --- a/core/java/com/android/internal/widget/FloatingToolbar.java +++ b/core/java/com/android/internal/widget/FloatingToolbar.java @@ -1247,9 +1247,13 @@ public final class FloatingToolbar { } private static int getAdjustedToolbarWidth(Context context, int width) { - if (width <= 0 || width > getScreenWidth(context)) { - width = context.getResources() - .getDimensionPixelSize(R.dimen.floating_toolbar_default_width); + int maximumWidth = getScreenWidth(context) - 2 * context.getResources() + .getDimensionPixelSize(R.dimen.floating_toolbar_horizontal_margin); + + if (width <= 0 || width > maximumWidth) { + int defaultWidth = context.getResources() + .getDimensionPixelSize(R.dimen.floating_toolbar_preferred_width); + width = Math.min(defaultWidth, maximumWidth); } return width; } diff --git a/core/java/com/android/server/BootReceiver.java b/core/java/com/android/server/BootReceiver.java index 155f5d3..92d5aea 100644 --- a/core/java/com/android/server/BootReceiver.java +++ b/core/java/com/android/server/BootReceiver.java @@ -144,10 +144,6 @@ public class BootReceiver extends BroadcastReceiver { -LOG_SIZE, "SYSTEM_RECOVERY_LOG"); addFileToDropBox(db, prefs, headers, "/cache/recovery/last_kmsg", -LOG_SIZE, "SYSTEM_RECOVERY_KMSG"); - addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_console", - -LOG_SIZE, "APANIC_CONSOLE"); - addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_threads", - -LOG_SIZE, "APANIC_THREADS"); addAuditErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_AUDIT"); addFsckErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_FSCK"); } else { |