Skip to content

Commit 65ff524

Browse files
author
android-build-team Robot
committed
Snap for 4603989 from 833770d to oc-m2-release
Change-Id: Id2935bbe1630247131e87ed78cc70a7e3aaa0f5b
2 parents 1e79675 + 833770d commit 65ff524

File tree

19 files changed

+98
-170
lines changed

19 files changed

+98
-170
lines changed

core/java/android/app/Activity.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5871,16 +5871,6 @@ public ComponentName getComponentName()
58715871
return mComponent;
58725872
}
58735873

5874-
/**
5875-
* Temporary method on O-MR1 only.
5876-
*
5877-
* @hide
5878-
*/
5879-
@Override
5880-
public ComponentName getComponentNameForAutofill() {
5881-
return mComponent;
5882-
}
5883-
58845874
/**
58855875
* Retrieve a {@link SharedPreferences} object for accessing preferences
58865876
* that are private to this activity. This simply calls the underlying

core/java/android/app/ActivityManagerInternal.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,4 @@ public abstract int startActivitiesAsPackage(String packageName,
268268
* @param token The IApplicationToken for the activity
269269
*/
270270
public abstract void setFocusedActivity(IBinder token);
271-
272-
/**
273-
* Returns {@code true} if {@code uid} is running an activity from {@code packageName}.
274-
*/
275-
public abstract boolean hasRunningActivity(int uid, @Nullable String packageName);
276271
}

core/java/android/app/assist/AssistStructure.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,16 +2058,6 @@ public ComponentName getActivityComponent() {
20582058
return mActivityComponent;
20592059
}
20602060

