Skip to content

Commit b7e072c

Browse files
author
Android Build Coastguard Worker
committed
Snap for 10276566 from 7819640 to tm-platform-release
Change-Id: I6836b564e5a4b9dda44e89f0a119b93f3dfb269b
2 parents 8f9ef19 + 7819640 commit b7e072c

2,898 files changed

Lines changed: 125780 additions & 39106 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apex/jobscheduler/framework/java/android/app/AlarmManager.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
import android.os.HandlerExecutor;
3838
import android.os.Parcel;
3939
import android.os.Parcelable;
40+
import android.os.Process;
4041
import android.os.RemoteException;
42+
import android.os.UserHandle;
4143
import android.os.WorkSource;
4244
import android.text.TextUtils;
4345
import android.util.Log;
@@ -91,6 +93,14 @@
9193
public class AlarmManager {
9294
private static final String TAG = "AlarmManager";
9395

96+
/**
97+
* Prefix used by {{@link #makeTag(long, WorkSource)}} to make a tag on behalf of the caller
98+
* when the {@link #set(int, long, long, long, OnAlarmListener, Handler, WorkSource)} API is
99+
* used. This prefix is a unique sequence of characters to differentiate with other tags that
100+
* apps may provide to other APIs that accept a listener callback.
101+
*/
102+
private static final String GENERATED_TAG_PREFIX = "$android.alarm.generated";
103+
94104
/** @hide */
95105
@IntDef(prefix = { "RTC", "ELAPSED" }, value = {
96106
RTC_WAKEUP,
@@ -860,6 +870,24 @@ public void set(@AlarmType int type, long triggerAtMillis, long windowMillis,
860870
targetHandler, workSource, null);
861871
}
862872

873+
/**
874+
* This is only used to make an identifying tag for the deprecated
875+
* {@link #set(int, long, long, long, OnAlarmListener, Handler, WorkSource)} API which doesn't
876+
* accept a tag. For all other APIs, the tag provided by the app is used, even if it is
877+
* {@code null}.
878+
*/
879+
private static String makeTag(long triggerMillis, WorkSource ws) {
880+
final StringBuilder tagBuilder = new StringBuilder(GENERATED_TAG_PREFIX);
881+
882+
tagBuilder.append(":");
883+
final int attributionUid =
884+
(ws == null || ws.isEmpty()) ? Process.myUid() : ws.getAttributionUid();
885+
tagBuilder.append(UserHandle.formatUid(attributionUid));
886+
tagBuilder.append(":");
887+
tagBuilder.append(triggerMillis);
888+
return tagBuilder.toString();
889+
}
890+
863891
/**
864892
* Direct callback version of {@link #set(int, long, long, long, PendingIntent, WorkSource)}.
865893
* Note that repeating alarms must use the PendingIntent variant, not an OnAlarmListener.
@@ -875,8 +903,8 @@ public void set(@AlarmType int type, long triggerAtMillis, long windowMillis,
875903
public void set(@AlarmType int type, long triggerAtMillis, long windowMillis,
876904
long intervalMillis, OnAlarmListener listener, Handler targetHandler,
877905
WorkSource workSource) {
878-
setImpl(type, triggerAtMillis, windowMillis, intervalMillis, 0, null, listener, null,
879-
targetHandler, workSource, null);
906+
setImpl(type, triggerAtMillis, windowMillis, intervalMillis, 0, null, listener,
907+
makeTag(triggerAtMillis, workSource), targetHandler, workSource, null);
880908
}
881909

882910
/**

apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ void maybeUnrestrictApp(@NonNull String packageName, int userId, int prevMainRea
225225

226226
void setActiveAdminApps(Set<String> adminPkgs, int userId);
227227

228+
void setAdminProtectedPackages(Set<String> packageNames, int userId);
229+
228230
/**
229231
* @return {@code true} if the given package is an active device admin app.
230232
*/

apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,8 +4739,14 @@ public void run() {
47394739
}
47404740
final ArraySet<Pair<String, Integer>> triggerPackages =
47414741
new ArraySet<>();
4742+
final SparseIntArray countsPerUid = new SparseIntArray();
4743+
final SparseIntArray wakeupCountsPerUid = new SparseIntArray();
47424744
for (int i = 0; i < triggerList.size(); i++) {
47434745
final Alarm a = triggerList.get(i);
4746+
increment(countsPerUid, a.uid);
4747+
if (a.wakeup) {
4748+
increment(wakeupCountsPerUid, a.uid);
4749+
}
47444750
if (mConstants.USE_TARE_POLICY) {
47454751
if (!isExemptFromTare(a)) {
47464752
triggerPackages.add(Pair.create(
@@ -4761,7 +4767,8 @@ public void run() {
47614767
}
47624768
rescheduleKernelAlarmsLocked();
47634769
updateNextAlarmClockLocked();
4764-
MetricsHelper.pushAlarmBatchDelivered(triggerList.size(), wakeUps);
4770+
logAlarmBatchDelivered(
4771+
triggerList.size(), wakeUps, countsPerUid, wakeupCountsPerUid);
47654772
}
47664773
}
47674774

@@ -4776,6 +4783,32 @@ public void run() {
47764783
}
47774784
}
47784785

4786+
private static void increment(SparseIntArray array, int key) {
4787+
final int index = array.indexOfKey(key);
4788+
if (index >= 0) {
4789+
array.setValueAt(index, array.valueAt(index) + 1);
4790+
} else {
4791+
array.put(key, 1);
4792+
}
4793+
}
4794+
4795+
private void logAlarmBatchDelivered(
4796+
int alarms,
4797+
int wakeups,
4798+
SparseIntArray countsPerUid,
4799+
SparseIntArray wakeupCountsPerUid) {
4800+
final int[] uids = new int[countsPerUid.size()];
4801+
final int[] countsArray = new int[countsPerUid.size()];
4802+
final int[] wakeupCountsArray = new int[countsPerUid.size()];
4803+
for (int i = 0; i < countsPerUid.size(); i++) {
4804+
uids[i] = countsPerUid.keyAt(i);
4805+
countsArray[i] = countsPerUid.valueAt(i);
4806+
wakeupCountsArray[i] = wakeupCountsPerUid.get(uids[i], 0);
4807+
}
4808+
MetricsHelper.pushAlarmBatchDelivered(
4809+
alarms, wakeups, uids, countsArray, wakeupCountsArray);
4810+
}
4811+
47794812
/**
47804813
* Attribute blame for a WakeLock.
47814814
*
@@ -5695,12 +5728,7 @@ public void deliverLocked(Alarm alarm, long nowELAPSED) {
56955728
}
56965729

56975730
private void incrementAlarmCount(int uid) {
5698-
final int uidIndex = mAlarmsPerUid.indexOfKey(uid);
5699-
if (uidIndex >= 0) {
5700-
mAlarmsPerUid.setValueAt(uidIndex, mAlarmsPerUid.valueAt(uidIndex) + 1);
5701-
} else {
5702-
mAlarmsPerUid.put(uid, 1);
5703-
}
5731+
increment(mAlarmsPerUid, uid);
57045732
}
57055733

57065734
/**

apex/jobscheduler/service/java/com/android/server/alarm/MetricsHelper.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ static void pushAlarmScheduled(Alarm a, int callerProcState) {
111111
ActivityManager.processStateAmToProto(callerProcState));
112112
}
113113

114-
static void pushAlarmBatchDelivered(int numAlarms, int wakeups) {
114+
static void pushAlarmBatchDelivered(
115+
int numAlarms, int wakeups, int[] uids, int[] alarmsPerUid, int[] wakeupAlarmsPerUid) {
115116
FrameworkStatsLog.write(
116117
FrameworkStatsLog.ALARM_BATCH_DELIVERED,
117118
numAlarms,
118-
wakeups);
119+
wakeups,
120+
uids,
121+
alarmsPerUid,
122+
wakeupAlarmsPerUid);
119123
}
120124
}

apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ static class Lock {}
264264
@GuardedBy("mActiveAdminApps")
265265
private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>();
266266

267+
/** List of admin protected packages. Can contain {@link android.os.UserHandle#USER_ALL}. */
268+
@GuardedBy("mAdminProtectedPackages")
269+
private final SparseArray<Set<String>> mAdminProtectedPackages = new SparseArray<>();
270+
267271
/**
268272
* Set of system apps that are headless (don't have any "front door" activities, enabled or
269273
* disabled). Presence in this map indicates that the app is a headless system app.
@@ -1335,6 +1339,9 @@ public void onUserRemoved(int userId) {
13351339
synchronized (mActiveAdminApps) {
13361340
mActiveAdminApps.remove(userId);
13371341
}
1342+
synchronized (mAdminProtectedPackages) {
1343+
mAdminProtectedPackages.remove(userId);
1344+
}
13381345
}
13391346
}
13401347

@@ -1424,6 +1431,10 @@ private int getAppMinBucket(String packageName, int appId, int userId) {
14241431
return STANDBY_BUCKET_EXEMPTED;
14251432
}
14261433

1434+
if (isAdminProtectedPackages(packageName, userId)) {
1435+
return STANDBY_BUCKET_EXEMPTED;
1436+
}
1437+
14271438
if (isActiveNetworkScorer(packageName)) {
14281439
return STANDBY_BUCKET_EXEMPTED;
14291440
}
@@ -1871,6 +1882,17 @@ public boolean isActiveDeviceAdmin(String packageName, int userId) {
18711882
}
18721883
}
18731884

1885+
private boolean isAdminProtectedPackages(String packageName, int userId) {
1886+
synchronized (mAdminProtectedPackages) {
1887+
if (mAdminProtectedPackages.contains(UserHandle.USER_ALL)
1888+
&& mAdminProtectedPackages.get(UserHandle.USER_ALL).contains(packageName)) {
1889+
return true;
1890+
}
1891+
return mAdminProtectedPackages.contains(userId)
1892+
&& mAdminProtectedPackages.get(userId).contains(packageName);
1893+
}
1894+
}
1895+
18741896
@Override
18751897
public void addActiveDeviceAdmin(String adminPkg, int userId) {
18761898
synchronized (mActiveAdminApps) {
@@ -1894,6 +1916,17 @@ public void setActiveAdminApps(Set<String> adminPkgs, int userId) {
18941916
}
18951917
}
18961918

1919+
@Override
1920+
public void setAdminProtectedPackages(Set<String> packageNames, int userId) {
1921+
synchronized (mAdminProtectedPackages) {
1922+
if (packageNames == null || packageNames.isEmpty()) {
1923+
mAdminProtectedPackages.remove(userId);
1924+
} else {
1925+
mAdminProtectedPackages.put(userId, packageNames);
1926+
}
1927+
}
1928+
}
1929+
18971930
@Override
18981931
public void onAdminDataAvailable() {
18991932
mAdminDataAvailableLatch.countDown();
@@ -1916,6 +1949,13 @@ Set<String> getActiveAdminAppsForTest(int userId) {
19161949
}
19171950
}
19181951

1952+
@VisibleForTesting
1953+
Set<String> getAdminProtectedPackagesForTest(int userId) {
1954+
synchronized (mAdminProtectedPackages) {
1955+
return mAdminProtectedPackages.get(userId);
1956+
}
1957+
}
1958+
19191959
/**
19201960
* Returns {@code true} if the supplied package is the device provisioning app. Otherwise,
19211961
* returns {@code false}.

cmds/uiautomator/cmds/uiautomator/src/com/android/commands/uiautomator/DumpCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ else if (arg.equals("--windows")) {
107107
DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
108108
int rotation = display.getRotation();
109109
Point size = new Point();
110-
display.getSize(size);
110+
display.getRealSize(size);
111111
AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x,
112112
size.y);
113113
}

cmds/uiautomator/library/core-src/com/android/uiautomator/core/AccessibilityNodeInfoDumper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static void dumpWindowsToFile(SparseArray<List<AccessibilityWindowInfo>>
139139
serializer.attribute("", "id", Integer.toString(displayId));
140140
int rotation = display.getRotation();
141141
Point size = new Point();
142-
display.getSize(size);
142+
display.getRealSize(size);
143143
for (int i = 0, n = windows.size(); i < n; ++i) {
144144
dumpWindowRec(windows.get(i), serializer, i, size.x, size.y, rotation);
145145
}

cmds/uiautomator/library/core-src/com/android/uiautomator/core/UiDevice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public void dumpWindowHierarchy(String fileName) {
767767
if(root != null) {
768768
Display display = getAutomatorBridge().getDefaultDisplay();
769769
Point size = new Point();
770-
display.getSize(size);
770+
display.getRealSize(size);
771771
AccessibilityNodeInfoDumper.dumpWindowToFile(root,
772772
new File(new File(Environment.getDataDirectory(), "local/tmp"), fileName),
773773
display.getRotation(), size.x, size.y);

core/api/test-current.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ package android.content.pm {
797797
field public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // 0xabf91bdL
798798
field public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 1.5f;
799799
field public static final long OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY = 203647190L; // 0xc2368d6L
800+
field public static final long OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS = 237531167L; // 0xe28701fL
800801
field public static final int RESIZE_MODE_RESIZEABLE = 2; // 0x2
801802
}
802803

@@ -1139,7 +1140,6 @@ package android.hardware.camera2 {
11391140
public final class CameraManager {
11401141
method public String[] getCameraIdListNoLazy() throws android.hardware.camera2.CameraAccessException;
11411142
method @RequiresPermission(allOf={android.Manifest.permission.SYSTEM_CAMERA, android.Manifest.permission.CAMERA}) public void openCamera(@NonNull String, int, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.camera2.CameraDevice.StateCallback) throws android.hardware.camera2.CameraAccessException;
1142-
field public static final long OVERRIDE_FRONT_CAMERA_APP_COMPAT = 250678880L; // 0xef10e60L
11431143
}
11441144

11451145
public abstract static class CameraManager.AvailabilityCallback {
@@ -2412,6 +2412,7 @@ package android.service.dreams {
24122412
public abstract class DreamOverlayService extends android.app.Service {
24132413
ctor public DreamOverlayService();
24142414
method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent);
2415+
method public void onEndDream();
24152416
method public abstract void onStartDream(@NonNull android.view.WindowManager.LayoutParams);
24162417
method public final void requestExit();
24172418
method public final boolean shouldShowComplications();
@@ -2917,7 +2918,9 @@ package android.view {
29172918
}
29182919

29192920
@UiThread public class View implements android.view.accessibility.AccessibilityEventSource android.graphics.drawable.Drawable.Callback android.view.KeyEvent.Callback {
2921+
method public void getBoundsOnScreen(@NonNull android.graphics.Rect, boolean);
29202922
method public android.view.View getTooltipView();
2923+
method public void getWindowDisplayFrame(@NonNull android.graphics.Rect);
29212924
method public boolean isAutofilled();
29222925
method public static boolean isDefaultFocusHighlightEnabled();
29232926
method public boolean isDefaultFocusHighlightNeeded(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);

core/java/android/app/Activity.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ private static final class ManagedCursor {
997997

998998
private ComponentCallbacksController mCallbacksController;
999999

1000+
@Nullable private IVoiceInteractionManagerService mVoiceInteractionManagerService;
1001+
10001002
private final WindowControllerCallback mWindowControllerCallback =
10011003
new WindowControllerCallback() {
10021004
/**
@@ -1606,18 +1608,17 @@ private Object[] collectActivityLifecycleCallbacks() {
16061608

16071609
private void notifyVoiceInteractionManagerServiceActivityEvent(
16081610
@VoiceInteractionSession.VoiceInteractionActivityEventType int type) {
1609-
1610-
final IVoiceInteractionManagerService service =
1611-
IVoiceInteractionManagerService.Stub.asInterface(
1612-
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
1613-
if (service == null) {
1614-
Log.w(TAG, "notifyVoiceInteractionManagerServiceActivityEvent: Can not get "
1615-
+ "VoiceInteractionManagerService");
1616-
return;
1611+
if (mVoiceInteractionManagerService == null) {
1612+
mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface(
1613+
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
1614+
if (mVoiceInteractionManagerService == null) {
1615+
Log.w(TAG, "notifyVoiceInteractionManagerServiceActivityEvent: Can not get "
1616+
+ "VoiceInteractionManagerService");
1617+
return;
1618+
}
16171619
}
1618-
16191620
try {
1620-
service.notifyActivityEventChanged(mToken, type);
1621+
mVoiceInteractionManagerService.notifyActivityEventChanged(mToken, type);
16211622
} catch (RemoteException e) {
16221623
// Empty
16231624
}

0 commit comments

Comments
 (0)