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

Commit c199fc3a authored by Kiran S's avatar Kiran S Committed by Android (Google) Code Review
Browse files

Merge "Restrict USB poups while setup is in progress" into sc-qpr1-dev

parents 6503057f df4ca2dd
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.usb;

import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;

import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;

import android.annotation.NonNull;
@@ -42,6 +44,7 @@ import android.os.AsyncTask;
import android.os.Environment;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.usb.UsbProfileGroupSettingsManagerProto;
import android.service.usb.UsbSettingsAccessoryPreferenceProto;
import android.service.usb.UsbSettingsDevicePreferenceProto;
@@ -908,10 +911,28 @@ class UsbProfileGroupSettingsManager {
            return;
        }

        if (shouldRestrictOverlayActivities()) {
            return;
        }

        // Start activity with registered intent
        resolveActivity(intent, matches, defaultActivity, device, null);
    }

    private boolean shouldRestrictOverlayActivities() {
        if (Settings.Secure.getIntForUser(
                mContext.getContentResolver(),
                USER_SETUP_COMPLETE,
                /* defaultValue= */ 1,
                UserHandle.CURRENT.getIdentifier())
                == 0) {
            Slog.d(TAG, "restricting usb overlay activities as setup is not complete");
            return true;
        }

        return false;
    }

    public void deviceAttachedForFixedHandler(UsbDevice device, ComponentName component) {
        final Intent intent = createDeviceAttachedIntent(device);