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

Commit 69c7a768 authored by Steve Kondik's avatar Steve Kondik
Browse files

Merge branch 'LA.BF64.1.2.2_rb4.1' of git://codeaurora.org/platform/system/core into caf-merge

parents 0fcbde44 6013e8d8
Loading
Loading
Loading
Loading
+49 −1
Original line number Diff line number Diff line
@@ -64,6 +64,14 @@ struct func_desc {
    struct usb_endpoint_descriptor_no_audio sink;
} __attribute__((packed));

struct ss_func_desc {
    struct usb_interface_descriptor intf;
    struct usb_endpoint_descriptor_no_audio source;
    struct usb_ss_ep_comp_descriptor source_comp;
    struct usb_endpoint_descriptor_no_audio sink;
    struct usb_ss_ep_comp_descriptor sink_comp;
} __attribute__((packed));

struct desc_v1 {
    struct usb_functionfs_descs_head_v1 {
        __le32 magic;
@@ -79,7 +87,9 @@ struct desc_v2 {
    // The rest of the structure depends on the flags in the header.
    __le32 fs_count;
    __le32 hs_count;
    __le32 ss_count;
    struct func_desc fs_descs, hs_descs;
    struct ss_func_desc ss_descs;
} __attribute__((packed));

struct func_desc fs_descriptors = {
@@ -136,6 +146,41 @@ struct func_desc hs_descriptors = {
    },
};

static struct ss_func_desc ss_descriptors = {
    .intf = {
        .bLength = sizeof(ss_descriptors.intf),
        .bDescriptorType = USB_DT_INTERFACE,
        .bInterfaceNumber = 0,
        .bNumEndpoints = 2,
        .bInterfaceClass = ADB_CLASS,
        .bInterfaceSubClass = ADB_SUBCLASS,
        .bInterfaceProtocol = ADB_PROTOCOL,
        .iInterface = 1, /* first string from the provided table */
    },
    .source = {
        .bLength = sizeof(ss_descriptors.source),
        .bDescriptorType = USB_DT_ENDPOINT,
        .bEndpointAddress = 1 | USB_DIR_OUT,
        .bmAttributes = USB_ENDPOINT_XFER_BULK,
        .wMaxPacketSize = MAX_PACKET_SIZE_SS,
    },
    .source_comp = {
        .bLength = sizeof(ss_descriptors.source_comp),
        .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
    },
    .sink = {
        .bLength = sizeof(ss_descriptors.sink),
        .bDescriptorType = USB_DT_ENDPOINT,
        .bEndpointAddress = 2 | USB_DIR_IN,
        .bmAttributes = USB_ENDPOINT_XFER_BULK,
        .wMaxPacketSize = MAX_PACKET_SIZE_SS,
    },
    .sink_comp = {
        .bLength = sizeof(ss_descriptors.sink_comp),
        .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
    },
};

#define STR_INTERFACE_ "ADB Interface"

static const struct {
@@ -279,11 +324,14 @@ static void init_functionfs(struct usb_handle *h)

    v2_descriptor.header.magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2);
    v2_descriptor.header.length = cpu_to_le32(sizeof(v2_descriptor));
    v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC;
    v2_descriptor.header.flags = FUNCTIONFS_HAS_FS_DESC | FUNCTIONFS_HAS_HS_DESC |
                                 FUNCTIONFS_HAS_SS_DESC;
    v2_descriptor.fs_count = 3;
    v2_descriptor.hs_count = 3;
    v2_descriptor.ss_count = 5;
    v2_descriptor.fs_descs = fs_descriptors;
    v2_descriptor.hs_descs = hs_descriptors;
    v2_descriptor.ss_descs = ss_descriptors;

