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

Unverified Commit 091381b3 authored by Yumi Yukimura's avatar Yumi Yukimura Committed by Michael Bestas
Browse files

recovery: Bringup network all the times

* For ADB mode (on devices without USB Gadget mode, same for fastboot)

Change-Id: Ia5937e71e4800872970b568152c5e5d6d722bf04
parent b4457166
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -527,6 +527,8 @@ int main(int argc, char** argv) {
    android::base::SetProperty("service.adb.root", "1");
  }

  device->InitDevice();

  while (true) {
    // We start adbd in recovery for the device with userdebug build or a unlocked bootloader.
    std::string usb_config =
+11 −5
Original line number Diff line number Diff line
@@ -41,20 +41,26 @@ EthernetDevice::EthernetDevice(EthernetRecoveryUI* ui, std::string interface)
  }
}

void EthernetDevice::InitDevice() {
  BringupInterface();
  sleep(1);
}

void EthernetDevice::PreRecovery() {
  SetInterfaceFlags(0, IFF_UP);
  SetTitleIPAddress(false);
  SetTitleIPAddress(BringupInterface());
}

void EthernetDevice::PreFastboot() {
  android::base::SetProperty("fastbootd.protocol", "tcp");
  SetTitleIPAddress(BringupInterface());
}

bool EthernetDevice::BringupInterface() {
  if (SetInterfaceFlags(IFF_UP, 0) < 0) {
    LOG(ERROR) << "Failed to bring up interface";
    return;
    return false;
  }

  SetTitleIPAddress(true);
  return true;
}

int EthernetDevice::SetInterfaceFlags(const unsigned set, const unsigned clr) {
+3 −0
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ class Device {
    ui_.reset(ui);
  }

  // Called before any mode started up, to bring up network.
  virtual void InitDevice() {}

  // Called before recovery mode started up, to perform whatever device-specific recovery mode
  // preparation as needed.
  virtual void PreRecovery() {}
+2 −0
Original line number Diff line number Diff line
@@ -29,10 +29,12 @@ class EthernetDevice : public Device {
  explicit EthernetDevice(EthernetRecoveryUI* ui);
  explicit EthernetDevice(EthernetRecoveryUI* ui, std::string interface);

  void InitDevice() override;
  void PreRecovery() override;
  void PreFastboot() override;

 private:
  bool BringupInterface();
  int SetInterfaceFlags(const unsigned set, const unsigned clr);
  void SetTitleIPAddress(const bool interface_up);