Skip to content

Commit dda2666

Browse files
author
android-build-team Robot
committed
Merge cherrypicks of [3519487, 3519488, 3520743, 3521264, 3521265] into oc-m2-release
Change-Id: I890e0abea705523c9dc9c38818a74b6d0a939a61
2 parents b80cf47 + b6494a9 commit dda2666

5 files changed

Lines changed: 36 additions & 26 deletions

File tree

core/java/android/app/Activity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5871,6 +5871,16 @@ 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+
58745884
/**
58755885
* Retrieve a {@link SharedPreferences} object for accessing preferences
58765886
* that are private to this activity. This simply calls the underlying

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

Lines changed: 13 additions & 10 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.app.Activity;
2827
import android.content.ComponentName;
2928
import android.content.Context;
3029
import android.content.Intent;
@@ -387,6 +386,13 @@ boolean autofillCallbackRequestShowFillUi(@NonNull View anchor, int width, int h
387386
* Runs the specified action on the UI thread.
388387
*/
389388
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();
390396
}
391397

392398
/**
@@ -943,11 +949,8 @@ private AutofillClient getClientLocked() {
943949
return mContext.getAutofillClient();
944950
}
945951

946-
private ComponentName getComponentNameFromContext() {
947-
if (mContext instanceof Activity) {
948-
return ((Activity) mContext).getComponentName();
949-
}
950-
return null;
952+
private ComponentName getComponentNameFromContext(AutofillClient client) {
953+
return client == null ? null : client.getComponentNameForAutofill();
951954
}
952955

953956
/** @hide */
@@ -1000,7 +1003,8 @@ private void startSessionLocked(@NonNull AutofillId id, @NonNull Rect bounds,
10001003
return;
10011004
}
10021005
try {
1003-
final ComponentName componentName = getComponentNameFromContext();
1006+
final AutofillClient client = getClientLocked();
1007+
final ComponentName componentName = getComponentNameFromContext(client);
10041008
if (componentName == null) {
10051009
Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext);
10061010
return;
@@ -1011,7 +1015,6 @@ private void startSessionLocked(@NonNull AutofillId id, @NonNull Rect bounds,
10111015
if (mSessionId != NO_SESSION) {
10121016
mState = STATE_ACTIVE;
10131017
}
1014-
final AutofillClient client = getClientLocked();
10151018
if (client != null) {
10161019
client.autofillCallbackResetableStateAvailable();
10171020
}
@@ -1065,7 +1068,8 @@ private void updateSessionLocked(AutofillId id, Rect bounds, AutofillValue value
10651068

10661069
try {
10671070
if (restartIfNecessary) {
1068-
final ComponentName componentName = getComponentNameFromContext();
1071+
final AutofillClient client = getClientLocked();
1072+
final ComponentName componentName = getComponentNameFromContext(client);
10691073
if (componentName == null) {
10701074
Log.w(TAG, "startSessionLocked(): context is not activity: " + mContext);
10711075
return;
@@ -1077,7 +1081,6 @@ private void updateSessionLocked(AutofillId id, Rect bounds, AutofillValue value
10771081
if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId);
10781082
mSessionId = newId;
10791083
mState = (mSessionId == NO_SESSION) ? STATE_UNKNOWN : STATE_ACTIVE;
1080-
final AutofillClient client = getClientLocked();
10811084
if (client != null) {
10821085
client.autofillCallbackResetableStateAvailable();
10831086
}

packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,18 +1687,9 @@ private Set<String> getOverlayInstantAppAccessibleSettings(int settingsType) {
16871687
}
16881688

16891689
private List<String> getSettingsNamesLocked(int settingsType, int userId) {
1690-
boolean instantApp;
1691-
if (UserHandle.getAppId(Binder.getCallingUid()) < Process.FIRST_APPLICATION_UID) {
1692-
instantApp = false;
1693-
} else {
1694-
ApplicationInfo ai = getCallingApplicationInfoOrThrow();
1695-
instantApp = ai.isInstantApp();
1696-
}
1697-
if (instantApp) {
1698-
return new ArrayList<String>(getInstantAppAccessibleSettings(settingsType));
1699-
} else {
1700-
return mSettingsRegistry.getSettingsNamesLocked(settingsType, userId);
1701-
}
1690+
// Don't enforce the instant app whitelist for now -- its too prone to unintended breakage
1691+
// in the current form.
1692+
return mSettingsRegistry.getSettingsNamesLocked(settingsType, userId);
17021693
}
17031694

17041695
private void enforceSettingReadable(String settingName, int settingsType, int userId) {
@@ -1711,8 +1702,10 @@ private void enforceSettingReadable(String settingName, int settingsType, int us
17111702
}
17121703
if (!getInstantAppAccessibleSettings(settingsType).contains(settingName)
17131704
&& !getOverlayInstantAppAccessibleSettings(settingsType).contains(settingName)) {
1714-
throw new SecurityException("Setting " + settingName + " is not accessible from"
1715-
+ " ephemeral package " + getCallingPackage());
1705+
// Don't enforce the instant app whitelist for now -- its too prone to unintended
1706+
// breakage in the current form.
1707+
Slog.w(LOG_TAG, "Instant App " + ai.packageName
1708+
+ " trying to access unexposed setting, this will be an error in the future.");
17161709
}
17171710
}
17181711

proto/src/metrics_constants.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4545,7 +4545,8 @@ message MetricsEvent {
45454545
// OS: O MR
45464546
AUTOFILL_SERVICE_DISABLED_SELF = 1135;
45474547

4548-
// Counter showing how long it took (in ms) to show the autofill UI after a field was focused
4548+
// Reports how long it took to show the autofill UI after a field was focused
4549+
// Tag FIELD_AUTOFILL_DURATION: Duration in ms
45494550
// Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
45504551
// Package: Package of the autofill service
45514552
// OS: O MR
@@ -4584,6 +4585,9 @@ message MetricsEvent {
45844585
// logged when we cancel an app transition.
45854586
APP_TRANSITION_CANCELLED = 1144;
45864587

4588+
// Tag of a field representing a duration on autofill-related metrics.
4589+
FIELD_AUTOFILL_DURATION = 1145;
4590+
45874591
// ---- End O-MR1 Constants, all O-MR1 constants go above this line ----
45884592

45894593
// ACTION: Stop an app and turn on background check

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ public void onFillReady(FillResponse response, AutofillId filledId,
13971397
mUiLatencyHistory.log(historyLog.toString());
13981398

13991399
final LogMaker metricsLog = newLogMaker(MetricsEvent.AUTOFILL_UI_LATENCY)
1400-
.setCounterValue((int) duration);
1400+
.addTaggedData(MetricsEvent.FIELD_AUTOFILL_DURATION, duration);
14011401
mMetricsLogger.write(metricsLog);
14021402
}
14031403
}

0 commit comments

Comments
 (0)