    if (h->control < 0) { // might have already done this before
        D("OPENING %s\n", USB_FFS_ADB_EP0);
+133 −72
Original line number Diff line number Diff line
@@ -492,6 +492,52 @@ static int handle_encryptable(struct fstab *fstab, const struct fstab_rec* rec)
    return FS_MGR_MNTALL_DEV_NOT_ENCRYPTED;
}

/*
 * Reads the kernel cmdline to check if MDTP is activated.
 * When MDTP is activated, kernel cmdline will have the word 'mdtp'.
 */
int fs_mgr_is_mdtp_activated()
{
      char cmdline[2048];
      char *ptr;
      int fd;
      static int mdtp_activated = 0;
      static int mdtp_activated_set = 0;

      if (mdtp_activated_set) {
          return mdtp_activated;
      }

      fd = open("/proc/cmdline", O_RDONLY);
      if (fd >= 0) {
          int n = read(fd, cmdline, sizeof(cmdline) - 1);
          if (n < 0) n = 0;

          /* get rid of trailing newline, it happens */
          if (n > 0 && cmdline[n-1] == '\n') n--;

          cmdline[n] = 0;
          close(fd);
      } else {
          cmdline[0] = 0;
      }

      ptr = cmdline;
      while (ptr && *ptr) {
          char *x = strchr(ptr, ' ');
          if (x != 0) *x++ = 0;
          if (!strcmp(ptr,"mdtp")) {
            mdtp_activated = 1;
            break;
          }
          ptr = x;
      }

      mdtp_activated_set = 1;

      return mdtp_activated;
}

/* When multiple fstab records share the same mount_point, it will
 * try to mount each one in turn, and ignore any duplicates after a
 * first successful mount.
@@ -547,6 +593,20 @@ int fs_mgr_mount_all(struct fstab *fstab)
                continue;
            }
        }

        if (fs_mgr_is_mdtp_activated() && ((fstab->recs[i].fs_mgr_flags & MF_FORCECRYPT) ||
            device_is_force_encrypted())) {
            INFO("%s(): mdtp activated, blkdev %s for mount %s type %s expected to be encrypted)\n",
                 __func__, fstab->recs[i].blk_device, fstab->recs[i].mount_point,
                 fstab->recs[i].fs_type);
            if (fs_mgr_do_tmpfs_mount(fstab->recs[i].mount_point) < 0) {
                ++error_count;
                continue;
            }

            encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;

        } else {
            int last_idx_inspected;
            int top_idx = i;

@@ -634,6 +694,7 @@ int fs_mgr_mount_all(struct fstab *fstab)
                continue;
            }
        }
    }

    if (error_count) {
        return -1;
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ int fs_mgr_is_noemulatedsd(const struct fstab_rec *fstab);
int fs_mgr_is_notrim(struct fstab_rec *fstab);
int fs_mgr_is_formattable(struct fstab_rec *fstab);
int fs_mgr_swapon_all(struct fstab *fstab);
int fs_mgr_is_mdtp_activated(void);

int fs_mgr_do_format(struct fstab_rec *fstab);

+56 −25
Original line number Diff line number Diff line
@@ -134,7 +134,10 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String
            { "USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC },
            { "USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC },
            { "USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC },
            { "USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC },
            { "USB_HVDCP_3", ANDROID_POWER_SUPPLY_TYPE_AC },
            { "Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS },
            { "Wipower", ANDROID_POWER_SUPPLY_TYPE_WIRELESS },
            { NULL, 0 },
    };

@@ -209,18 +212,37 @@ bool BatteryMonitor::update(void) {
    if (readFromFile(mHealthdConfig->batteryTechnologyPath, buf, SIZE) > 0)
        props.batteryTechnology = String8(buf);

    unsigned int i;

    for (i = 0; i < mChargerNames.size(); i++) {
    // reinitialize the mChargerNames vector everytime there is an update
    String8 path;
        path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
                          mChargerNames[i].string());
    DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH);
    if (dir == NULL) {
        KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH);
    } else {
        struct dirent* entry;
        // reconstruct the charger strings
        mChargerNames.clear();
        while ((entry = readdir(dir))) {
            const char* name = entry->d_name;

            if (!strcmp(name, ".") || !strcmp(name, ".."))
                continue;

            // Look for "type" file in each subdirectory
            path.clear();
            path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name);
            switch(readPowerSupplyType(path)) {
            case ANDROID_POWER_SUPPLY_TYPE_AC:
            case ANDROID_POWER_SUPPLY_TYPE_USB:
            case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
                path.clear();
                path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
                if (access(path.string(), R_OK) == 0) {
                    mChargerNames.add(String8(name));
                    if (readFromFile(path, buf, SIZE) > 0) {
                        if (buf[0] != '0') {
                            path.clear();
                            path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH,
                                  mChargerNames[i].string());
                                              name);
                            switch(readPowerSupplyType(path)) {
                            case ANDROID_POWER_SUPPLY_TYPE_AC:
                                props.chargerAcOnline = true;
@@ -233,11 +255,20 @@ bool BatteryMonitor::update(void) {
                                break;
                            default:
                                KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
                                 mChargerNames[i].string());
                                             name);
                            }
                        }
                    }
                }
                break;
            case ANDROID_POWER_SUPPLY_TYPE_BATTERY:
                break;
            default:
                break;
            } //switch
        } //while
        closedir(dir);
    }//else

    logthis = !healthd_board_battery_update(&props);

+12 −0
Original line number Diff line number Diff line
@@ -97,6 +97,12 @@
#define AID_NET_BW_STATS  3006  /* read bandwidth statistics */
#define AID_NET_BW_ACCT   3007  /* change bandwidth statistics accounting */
#define AID_NET_BT_STACK  3008  /* bluetooth: access config files */
#define AID_QCOM_DIAG     3009  /* can read/write /dev/diag */

#define AID_SENSORS       3011 /* access to /dev/socket/sensor_ctl_socket & QCCI/QCSI */

#define AID_RFS           3012  /* Remote Filesystem for peripheral processors */
#define AID_RFS_SHARED    3013  /* Shared files for Remote Filesystem for peripheral processors  */

#define AID_EVERYBODY     9997  /* shared between all apps in the same profile */
#define AID_MISC          9998  /* access to misc storage */
@@ -172,6 +178,7 @@ static const struct android_id_info android_ids[] = {
    { "shell",         AID_SHELL, },
    { "cache",         AID_CACHE, },
    { "diag",          AID_DIAG, },
    { "qcom_diag",     AID_QCOM_DIAG, },

    { "net_bt_admin",  AID_NET_BT_ADMIN, },
    { "net_bt",        AID_NET_BT, },
@@ -182,6 +189,11 @@ static const struct android_id_info android_ids[] = {
    { "net_bw_acct",   AID_NET_BW_ACCT, },
    { "net_bt_stack",  AID_NET_BT_STACK, },

    { "sensors",       AID_SENSORS, },

    { "rfs",           AID_RFS, },
    { "rfs_shared",    AID_RFS_SHARED, },

    { "everybody",     AID_EVERYBODY, },
    { "misc",          AID_MISC, },
    { "nobody",        AID_NOBODY, },
Loading