Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d995fb3
Revert "Revert "[pm] remove old stage dirs on low storage""
schfan-1 Oct 14, 2021
0e4fd10
base: PixelPropsUtils: Update redfin fp to SQ1A.220105.002
SonalSingh18 Jan 10, 2022
bf0b586
Prevent apps from spamming addAccountExplicitly.
May 17, 2021
9e3cc10
Allow forcing status bar state changes and do so when the screen turn…
Oct 21, 2021
a5019f9
Update deletion conditions for a package's UsageStats.
Nov 9, 2021
3931799
RESTRICT AUTOMERGE Remove line of code that was mistakently left in.
Nov 15, 2021
ea3d355
[DO NOT MERGE] Controls - Do not recreate intent
mpietal79 Oct 4, 2021
a3b2c10
DO NOT MERGE Re-implement reading/writing Throwables from/to Parcel, …
zhanghai Dec 31, 2020
f4e5884
Don't crash if default supervision profile owner is not set
Jan 26, 2021
ea4bfb8
[RESTRICT AUTOMERGE] Fix the inconsistency of protection level
kjackal Dec 24, 2021
4465b0d
Check group channels for FGSes
Jan 7, 2022
dc7e204
Handle onNullBinding
Jan 11, 2022
fed84f2
Only allow trusted overlays to specify FLAG_SLIPPERY
vishniakou Jul 20, 2021
9130e61
Add ALLOW_SLIPPERY_TOUCHES permission
vishniakou Nov 29, 2021
065077e
Don't abandon child sessions (1/n)
Jan 3, 2022
41021a8
base: PixelPropsUtils: Update redfin fp to SP2A.220305.012
InVictusXV Mar 11, 2022
0a48d1b
Revert "Revert "Revert "BG-FGS-start while-in-use permission restrict…
haggertk Apr 5, 2022
d972ca6
Prevent apps from creating blocked channel groups
Jan 12, 2022
1321616
Restrict AdbManager broadcasts to apps with MANAGE_DEBUGGING permission.
jdd510 Dec 22, 2021
e39d903
BG-FGS-start while-in-use permission restriction improvement.
Feb 7, 2022
53b9ff2
[RESTRICT AUTOMERGE] Add hide-non-system-overlay flag for HarmfulAppW…
Jan 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/java/android/accounts/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import com.android.internal.annotations.GuardedBy;

