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

Commit 117956ee authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cherrypicker-L74700030005440312:N13700030084650775" into aosp-24Q3-ts-dev

* changes:
  Fix CDM discovery timeout
  Fix CDM UI regressions
parents 21337221 26c12d9b
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE

import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.DiscoveryState;
import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.DiscoveryState.FINISHED_TIMEOUT;
import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.LOCK;
import static com.android.companiondevicemanager.CompanionDeviceDiscoveryService.sDiscoveryStarted;
import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILE_ICONS;
import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILE_NAMES;
import static com.android.companiondevicemanager.CompanionDeviceResources.PROFILE_PERMISSIONS;
@@ -326,10 +328,14 @@ public class CompanionAssociationActivity extends FragmentActivity implements
    private void onDiscoveryStateChanged(DiscoveryState newState) {
        if (newState == FINISHED_TIMEOUT
                && CompanionDeviceDiscoveryService.getScanResult().getValue().isEmpty()) {
            synchronized (LOCK) {
                if (sDiscoveryStarted) {
                    cancel(/* discoveryTimeOut */ true,
                            /* userRejected */ false, /* internalError */ false);
                }
            }
        }
    }

    private void onUserSelectedDevice(@NonNull DeviceFilterPair<?> selectedDevice) {
        final MacAddress macAddress = selectedDevice.getMacAddress();
@@ -568,6 +574,8 @@ public class CompanionAssociationActivity extends FragmentActivity implements

        updateSingleDeviceUi();

        if (mRequest.isSkipPrompt()) return;

        mSummary.setVisibility(View.VISIBLE);
        mButtonAllow.setVisibility(View.VISIBLE);
        mButtonNotAllow.setVisibility(View.VISIBLE);
+5 −4
Original line number Diff line number Diff line
@@ -90,9 +90,6 @@ public class CompanionDeviceDiscoveryService extends Service {
            new MutableLiveData<>(Collections.emptyList());
    private static MutableLiveData<DiscoveryState> sStateLiveData =
            new MutableLiveData<>(DiscoveryState.NOT_STARTED);
    private static final Object LOCK = new Object();
    @GuardedBy("LOCK")
    private static boolean sDiscoveryStarted = false;

    private BluetoothManager mBtManager;
    private BluetoothAdapter mBtAdapter;
@@ -109,6 +106,10 @@ public class CompanionDeviceDiscoveryService extends Service {

    private boolean mStopAfterFirstMatch;

    static final Object LOCK = new Object();
    @GuardedBy("LOCK")
    static boolean sDiscoveryStarted = false;

    /**
     * A state enum for devices' discovery.
     */
@@ -127,6 +128,7 @@ public class CompanionDeviceDiscoveryService extends Service {
                return false;
            }
        }
        sScanResultsLiveData.setValue(Collections.emptyList());
        requireNonNull(associationRequest);
        final Intent intent = new Intent(context, CompanionDeviceDiscoveryService.class);
        intent.setAction(ACTION_START_DISCOVERY);
@@ -192,7 +194,6 @@ public class CompanionDeviceDiscoveryService extends Service {
            sDiscoveryStarted = true;
        }
        mStopAfterFirstMatch = request.isSingleDevice();
        sScanResultsLiveData.setValue(Collections.emptyList());
        sStateLiveData.setValue(DiscoveryState.IN_PROGRESS);

        final List<DeviceFilter<?>> allFilters = request.getDeviceFilters();