Skip to content

Commit 119e0a2

Browse files
author
Android Build Coastguard Worker
committed
Merge cherrypicks of ['googleplex-android-review.googlesource.com/20064089', 'googleplex-android-review.googlesource.com/20831956', 'googleplex-android-review.googlesource.com/20828777', 'googleplex-android-review.googlesource.com/20642112', 'googleplex-android-review.googlesource.com/20709903', 'googleplex-android-review.googlesource.com/20899934', 'googleplex-android-review.googlesource.com/20920023', 'googleplex-android-review.googlesource.com/20322503', 'googleplex-android-review.googlesource.com/20953243', 'googleplex-android-review.googlesource.com/21129648', 'googleplex-android-review.googlesource.com/21005178', 'googleplex-android-review.googlesource.com/21414918'] into tm-qpr2-release.
Change-Id: I3a0d202607b0a89e6f6bf1b5dea1d14cfe773339
2 parents d69be73 + 25ad513 commit 119e0a2

19 files changed

Lines changed: 232 additions & 31 deletions

File tree

core/java/android/content/Intent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11488,7 +11488,7 @@ private void toUriFragment(StringBuilder uri, String scheme, String defAction,
1148811488
private void toUriInner(StringBuilder uri, String scheme, String defAction,
1148911489
String defPackage, int flags) {
1149011490
if (scheme != null) {
11491-
uri.append("scheme=").append(scheme).append(';');
11491+
uri.append("scheme=").append(Uri.encode(scheme)).append(';');
1149211492
}
1149311493
if (mAction != null && !mAction.equals(defAction)) {
1149411494
uri.append("action=").append(Uri.encode(mAction)).append(';');

core/java/android/content/IntentSender.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.annotation.Nullable;
2020
import android.app.ActivityManager;
2121
import android.app.ActivityManager.PendingIntentInfo;
22+
import android.app.ActivityOptions;
2223
import android.compat.annotation.UnsupportedAppUsage;
2324
import android.os.Bundle;
2425
import android.os.Handler;
@@ -158,7 +159,7 @@ public void run() {
158159
*/
159160
public void sendIntent(Context context, int code, Intent intent,
160161
OnFinished onFinished, Handler handler) throws SendIntentException {
161-
sendIntent(context, code, intent, onFinished, handler, null);
162+
sendIntent(context, code, intent, onFinished, handler, null, null /* options */);
162163
}
163164

164165
/**
@@ -190,6 +191,42 @@ public void sendIntent(Context context, int code, Intent intent,
190191
public void sendIntent(Context context, int code, Intent intent,
191192
OnFinished onFinished, Handler handler, String requiredPermission)
192193
throws SendIntentException {
194+
sendIntent(context, code, intent, onFinished, handler, requiredPermission,
195+
null /* options */);
196+
}
197+
198+
/**
199+
* Perform the operation associated with this IntentSender, allowing the
200+
* caller to specify information about the Intent to use and be notified
201+
* when the send has completed.
202+
*
203+
* @param context The Context of the caller. This may be null if
204+
* <var>intent</var> is also null.
205+
* @param code Result code to supply back to the IntentSender's target.
206+
* @param intent Additional Intent data. See {@link Intent#fillIn
207+
* Intent.fillIn()} for information on how this is applied to the
208+
* original Intent. Use null to not modify the original Intent.
209+
* @param onFinished The object to call back on when the send has
210+
* completed, or null for no callback.
211+
* @param handler Handler identifying the thread on which the callback
212+
* should happen. If null, the callback will happen from the thread
213+
* pool of the process.
214+
* @param requiredPermission Name of permission that a recipient of the PendingIntent
215+
* is required to hold. This is only valid for broadcast intents, and
216+
* corresponds to the permission argument in
217+
* {@link Context#sendBroadcast(Intent, String) Context.sendOrderedBroadcast(Intent, String)}.
218+
* If null, no permission is required.
219+
* @param options Additional options the caller would like to provide to modify the sending
220+
* behavior. May be built from an {@link ActivityOptions} to apply to an activity start.
221+
*
222+
* @throws SendIntentException Throws CanceledIntentException if the IntentSender
223+
* is no longer allowing more intents to be sent through it.
224+
* @hide
225+
*/
226+
public void sendIntent(Context context, int code, Intent intent,
227+
OnFinished onFinished, Handler handler, String requiredPermission,
228+
@Nullable Bundle options)
229+
throws SendIntentException {
193230
try {
194231
String resolvedType = intent != null ?
195232
intent.resolveTypeIfNeeded(context.getContentResolver())
@@ -199,7 +236,7 @@ public void sendIntent(Context context, int code, Intent intent,
199236
onFinished != null
200237
? new FinishedDispatcher(this, onFinished, handler)
201238
: null,
202-
requiredPermission, null);
239+
requiredPermission, options);
203240
if (res < 0) {
204241
throw new SendIntentException();
205242
}

packages/SystemUI/animation/src/com/android/systemui/animation/DialogLaunchAnimator.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,16 @@ constructor(
298298
) {
299299
val view =
300300
openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground
301-
?: throw IllegalStateException(
302-
"The animateFrom dialog was not animated using " +
303-
"DialogLaunchAnimator.showFrom(View|Dialog)"
304-
)
301+
if (view == null) {
302+
Log.w(
303+
TAG,
304+
"Showing dialog $dialog normally as the dialog it is shown from was not shown " +
305+
"using DialogLaunchAnimator"
306+
)
307+
dialog.show()
308+
return
309+
}
310+
305311
showFromView(
306312
dialog,
307313
view,

packages/SystemUI/tests/src/com/android/systemui/animation/DialogLaunchAnimatorTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ class DialogLaunchAnimatorTest : SysuiTestCase() {
260260
assertThat(touchSurface.visibility).isEqualTo(View.GONE)
261261
}
262262

263+
@Test
264+
fun showFromDialogDoesNotCrashWhenShownFromRandomDialog() {
265+
val dialog = createDialogAndShowFromDialog(animateFrom = TestDialog(context))
266+
dialog.dismiss()
267+
}
268+
263269
private fun createAndShowDialog(
264270
animator: DialogLaunchAnimator = dialogLaunchAnimator,
265271
): TestDialog {

services/core/java/com/android/server/accounts/AccountManagerService.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,7 @@ public void onResult(Bundle result) {
30913091
}
30923092
}
30933093

3094-
Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
3094+
Intent intent = result.getParcelable(AccountManager.KEY_INTENT, Intent.class);
30953095
if (intent != null && notifyOnAuthFailure && !customTokens) {
30963096
/*
30973097
* Make sure that the supplied intent is owned by the authenticator
@@ -3516,8 +3516,7 @@ public void onResult(Bundle result) {
35163516
Bundle.setDefusable(result, true);
35173517
mNumResults++;
35183518
Intent intent = null;
3519-
if (result != null
3520-
&& (intent = result.getParcelable(AccountManager.KEY_INTENT)) != null) {
3519+
if (result != null) {
35213520
if (!checkKeyIntent(
35223521
Binder.getCallingUid(),
35233522
result)) {
@@ -4885,8 +4884,10 @@ protected boolean checkKeyIntent(int authUid, Bundle bundle) {
48854884
EventLog.writeEvent(0x534e4554, "250588548", authUid, "");
48864885
return false;
48874886
}
4888-
48894887
Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT, Intent.class);
4888+
if (intent == null) {
4889+
return true;
4890+
}
48904891
// Explicitly set an empty ClipData to ensure that we don't offer to
48914892
// promote any Uris contained inside for granting purposes
48924893
if (intent.getClipData() == null) {
@@ -4936,8 +4937,12 @@ private boolean checkKeyIntentParceledCorrectly(Bundle bundle) {
49364937
Bundle simulateBundle = p.readBundle();
49374938
p.recycle();
49384939
Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT, Intent.class);
4939-
return (intent.filterEquals(simulateBundle.getParcelable(AccountManager.KEY_INTENT,
4940-
Intent.class)));
4940+
Intent simulateIntent = simulateBundle.getParcelable(AccountManager.KEY_INTENT,
4941+
Intent.class);
4942+
if (intent == null) {
4943+
return (simulateIntent == null);
4944+
}
4945+
return intent.filterEquals(simulateIntent);
49414946
}
49424947

49434948
private boolean isExportedSystemActivity(ActivityInfo activityInfo) {
@@ -5082,8 +5087,7 @@ public void onResult(Bundle result) {
50825087
}
50835088
}
50845089
}
5085-
if (result != null
5086-
&& (intent = result.getParcelable(AccountManager.KEY_INTENT)) != null) {
5090+
if (result != null) {
50875091
if (!checkKeyIntent(
50885092
Binder.getCallingUid(),
50895093
result)) {

services/core/java/com/android/server/am/ActiveServices.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3420,6 +3420,11 @@ private ServiceLookupResult retrieveServiceLocked(Intent service,
34203420
throw new SecurityException("BIND_EXTERNAL_SERVICE failed, "
34213421
+ className + " is not an isolatedProcess");
34223422
}
3423+
if (!mAm.getPackageManagerInternal().isSameApp(callingPackage, callingUid,
3424+
userId)) {
3425+
throw new SecurityException("BIND_EXTERNAL_SERVICE failed, "
3426+
+ "calling package not owned by calling UID ");
3427+
}
34233428
// Run the service under the calling package's application.
34243429
ApplicationInfo aInfo = AppGlobals.getPackageManager().getApplicationInfo(
34253430
callingPackage, ActivityManagerService.STOCK_PM_FLAGS, userId);

services/core/java/com/android/server/am/ActivityManagerService.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14655,6 +14655,17 @@ public boolean startInstrumentation(ComponentName className,
1465514655
throw new SecurityException(msg);
1465614656
}
1465714657
}
14658+
if (!Build.IS_DEBUGGABLE && callingUid != ROOT_UID && callingUid != SHELL_UID
14659+
&& callingUid != SYSTEM_UID && !hasActiveInstrumentationLocked(callingPid)) {
14660+
// If it's not debug build and not called from root/shell/system uid, reject it.
14661+
final String msg = "Permission Denial: instrumentation test "
14662+
+ className + " from pid=" + callingPid + ", uid=" + callingUid
14663+
+ ", pkgName=" + getPackageNameByPid(callingPid)
14664+
+ " not allowed because it's not started from SHELL";
14665+
Slog.wtfQuiet(TAG, msg);
14666+
reportStartInstrumentationFailureLocked(watcher, className, msg);
14667+
throw new SecurityException(msg);
14668+
}
1465814669

1465914670
boolean disableHiddenApiChecks = ai.usesNonSdkApi()
1466014671
|| (flags & INSTR_FLAG_DISABLE_HIDDEN_API_CHECKS) != 0;
@@ -14877,6 +14888,29 @@ private void instrumentWithoutRestart(ActiveInstrumentation activeInstr,
1487714888
}
1487814889
}
1487914890

14891+
@GuardedBy("this")
14892+
private boolean hasActiveInstrumentationLocked(int pid) {
14893+
if (pid == 0) {
14894+
return false;
14895+
}
14896+
synchronized (mPidsSelfLocked) {
14897+
ProcessRecord process = mPidsSelfLocked.get(pid);
14898+
return process != null && process.getActiveInstrumentation() != null;
14899+
}
14900+
}
14901+
14902+
private String getPackageNameByPid(int pid) {
14903+
synchronized (mPidsSelfLocked) {
14904+
final ProcessRecord app = mPidsSelfLocked.get(pid);
14905+
14906+
if (app != null && app.info != null) {
14907+
return app.info.packageName;
14908+
}
14909+
14910+
return null;
14911+
}
14912+
}
14913+
1488014914
private boolean isCallerShell() {
1488114915
final int callingUid = Binder.getCallingUid();
1488214916
return callingUid == SHELL_UID || callingUid == ROOT_UID;

services/core/java/com/android/server/location/provider/LocationProviderManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ public void deliverOnLocationChanged(LocationResult locationResult,
300300
public void deliverOnFlushComplete(int requestCode) throws PendingIntent.CanceledException {
301301
BroadcastOptions options = BroadcastOptions.makeBasic();
302302
options.setDontSendToRestrictedApps(true);
303+
options.setPendingIntentBackgroundActivityLaunchAllowed(false);
303304

304305
mPendingIntent.send(mContext, 0, new Intent().putExtra(KEY_FLUSH_COMPLETE, requestCode),
305306
null, null, null, options.toBundle());

services/core/java/com/android/server/notification/PreferencesHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class PreferencesHelper implements RankingConfig {
108108
@VisibleForTesting
109109
static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 5000;
110110
@VisibleForTesting
111-
static final int NOTIFICATION_CHANNEL_GROUP_COUNT_LIMIT = 50000;
111+
static final int NOTIFICATION_CHANNEL_GROUP_COUNT_LIMIT = 6000;
112112

113113
private static final int NOTIFICATION_PREFERENCES_PULL_LIMIT = 1000;
114114
private static final int NOTIFICATION_CHANNEL_PULL_LIMIT = 2000;

services/core/java/com/android/server/pm/InstallPackageHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
import android.annotation.UserIdInt;
9595
import android.app.AppOpsManager;
9696
import android.app.ApplicationPackageManager;
97+
import android.app.BroadcastOptions;
9798
import android.app.backup.IBackupManager;
9899
import android.content.ContentResolver;
99100
import android.content.Context;
@@ -641,7 +642,10 @@ private static void onRestoreComplete(int returnCode, Context context, IntentSen
641642
fillIn.putExtra(PackageInstaller.EXTRA_STATUS,
642643
PackageManager.installStatusToPublicStatus(returnCode));
643644
try {
644-
target.sendIntent(context, 0, fillIn, null, null);
645+
final BroadcastOptions options = BroadcastOptions.makeBasic();
646+
options.setPendingIntentBackgroundActivityLaunchAllowed(false);
647+
target.sendIntent(context, 0, fillIn, null /* onFinished*/, null /* handler */,
648+
null /* requiredPermission */, options.toBundle());
645649
} catch (IntentSender.SendIntentException ignored) {
646650
}
647651
}

0 commit comments

Comments
 (0)