import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -85,6 +86,12 @@ public Account(String name, String type, String accessId) {
if (TextUtils.isEmpty(type)) {
throw new IllegalArgumentException("the type must not be empty: " + type);
}
if (name.length() > 200) {
throw new IllegalArgumentException("account name is longer than 200 characters");
}
if (type.length() > 200) {
throw new IllegalArgumentException("account type is longer than 200 characters");
}
this.name = name;
this.type = type;
this.accessId = accessId;
Expand Down
8 changes: 8 additions & 0 deletions core/java/android/app/admin/DevicePolicyManagerInternal.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package android.app.admin;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.content.ComponentName;
Expand Down Expand Up @@ -76,6 +77,13 @@ public interface OnCrossProfileWidgetProvidersChangeListener {
public abstract void addOnCrossProfileWidgetProvidersChangeListener(
OnCrossProfileWidgetProvidersChangeListener listener);

/**
* @param userHandle the handle of the user whose profile owner is being fetched.
* @return the configured supervision app if it exists and is the device owner or policy owner.
*/
public abstract @Nullable ComponentName getProfileOwnerOrDeviceOwnerSupervisionComponent(
@NonNull UserHandle userHandle);

/**
* Checks if an app with given uid is an active device admin of its user and has the policy
* specified.
Expand Down
3 changes: 3 additions & 0 deletions core/java/android/debug/AdbManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class AdbManager {
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
public static final String WIRELESS_DEBUG_STATE_CHANGED_ACTION =
"com.android.server.adb.WIRELESS_DEBUG_STATUS";

Expand All @@ -46,6 +47,7 @@ public class AdbManager {
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
public static final String WIRELESS_DEBUG_PAIRED_DEVICES_ACTION =
"com.android.server.adb.WIRELESS_DEBUG_PAIRED_DEVICES";

Expand All @@ -59,6 +61,7 @@ public class AdbManager {
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.MANAGE_DEBUGGING)
public static final String WIRELESS_DEBUG_PAIRING_RESULT_ACTION =
"com.android.server.adb.WIRELESS_DEBUG_PAIRING_RESULT";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.android.internal.app;

import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -27,6 +29,7 @@
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.android.internal.R;

/**
Expand All @@ -48,6 +51,7 @@ public class HarmfulAppWarningActivity extends AlertActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
final Intent intent = getIntent();
mPackageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
mTarget = intent.getParcelableExtra(Intent.EXTRA_INTENT);
Expand Down
116 changes: 76 additions & 40 deletions core/java/com/android/internal/infra/AndroidFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@

package com.android.internal.infra;

import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;

import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Handler;
import android.os.Message;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.ExceptionUtils;
import android.util.EventLog;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;
import com.android.internal.util.function.pooled.PooledLambda;

import java.lang.reflect.Constructor;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
Expand Down Expand Up @@ -75,14 +73,16 @@ public class AndroidFuture<T> extends CompletableFuture<T> implements Parcelable

private static final boolean DEBUG = false;
private static final String LOG_TAG = AndroidFuture.class.getSimpleName();
private static final Executor DIRECT_EXECUTOR = Runnable::run;
private static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0];
private static @Nullable Handler sMainHandler;

private final @NonNull Object mLock = new Object();
@GuardedBy("mLock")
private @Nullable BiConsumer<? super T, ? super Throwable> mListener;
@GuardedBy("mLock")
private @Nullable Executor mListenerExecutor = DIRECT_EXECUTOR;
private @NonNull Handler mTimeoutHandler = Handler.getMain();
private @NonNull Handler mTimeoutHandler = getMainHandler();
private final @Nullable IAndroidFuture mRemoteOrigin;

public AndroidFuture() {
Expand All @@ -96,7 +96,7 @@ public AndroidFuture() {
// Done
if (in.readBoolean()) {
// Failed
completeExceptionally(unparcelException(in));
completeExceptionally(readThrowable(in));
} else {
// Success
complete((T) in.readValue(null));
Expand All @@ -108,6 +108,15 @@ public AndroidFuture() {
}
}

@NonNull
private static Handler getMainHandler() {
// This isn't thread-safe but we are okay with it.
if (sMainHandler == null) {
sMainHandler = new Handler(Looper.getMainLooper());
}
return sMainHandler;
}

/**
* Create a completed future with the given value.
*
Expand Down Expand Up @@ -236,9 +245,7 @@ private void callListenerAsync(BiConsumer<? super T, ? super Throwable> listener
if (mListenerExecutor == DIRECT_EXECUTOR) {
callListener(listener, res, err);
} else {
mListenerExecutor.execute(PooledLambda
.obtainRunnable(AndroidFuture::callListener, listener, res, err)
.recycleOnUse());
mListenerExecutor.execute(() -> callListener(listener, res, err));
}
}

Expand All @@ -260,7 +267,8 @@ static <TT> void callListener(
} else {
// listener exception-case threw
// give up on listener but preserve the original exception when throwing up
throw ExceptionUtils.appendCause(t, err);
t.addSuppressed(err);
throw t;
}
}
} catch (Throwable t2) {
Expand All @@ -272,9 +280,7 @@ static <TT> void callListener(
/** @inheritDoc */
//@Override //TODO uncomment once java 9 APIs are exposed to frameworks
public AndroidFuture<T> orTimeout(long timeout, @NonNull TimeUnit unit) {
Message msg = PooledLambda.obtainMessage(AndroidFuture::triggerTimeout, this);
msg.obj = this;
mTimeoutHandler.sendMessageDelayed(msg, unit.toMillis(timeout));
mTimeoutHandler.postDelayed(this::triggerTimeout, this, unit.toMillis(timeout));
return this;
}

Expand Down Expand Up @@ -507,7 +513,7 @@ public void writeToParcel(Parcel dest, int flags) {
result = get();
} catch (Throwable t) {
dest.writeBoolean(true);
parcelException(dest, unwrapExecutionException(t));
writeThrowable(dest, unwrapExecutionException(t));
return;
}
dest.writeBoolean(false);
Expand Down Expand Up @@ -545,45 +551,75 @@ Throwable unwrapExecutionException(Throwable t) {
* Alternative to {@link Parcel#writeException} that stores the stack trace, in a
* way consistent with the binder IPC exception propagation behavior.
*/
private static void parcelException(Parcel p, @Nullable Throwable t) {
p.writeBoolean(t == null);
if (t == null) {
private static void writeThrowable(@NonNull Parcel parcel, @Nullable Throwable throwable) {
boolean hasThrowable = throwable != null;
parcel.writeBoolean(hasThrowable);
if (!hasThrowable) {
return;
}

boolean isFrameworkParcelable = throwable instanceof Parcelable
&& throwable.getClass().getClassLoader() == Parcelable.class.getClassLoader();
parcel.writeBoolean(isFrameworkParcelable);
if (isFrameworkParcelable) {
parcel.writeParcelable((Parcelable) throwable,
Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
return;
}

p.writeInt(Parcel.getExceptionCode(t));
p.writeString(t.getClass().getName());
p.writeString(t.getMessage());
p.writeStackTrace(t);
parcelException(p, t.getCause());
parcel.writeString(throwable.getClass().getName());
parcel.writeString(throwable.getMessage());
StackTraceElement[] stackTrace = throwable.getStackTrace();
StringBuilder stackTraceBuilder = new StringBuilder();
int truncatedStackTraceLength = Math.min(stackTrace != null ? stackTrace.length : 0, 5);
for (int i = 0; i < truncatedStackTraceLength; i++) {
if (i > 0) {
stackTraceBuilder.append('\n');
}
stackTraceBuilder.append("\tat ").append(stackTrace[i]);
}
parcel.writeString(stackTraceBuilder.toString());
writeThrowable(parcel, throwable.getCause());
}

/**
* @see #parcelException
* @see #writeThrowable
*/
private static @Nullable Throwable unparcelException(Parcel p) {
if (p.readBoolean()) {
private static @Nullable Throwable readThrowable(@NonNull Parcel parcel) {
final boolean hasThrowable = parcel.readBoolean();
if (!hasThrowable) {
return null;
}

int exCode = p.readInt();
String cls = p.readString();
String msg = p.readString();
String stackTrace = p.readInt() > 0 ? p.readString() : "\t<stack trace unavailable>";
msg += "\n" + stackTrace;

Exception ex = p.createExceptionOrNull(exCode, msg);
if (ex == null) {
ex = new RuntimeException(cls + ": " + msg);
boolean isFrameworkParcelable = parcel.readBoolean();
if (isFrameworkParcelable) {
return parcel.readParcelable(Parcelable.class.getClassLoader());
}
ex.setStackTrace(EMPTY_STACK_TRACE);

Throwable cause = unparcelException(p);
String className = parcel.readString();
String message = parcel.readString();
String stackTrace = parcel.readString();
String messageWithStackTrace = message + '\n' + stackTrace;
Throwable throwable;
try {
Class<?> clazz = Class.forName(className, true, Parcelable.class.getClassLoader());
if (Throwable.class.isAssignableFrom(clazz)) {
Constructor<?> constructor = clazz.getConstructor(String.class);
throwable = (Throwable) constructor.newInstance(messageWithStackTrace);
} else {
android.util.EventLog.writeEvent(0x534e4554, "186530450", -1, "");
throwable = new RuntimeException(className + ": " + messageWithStackTrace);
}
} catch (Throwable t) {
throwable = new RuntimeException(className + ": " + messageWithStackTrace);
throwable.addSuppressed(t);
}
throwable.setStackTrace(EMPTY_STACK_TRACE);
Throwable cause = readThrowable(parcel);
if (cause != null) {
ex.initCause(ex);
throwable.initCause(cause);
}

return ex;
return throwable;
}

@Override
Expand Down
Loading