summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-06-18 00:30:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-06-18 00:30:39 +0000
commit58175ace735cbd3ddeee76aa8ca5cb46db7aa24b (patch)
tree7ec3d0428b227630fc71cc0dbb213eacf6aad6c9 /core/java
parent46a57e4af2869398db350b3b2d8f810232d65385 (diff)
parent48e70ad8bc76952075f07600bbf4a0844c6462d7 (diff)
Merge "DO NOT MERGE - Merge ab/7272582" into stage-aosp-master
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/Activity.java6
-rw-r--r--core/java/android/app/ActivityManagerInternal.java22
-rw-r--r--core/java/android/app/ActivityThread.java4
-rw-r--r--core/java/android/app/admin/DevicePolicyManagerInternal.java7
-rw-r--r--core/java/android/hardware/display/DisplayManager.java58
-rw-r--r--core/java/android/hardware/usb/AccessoryFilter.java2
-rw-r--r--core/java/android/os/Process.java49
-rw-r--r--core/java/android/view/InsetsAnimationThreadControlRunner.java3
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java15
-rw-r--r--core/java/android/view/WindowlessWindowManager.java17
-rw-r--r--core/java/android/widget/RemoteViews.java8
-rw-r--r--core/java/com/android/internal/app/NetInitiatedActivity.java31
-rw-r--r--core/java/com/android/internal/app/ProcessMap.java4
13 files changed, 173 insertions, 53 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 4c16072cefd3..2c44c8d7cf2e 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -5183,12 +5183,6 @@ public class Activity extends ContextThemeWrapper
* #checkSelfPermission(String)}.
* </p>
* <p>
- * Calling this API for permissions already granted to your app would show UI
- * to the user to decide whether the app can still hold these permissions. This
- * can be useful if the way your app uses data guarded by the permissions
- * changes significantly.
- * </p>
- * <p>
* You cannot request a permission if your activity sets {@link
* android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
* <code>true</code> because in this case the activity would not receive
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index a5965bc7f85f..e977bab7374e 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -378,6 +378,21 @@ public abstract class ActivityManagerInternal {
public abstract boolean hasRunningForegroundService(int uid, int foregroundServiceType);
/**
+ * Returns {@code true} if the given notification channel currently has a
+ * notification associated with a foreground service. This is an AMS check
+ * because that is the source of truth for the FGS state.
+ */
+ public abstract boolean hasForegroundServiceNotification(String pkg, @UserIdInt int userId,
+ String channelId);
+
+ /**
+ * If the given app has any FGSs whose notifications are in the given channel,
+ * stop them.
+ */
+ public abstract void stopForegroundServicesForChannel(String pkg, @UserIdInt int userId,
+ String channelId);
+
+ /**
* Registers the specified {@code processObserver} to be notified of future changes to
* process state.
*/
@@ -440,4 +455,11 @@ public abstract class ActivityManagerInternal {
* @return true if exists, false otherwise.
*/
public abstract boolean isPendingTopUid(int uid);
+
+ public abstract void tempAllowWhileInUsePermissionInFgs(int uid, long duration);
+
+ public abstract boolean isTempAllowlistedForFgsWhileInUse(int uid);
+
+ public abstract boolean canAllowWhileInUsePermissionInFgs(int pid, int uid,
+ @NonNull String packageName);
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b08705446439..193f7754f974 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4602,6 +4602,10 @@ public final class ActivityThread extends ClientTransactionHandler {
}
if (r.isTopResumedActivity == onTop) {
+ if (!Build.IS_DEBUGGABLE) {
+ Slog.w(TAG, "Activity top position already set to onTop=" + onTop);
+ return;
+ }
throw new IllegalStateException("Activity top position already set to onTop=" + onTop);
}
diff --git a/core/java/android/app/admin/DevicePolicyManagerInternal.java b/core/java/android/app/admin/DevicePolicyManagerInternal.java
index ec17e4497ba4..aca74ce78971 100644
--- a/core/java/android/app/admin/DevicePolicyManagerInternal.java
+++ b/core/java/android/app/admin/DevicePolicyManagerInternal.java
@@ -16,6 +16,7 @@
package android.app.admin;
+import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.content.ComponentName;
import android.content.Intent;
@@ -241,6 +242,7 @@ public abstract class DevicePolicyManagerInternal {
/**
* Returns the profile owner component for the given user, or {@code null} if there is not one.
*/
+ @Nullable
public abstract ComponentName getProfileOwnerAsUser(int userHandle);
/**
@@ -254,4 +256,9 @@ public abstract class DevicePolicyManagerInternal {
* {@link #supportsResetOp(int)} is true.
*/
public abstract void resetOp(int op, String packageName, @UserIdInt int userId);
+
+ /**
+ * Returns whether the given package is a device owner or a profile owner in the calling user.
+ */
+ public abstract boolean isDeviceOrProfileOwnerInCallingUser(String packageName);
}
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index 9271d0e05fa0..d83b4321a8ab 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -62,6 +62,9 @@ public final class DisplayManager {
* {@link #EXTRA_WIFI_DISPLAY_STATUS} extra.
* </p><p>
* This broadcast is only sent to registered receivers and can only be sent by the system.
+ * </p><p>
+ * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permission is required to
+ * receive this broadcast.
* </p>
* @hide
*/
@@ -870,38 +873,77 @@ public final class DisplayManager {
public interface DeviceConfig {
/**
- * Key for refresh rate in the zone defined by thresholds.
+ * Key for refresh rate in the low zone defined by thresholds.
*
+ * Note that the name and value don't match because they were added before we had a high
+ * zone to consider.
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.integer#config_defaultZoneBehavior
*/
- String KEY_REFRESH_RATE_IN_ZONE = "refresh_rate_in_zone";
+ String KEY_REFRESH_RATE_IN_LOW_ZONE = "refresh_rate_in_zone";
/**
- * Key for accessing the display brightness thresholds for the configured refresh rate zone.
+ * Key for accessing the low display brightness thresholds for the configured refresh
+ * rate zone.
* The value will be a pair of comma separated integers representing the minimum and maximum
* thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
*
+ * Note that the name and value don't match because they were added before we had a high
+ * zone to consider.
+ *
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_brightnessThresholdsOfPeakRefreshRate
* @hide
*/
- String KEY_PEAK_REFRESH_RATE_DISPLAY_BRIGHTNESS_THRESHOLDS =
+ String KEY_FIXED_REFRESH_RATE_LOW_DISPLAY_BRIGHTNESS_THRESHOLDS =
"peak_refresh_rate_brightness_thresholds";
/**
- * Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
- * The value will be a pair of comma separated integers representing the minimum and maximum
- * thresholds of the zone, respectively, in lux.
+ * Key for accessing the low ambient brightness thresholds for the configured refresh
+ * rate zone. The value will be a pair of comma separated integers representing the minimum
+ * and maximum thresholds of the zone, respectively, in lux.
+ *
+ * Note that the name and value don't match because they were added before we had a high
+ * zone to consider.
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
* @see android.R.array#config_ambientThresholdsOfPeakRefreshRate
* @hide
*/
- String KEY_PEAK_REFRESH_RATE_AMBIENT_BRIGHTNESS_THRESHOLDS =
+ String KEY_FIXED_REFRESH_RATE_LOW_AMBIENT_BRIGHTNESS_THRESHOLDS =
"peak_refresh_rate_ambient_thresholds";
+ /**
+ * Key for refresh rate in the high zone defined by thresholds.
+ *
+ * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
+ * @see android.R.integer#config_fixedRefreshRateInHighZone
+ */
+ String KEY_REFRESH_RATE_IN_HIGH_ZONE = "refresh_rate_in_high_zone";
+
+ /**
+ * Key for accessing the display brightness thresholds for the configured refresh rate zone.
+ * The value will be a pair of comma separated integers representing the minimum and maximum
+ * thresholds of the zone, respectively, in display backlight units (i.e. [0, 255]).
+ *
+ * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
+ * @see android.R.array#config_brightnessHighThresholdsOfFixedRefreshRate
+ * @hide
+ */
+ String KEY_FIXED_REFRESH_RATE_HIGH_DISPLAY_BRIGHTNESS_THRESHOLDS =
+ "fixed_refresh_rate_high_display_brightness_thresholds";
/**
+ * Key for accessing the ambient brightness thresholds for the configured refresh rate zone.
+ * The value will be a pair of comma separated integers representing the minimum and maximum
+ * thresholds of the zone, respectively, in lux.
+ *
+ * @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
+ * @see android.R.array#config_ambientHighThresholdsOfFixedRefreshRate
+ * @hide
+ */
+ String KEY_FIXED_REFRESH_RATE_HIGH_AMBIENT_BRIGHTNESS_THRESHOLDS =
+ "fixed_refresh_rate_high_ambient_brightness_thresholds";
+ /**
* Key for default peak refresh rate
*
* @see android.provider.DeviceConfig#NAMESPACE_DISPLAY_MANAGER
diff --git a/core/java/android/hardware/usb/AccessoryFilter.java b/core/java/android/hardware/usb/AccessoryFilter.java
index f22dad4124d2..f4c73d56e433 100644
--- a/core/java/android/hardware/usb/AccessoryFilter.java
+++ b/core/java/android/hardware/usb/AccessoryFilter.java
@@ -101,7 +101,7 @@ public class AccessoryFilter {
public boolean matches(UsbAccessory acc) {
if (mManufacturer != null && !acc.getManufacturer().equals(mManufacturer)) return false;
if (mModel != null && !acc.getModel().equals(mModel)) return false;
- return !(mVersion != null && !acc.getVersion().equals(mVersion));
+ return !(mVersion != null && !mVersion.equals(acc.getVersion()));
}
/**
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 9b29fb1dfaac..46140a4ab399 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -34,8 +34,12 @@ import dalvik.system.VMRuntime;
import libcore.io.IoUtils;
+import java.io.BufferedReader;
import java.io.FileDescriptor;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.concurrent.TimeoutException;
/**
@@ -208,6 +212,12 @@ public class Process {
public static final int SE_UID = 1068;
/**
+ * Defines the UID/GID for the iorapd.
+ * @hide
+ */
+ public static final int IORAPD_UID = 1071;
+
+ /**
* Defines the UID/GID for the NetworkStack app.
* @hide
*/
@@ -1397,4 +1407,43 @@ public class Process {
}
private static native int nativePidFdOpen(int pid, int flags) throws ErrnoException;
+
+ /**
+ * Checks if a process corresponding to a specific pid owns any file locks.
+ * @param pid The process ID for which we want to know the existence of file locks.
+ * @return true If the process holds any file locks, false otherwise.
+ * @throws IOException if /proc/locks can't be accessed.
+ *
+ * @hide
+ */
+ public static boolean hasFileLocks(int pid) throws Exception {
+ BufferedReader br = null;
+
+ try {
+ br = new BufferedReader(new FileReader("/proc/locks"));
+ String line;
+
+ while ((line = br.readLine()) != null) {
+ StringTokenizer st = new StringTokenizer(line);
+
+ for (int i = 0; i < 5 && st.hasMoreTokens(); i++) {
+ String str = st.nextToken();
+ try {
+ if (i == 4 && Integer.parseInt(str) == pid) {
+ return true;
+ }
+ } catch (NumberFormatException nfe) {
+ throw new Exception("Exception parsing /proc/locks at \" "
+ + line + " \", token #" + i);
+ }
+ }
+ }
+
+ return false;
+ } finally {
+ if (br != null) {
+ br.close();
+ }
+ }
+ }
}
diff --git a/core/java/android/view/InsetsAnimationThreadControlRunner.java b/core/java/android/view/InsetsAnimationThreadControlRunner.java
index 123604489da4..09e4557135b5 100644
--- a/core/java/android/view/InsetsAnimationThreadControlRunner.java
+++ b/core/java/android/view/InsetsAnimationThreadControlRunner.java
@@ -108,6 +108,9 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro
mControl = new InsetsAnimationControlImpl(controls, frame, state, listener,
types, mCallbacks, durationMs, interpolator, animationType);
InsetsAnimationThread.getHandler().post(() -> {
+ if (mControl.isCancelled()) {
+ return;
+ }
Trace.asyncTraceBegin(Trace.TRACE_TAG_VIEW,
"InsetsAsyncAnimation: " + WindowInsets.Type.toString(types), types);
listener.onReady(mControl, types);
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index 700dc66fab55..ba40459692f7 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -113,13 +113,20 @@ public class InsetsSourceConsumer {
InsetsState.typeToString(control.getType()),
mController.getHost().getRootViewTitle()));
}
- // We are loosing control
if (mSourceControl == null) {
+ // We are loosing control
mController.notifyControlRevoked(this);
- // Restore server visibility.
- mState.getSource(getType()).setVisible(
- mController.getLastDispatchedState().getSource(getType()).isVisible());
+ // Check if we need to restore server visibility.
+ final InsetsSource source = mState.getSource(mType);
+ final boolean serverVisibility =
+ mController.getLastDispatchedState().getSourceOrDefaultVisibility(mType);
+ if (source.isVisible() != serverVisibility) {
+ source.setVisible(serverVisibility);
+ mController.notifyVisibilityChanged();
+ }
+
+ // For updateCompatSysUiVisibility
applyLocalVisibilityOverride();
} else {
// We are gaining control, and need to run an animation since previous state
diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java
index 1af4c3636ac5..f0006d988163 100644
--- a/core/java/android/view/WindowlessWindowManager.java
+++ b/core/java/android/view/WindowlessWindowManager.java
@@ -156,7 +156,10 @@ public class WindowlessWindowManager implements IWindowSession {
mStateForWindow.put(window.asBinder(), state);
}
- return WindowManagerGlobal.ADD_OKAY | WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
+ final int res = WindowManagerGlobal.ADD_OKAY | WindowManagerGlobal.ADD_FLAG_APP_VISIBLE;
+
+ // Include whether the window is in touch mode.
+ return isInTouchMode() ? res | WindowManagerGlobal.ADD_FLAG_IN_TOUCH_MODE : res;
}
/**
@@ -207,6 +210,15 @@ public class WindowlessWindowManager implements IWindowSession {
return !PixelFormat.formatHasAlpha(attrs.format);
}
+ private boolean isInTouchMode() {
+ try {
+ return WindowManagerGlobal.getWindowSession().getInTouchMode();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to check if the window is in touch mode", e);
+ }
+ return false;
+ }
+
/** @hide */
protected SurfaceControl getSurfaceControl(View rootView) {
final ViewRootImpl root = rootView.getViewRootImpl();
@@ -268,7 +280,8 @@ public class WindowlessWindowManager implements IWindowSession {
}
}
- return 0;
+ // Include whether the window is in touch mode.
+ return isInTouchMode() ? WindowManagerGlobal.RELAYOUT_RES_IN_TOUCH_MODE : 0;
}
@Override
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 99cd2702a03d..76267d8c1e6f 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -593,6 +593,14 @@ public class RemoteViews implements Parcelable, Filter {
public String getPackageName() {
return mContextForResources.getPackageName();
}
+
+ @Override
+ public boolean isRestricted() {
+ // Override isRestricted and direct to resource's implementation. The isRestricted is
+ // used for determining the risky resources loading, e.g. fonts, thus direct to context
+ // for resource.
+ return mContextForResources.isRestricted();
+ }
}
private class SetEmptyView extends Action {
diff --git a/core/java/com/android/internal/app/NetInitiatedActivity.java b/core/java/com/android/internal/app/NetInitiatedActivity.java
index 56ec87cc8188..375e5036c083 100644
--- a/core/java/com/android/internal/app/NetInitiatedActivity.java
+++ b/core/java/com/android/internal/app/NetInitiatedActivity.java
@@ -17,18 +17,14 @@
package com.android.internal.app;
import android.app.AlertDialog;
-import android.compat.annotation.UnsupportedAppUsage;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.IntentFilter;
import android.location.LocationManagerInternal;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
-import android.widget.Toast;
import com.android.internal.R;
import com.android.internal.location.GpsNetInitiatedHandler;
@@ -43,7 +39,6 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
private static final String TAG = "NetInitiatedActivity";
private static final boolean DEBUG = true;
- private static final boolean VERBOSE = false;
private static final int POSITIVE_BUTTON = AlertDialog.BUTTON_POSITIVE;
private static final int NEGATIVE_BUTTON = AlertDialog.BUTTON_NEGATIVE;
@@ -55,17 +50,6 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
private int default_response = -1;
private int default_response_timeout = 6;
- /** Used to detect when NI request is received */
- private BroadcastReceiver mNetInitiatedReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (DEBUG) Log.d(TAG, "NetInitiatedReceiver onReceive: " + intent.getAction());
- if (intent.getAction() == GpsNetInitiatedHandler.ACTION_NI_VERIFY) {
- handleNIVerify(intent);
- }
- }
- };
-
private final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -109,14 +93,12 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
protected void onResume() {
super.onResume();
if (DEBUG) Log.d(TAG, "onResume");
- registerReceiver(mNetInitiatedReceiver, new IntentFilter(GpsNetInitiatedHandler.ACTION_NI_VERIFY));
}
@Override
protected void onPause() {
super.onPause();
if (DEBUG) Log.d(TAG, "onPause");
- unregisterReceiver(mNetInitiatedReceiver);
}
/**
@@ -141,17 +123,4 @@ public class NetInitiatedActivity extends AlertActivity implements DialogInterfa
LocationManagerInternal lm = LocalServices.getService(LocationManagerInternal.class);
lm.sendNiResponse(notificationId, response);
}
-
- @UnsupportedAppUsage
- private void handleNIVerify(Intent intent) {
- int notifId = intent.getIntExtra(GpsNetInitiatedHandler.NI_INTENT_KEY_NOTIF_ID, -1);
- notificationId = notifId;
-
- if (DEBUG) Log.d(TAG, "handleNIVerify action: " + intent.getAction());
- }
-
- private void showNIError() {
- Toast.makeText(this, "NI error" /* com.android.internal.R.string.usb_storage_error_message */,
- Toast.LENGTH_LONG).show();
- }
}
diff --git a/core/java/com/android/internal/app/ProcessMap.java b/core/java/com/android/internal/app/ProcessMap.java
index 81036f7ecba8..4917a47eb000 100644
--- a/core/java/com/android/internal/app/ProcessMap.java
+++ b/core/java/com/android/internal/app/ProcessMap.java
@@ -22,7 +22,7 @@ import android.util.SparseArray;
public class ProcessMap<E> {
final ArrayMap<String, SparseArray<E>> mMap
= new ArrayMap<String, SparseArray<E>>();
-
+
public E get(String name, int uid) {
SparseArray<E> uids = mMap.get(name);
if (uids == null) return null;
@@ -58,4 +58,6 @@ public class ProcessMap<E> {
public int size() {
return mMap.size();
}
+
+ public void putAll(ProcessMap<E> other) { mMap.putAll(other.mMap); }
}