diff options
| author | Xin Li <delphij@google.com> | 2020-06-03 10:45:02 -0700 |
|---|---|---|
| committer | Xin Li <delphij@google.com> | 2020-06-03 10:45:02 -0700 |
| commit | 80fe5964bc4aaeef5dc70cb85da21933722cffac (patch) | |
| tree | c181fc219efaa5d17dcd4e68e8993fdf32e31fb7 /core/java | |
| parent | b101411b95baf3fc14ff6f2e72103a649d57cb9b (diff) | |
| parent | afbf77813b54ef7019078bc4f595103a55aa93ff (diff) | |
Merge QQ3A.200605.002 into master
Bug: 158095402
Merged-In: I5e28537689d1a53e99f91eafd494eb3a0c890f46
Change-Id: I436ef37a509cbe56d02c6d8d3a38c776f4b4883f
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/accounts/AccountManager.java | 29 | ||||
| -rw-r--r-- | core/java/android/accounts/IAccountManager.aidl | 3 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManagerInternal.java | 3 | ||||
| -rw-r--r-- | core/java/android/app/DisabledWallpaperManager.java | 7 | ||||
| -rw-r--r-- | core/java/android/app/Presentation.java | 10 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 7 | ||||
| -rw-r--r-- | core/java/android/content/pm/PackageManagerInternal.java | 12 | ||||
| -rw-r--r-- | core/java/android/hardware/camera2/CameraManager.java | 85 | ||||
| -rw-r--r-- | core/java/android/net/Uri.java | 61 | ||||
| -rw-r--r-- | core/java/android/os/GraphicsEnvironment.java | 25 | ||||
| -rw-r--r-- | core/java/android/os/IUserManager.aidl | 1 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/ViewConfiguration.java | 3 |
13 files changed, 163 insertions, 93 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 6519366cf7c6..3e11831062bb 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -1943,35 +1943,6 @@ public class AccountManager { } /** - * @hide - * Removes the shared account. - * @param account the account to remove - * @param user the user to remove the account from - * @return - */ - public boolean removeSharedAccount(final Account account, UserHandle user) { - try { - boolean val = mService.removeSharedAccountAsUser(account, user.getIdentifier()); - return val; - } catch (RemoteException re) { - throw re.rethrowFromSystemServer(); - } - } - - /** - * @hide - * @param user - * @return - */ - public Account[] getSharedAccounts(UserHandle user) { - try { - return mService.getSharedAccountsAsUser(user.getIdentifier()); - } catch (RemoteException re) { - throw re.rethrowFromSystemServer(); - } - } - - /** * Confirms that the user knows the password for an account to make extra * sure they are the owner of the account. The user-entered password can * be supplied directly, otherwise the authenticator for this account type diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl index 4cf0a2089fe5..012713891d11 100644 --- a/core/java/android/accounts/IAccountManager.aidl +++ b/core/java/android/accounts/IAccountManager.aidl @@ -80,14 +80,11 @@ interface IAccountManager { String authTokenType); /* Shared accounts */ - Account[] getSharedAccountsAsUser(int userId); - boolean removeSharedAccountAsUser(in Account account, int userId); void addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName); /* Account renaming. */ void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName); String getPreviousName(in Account account); - boolean renameSharedAccountAsUser(in Account accountToRename, String newName, int userId); /* Add account in two steps. */ void startAddAccountSession(in IAccountManagerResponse response, String accountType, diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index 9b59ab453acf..c36b4673ebdf 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -344,4 +344,7 @@ public abstract class ActivityManagerInternal { * Unregisters the specified {@code processObserver}. */ public abstract void unregisterProcessObserver(IProcessObserver processObserver); + + /** Returns true if the given UID is registered as an active instrumentation. */ + public abstract boolean isActiveInstrumentation(int uid); } diff --git a/core/java/android/app/DisabledWallpaperManager.java b/core/java/android/app/DisabledWallpaperManager.java index 518594191e6c..7151f900c5af 100644 --- a/core/java/android/app/DisabledWallpaperManager.java +++ b/core/java/android/app/DisabledWallpaperManager.java @@ -41,8 +41,7 @@ final class DisabledWallpaperManager extends WallpaperManager { // Don't need to worry about synchronization private static DisabledWallpaperManager sInstance; - // TODO(b/138939803): STOPSHIP changed to false and/or remove it - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; @NonNull static DisabledWallpaperManager getInstance() { @@ -66,10 +65,6 @@ final class DisabledWallpaperManager extends WallpaperManager { return false; } - // TODO(b/138939803): STOPSHIP methods below should not be necessary, - // callers should check if isWallpaperSupported(), consider removing them to keep this class - // simpler - private static <T> T unsupported() { if (DEBUG) Log.w(TAG, "unsupported method called; returning null", new Exception()); return null; diff --git a/core/java/android/app/Presentation.java b/core/java/android/app/Presentation.java index f864fb57d00a..138578ef6654 100644 --- a/core/java/android/app/Presentation.java +++ b/core/java/android/app/Presentation.java @@ -26,18 +26,18 @@ import android.content.res.Resources; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager.DisplayListener; import android.os.Binder; -import android.os.Handler; import android.os.IBinder; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; -import android.util.TypedValue; import android.view.ContextThemeWrapper; import android.view.Display; import android.view.Gravity; import android.view.Window; import android.view.WindowManager; import android.view.WindowManagerImpl; +import android.os.Handler; +import android.os.Message; +import android.util.DisplayMetrics; +import android.util.Log; +import android.util.TypedValue; /** * Base class for presentations. diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index 1508a657cf4a..f962ea0966bd 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1196,10 +1196,11 @@ public final class BluetoothAdapter { public boolean factoryReset() { try { mServiceLock.readLock().lock(); - if (mService != null) { - return mService.factoryReset(); + if (mService != null && mService.factoryReset() + && mManagerService != null && mManagerService.onFactoryReset()) { + return true; } - Log.e(TAG, "factoryReset(): IBluetooth Service is null"); + Log.e(TAG, "factoryReset(): Setting persist.bluetooth.factoryreset to retry later"); SystemProperties.set("persist.bluetooth.factoryreset", "true"); } catch (RemoteException e) { Log.e(TAG, "", e); diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java index ce5fc3b3deca..15e36159b102 100644 --- a/core/java/android/content/pm/PackageManagerInternal.java +++ b/core/java/android/content/pm/PackageManagerInternal.java @@ -1007,4 +1007,16 @@ public abstract class PackageManagerInternal { * Migrates legacy obb data to its new location. */ public abstract void migrateLegacyObbData(); + + /** + * Ensures that we block deletion of unused packages on user removal. This is purely for the + * purpose of ensuring that b/141413692 is not reproducible on Q. + */ + public abstract void notifyingOnNextUserRemovalForTest(); + + /** + * Notifies PackageManager of the removal of a user. This is purely for the purpose of ensuring + * that b/141413692 is not reproducible on Q. + */ + public abstract void userRemovedForTest(); } diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java index c8276b25c52d..13f2a5ebc785 100644 --- a/core/java/android/hardware/camera2/CameraManager.java +++ b/core/java/android/hardware/camera2/CameraManager.java @@ -701,6 +701,33 @@ public final class CameraManager { public void onCameraAccessPrioritiesChanged() { // default empty implementation } + + /** + * A camera device has been opened by an application. + * + * <p>The default implementation of this method does nothing.</p> + * + * @param cameraId The unique identifier of the new camera. + * @param packageId The package Id of the application opening the camera. + * + * @see #onCameraClosed + */ + /** @hide */ + public void onCameraOpened(@NonNull String cameraId, @NonNull String packageId) { + // default empty implementation + } + + /** + * A previously-opened camera has been closed. + * + * <p>The default implementation of this method does nothing.</p> + * + * @param cameraId The unique identifier of the closed camera. + */ + /** @hide */ + public void onCameraClosed(@NonNull String cameraId) { + // default empty implementation + } } /** @@ -1139,6 +1166,38 @@ public final class CameraManager { } } + private void postSingleCameraOpenedUpdate(final AvailabilityCallback callback, + final Executor executor, final String id, final String packageId) { + final long ident = Binder.clearCallingIdentity(); + try { + executor.execute( + new Runnable() { + @Override + public void run() { + callback.onCameraOpened(id, packageId); + } + }); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + private void postSingleCameraClosedUpdate(final AvailabilityCallback callback, + final Executor executor, final String id) { + final long ident = Binder.clearCallingIdentity(); + try { + executor.execute( + new Runnable() { + @Override + public void run() { + callback.onCameraClosed(id); + } + }); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + private void postSingleUpdate(final AvailabilityCallback callback, final Executor executor, final String id, final int status) { if (isAvailable(status)) { @@ -1401,6 +1460,32 @@ public final class CameraManager { } } + @Override + public void onCameraOpened(String cameraId, String clientPackageId) { + synchronized (mLock) { + final int callbackCount = mCallbackMap.size(); + for (int i = 0; i < callbackCount; i++) { + Executor executor = mCallbackMap.valueAt(i); + final AvailabilityCallback callback = mCallbackMap.keyAt(i); + + postSingleCameraOpenedUpdate(callback, executor, cameraId, clientPackageId); + } + } + } + + @Override + public void onCameraClosed(String cameraId) { + synchronized (mLock) { + final int callbackCount = mCallbackMap.size(); + for (int i = 0; i < callbackCount; i++) { + Executor executor = mCallbackMap.valueAt(i); + final AvailabilityCallback callback = mCallbackMap.keyAt(i); + + postSingleCameraClosedUpdate(callback, executor, cameraId); + } + } + } + /** * Try to connect to camera service after some delay if any client registered camera * availability callback or torch status callback. diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java index ddca4b464123..e4744f79fcda 100644 --- a/core/java/android/net/Uri.java +++ b/core/java/android/net/Uri.java @@ -1987,17 +1987,26 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { * Enum which indicates which representation of a given part we have. */ static class Representation { - static final int BOTH = 0; static final int ENCODED = 1; static final int DECODED = 2; } volatile String encoded; volatile String decoded; + private final int mCanonicalRepresentation; AbstractPart(String encoded, String decoded) { - this.encoded = encoded; - this.decoded = decoded; + if (encoded != NOT_CACHED) { + this.mCanonicalRepresentation = Representation.ENCODED; + this.encoded = encoded; + this.decoded = NOT_CACHED; + } else if (decoded != NOT_CACHED) { + this.mCanonicalRepresentation = Representation.DECODED; + this.encoded = NOT_CACHED; + this.decoded = decoded; + } else { + throw new IllegalArgumentException("Neither encoded nor decoded"); + } } abstract String getEncoded(); @@ -2009,25 +2018,21 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { } final void writeTo(Parcel parcel) { - @SuppressWarnings("StringEquality") - boolean hasEncoded = encoded != NOT_CACHED; - - @SuppressWarnings("StringEquality") - boolean hasDecoded = decoded != NOT_CACHED; - - if (hasEncoded && hasDecoded) { - parcel.writeInt(Representation.BOTH); - parcel.writeString(encoded); - parcel.writeString(decoded); - } else if (hasEncoded) { - parcel.writeInt(Representation.ENCODED); - parcel.writeString(encoded); - } else if (hasDecoded) { - parcel.writeInt(Representation.DECODED); - parcel.writeString(decoded); + final String canonicalValue; + if (mCanonicalRepresentation == Representation.ENCODED) { + canonicalValue = encoded; + } else if (mCanonicalRepresentation == Representation.DECODED) { + canonicalValue = decoded; } else { - throw new IllegalArgumentException("Neither encoded nor decoded"); + throw new IllegalArgumentException("Unknown representation: " + + mCanonicalRepresentation); + } + if (canonicalValue == NOT_CACHED) { + throw new AssertionError("Canonical value not cached (" + + mCanonicalRepresentation + ")"); } + parcel.writeInt(mCanonicalRepresentation); + parcel.writeString(canonicalValue); } } @@ -2059,13 +2064,12 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { static Part readFrom(Parcel parcel) { int representation = parcel.readInt(); + String value = parcel.readString(); switch (representation) { - case Representation.BOTH: - return from(parcel.readString(), parcel.readString()); case Representation.ENCODED: - return fromEncoded(parcel.readString()); + return fromEncoded(value); case Representation.DECODED: - return fromDecoded(parcel.readString()); + return fromDecoded(value); default: throw new IllegalArgumentException("Unknown representation: " + representation); @@ -2127,6 +2131,11 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { private static class EmptyPart extends Part { public EmptyPart(String value) { super(value, value); + if (value != null && !value.isEmpty()) { + throw new IllegalArgumentException("Expected empty value, got: " + value); + } + // Avoid having to re-calculate the non-canonical value. + encoded = decoded = value; } @Override @@ -2245,14 +2254,12 @@ public abstract class Uri implements Parcelable, Comparable<Uri> { static PathPart readFrom(Parcel parcel) { int representation = parcel.readInt(); switch (representation) { - case Representation.BOTH: - return from(parcel.readString(), parcel.readString()); case Representation.ENCODED: return fromEncoded(parcel.readString()); case Representation.DECODED: return fromDecoded(parcel.readString()); default: - throw new IllegalArgumentException("Bad representation: " + representation); + throw new IllegalArgumentException("Unknown representation: " + representation); } } diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java index 7a70e93b69d5..31cdf42e3a06 100644 --- a/core/java/android/os/GraphicsEnvironment.java +++ b/core/java/android/os/GraphicsEnvironment.java @@ -173,13 +173,6 @@ public class GraphicsEnvironment { } /** - * Check whether application is debuggable - */ - private static boolean isDebuggable(Context context) { - return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0; - } - - /** * Store the layer paths available to the loader. */ public void setLayerPaths(ClassLoader classLoader, @@ -233,7 +226,7 @@ public class GraphicsEnvironment { // 2. ENABLE_GPU_DEBUG_LAYERS is true // 3. Package name is equal to GPU_DEBUG_APP - if (isDebuggable(context) || (getCanLoadSystemLibraries() == 1)) { + if (isDebuggable()) { final int enable = coreSettings.getInt(Settings.Global.ENABLE_GPU_DEBUG_LAYERS, 0); @@ -414,9 +407,7 @@ public class GraphicsEnvironment { * Check for ANGLE debug package, but only for apps that can load them (dumpable) */ private String getAngleDebugPackage(Context context, Bundle coreSettings) { - final boolean appIsDebuggable = isDebuggable(context); - final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1; - if (appIsDebuggable || deviceIsDebuggable) { + if (isDebuggable()) { String debugPackage; if (coreSettings != null) { @@ -451,12 +442,8 @@ public class GraphicsEnvironment { * - devices that are running a userdebug build (ro.debuggable) or can inject libraries for * debugging (PR_SET_DUMPABLE). */ - final boolean appIsDebuggable = isDebuggable(context); - final boolean deviceIsDebuggable = getCanLoadSystemLibraries() == 1; - if (!(appIsDebuggable || deviceIsDebuggable)) { - Log.v(TAG, "Skipping loading temporary rules file: " - + "appIsDebuggable = " + appIsDebuggable + ", " - + "adbRootEnabled = " + deviceIsDebuggable); + if (!isDebuggable()) { + Log.v(TAG, "Skipping loading temporary rules file"); return false; } @@ -725,7 +712,7 @@ public class GraphicsEnvironment { final boolean enablePrereleaseDriver = (ai.metaData != null && ai.metaData.getBoolean(METADATA_DEVELOPER_DRIVER_ENABLE)) - || getCanLoadSystemLibraries() == 1; + || isDebuggable(); // Priority for Game Driver settings global on confliction (Higher priority comes first): // 1. GAME_DRIVER_ALL_APPS @@ -901,7 +888,7 @@ public class GraphicsEnvironment { return ""; } - private static native int getCanLoadSystemLibraries(); + private static native boolean isDebuggable(); private static native void setLayerPaths(ClassLoader classLoader, String layerPaths); private static native void setDebugLayers(String layers); private static native void setDebugLayersGLES(String layers); diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index c30491a3965c..7721116d5862 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -106,4 +106,5 @@ interface IUserManager { String getUserName(); long getUserStartRealtime(); long getUserUnlockRealtime(); + void notifyOnNextUserRemoveForTest(); } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 0dfb7c380b04..d75ae4cb9868 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -1275,6 +1275,16 @@ public class UserManager { } /** + * @hide + * @return Whether the device is running in a headless system user mode. It means the headless + * user (system user) runs system services and system UI, but is not associated with any real + * person. Secondary users can be created to be associated with real person. + */ + public static boolean isHeadlessSystemUserMode() { + return RoSystemProperties.MULTIUSER_HEADLESS_SYSTEM_USER; + } + + /** * @return Whether guest user is always ephemeral * @hide */ diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 774a2dea6311..38f81140af3c 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -64,8 +64,9 @@ public class ViewConfiguration { /** * Defines the default duration in milliseconds before a press turns into * a long press + * @hide */ - private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; + public static final int DEFAULT_LONG_PRESS_TIMEOUT = 400; /** * Defines the default duration in milliseconds between the first tap's up event and the second |
