summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/accounts/AccountManager.java29
-rw-r--r--core/java/android/accounts/IAccountManager.aidl3
-rw-r--r--core/java/android/app/ActivityManagerInternal.java4
-rw-r--r--core/java/android/app/AppOpsManagerInternal.java29
-rw-r--r--core/java/android/app/DisabledWallpaperManager.java7
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java6
-rw-r--r--core/java/android/content/pm/PackageManagerInternal.java12
-rw-r--r--core/java/android/hardware/camera2/CameraManager.java85
-rw-r--r--core/java/android/net/INetworkPolicyListener.aidl2
-rw-r--r--core/java/android/net/NetworkPolicyManager.java2
-rw-r--r--core/java/android/net/Uri.java61
-rw-r--r--core/java/android/os/GraphicsEnvironment.java25
-rw-r--r--core/java/android/os/IUserManager.aidl1
-rw-r--r--core/java/android/os/UserManager.java10
-rw-r--r--core/java/android/view/ViewConfiguration.java3
15 files changed, 162 insertions, 117 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index f4e465ab3ad..0f10c398002 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 4cf0a2089fe..012713891d1 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 1725db046a9..a30238ac9e3 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -29,7 +29,6 @@ import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.IBinder;
import android.os.TransactionTooLargeException;
-import android.view.RemoteAnimationAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -345,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/AppOpsManagerInternal.java b/core/java/android/app/AppOpsManagerInternal.java
index 08cad04401e..996939eb9ee 100644
--- a/core/java/android/app/AppOpsManagerInternal.java
+++ b/core/java/android/app/AppOpsManagerInternal.java
@@ -16,7 +16,6 @@
package android.app;
-import android.annotation.NonNull;
import android.util.SparseIntArray;
import com.android.internal.util.function.QuadFunction;
@@ -77,38 +76,10 @@ public abstract class AppOpsManagerInternal {
public abstract void setDeviceAndProfileOwners(SparseIntArray owners);
/**
- * Sets the app-ops mode for a certain app-op and uid.
- *
- * <p>Similar as {@link AppOpsManager#setUidMode} but does not require the package manager to be
- * working. Hence this can be used very early during boot.
- *
- * <p>Only for internal callers. Does <u>not</u> verify that package name belongs to uid.
- *
- * @param code The op code to set.
- * @param uid The UID for which to set.
- * @param mode The new mode to set.
- */
- public abstract void setUidMode(int code, int uid, int mode);
-
- /**
* Set all {@link #setMode (package) modes} for this uid to the default value.
*
* @param code The app-op
* @param uid The uid
*/
public abstract void setAllPkgModesToDefault(int code, int uid);
-
- /**
- * Get the (raw) mode of an app-op.
- *
- * <p>Does <u>not</u> verify that package belongs to uid. The caller needs to do that.
- *
- * @param code The code of the op
- * @param uid The uid of the package the op belongs to
- * @param packageName The package the op belongs to
- *
- * @return The mode of the op
- */
- public abstract @AppOpsManager.Mode int checkOperationUnchecked(int code, int uid,
- @NonNull String packageName);
}
diff --git a/core/java/android/app/DisabledWallpaperManager.java b/core/java/android/app/DisabledWallpaperManager.java
index 518594191e6..7151f900c5a 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/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 31bbd16497c..3b620b388ef 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -1195,9 +1195,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(): 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 672994e7913..3e880f03b22 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -999,4 +999,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 f1645c6afd8..7e89b1f01a5 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -702,6 +702,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
+ }
}
/**
@@ -1143,6 +1170,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)) {
@@ -1410,6 +1469,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/INetworkPolicyListener.aidl b/core/java/android/net/INetworkPolicyListener.aidl
index 10667aecd12..fe9141cb6a2 100644
--- a/core/java/android/net/INetworkPolicyListener.aidl
+++ b/core/java/android/net/INetworkPolicyListener.aidl
@@ -15,6 +15,7 @@
*/
package android.net;
+import android.telephony.SubscriptionPlan;
/** {@hide} */
oneway interface INetworkPolicyListener {
@@ -23,4 +24,5 @@ oneway interface INetworkPolicyListener {
void onRestrictBackgroundChanged(boolean restrictBackground);
void onUidPoliciesChanged(int uid, int uidPolicies);
void onSubscriptionOverride(int subId, int overrideMask, int overrideValue);
+ void onSubscriptionPlansChanged(int subId, in SubscriptionPlan[] plans);
}
diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java
index dbe1e094ce1..11029c2fb82 100644
--- a/core/java/android/net/NetworkPolicyManager.java
+++ b/core/java/android/net/NetworkPolicyManager.java
@@ -31,6 +31,7 @@ import android.net.wifi.WifiInfo;
import android.os.Build;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.telephony.SubscriptionPlan;
import android.util.DebugUtils;
import android.util.Pair;
import android.util.Range;
@@ -387,5 +388,6 @@ public class NetworkPolicyManager {
@Override public void onRestrictBackgroundChanged(boolean restrictBackground) { }
@Override public void onUidPoliciesChanged(int uid, int uidPolicies) { }
@Override public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue) { }
+ @Override public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) { }
}
}
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index c3166e91fac..8cf182b4156 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 7a70e93b69d..31cdf42e3a0 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 c30491a3965..7721116d586 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 45842926ff1..da41478e91a 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 9e914d4e7d4..d83bbf6d6ab 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