2061-
/**
2062-
* Called by Autofill server when app forged a different value.
2063-
*
2064-
* @hide
2065-
*/
2066-
public void setActivityComponent(ComponentName componentName) {
2067-
ensureData();
2068-
mActivityComponent = componentName;
2069-
}
2070-
20712061
/** @hide */
20722062
public int getFlags() {
20732063
return mFlags;

core/java/android/view/autofill/AutofillManager.java

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import android.annotation.NonNull;
2525
import android.annotation.Nullable;
2626
import android.annotation.SystemService;
27-
import android.content.ComponentName;
2827
import android.content.Context;
2928
import android.content.Intent;
3029
import android.content.IntentSender;
@@ -45,7 +44,6 @@
4544
import com.android.internal.annotations.GuardedBy;
4645
import com.android.internal.logging.MetricsLogger;
4746
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
48-
import com.android.internal.util.Preconditions;
4947

5048
import java.io.PrintWriter;
5149
import java.lang.annotation.Retention;
@@ -386,20 +384,13 @@ boolean autofillCallbackRequestShowFillUi(@NonNull View anchor, int width, int h
386384
* Runs the specified action on the UI thread.
387385
*/
388386
void runOnUiThread(Runnable action);
389-
390-
/**
391-
* Gets the complete component name of this client.
392-
*
393-
* <p>Temporary method on O-MR1 only.
394-
*/
395-
ComponentName getComponentNameForAutofill();
396387
}
397388

398389
/**
399390
* @hide
400391
*/
401392
public AutofillManager(Context context, IAutoFillManager service) {
402-
mContext = Preconditions.checkNotNull(context, "context cannot be null");
393+
mContext = context;
403394
mService = service;
404395
}
405396

@@ -949,10 +940,6 @@ private AutofillClient getClientLocked() {
949940
return mContext.getAutofillClient();
950941
}
951942

952-
private ComponentName getComponentNameFromContext(AutofillClient client) {
953-
return client == null ? null : client.getComponentNameForAutofill();
954-
}
955-
956943
/** @hide */
957944
public void onAuthenticationResult(int authenticationId, Intent data) {
958945
if (!hasAutofillFeature()) {
@@ -1003,18 +990,13 @@ private void startSessionLocked(@NonNull AutofillId id, @NonNull Rect bounds,
1003990
return;
1004991
}
1005992
try {
1006-
final AutofillClient client = getClientLocked();
1007-
final ComponentName componentName = getComponentNameFromContext(client);
1008-
if (componentName == null) {
1009-
Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext);
1010-
return;
1011-
}
1012993
mSessionId = mService.startSession(mContext.getActivityToken(),
1013994
mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
1014-
mCallback != null, flags, componentName);
995+
mCallback != null, flags, mContext.getOpPackageName());
1015996
if (mSessionId != NO_SESSION) {
1016997
mState = STATE_ACTIVE;
1017998
}
999+
final AutofillClient client = getClientLocked();
10181000
if (client != null) {
10191001
client.autofillCallbackResetableStateAvailable();
10201002
}
@@ -1068,19 +1050,14 @@ private void updateSessionLocked(AutofillId id, Rect bounds, AutofillValue value
10681050

10691051
try {
10701052
if (restartIfNecessary) {
1071-
final AutofillClient client = getClientLocked();
1072-
final ComponentName componentName = getComponentNameFromContext(client);
1073-
if (componentName == null) {
1074-
Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext);
1075-
return;
1076-
}
10771053
final int newId = mService.updateOrRestartSession(mContext.getActivityToken(),
10781054
mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
1079-
mCallback != null, flags, componentName, mSessionId, action);
1055+
mCallback != null, flags, mContext.getOpPackageName(), mSessionId, action);
10801056
if (newId != mSessionId) {
10811057
if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId);
10821058
mSessionId = newId;
10831059
mState = (mSessionId == NO_SESSION) ? STATE_UNKNOWN : STATE_ACTIVE;
1060+
final AutofillClient client = getClientLocked();
10841061
if (client != null) {
10851062
client.autofillCallbackResetableStateAvailable();
10861063
}

core/java/android/view/autofill/IAutoFillManager.aidl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package android.view.autofill;
1818

19-
import android.content.ComponentName;
2019
import android.graphics.Rect;
2120
import android.os.Bundle;
2221
import android.os.IBinder;
@@ -35,15 +34,14 @@ interface IAutoFillManager {
3534
int addClient(in IAutoFillManagerClient client, int userId);
3635
int startSession(IBinder activityToken, in IBinder appCallback, in AutofillId autoFillId,
3736
in Rect bounds, in AutofillValue value, int userId, boolean hasCallback, int flags,
38-
in ComponentName componentName);
37+
String packageName);
3938
FillEventHistory getFillEventHistory();
4039
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
4140
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
4241
in AutofillValue value, int action, int flags, int userId);
4342
int updateOrRestartSession(IBinder activityToken, in IBinder appCallback,
4443
in AutofillId autoFillId, in Rect bounds, in AutofillValue value, int userId,
45-
boolean hasCallback, int flags, in ComponentName componentName, int sessionId,
46-
int action);
44+
boolean hasCallback, int flags, String packageName, int sessionId, int action);
4745
void finishSession(int sessionId, int userId);
4846
void cancelSession(int sessionId, int userId);
4947
void setAuthenticationResult(in Bundle data, int sessionId, int authenticationId, int userId);

core/java/com/android/internal/widget/VerifyCredentialResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public void writeToParcel(Parcel dest, int flags) {
9898
if (mPayload != null) {
9999
dest.writeInt(mPayload.length);
100100
dest.writeByteArray(mPayload);
101+
} else {
102+
dest.writeInt(0);
101103
}
102104
}
103105
}

core/proto/android/service/diskstats.proto

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ message DiskStatsServiceDumpProto {
4747
}
4848

