diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index 77a777024a2..a37fc80d6ee 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -294,6 +294,13 @@ public class DownloadManager { */ public final static int PAUSED_UNKNOWN = 4; + /** + * Value of {@link #COLUMN_REASON} when the download is paused manually. + * + * @hide + */ + public final static int PAUSED_MANUAL = 5; + /** * Broadcast intent action sent by the download manager when a download completes. */ @@ -987,6 +994,7 @@ Cursor runQuery(ContentResolver resolver, String[] projection, Uri baseUri) { parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_TO_RETRY)); parts.add(statusClause("=", Downloads.Impl.STATUS_WAITING_FOR_NETWORK)); parts.add(statusClause("=", Downloads.Impl.STATUS_QUEUED_FOR_WIFI)); + parts.add(statusClause("=", Downloads.Impl.STATUS_PAUSED_MANUAL)); } if ((mStatusFlags & STATUS_SUCCESSFUL) != 0) { parts.add(statusClause("=", Downloads.Impl.STATUS_SUCCESS)); @@ -1245,6 +1253,34 @@ public void forceDownload(long... ids) { mResolver.update(mBaseUri, values, getWhereClauseForIds(ids), getWhereArgsForIds(ids)); } + /** + * Pause the given running download manually. + * + * @param id the ID of the download to be paused + * @return the number of downloads actually updated + * @hide + */ + public int pauseDownload(long id) { + ContentValues values = new ContentValues(); + values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_PAUSED_MANUAL); + + return mResolver.update(ContentUris.withAppendedId(mBaseUri, id), values, null, null); + } + + /** + * Resume the given paused download manually. + * + * @param id the ID of the download to be resumed + * @return the number of downloads actually updated + * @hide + */ + public int resumeDownload(long id) { + ContentValues values = new ContentValues(); + values.put(Downloads.Impl.COLUMN_STATUS, Downloads.Impl.STATUS_RUNNING); + + return mResolver.update(ContentUris.withAppendedId(mBaseUri, id), values, null, null); + } + /** * Returns maximum size, in bytes, of downloads that may go over a mobile connection; or null if * there's no limit @@ -1682,6 +1718,9 @@ private long getPausedReason(int status) { case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: return PAUSED_QUEUED_FOR_WIFI; + case Downloads.Impl.STATUS_PAUSED_MANUAL: + return PAUSED_MANUAL; + default: return PAUSED_UNKNOWN; } @@ -1737,6 +1776,7 @@ private int translateStatus(int status) { case Downloads.Impl.STATUS_WAITING_TO_RETRY: case Downloads.Impl.STATUS_WAITING_FOR_NETWORK: case Downloads.Impl.STATUS_QUEUED_FOR_WIFI: + case Downloads.Impl.STATUS_PAUSED_MANUAL: return STATUS_PAUSED; case Downloads.Impl.STATUS_SUCCESS: diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index c0c63555b10..42662dbf8b3 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -593,4 +593,9 @@ interface IActivityManager { * unlockProgressListener can be null if monitoring progress is not necessary. */ boolean startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener); + + /** + * Should disable touch if three fingers to screen shot is active? + */ + boolean isSwipeToScreenshotGestureActive(); } diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 5c6e77195bf..ba35816c634 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4424,6 +4424,21 @@ public static Intent createChooser(Intent target, CharSequence title, IntentSend @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; + /** + * Broadcast action: Camera satus Changed + * @hide + */ + public static final String ACTION_CAMERA_STATUS_CHANGED = + "android.intent.action.CAMERA_STATUS_CHANGED"; + + /** + * This field is part of the intent {@link #ACTION_CAMERA_STATUS_CHANGED}. + * Intent extra field for the state of changed camera state + * @hide + */ + public static final String EXTRA_CAMERA_STATE = + "android.intent.extra.CAMERA_STATE"; + // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 535a8bc9db7..0e71020d6ed 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -3666,11 +3666,7 @@ private boolean parseBaseApplication(Package owner, Resources res, ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE; } - if (sa.getBoolean( - R.styleable.AndroidManifestApplication_allowAudioPlaybackCapture, - owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q)) { - ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE; - } + ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE; if (sa.getBoolean( R.styleable.AndroidManifestApplication_requestLegacyExternalStorage, diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index d0622c88b4c..d96adaa9a84 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -927,13 +927,15 @@ private void cancelAuthentication(android.hardware.biometrics.CryptoObject crypt * @hide */ public static String getErrorString(Context context, int errMsg, int vendorCode) { + final String retry = context.getString( + com.android.internal.R.string.fingerprint_error_unable_to_process); + switch (errMsg) { case FINGERPRINT_ERROR_HW_UNAVAILABLE: return context.getString( com.android.internal.R.string.fingerprint_error_hw_not_available); case FINGERPRINT_ERROR_UNABLE_TO_PROCESS: - return context.getString( - com.android.internal.R.string.fingerprint_error_unable_to_process); + return retry; case FINGERPRINT_ERROR_TIMEOUT: return context.getString(com.android.internal.R.string.fingerprint_error_timeout); case FINGERPRINT_ERROR_NO_SPACE: @@ -964,7 +966,7 @@ public static String getErrorString(Context context, int errMsg, int vendorCode) } } Slog.w(TAG, "Invalid error message: " + errMsg + ", " + vendorCode); - return null; + return retry; } /** diff --git a/core/java/android/os/BaseBundle.java b/core/java/android/os/BaseBundle.java index 7f63f8fb9e2..bd94cef25b2 100644 --- a/core/java/android/os/BaseBundle.java +++ b/core/java/android/os/BaseBundle.java @@ -298,6 +298,13 @@ private void initializeFromParcelLocked(@NonNull Parcel parcelledData, boolean r } else { throw e; } + } catch (RuntimeException e) { + if (sShouldDefuse && (e.getCause() instanceof ClassNotFoundException)) { + Log.w(TAG, "Failed to parse Bundle, but defusing quietly", e); + map.erase(); + } else { + throw e; + } } finally { mMap = map; if (recycleParcel) { diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 176c2b7db05..75002bd96ad 100755 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -34,9 +34,14 @@ import dalvik.system.VMRuntime; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Information about the current build, extracted from system properties. @@ -62,6 +67,12 @@ public class Build { /** The name of the underlying board, like "goldfish". */ public static final String BOARD = getString("ro.product.board"); + /** + * The build date + * @hide + */ + public static final String DATE = getString("ro.build.date"); + /** * The name of the instruction set (CPU type + ABI convention) of native code. * @@ -995,6 +1006,7 @@ public static class VERSION_CODES { /** The type of build, like "user" or "eng". */ public static final String TYPE = getString("ro.build.type"); + private static String TYPE_FOR_APPS = parseBuildTypeFromFingerprint(); /** Comma-separated tags describing the build, like "unsigned,debug". */ public static final String TAGS = getString("ro.build.tags"); @@ -1021,6 +1033,42 @@ private static String deriveFingerprint() { return finger; } + // Some apps like to compare the build type embedded in fingerprint + // to the actual build type. As the fingerprint in our case is almost + // always hardcoded to the stock ROM fingerprint, provide that instead + // of the actual one if possible. + private static String parseBuildTypeFromFingerprint() { + final String fingerprint = SystemProperties.get("ro.build.fingerprint"); + if (TextUtils.isEmpty(fingerprint)) { + return null; + } + Pattern fingerprintPattern = + Pattern.compile("(.*)\\/(.*)\\/(.*):(.*)\\/(.*)\\/(.*):(.*)\\/(.*)"); + Matcher matcher = fingerprintPattern.matcher(fingerprint); + return matcher.matches() ? matcher.group(7) : null; + } + + /** @hide */ + public static void adjustBuildTypeIfNeeded() { + if (Process.isApplicationUid(Process.myUid()) && !TextUtils.isEmpty(TYPE_FOR_APPS)) { + try { + // This is sick. TYPE is final (which can't be changed because it's an API + // guarantee), but we have to reassign it. Resort to reflection to unset the + // final modifier, change the value and restore the final modifier afterwards. + Field typeField = Build.class.getField("TYPE"); + Field accessFlagsField = Field.class.getDeclaredField("accessFlags"); + accessFlagsField.setAccessible(true); + int currentFlags = accessFlagsField.getInt(typeField); + accessFlagsField.setInt(typeField, currentFlags & ~Modifier.FINAL); + typeField.set(null, TYPE_FOR_APPS); + accessFlagsField.setInt(typeField, currentFlags); + accessFlagsField.setAccessible(false); + } catch (Exception e) { + // shouldn't happen, but we don't want to crash the app even if it does happen + } + } + } + /** * Ensure that raw fingerprint system property is defined. If it was derived * dynamically by {@link #deriveFingerprint()} this is where we push the diff --git a/core/java/android/os/HwParcel.java b/core/java/android/os/HwParcel.java index cfb582ef442..5e8929c6c99 100644 --- a/core/java/android/os/HwParcel.java +++ b/core/java/android/os/HwParcel.java @@ -23,6 +23,8 @@ import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; +import dalvik.annotation.optimization.FastNative; + import libcore.util.NativeAllocationRegistry; import java.lang.annotation.Retention; @@ -72,46 +74,54 @@ public HwParcel() { /** * Writes an interface token into the parcel used to verify that - * a transaction has made it to the write type of interface. + * a transaction has made it to the right type of interface. * * @param interfaceName fully qualified name of interface message * is being sent to. */ + @FastNative public native final void writeInterfaceToken(String interfaceName); /** * Writes a boolean value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeBool(boolean val); /** * Writes a byte value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeInt8(byte val); /** * Writes a short value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeInt16(short val); /** * Writes a int value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeInt32(int val); /** * Writes a long value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeInt64(long val); /** * Writes a float value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeFloat(float val); /** * Writes a double value to the end of the parcel. * @param val to write */ + @FastNative public native final void writeDouble(double val); /** * Writes a String value to the end of the parcel. @@ -120,6 +130,7 @@ public HwParcel() { * * @param val to write */ + @FastNative public native final void writeString(String val); /** * Writes a native handle (without duplicating the underlying @@ -127,42 +138,50 @@ public HwParcel() { * * @param val to write */ + @FastNative public native final void writeNativeHandle(@Nullable NativeHandle val); /** * Writes an array of boolean values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeBoolVector(boolean[] val); /** * Writes an array of byte values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeInt8Vector(byte[] val); /** * Writes an array of short values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeInt16Vector(short[] val); /** * Writes an array of int values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeInt32Vector(int[] val); /** * Writes an array of long values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeInt64Vector(long[] val); /** * Writes an array of float values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeFloatVector(float[] val); /** * Writes an array of double values to the end of the parcel. * @param val to write */ + @FastNative private native final void writeDoubleVector(double[] val); /** * Writes an array of String values to the end of the parcel. @@ -171,6 +190,7 @@ public HwParcel() { * * @param val to write */ + @FastNative private native final void writeStringVector(String[] val); /** * Writes an array of native handles to the end of the parcel. @@ -179,6 +199,7 @@ public HwParcel() { * * @param val array of {@link NativeHandle} objects to write */ + @FastNative private native final void writeNativeHandleVector(NativeHandle[] val); /** @@ -299,6 +320,7 @@ public final void writeNativeHandleVector(@NonNull ArrayList val) * Write a hwbinder object to the end of the parcel. * @param binder value to write */ + @FastNative public native final void writeStrongBinder(IHwBinder binder); /** @@ -314,48 +336,56 @@ public final void writeNativeHandleVector(@NonNull ArrayList val) * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final boolean readBool(); /** * Reads a byte value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final byte readInt8(); /** * Reads a short value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final short readInt16(); /** * Reads a int value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final int readInt32(); /** * Reads a long value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final long readInt64(); /** * Reads a float value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final float readFloat(); /** * Reads a double value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final double readDouble(); /** * Reads a String value from the current location in the parcel. * @return value parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final String readString(); /** * Reads a native handle (without duplicating the underlying file @@ -366,6 +396,7 @@ public final void writeNativeHandleVector(@NonNull ArrayList val) * @return a {@link NativeHandle} instance parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final @Nullable NativeHandle readNativeHandle(); /** * Reads an embedded native handle (without duplicating the underlying @@ -379,6 +410,7 @@ public final void writeNativeHandleVector(@NonNull ArrayList val) * @return a {@link NativeHandle} instance parsed from the parcel * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final @Nullable NativeHandle readEmbeddedNativeHandle( long parentHandle, long offset); @@ -387,54 +419,63 @@ public final void writeNativeHandleVector(@NonNull ArrayList val) * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final boolean[] readBoolVectorAsArray(); /** * Reads an array of byte values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final byte[] readInt8VectorAsArray(); /** * Reads an array of short values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final short[] readInt16VectorAsArray(); /** * Reads an array of int values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final int[] readInt32VectorAsArray(); /** * Reads an array of long values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final long[] readInt64VectorAsArray(); /** * Reads an array of float values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final float[] readFloatVectorAsArray(); /** * Reads an array of double values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final double[] readDoubleVectorAsArray(); /** * Reads an array of String values from the parcel. * @return array of parsed values * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final String[] readStringVectorAsArray(); /** * Reads an array of native handles from the parcel. * @return array of {@link NativeHandle} objects * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative private native final NativeHandle[] readNativeHandleAsArray(); /** @@ -537,6 +578,7 @@ public final ArrayList readStringVector() { * @return binder object read from parcel or null if no binder can be read * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final IHwBinder readStrongBinder(); /** @@ -544,6 +586,7 @@ public final ArrayList readStringVector() { * @return blob of size expectedSize * @throws IllegalArgumentException if the parcel has no more data */ + @FastNative public native final HwBlob readBuffer(long expectedSize); /** @@ -559,6 +602,7 @@ public final ArrayList readStringVector() { * @throws NullPointerException if the transaction specified the blob to be null * but nullable is false */ + @FastNative public native final HwBlob readEmbeddedBuffer( long expectedSize, long parentHandle, long offset, boolean nullable); @@ -567,26 +611,31 @@ public native final HwBlob readEmbeddedBuffer( * Write a buffer into the transaction. * @param blob blob to write into the parcel. */ + @FastNative public native final void writeBuffer(HwBlob blob); /** * Write a status value into the blob. * @param status value to write */ + @FastNative public native final void writeStatus(int status); /** * @throws IllegalArgumentException if a success vaue cannot be read * @throws RemoteException if success value indicates a transaction error */ + @FastNative public native final void verifySuccess(); /** * Should be called to reduce memory pressure when this object no longer needs * to be written to. */ + @FastNative public native final void releaseTemporaryStorage(); /** * Should be called when object is no longer needed to reduce possible memory * pressure if the Java GC does not get to this object in time. */ + @FastNative public native final void release(); /** @@ -597,6 +646,7 @@ public native final HwBlob readEmbeddedBuffer( // Returns address of the "freeFunction". private static native final long native_init(); + @FastNative private native final void native_setup(boolean allocate); static { diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index e1d605e1c99..a497f412673 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -63,6 +63,7 @@ interface IPowerManager @UnsupportedAppUsage void reboot(boolean confirm, String reason, boolean wait); void rebootSafeMode(boolean confirm, boolean wait); + void rebootCustom(boolean confirm, String reason, boolean wait); void shutdown(boolean confirm, String reason, boolean wait); void crash(String message); int getLastShutdownReason(); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 45e777c7d01..937def1426d 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -519,6 +519,18 @@ public WakeData(long wakeTime, @WakeReason int wakeReason) { */ public static final String REBOOT_RECOVERY = "recovery"; + /** + * The value to pass as the 'reason' argument to reboot() to + * reboot into bootloader mode + *

+ * Requires the {@link android.Manifest.permission#RECOVERY} + * permission (in addition to + * {@link android.Manifest.permission#REBOOT}). + *

+ * @hide + */ + public static final String REBOOT_BOOTLOADER = "bootloader"; + /** * The value to pass as the 'reason' argument to reboot() to reboot into * recovery mode for applying system updates. @@ -1354,6 +1366,24 @@ public void rebootSafeMode() { } } + /** + * Reboot the device with custom progress meassges. + * Will not return if the reboot is successful. + *

+ * Requires the {@link android.Manifest.permission#REBOOT} permission. + *

+ * + * @param reason code to pass to the kernel (e.g., "recovery") to + * request special boot modes, or null. + * @hide + */ + public void rebootCustom(String reason) { + try { + mService.rebootCustom(false, reason, true); + } catch (RemoteException e) { + } + } + /** * Returns true if the device is currently in power save mode. When in this mode, * applications should reduce their functionality in order to conserve battery as diff --git a/core/java/android/os/storage/DiskInfo.java b/core/java/android/os/storage/DiskInfo.java index 19d1ce16687..63ea6a73757 100644 --- a/core/java/android/os/storage/DiskInfo.java +++ b/core/java/android/os/storage/DiskInfo.java @@ -52,6 +52,7 @@ public class DiskInfo implements Parcelable { public static final int FLAG_USB = 1 << 3; public static final int FLAG_EMMC = 1 << 4; public static final int FLAG_UFS_CARD = 1 << 5; + public static final int FLAG_NON_REMOVABLE = 1 << 6; public final String id; @UnsupportedAppUsage @@ -154,6 +155,10 @@ public boolean isUsb() { return (flags & FLAG_USB) != 0; } + public boolean isNonRemovable() { + return (flags & FLAG_NON_REMOVABLE) != 0; + } + @Override public String toString() { final CharArrayWriter writer = new CharArrayWriter(); diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java index 9a384c6d9d7..e401ac3d403 100644 --- a/core/java/android/provider/Downloads.java +++ b/core/java/android/provider/Downloads.java @@ -645,6 +645,11 @@ public static boolean isStatusCompleted(int status) { */ public static final int STATUS_QUEUED_FOR_WIFI = 196; + /** + * This download is paused manually. + */ + public static final int STATUS_PAUSED_MANUAL = 197; + /** * This download couldn't be completed due to insufficient storage * space. Typically, this is because the SD card is full. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 7ac5dc76303..8a1d2f4e991 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4503,6 +4503,196 @@ public boolean validate(@Nullable String value) { * it to PRIVATE_SETTINGS below. Also add a validator that can validate * the setting value. See an example above. */ + + /** + * Setting to determine whether or not to show the battery percentage in the status bar. + * 0 - Don't show percentage + * 1 - Show percentage + * @hide + */ + public static final String ADVANCED_REBOOT = "advanced_reboot"; + + /** @hide */ + private static final Validator ADVANCED_REBOOT_VALIDATOR = BOOLEAN_VALIDATOR; + + /** + * Enable statusbar double tap gesture on to put device to sleep + * @hide + */ + public static final String DOUBLE_TAP_SLEEP_GESTURE = "double_tap_sleep_gesture"; + + /** @hide */ + private static final Validator DOUBLE_TAP_SLEEP_GESTURE_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Double tap on lockscreen to sleep + * @hide + */ + public static final String DOUBLE_TAP_SLEEP_LOCKSCREEN = + "double_tap_sleep_lockscreen"; + + /** @hide */ + private static final Validator DOUBLE_TAP_SLEEP_LOCKSCREEN_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Disable Screenshot shutter sound + * @hide + */ + public static final String SCREENSHOT_SHUTTER_SOUND = "screenshot_shutter_sound"; + + /** @hide */ + private static final Validator SCREENSHOT_SHUTTER_SOUND_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** @hide */ + public static final String LOCK_POWER_MENU_DISABLED = "lockscreen_power_menu_disabled"; + + /** @hide */ + private static final Validator LOCK_POWER_MENU_DISABLED_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** @hide */ + public static final String BACK_GESTURE_HEIGHT = "back_gesture_height"; + + /** @hide */ + private static final Validator BACK_GESTURE_HEIGHT_VALIDATOR = + ANY_INTEGER_VALIDATOR; + + /** + * whether to enable or disable vibration on succesful fingerprint auth + * + * @hide + */ + public static final String FINGERPRINT_SUCCESS_VIB = "fingerprint_success_vib"; + + /** @hide */ + private static final Validator FINGERPRINT_SUCCESS_VIB_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether the phone vibrates on call connect + * @hide + */ + public static final String VIBRATE_ON_CONNECT = "vibrate_on_connect"; + + private static final Validator VIBRATE_ON_CONNECT_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether the phone vibrates on call waiting + * @hide + */ + public static final String VIBRATE_ON_CALLWAITING = "vibrate_on_callwaiting"; + + private static final Validator VIBRATE_ON_CALLWAITING_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether the phone vibrates on disconnect + * @hide + */ + public static final String VIBRATE_ON_DISCONNECT = "vibrate_on_disconnect"; + + private static final Validator VIBRATE_ON_DISCONNECT_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether to use old mobile data icons + * @hide + */ + public static final String USE_OLD_MOBILETYPE = "use_old_mobiletype"; + + private static final Validator USE_OLD_MOBILETYPE_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** Whether to allow one finger quick settings expansion on the right side of the statusbar. + * + * @hide + */ + public static final String STATUS_BAR_QUICK_QS_PULLDOWN = "status_bar_quick_qs_pulldown"; + + private static final Validator STATUS_BAR_QUICK_QS_PULLDOWN_VALIDATOR = + ANY_INTEGER_VALIDATOR; + + /** + * Disable expanding quick settings on secure lock screens + * + * @hide + */ + public static final String LOCK_QS_DISABLED = "lockscreen_qs_disabled"; + + private static final Validator LOCK_QS_DISABLED_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether to display 4G icon instead LTE + * @hide + */ + public static final String SHOW_FOURG_ICON = "show_fourg_icon"; + + private static final Validator SHOW_FOURG_ICON_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether to show VoLTE icon or not + * @hide + */ + public static final String SHOW_VOLTE_ICON = "show_volte_icon"; + + private static final Validator SHOW_VOLTE_ICON_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Swipe to screenshot gesture + * Also known as Three Fingers Screenshot. + * @hide + */ + public static final String SWIPE_TO_SCREENSHOT = "swipe_to_screenshot"; + + private static final Validator SWIPE_TO_SCREENSHOT_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether to show the battery info on the lockscreen while charging + * @hide + */ + public static final String LOCKSCREEN_BATTERY_INFO = "lockscreen_battery_info"; + + private static final Validator LOCKSCREEN_BATTERY_INFO_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Whether to allow battery light + * @hide + */ + public static final String BATTERY_LIGHT_ENABLED = "battery_light_enabled"; + + /** @hide */ + public static final Validator BATTERY_LIGHT_ENABLED_VALIDATOR = + BOOLEAN_VALIDATOR; + + /** + * Network traffic indicator mode + * 0 = Disabled + * 1 = Statusbar + * 2 = Expanded QS + * @hide + */ + public static final String NETWORK_TRAFFIC_MODE = "network_traffic_mode"; + + private static final Validator NETWORK_TRAFFIC_MODE_VALIDATOR = + new SettingsValidators.InclusiveIntegerRangeValidator(0, 2); + + /** + * Whether to hide network traffic on inactivity + * @hide + */ + public static final String NETWORK_TRAFFIC_AUTOHIDE = "network_traffic_autohide"; + + private static final Validator NETWORK_TRAFFIC_AUTOHIDE_VALIDATOR = + BOOLEAN_VALIDATOR; /** * Settings to backup. This is here so that it's in the same place as the settings @@ -4570,6 +4760,26 @@ public boolean validate(@Nullable String value) { DISPLAY_COLOR_MODE, ALARM_ALERT, NOTIFICATION_LIGHT_PULSE, + ADVANCED_REBOOT, + DOUBLE_TAP_SLEEP_GESTURE, + DOUBLE_TAP_SLEEP_LOCKSCREEN, + SCREENSHOT_SHUTTER_SOUND, + LOCK_POWER_MENU_DISABLED, + FINGERPRINT_SUCCESS_VIB, + VIBRATE_ON_CONNECT, + VIBRATE_ON_CALLWAITING, + VIBRATE_ON_DISCONNECT, + USE_OLD_MOBILETYPE, + STATUS_BAR_QUICK_QS_PULLDOWN, + LOCK_QS_DISABLED, + SHOW_FOURG_ICON, + SHOW_VOLTE_ICON, + SWIPE_TO_SCREENSHOT, + LOCKSCREEN_BATTERY_INFO, + BACK_GESTURE_HEIGHT, + BATTERY_LIGHT_ENABLED, + NETWORK_TRAFFIC_MODE, + NETWORK_TRAFFIC_AUTOHIDE, }; /** @@ -4690,6 +4900,26 @@ public boolean validate(@Nullable String value) { PRIVATE_SETTINGS.add(EGG_MODE); PRIVATE_SETTINGS.add(SHOW_BATTERY_PERCENT); PRIVATE_SETTINGS.add(DISPLAY_COLOR_MODE); + PRIVATE_SETTINGS.add(ADVANCED_REBOOT); + PRIVATE_SETTINGS.add(DOUBLE_TAP_SLEEP_GESTURE); + PRIVATE_SETTINGS.add(DOUBLE_TAP_SLEEP_LOCKSCREEN); + PRIVATE_SETTINGS.add(SCREENSHOT_SHUTTER_SOUND); + PRIVATE_SETTINGS.add(LOCK_POWER_MENU_DISABLED); + PRIVATE_SETTINGS.add(FINGERPRINT_SUCCESS_VIB); + PRIVATE_SETTINGS.add(VIBRATE_ON_CONNECT); + PRIVATE_SETTINGS.add(VIBRATE_ON_CALLWAITING); + PRIVATE_SETTINGS.add(VIBRATE_ON_DISCONNECT); + PRIVATE_SETTINGS.add(USE_OLD_MOBILETYPE); + PRIVATE_SETTINGS.add(STATUS_BAR_QUICK_QS_PULLDOWN); + PRIVATE_SETTINGS.add(LOCK_QS_DISABLED); + PRIVATE_SETTINGS.add(SHOW_FOURG_ICON); + PRIVATE_SETTINGS.add(SHOW_VOLTE_ICON); + PRIVATE_SETTINGS.add(SWIPE_TO_SCREENSHOT); + PRIVATE_SETTINGS.add(LOCKSCREEN_BATTERY_INFO); + PRIVATE_SETTINGS.add(BACK_GESTURE_HEIGHT); + PRIVATE_SETTINGS.add(BATTERY_LIGHT_ENABLED); + PRIVATE_SETTINGS.add(NETWORK_TRAFFIC_MODE); + PRIVATE_SETTINGS.add(NETWORK_TRAFFIC_AUTOHIDE); } /** @@ -4784,6 +5014,26 @@ public boolean validate(@Nullable String value) { VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR); VALIDATORS.put(SHOW_BATTERY_PERCENT, SHOW_BATTERY_PERCENT_VALIDATOR); VALIDATORS.put(NOTIFICATION_LIGHT_PULSE, BOOLEAN_VALIDATOR); + VALIDATORS.put(ADVANCED_REBOOT, ADVANCED_REBOOT_VALIDATOR); + VALIDATORS.put(DOUBLE_TAP_SLEEP_GESTURE, DOUBLE_TAP_SLEEP_GESTURE_VALIDATOR); + VALIDATORS.put(DOUBLE_TAP_SLEEP_LOCKSCREEN, DOUBLE_TAP_SLEEP_LOCKSCREEN_VALIDATOR); + VALIDATORS.put(SCREENSHOT_SHUTTER_SOUND, SCREENSHOT_SHUTTER_SOUND_VALIDATOR); + VALIDATORS.put(LOCK_POWER_MENU_DISABLED, LOCK_POWER_MENU_DISABLED_VALIDATOR); + VALIDATORS.put(FINGERPRINT_SUCCESS_VIB, FINGERPRINT_SUCCESS_VIB_VALIDATOR); + VALIDATORS.put(VIBRATE_ON_CONNECT, VIBRATE_ON_CONNECT_VALIDATOR); + VALIDATORS.put(VIBRATE_ON_CALLWAITING, VIBRATE_ON_CALLWAITING_VALIDATOR); + VALIDATORS.put(VIBRATE_ON_DISCONNECT, VIBRATE_ON_DISCONNECT_VALIDATOR); + VALIDATORS.put(USE_OLD_MOBILETYPE, USE_OLD_MOBILETYPE_VALIDATOR); + VALIDATORS.put(STATUS_BAR_QUICK_QS_PULLDOWN, STATUS_BAR_QUICK_QS_PULLDOWN_VALIDATOR); + VALIDATORS.put(LOCK_QS_DISABLED, LOCK_QS_DISABLED_VALIDATOR); + VALIDATORS.put(SHOW_FOURG_ICON, SHOW_FOURG_ICON_VALIDATOR); + VALIDATORS.put(SHOW_VOLTE_ICON, SHOW_VOLTE_ICON_VALIDATOR); + VALIDATORS.put(SWIPE_TO_SCREENSHOT, SWIPE_TO_SCREENSHOT_VALIDATOR); + VALIDATORS.put(LOCKSCREEN_BATTERY_INFO, LOCKSCREEN_BATTERY_INFO_VALIDATOR); + VALIDATORS.put(BACK_GESTURE_HEIGHT, BACK_GESTURE_HEIGHT_VALIDATOR); + VALIDATORS.put(BATTERY_LIGHT_ENABLED, BATTERY_LIGHT_ENABLED_VALIDATOR); + VALIDATORS.put(NETWORK_TRAFFIC_MODE, NETWORK_TRAFFIC_MODE_VALIDATOR); + VALIDATORS.put(NETWORK_TRAFFIC_AUTOHIDE, NETWORK_TRAFFIC_AUTOHIDE_VALIDATOR); } /** diff --git a/core/java/android/util/NtpTrustedTime.java b/core/java/android/util/NtpTrustedTime.java index bb3ddcfbe3f..7144fb36f2b 100644 --- a/core/java/android/util/NtpTrustedTime.java +++ b/core/java/android/util/NtpTrustedTime.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,17 +71,14 @@ public static synchronized NtpTrustedTime getInstance(Context context) { final Resources res = context.getResources(); final ContentResolver resolver = context.getContentResolver(); - final String defaultServer = res.getString( - com.android.internal.R.string.config_ntpServer); final long defaultTimeout = res.getInteger( com.android.internal.R.integer.config_ntpTimeout); - final String secureServer = Settings.Global.getString( + final String server = Settings.Global.getString( resolver, Settings.Global.NTP_SERVER); final long timeout = Settings.Global.getLong( resolver, Settings.Global.NTP_TIMEOUT, defaultTimeout); - final String server = secureServer != null ? secureServer : defaultServer; sSingleton = new NtpTrustedTime(server, timeout); sContext = context; @@ -125,10 +123,8 @@ public boolean forceSync() { } public boolean forceRefresh(Network network) { - if (TextUtils.isEmpty(mServer)) { - // missing server, so no trusted time available - return false; - } + final String realServer = TextUtils.isEmpty(mServer) ? sContext.getResources().getString( + com.android.internal.R.string.config_ntpServer) : mServer; // We can't do this at initialization time: ConnectivityService might not be running yet. synchronized (this) { @@ -147,7 +143,7 @@ public boolean forceRefresh(Network network) { if (LOGD) Log.d(TAG, "forceRefresh() from cache miss"); final SntpClient client = new SntpClient(); - String targetServer = mServer; + String targetServer = realServer; if (getBackupmode()) { setBackupmode(false); targetServer = mBackupServer; diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index b347a78a878..ce39d9d46c8 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -21,6 +21,7 @@ import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IShortcutService; import android.app.IAssistDataReceiver; +import android.content.Intent; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; @@ -313,6 +314,11 @@ interface IWindowManager */ oneway void setForceShowSystemBars(boolean show); + /** + * Send some ActionHandler commands to WindowManager. + */ + void sendCustomAction(in Intent intent); + /** * Called by System UI to notify of changes to the visibility of Recents. */ diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 9e914d4e7d4..4de0fb53438 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -234,7 +234,7 @@ public class ViewConfiguration { * The coefficient of friction applied to flings/scrolls. */ @UnsupportedAppUsage - private static final float SCROLL_FRICTION = 0.015f; + private static final float SCROLL_FRICTION = 0.012f; /** * Max distance in dips to overscroll for edge effects diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 36fcb5ad5c6..f889c38e9fc 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -5648,6 +5648,11 @@ private int processKeyEvent(QueuedInputEvent q) { private int processPointerEvent(QueuedInputEvent q) { final MotionEvent event = (MotionEvent)q.mEvent; + if (event.getPointerCount() == 3 && isSwipeToScreenshotGestureActive()) { + event.setAction(MotionEvent.ACTION_CANCEL); + Log.d("teste", "canceling motionEvent because of threeGesture detecting"); + } + mAttachInfo.mUnbufferedDispatchRequested = false; mAttachInfo.mHandlingPointerEvent = true; boolean handled = mView.dispatchPointerEvent(event); @@ -9202,4 +9207,13 @@ boolean preViewDispatch(KeyEvent event) { return false; } } + + private boolean isSwipeToScreenshotGestureActive() { + try { + return ActivityManager.getService().isSwipeToScreenshotGestureActive(); + } catch (RemoteException e) { + Log.e("teste", "isSwipeToScreenshotGestureActive exception", e); + return false; + } + } } diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 73e0e4b2eb8..fd7fe550def 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -1122,6 +1122,11 @@ public void clearFlags(int flags) { setFlags(0, flags); } + /** @hide */ + public void clearPrivateFlags(int flags) { + setPrivateFlags(0, flags); + } + /** * Set the flags of the window, as per the * {@link WindowManager.LayoutParams WindowManager.LayoutParams} @@ -1149,6 +1154,10 @@ public void setFlags(int flags, int mask) { } private void setPrivateFlags(int flags, int mask) { + if ((flags & mask & WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY) != 0) { + mContext.enforceCallingOrSelfPermission("android.permission.PREVENT_POWER_KEY", + "No permission to prevent power key"); + } final WindowManager.LayoutParams attrs = getAttributes(); attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask); dispatchWindowAttributesChanged(attrs); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 36fea589da9..4798d19e946 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -1831,6 +1831,12 @@ public static boolean isSystemAlertWindowType(int type) { */ public static final int PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC = 0x01000000; + /** + * Window flag: Overrides default power key behavior + * @hide + */ + public static final int PRIVATE_FLAG_PREVENT_POWER_KEY = 0x20000000; + /** * An internal annotation for flags that can be specified to {@link #softInputMode}. * diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 95cd192ce12..bb02f3b8ca5 100755 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -664,6 +664,7 @@ public abstract class AbsListView extends AdapterView implements Te private int mMinimumVelocity; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 124051740) private int mMaximumVelocity; + private int mDecacheThreshold; private float mVelocityScale = 1.0f; final boolean[] mIsScrap = new boolean[1]; @@ -950,6 +951,7 @@ private void initAbsListView() { } mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); + mDecacheThreshold = mMaximumVelocity / 2; mOverscrollDistance = configuration.getScaledOverscrollDistance(); mOverflingDistance = configuration.getScaledOverflingDistance(); @@ -4755,7 +4757,7 @@ public void run() { // Keep the fling alive a little longer postDelayed(this, FLYWHEEL_TIMEOUT); } else { - endFling(); + endFling(false); // Don't disable the scrolling cache right after it was enabled mTouchMode = TOUCH_MODE_SCROLL; reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL); } @@ -4766,11 +4768,17 @@ public void run() { FlingRunnable() { mScroller = new OverScroller(getContext()); + mScroller.setFriction(0.006f); } // Use AbsListView#fling(int) instead @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) void start(int initialVelocity) { + if (Math.abs(initialVelocity) > mDecacheThreshold) { + // For long flings, scrolling cache causes stutter, so don't use it + clearScrollingCache(); + } + int initialY = initialVelocity < 0 ? Integer.MAX_VALUE : 0; mLastFlingY = initialY; mScroller.setInterpolator(null); @@ -4850,6 +4858,10 @@ void startScroll(int distance, int duration, boolean linear, // To interrupt a fling early you should use smoothScrollBy(0,0) instead @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) void endFling() { + endFling(true); + } + + void endFling(boolean clearCache) { mTouchMode = TOUCH_MODE_REST; removeCallbacks(this); @@ -4858,7 +4870,8 @@ void endFling() { if (!mSuppressIdleStateChangeCall) { reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); } - clearScrollingCache(); + if (clearCache) + clearScrollingCache(); mScroller.abortAnimation(); if (mFlingStrictSpan != null) { diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index ef68ce7daf5..4640c19bc16 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -922,10 +922,12 @@ public boolean onInterceptTouchEvent(MotionEvent event) { if (!mFlingScroller.isFinished()) { mFlingScroller.forceFinished(true); mAdjustScroller.forceFinished(true); + onScrollerFinished(mFlingScroller); onScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); } else if (!mAdjustScroller.isFinished()) { mFlingScroller.forceFinished(true); mAdjustScroller.forceFinished(true); + onScrollerFinished(mAdjustScroller); } else if (mLastDownEventY < mTopSelectionDividerTop) { postChangeCurrentByOneFromLongPress( false, ViewConfiguration.getLongPressTimeout()); diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 51b0950a754..6c9fef29db6 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -343,6 +343,7 @@ public int getMaxScrollAmount() { private void initScrollView() { mScroller = new OverScroller(getContext()); + mScroller.setFriction(0.006f); setFocusable(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index d9a78dadba4..bfd587c04ca 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -120,7 +120,14 @@ public final class SystemUiDeviceConfigFlags { */ public static final String HASH_SALT_MAX_DAYS = "hash_salt_max_days"; - // Flags related to Assistant + // Flag related to Privacy Indicators + + /** + * Whether the Permissions Hub is showing. + */ + public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled"; + + // Flags related to Assistant Handles /** * (String) Which behavior mode for the Assistant Handles to use. diff --git a/core/java/com/android/internal/os/DeviceKeyHandler.java b/core/java/com/android/internal/os/DeviceKeyHandler.java new file mode 100644 index 00000000000..8902337f3eb --- /dev/null +++ b/core/java/com/android/internal/os/DeviceKeyHandler.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2012 The CyanogenMod 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.os; + +import android.view.KeyEvent; + +public interface DeviceKeyHandler { + + /** + * Invoked when an unknown key was detected by the system, letting the device handle + * this special keys prior to pass the key to the active app. + * + * @param event The key event to be handled + * @return null if event is consumed, KeyEvent to be handled otherwise + */ + public KeyEvent handleKeyEvent(KeyEvent event); +} diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index eac150dbd32..c3abc71c474 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -201,6 +201,8 @@ protected static final void commonInit() { RuntimeHooks.setUncaughtExceptionPreHandler(loggingHandler); Thread.setDefaultUncaughtExceptionHandler(new KillApplicationHandler(loggingHandler)); + Build.adjustBuildTypeIfNeeded(); + /* * Install a time zone supplier that uses the Android persistent time zone system property. */ diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index dffaf252195..f2d66ca2d1b 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -91,11 +91,6 @@ public class ZygoteInit { private static final int LOG_BOOT_PROGRESS_PRELOAD_START = 3020; private static final int LOG_BOOT_PROGRESS_PRELOAD_END = 3030; - /** - * when preloading, GC after allocating this many bytes - */ - private static final int PRELOAD_GC_THRESHOLD = 50000; - private static final String ABI_LIST_ARG = "--abi-list="; // TODO (chriswailes): Re-name this --zygote-socket-name= and then add a @@ -285,11 +280,6 @@ private static void preloadClasses() { droppedPriviliges = true; } - // Alter the target heap utilization. With explicit GCs this - // is not likely to have any effect. - float defaultUtilization = runtime.getTargetHeapUtilization(); - runtime.setTargetHeapUtilization(0.8f); - try { BufferedReader br = new BufferedReader(new InputStreamReader(is), Zygote.SOCKET_BUFFER_SIZE); @@ -305,9 +295,6 @@ private static void preloadClasses() { Trace.traceBegin(Trace.TRACE_TAG_DALVIK, line); try { - if (false) { - Log.v(TAG, "Preloading " + line + "..."); - } // Load and explicitly initialize the given class. Use // Class.forName(String, boolean, ClassLoader) to avoid repeated stack lookups // (to derive the caller's class-loader). Use true to force initialization, and @@ -338,8 +325,6 @@ private static void preloadClasses() { Log.e(TAG, "Error reading " + PRELOADED_CLASSES + ".", e); } finally { IoUtils.closeQuietly(is); - // Restore default. - runtime.setTargetHeapUtilization(defaultUtilization); // Fill in dex caches with classes, fields, and methods brought in by preloading. Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadDexCaches"); diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index c715577cb7d..482e5961c1e 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -149,7 +149,7 @@ oneway interface IStatusBar void showPinningEnterExitToast(boolean entering); void showPinningEscapeToast(); - void showShutdownUi(boolean isReboot, String reason); + void showShutdownUi(boolean isReboot, String reason, boolean rebootCustom); // Used to show the dialog when BiometricService starts authentication void showBiometricDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, int type, diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 598c3917bf9..5921f64abed 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -85,7 +85,7 @@ interface IStatusBarService * These methods are needed for global actions control which the UI is shown in sysui. */ void shutdown(); - void reboot(boolean safeMode); + void reboot(boolean safeMode, String reason); void addTile(in ComponentName tile); void remTile(in ComponentName tile); diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java index d24d78c6f3d..68f32e5f4b0 100644 --- a/core/java/com/android/internal/util/ScreenshotHelper.java +++ b/core/java/com/android/internal/util/ScreenshotHelper.java @@ -1,5 +1,7 @@ package com.android.internal.util; +import static android.view.WindowManager.TAKE_SCREENSHOT_SELECTED_REGION; + import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; @@ -172,7 +174,9 @@ public void onServiceDisconnected(ComponentName name) { Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE, UserHandle.CURRENT)) { mScreenshotConnection = conn; - handler.postDelayed(mScreenshotTimeout, timeoutMs); + if (screenshotType != TAKE_SCREENSHOT_SELECTED_REGION) { + handler.postDelayed(mScreenshotTimeout, timeoutMs); + } } } } diff --git a/core/java/com/android/internal/util/reloaded/ReloadedUtils.java b/core/java/com/android/internal/util/reloaded/ReloadedUtils.java new file mode 100644 index 00000000000..bc168010f4c --- /dev/null +++ b/core/java/com/android/internal/util/reloaded/ReloadedUtils.java @@ -0,0 +1,37 @@ +/* + * 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 com.android.internal.util.reloaded; + +import android.content.Intent; +import android.os.RemoteException; +import android.view.IWindowManager; +import android.view.WindowManagerGlobal; + +public class ReloadedUtils { + + public static final String INTENT_SCREENSHOT = "action_handler_screenshot"; + public static final String INTENT_REGION_SCREENSHOT = "action_handler_region_screenshot"; + + public static void takeScreenshot(boolean full) { + IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); + try { + wm.sendCustomAction(new Intent(full? INTENT_SCREENSHOT : INTENT_REGION_SCREENSHOT)); + } catch (RemoteException e) { + e.printStackTrace(); + } + } +} diff --git a/core/java/com/android/internal/util/reloaded/recorder/RecorderConstants.java b/core/java/com/android/internal/util/reloaded/recorder/RecorderConstants.java new file mode 100644 index 00000000000..5798a661cba --- /dev/null +++ b/core/java/com/android/internal/util/reloaded/recorder/RecorderConstants.java @@ -0,0 +1,20 @@ +/* +* Copyright (C) 2019 The Pixel Experience 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.util.reloaded.recorder; + +public class RecorderConstants { + public static final String APP_PACKAGE_NAME = "org.pixelexperience.recorder"; +} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index c84494e4746..4ffe2964023 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -673,6 +673,10 @@ + + + + @@ -2675,6 +2679,13 @@ android:description="@string/permdesc_getPackageSize" android:protectionLevel="normal" /> + + + @@ -3562,6 +3573,11 @@ + + + + + + + @color/black - @color/material_grey_800 + @color/material_grey_900