Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8fd40b6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/23563581',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/23563581', 'googleplex-android-review.googlesource.com/23726246', 'googleplex-android-review.googlesource.com/23541011'] into security-aosp-rvc-release.

Change-Id: Id07d0aa7e0df92766c514fe27154673675ba1c3c
parents 14e30602 4736a34f
Loading
Loading
Loading
Loading
+64 −56
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ import android.text.method.ScrollingMovementMethod;
import android.util.EventLog;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
@@ -401,8 +403,8 @@ public class DeviceAdminAdd extends Activity {

        final View restrictedAction = findViewById(R.id.restricted_action);
        restrictedAction.setFilterTouchesWhenObscured(true);
        restrictedAction.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

        final View.OnClickListener restrictedActionClickListener = v -> {
            if (!mActionButton.isEnabled()) {
                showPolicyTransparencyDialogIfRequired();
                return;
@@ -445,14 +447,20 @@ public class DeviceAdminAdd extends Activity {
                            }
                        }, mHandler));
                // Don't want to wait too long.
                    getWindow().getDecorView().getHandler().postDelayed(new Runnable() {
                        @Override public void run() {
                            continueRemoveAction(null);
                        }
                    }, 2*1000);
                }
                getWindow().getDecorView().getHandler().postDelayed(
                        () -> continueRemoveAction(null), 2 * 1000);
            }
        };
        restrictedAction.setOnKeyListener((view, keyCode, keyEvent) -> {
            if ((keyEvent.getFlags() & KeyEvent.FLAG_FROM_SYSTEM) == 0) {
                Log.e(TAG, "Can not activate device-admin with KeyEvent from non-system app.");
                // Consume event to suppress click.
                return true;
            }
            // Fallback to view click handler.
            return false;
        });
        restrictedAction.setOnClickListener(restrictedActionClickListener);
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -181,7 +181,10 @@ public class NotificationAccessDetails extends AppInfoBase {

    public void updatePreference(SwitchPreference preference) {
        final CharSequence label = mPackageInfo.applicationInfo.loadLabel(mPm);
        final boolean isAllowedCn = mComponentName.flattenToShortString().length()
                <= NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH;
        preference.setChecked(isServiceEnabled(mComponentName));
        preference.setEnabled(preference.isChecked() || isAllowedCn);
        preference.setOnPreferenceChangeListener((p, newValue) -> {
            final boolean access = (Boolean) newValue;
            if (!access) {
+3 −1
Original line number Diff line number Diff line
@@ -67,7 +67,9 @@ public class NotificationAccessConfirmationActivity extends Activity
        mUserId = getIntent().getIntExtra(EXTRA_USER_ID, UserHandle.USER_NULL);
        CharSequence mAppLabel;

        if (mComponentName == null || mComponentName.getPackageName() == null) {
        if (mComponentName == null || mComponentName.getPackageName() == null
                || mComponentName.flattenToString().length()
                > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) {
            finish();
            return;
        }
+7 −9
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ import java.util.List;
public class NotificationAccessSettings extends EmptyTextSettings {
    private static final String TAG = "NotifAccessSettings";

    private static final int MAX_CN_LENGTH = 500;

    private static final ManagedServiceSettings.Config CONFIG =
            new ManagedServiceSettings.Config.Builder()
                    .setTag(TAG)
@@ -94,12 +92,6 @@ public class NotificationAccessSettings extends EmptyTextSettings {
                .setNoun(CONFIG.noun)
                .setSetting(CONFIG.setting)
                .setTag(CONFIG.tag)
                .setValidator(info -> {
                    if (info.getComponentName().flattenToString().length() > MAX_CN_LENGTH) {
                        return false;
                    }
                    return true;
                })
                .build();
        mServiceListing.addCallback(this::updateList);
        setPreferenceScreen(getPreferenceManager().createPreferenceScreen(mContext));
@@ -140,6 +132,12 @@ public class NotificationAccessSettings extends EmptyTextSettings {
        services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
        for (ServiceInfo service : services) {
            final ComponentName cn = new ComponentName(service.packageName, service.name);
            boolean isAllowed = mNm.isNotificationListenerAccessGranted(cn);
            if (!isAllowed && cn.flattenToString().length()
                    > NotificationManager.MAX_SERVICE_COMPONENT_NAME_LENGTH) {
                continue;
            }

            CharSequence title = null;
            try {
                title = mPm.getApplicationInfoAsUser(
@@ -154,7 +152,7 @@ public class NotificationAccessSettings extends EmptyTextSettings {
            pref.setIcon(mIconDrawableFactory.getBadgedIcon(service, service.applicationInfo,
                    UserHandle.getUserId(service.applicationInfo.uid)));
            pref.setKey(cn.flattenToString());
            pref.setSummary(mNm.isNotificationListenerAccessGranted(cn)
            pref.setSummary(isAllowed
                    ? R.string.app_permission_summary_allowed
                    : R.string.app_permission_summary_not_allowed);
            if (managedProfileId != UserHandle.USER_NULL