4949
message DiskStatsCachedValuesProto {
50-
// Total app data size, in kilobytes
50+
// Total app code size, in kilobytes
5151
int64 agg_apps_size = 1;
5252
// Total app cache size, in kilobytes
5353
int64 agg_apps_cache_size = 2;
@@ -65,15 +65,19 @@ message DiskStatsCachedValuesProto {
6565
int64 other_size = 8;
6666
// Sizes of individual packages
6767
repeated DiskStatsAppSizesProto app_sizes = 9;
68+
// Total app data size, in kilobytes
69+
int64 agg_apps_data_size = 10;
6870
}
6971

7072
message DiskStatsAppSizesProto {
7173
// Name of the package
7274
string package_name = 1;
73-
// App's data size in kilobytes
75+
// App's code size in kilobytes
7476
int64 app_size = 2;
7577
// App's cache size in kilobytes
7678
int64 cache_size = 3;
79+
// App's data size in kilobytes
80+
int64 app_data_size = 4;
7781
}
7882

7983
message DiskStatsFreeSpaceProto {

proto/src/metrics_constants.proto

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4006,19 +4006,6 @@ message MetricsEvent {
40064006
// OS: O
40074007
FIELD_NOTIFICATION_GROUP_SUMMARY = 947;
40084008

4009-
// An app attempted to forge a different component name in the AssisStructure that would be
4010-
// passed to the autofill service.
4011-
// OS: O (security patch)
4012-
// Package: Real package of the app being autofilled
4013-
// Tag FIELD_AUTOFILL_SERVICE: Package of the autofill service that processed the request
4014-
// TAG FIELD_AUTOFILL_FORGED_COMPONENT_NAME: Component name being forged
4015-
AUTOFILL_FORGED_COMPONENT_ATTEMPT = 948;
4016-
4017-
// FIELD - The component that an app tried tro forged.
4018-
// Type: string
4019-
// OS: O (security patch)
4020-
FIELD_AUTOFILL_FORGED_COMPONENT_NAME = 949;
4021-
40224009
// ---- End O Constants, all O constants go above this line ----
40234010

40244011
// OPEN: Settings > System > Languages & input > Advanced > Lift to open camera

services/autofill/java/com/android/server/autofill/AutofillManagerService.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,26 +533,25 @@ public void setHasCallback(int sessionId, int userId, boolean hasIt) {
533533
@Override
534534
public int startSession(IBinder activityToken, IBinder appCallback, AutofillId autofillId,
535535
Rect bounds, AutofillValue value, int userId, boolean hasCallback, int flags,
536-
ComponentName componentName) {
536+
String packageName) {
537537

538538
activityToken = Preconditions.checkNotNull(activityToken, "activityToken");
539539
appCallback = Preconditions.checkNotNull(appCallback, "appCallback");
540540
autofillId = Preconditions.checkNotNull(autofillId, "autoFillId");
541-
componentName = Preconditions.checkNotNull(componentName, "componentName");
542-
final String packageName = Preconditions.checkNotNull(componentName.getPackageName());
541+
packageName = Preconditions.checkNotNull(packageName, "packageName");
543542

544543
Preconditions.checkArgument(userId == UserHandle.getUserId(getCallingUid()), "userId");
545544

546545
try {
547546
mContext.getPackageManager().getPackageInfoAsUser(packageName, 0, userId);
548547
} catch (PackageManager.NameNotFoundException e) {
549-
throw new IllegalArgumentException(componentName + " is not a valid package", e);
548+
throw new IllegalArgumentException(packageName + " is not a valid package", e);
550549
}
551550

552551
synchronized (mLock) {
553552
final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
554553
return service.startSessionLocked(activityToken, getCallingUid(), appCallback,
555-
autofillId, bounds, value, hasCallback, flags, componentName);
554+
autofillId, bounds, value, hasCallback, flags, packageName);
556555
}
557556
}
558557

@@ -604,8 +603,7 @@ public void updateSession(int sessionId, AutofillId autoFillId, Rect bounds,
604603
@Override
605604
public int updateOrRestartSession(IBinder activityToken, IBinder appCallback,
606605
AutofillId autoFillId, Rect bounds, AutofillValue value, int userId,
607-
boolean hasCallback, int flags, ComponentName componentName, int sessionId,
608-
int action) {
606+
boolean hasCallback, int flags, String packageName, int sessionId, int action) {
609607
boolean restart = false;
610608
synchronized (mLock) {
611609
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
@@ -616,7 +614,7 @@ public int updateOrRestartSession(IBinder activityToken, IBinder appCallback,
616614
}
617615
if (restart) {
618616
return startSession(activityToken, appCallback, autoFillId, bounds, value, userId,
619-
hasCallback, flags, componentName);
617+
hasCallback, flags, packageName);
620618
}
621619

622620
// Nothing changed...

services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626
import android.annotation.NonNull;
2727
import android.annotation.Nullable;
2828
import android.app.ActivityManager;
29-
import android.app.ActivityManagerInternal;
3029
import android.app.AppGlobals;
3130
import android.app.IActivityManager;
3231
import android.content.ComponentName;
3332
import android.content.Context;
3433
import android.content.pm.ApplicationInfo;
3534
import android.content.pm.PackageManager;
36-
import android.content.pm.PackageManager.NameNotFoundException;
3735
import android.content.pm.ServiceInfo;
3836
import android.graphics.Rect;
3937
import android.graphics.drawable.Drawable;
@@ -45,7 +43,6 @@
4543
import android.os.Looper;
4644
import android.os.RemoteCallbackList;
4745
import android.os.RemoteException;
48-
import android.os.UserHandle;
4946
import android.os.UserManager;
5047
import android.provider.Settings;
5148
import android.service.autofill.AutofillService;
@@ -70,7 +67,6 @@
7067
import com.android.internal.logging.MetricsLogger;
7168
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
7269
import com.android.internal.os.HandlerCaller;
73-
import com.android.server.LocalServices;
7470
import com.android.server.autofill.ui.AutoFillUI;
7571

7672
import java.io.PrintWriter;
@@ -283,7 +279,7 @@ void setHasCallback(int sessionId, int uid, boolean hasIt) {
283279
int startSessionLocked(@NonNull IBinder activityToken, int uid,
284280
@NonNull IBinder appCallbackToken, @NonNull AutofillId autofillId,
285281
@NonNull Rect virtualBounds, @Nullable AutofillValue value, boolean hasCallback,
286-
int flags, @NonNull ComponentName componentName) {
282+
int flags, @NonNull String packageName) {
287283
if (!isEnabled()) {
288284
return 0;
289285
}
@@ -293,7 +289,7 @@ int startSessionLocked(@NonNull IBinder activityToken, int uid,
293289
pruneAbandonedSessionsLocked();
294290

295291
final Session newSession = createSessionByTokenLocked(activityToken, uid, appCallbackToken,
296-
hasCallback, componentName);
292+
hasCallback, packageName);
297293
if (newSession == null) {
298294
return NO_SESSION;
299295
}
@@ -390,8 +386,7 @@ void disableOwnedAutofillServicesLocked(int uid) {
390386
}
391387

392388
private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int uid,
393-
@NonNull IBinder appCallbackToken, boolean hasCallback,
394-
@NonNull ComponentName componentName) {
389+
@NonNull IBinder appCallbackToken, boolean hasCallback, @NonNull String packageName) {
395390
// use random ids so that one app cannot know that another app creates sessions
396391
int sessionId;
397392
int tries = 0;
@@ -405,44 +400,14 @@ private Session createSessionByTokenLocked(@NonNull IBinder activityToken, int u
405400
sessionId = sRandom.nextInt();
406401
} while (sessionId == NO_SESSION || mSessions.indexOfKey(sessionId) >= 0);
407402

408-
assertCallerLocked(componentName);
409-
410403
final Session newSession = new Session(this, mUi, mContext, mHandlerCaller, mUserId, mLock,
411404
sessionId, uid, activityToken, appCallbackToken, hasCallback,
412-
mUiLatencyHistory, mInfo.getServiceInfo().getComponentName(), componentName);
405+
mUiLatencyHistory, mInfo.getServiceInfo().getComponentName(), packageName);
413406
mSessions.put(newSession.id, newSession);
414407

415408
return newSession;
416409
}
417410

418-
/**
419-
* Asserts the component is owned by the caller.
420-
*/
421-
private void assertCallerLocked(@NonNull ComponentName componentName) {
422-
final String packageName = componentName.getPackageName();
423-
final PackageManager pm = mContext.getPackageManager();
424-
final int callingUid = Binder.getCallingUid();
425-
final int packageUid;
426-
try {
427-
packageUid = pm.getPackageUidAsUser(packageName, UserHandle.getCallingUserId());
428-
} catch (NameNotFoundException e) {
429-
throw new SecurityException("Could not verify UID for " + componentName);
430-
}
431-
if (callingUid != packageUid && !LocalServices.getService(ActivityManagerInternal.class)
432-
.hasRunningActivity(callingUid, packageName)) {
433-
final String[] packages = pm.getPackagesForUid(callingUid);
434-
final String callingPackage = packages != null ? packages[0] : "uid-" + callingUid;
435-
Slog.w(TAG, "App (package=" + callingPackage + ", UID=" + callingUid
436-
+ ") passed component (" + componentName + ") owned by UID " + packageUid);
437-
mMetricsLogger.write(new LogMaker(MetricsEvent.AUTOFILL_FORGED_COMPONENT_ATTEMPT)
438-
.setPackageName(callingPackage)
439-
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_SERVICE, getServicePackageName())
440-
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_FORGED_COMPONENT_NAME,
441-
componentName == null ? "null" : componentName.flattenToShortString()));
442-
throw new SecurityException("Invalid component: " + componentName);
443-
}
444-
}
445-
446411
/**
447412
* Restores a session after an activity was temporarily destroyed.
448413
*

0 commit comments

Comments
 (0)