当前位置: 编程技术>移动开发
本页文章导读:
▪使用选择器 应用选择器
==================================================
Android 使用MMS彩信或者Gmail发送图片
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_STREAM,imageUri);//这里必须是图片的uri
i.setType("image/j.........
▪ 挪动流媒体开发之 移动流媒体开发之
Android 平台分离视频帧和音频帧,实现在线直播应用.代码已经实现.qq:250449463
......
▪ wifi全程移栽 wifi全程移植
编译代码时,本目录下用mm,上级目录用mmm,如果加上参数-B则表示强制该目录下的所有文件。如果编译时显示的编译信息有乱码情况,则需要在该终端export LANG=en 。.........
[1]使用选择器
来源: 互联网 发布时间: 2014-02-18
应用选择器
==================================================
Android 使用MMS彩信或者Gmail发送图片
Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_STREAM,imageUri);//这里必须是图片的uri i.setType("image/jpeg"); startActivity(Intent.createChooser(i,TITLE_TIP));//TITLE_TIP是弹出的选择程序处理的文字标题
==================================================
Android
使用短信或者Gmail发送文字
Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT,SOMETHING_TITLE)//Gmail的邮件主题,可选 intent.putExtra(Intent.EXTRA_TEXT,SOMETHING_TEXT_BODY);//文本内容 startActivity(Intent.createChooser(intent,TITLE_TIP);//弹出的选择程序处理的文字标题
这样所有intent-filter的action设置为android.intent.action.SEND的Activity都将作为被选择程序出现在列表中。
[2] 挪动流媒体开发之
来源: 互联网 发布时间: 2014-02-18
移动流媒体开发之
Android 平台分离视频帧和音频帧,实现在线直播应用.代码已经实现.qq:250449463
Android 平台分离视频帧和音频帧,实现在线直播应用.代码已经实现.qq:250449463
[3] wifi全程移栽
来源: 互联网 发布时间: 2014-02-18
wifi全程移植
编译代码时,本目录下用mm,上级目录用mmm,如果加上参数-B则表示强制该目录下的所有文件。
如果编译时显示的编译信息有乱码情况,则需要在该终端export LANG=en 。
移植framework,hardware,wpa_supplicant,dhcpcd及system/core/init
一 修改framework
./frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java
将mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");改成 mInterfaceName = SystemProperties.get("wifi.interface", "eth0");
编译生成
framework.jar
更新jar包:
adb push system/framework/framework.jar /system/framework
二 修改hardware
./hardware/libhardware_legacy/wifi/wifi.c
1 引用库文件:#include <unistd.h>
2 更改wifi接口,将#define WIFI_DEF_IFNAME "wlan0"改成 #define WIFI_DEF_IFNAME "eth0"(视项目具体情况而定)
3 更改驱动名及路径:将#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/wlan.ko"改成 #define WIFI_DRIVER_MODULE_PATH "/data/dhd.ko"
4 更改驱动模块名:将#define WIFI_DRIVER_MODULE_NAME "wlan" 改成 #define WIFI_DRIVER_MODULE_NAME "dhd"
5 更改wifi接口路径:将static const char IFACE_DIR[] = "/data/system/wpa_supplicant"; 改成 static const char IFACE_DIR[] = "/data/wpa_supplicant";
6 增加wifi上电,下电代码:
static const char CONFIG_UP_NAME[] = "wifi_up";
static const char CONFIG_DOWN_NAME[] = "wifi_down";
static const char WIFI_POWER_PATH[] = "/sys/devices/platform/bcm4319-pm/power_state";
static const char * off_state = "off";
static const char * on_state = "on";
static int set_wifi_power(int on) // on is 0: wifi down power, otherwise wifi up power.
{
int fd = -1;
int ret = -1;
char buf[6];
int len;
fd = open(WIFI_POWER_PATH, O_WRONLY);
//fd = open("/sys/devices/platform/bcm4319-pm/power_state", O_RDWR);
LOGE("set_wifi_power fd=%d\n", fd);
if (fd < 0) {
LOGE("open wifi file %s failed.", WIFI_POWER_PATH);
goto out;
}
if (on) {
len = sprintf(buf, "on");
} else {
len = sprintf(buf, "off");
}
len = write(fd, buf, len);
if (len < 0) {
LOGE("write wifi file %s failed.", WIFI_POWER_PATH);
goto out;
}
LOGE("set wifi power %s", WIFI_POWER_PATH);
LOGE("whether wifi is on : %s", buf);
close(fd);
return 0;
out:
if (fd >= 0) {
close(fd);
}
return ret;
}
在insmod方法中的free(module);后面增加如下代码:
if (0 == ret) {
property_set("ctl.start", CONFIG_UP_NAME);
}
在rmmod方法中的while循环后面增加如下代码:
if (0 == ret) {
property_set("ctl.start", CONFIG_DOWN_NAME);
}
在wifi_load_driver中调用set_wifi_power(1);
在wifi_unload_driver中调用set_wifi_power(0);
编译生成
libhardware_legacy.so
更新so文件
adb push system/lib/libhardware_legacy.so /system/lib
三 修改wpa_supplicant
./external/wpa_supplicant/wpa_supplicant.conf
将 ctrl_interface=wlan0 改成 ctrl_interface=/data/wpa_supplicant
编译生成
wpa_supplicant.conf
更新文件
adb push system/etc/wifi/wpa_supplicant.conf /system/etc/wifi
如果希望log中能打印出所有级别的log信息,则可以更改wpa_supplicant目录下的common.h文件。
将wpa_printf定义中的if ((level) >= MSG_INFO) 改成 if ((level) >= MSG_ERROR) 如下:
#define wpa_printf(level, ...) \
do { \
if ((level) >= MSG_ERROR) { \
android_printf((level), __VA_ARGS__); \
} \
} while (0)
编译生成
wpa_supplicant
更新bin文件
adb push system/bin/wpa_supplicant /system/bin
四 修改dhcpcd
1 ./external/dhcpcd/Android.mk
将以下代码打开
include $(CLEAR_VARS)
LOCAL_MODULE := dhcpcd.conf
LOCAL_MODULE_TAGS := user
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(etc_dir)
LOCAL_SRC_FILES := android.conf
include $(BUILD_PREBUILT)
2 ./external/dhcpcd/android.conf
将interface wlan0注释掉
3 ./external/dhcpcd/dhcp.c
将 return (const uint8_t *)dhcp_opt_buffer; 改成 return (const uint8_t *)&dhcp_opt_buffer;
4 ./external/dhcpcd/dhcpcd-hooks/20-dns.conf
在set_dns_props方法最后加上如下脚本代码:
for i in 1 2 3 4; do
setprop net.dns${i} ""
done
count=1
for dnsaddr in ${new_domain_name_servers}; do
setprop net.dns${count} ${dnsaddr}
count=$(($count + 1))
done
在unset_dns_props方法中加上如下脚本代码:
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
for i in 1 2 3 4; do
setprop net.dns${i} ""
done
编译生成
dhcpcd,dhcpcd.conf, 20-dns.conf
更新文件
adb push system/bin/dhcpcd /system/bin
adb push system/etc/dhcpcd.conf /system/etc/dhcpcd
adb push system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf /system/etc/dhcpcd/dhcpcd-hooks
五 修改system/core
./system/core/init/property_service.c
如下结构体内容:
struct {
const char *prefix;
unsigned int uid;
unsigned int gid;
} property_perms[] = {
{ "net.rmnet0.", AID_RADIO, 0 },
{ "net.gprs.", AID_RADIO, 0 },
{ "net.ppp", AID_RADIO, 0 },
{ "ril.", AID_RADIO, 0 },
{ "gsm.", AID_RADIO, 0 },
{ "persist.radio", AID_RADIO, 0 },
{ "net.dns", AID_RADIO, 0 },
{ "net.", AID_SYSTEM, 0 },
{ "dev.", AID_SYSTEM, 0 },
{ "runtime.", AID_SYSTEM, 0 },
{ "hw.", AID_SYSTEM, 0 },
{ "sys.", AID_SYSTEM, 0 },
{ "service.", AID_SYSTEM, 0 },
{ "wlan.", AID_SYSTEM, 0 },
{ "dhcp.", AID_SYSTEM, 0 },
{ "dhcp.", AID_DHCP, 0 },
{ "net.", AID_DHCP, 0 }, // add to avoid "permission denied" error
{ "net.dns", AID_DHCP, 0 }, // add to avoid "permission denied" error
{ "vpn.", AID_SYSTEM, 0 },
{ "vpn.", AID_VPN, 0 },
{ "debug.", AID_SHELL, 0 },
{ "log.", AID_SHELL, 0 },
{ "service.adb.root", AID_SHELL, 0 },
{ "persist.sys.", AID_SYSTEM, 0 },
{ "persist.service.", AID_SYSTEM, 0 },
{ "persist.security.", AID_SYSTEM, 0 },
{ "xec.", AID_SYSTEM, 0 },
{ "user.", AID_SYSTEM, 0 },
{ "media.", AID_MEDIA, 0 },
{ NULL, 0, 0 }
};
/*
* White list of UID that are allowed to start/stop services.
* Currently there are no user apps that require.
*/
struct {
const char *service;
unsigned int uid;
unsigned int gid;
} control_perms[] = {
{ "dumpstate",AID_SHELL, AID_LOG },
{ "pppd_gprs", AID_RADIO, AID_RADIO },
{ "pppd_gprs2", AID_RADIO, AID_RADIO },
{ NULL, 0, 0 }
};
编译生成
system/lib/libpixelflinger.so
system/bin/test-opengl-codegen
root/init
最后将以上文件更新到设备上
六 更新驱动
adb push dhd.ko /data
adb push fw_bcm4329.bin /data
adb push nvram.txt /data
注意:如果移植后出现设备不能启动,并且log中一直循环打印“NetId1.0......”时,则可以考虑编译环境是否正确,版本是否一致。
比如,你的设备上烧写的是最新的image,kernel等,而你在本地的老版本中更改文件后,编译出的是老版本的bin文件,jar包,
当push到设备中后出现版本不一致,最新版本中很多库文件或者设备的配置环境已经发生改变,造成设备不能正常启动。
编译代码时,本目录下用mm,上级目录用mmm,如果加上参数-B则表示强制该目录下的所有文件。
如果编译时显示的编译信息有乱码情况,则需要在该终端export LANG=en 。
移植framework,hardware,wpa_supplicant,dhcpcd及system/core/init
一 修改framework
./frameworks/base/wifi/java/android/net/wifi/WifiStateTracker.java
将mInterfaceName = SystemProperties.get("wifi.interface", "tiwlan0");改成 mInterfaceName = SystemProperties.get("wifi.interface", "eth0");
编译生成
framework.jar
更新jar包:
adb push system/framework/framework.jar /system/framework
二 修改hardware
./hardware/libhardware_legacy/wifi/wifi.c
1 引用库文件:#include <unistd.h>
2 更改wifi接口,将#define WIFI_DEF_IFNAME "wlan0"改成 #define WIFI_DEF_IFNAME "eth0"(视项目具体情况而定)
3 更改驱动名及路径:将#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/wlan.ko"改成 #define WIFI_DRIVER_MODULE_PATH "/data/dhd.ko"
4 更改驱动模块名:将#define WIFI_DRIVER_MODULE_NAME "wlan" 改成 #define WIFI_DRIVER_MODULE_NAME "dhd"
5 更改wifi接口路径:将static const char IFACE_DIR[] = "/data/system/wpa_supplicant"; 改成 static const char IFACE_DIR[] = "/data/wpa_supplicant";
6 增加wifi上电,下电代码:
static const char CONFIG_UP_NAME[] = "wifi_up";
static const char CONFIG_DOWN_NAME[] = "wifi_down";
static const char WIFI_POWER_PATH[] = "/sys/devices/platform/bcm4319-pm/power_state";
static const char * off_state = "off";
static const char * on_state = "on";
static int set_wifi_power(int on) // on is 0: wifi down power, otherwise wifi up power.
{
int fd = -1;
int ret = -1;
char buf[6];
int len;
fd = open(WIFI_POWER_PATH, O_WRONLY);
//fd = open("/sys/devices/platform/bcm4319-pm/power_state", O_RDWR);
LOGE("set_wifi_power fd=%d\n", fd);
if (fd < 0) {
LOGE("open wifi file %s failed.", WIFI_POWER_PATH);
goto out;
}
if (on) {
len = sprintf(buf, "on");
} else {
len = sprintf(buf, "off");
}
len = write(fd, buf, len);
if (len < 0) {
LOGE("write wifi file %s failed.", WIFI_POWER_PATH);
goto out;
}
LOGE("set wifi power %s", WIFI_POWER_PATH);
LOGE("whether wifi is on : %s", buf);
close(fd);
return 0;
out:
if (fd >= 0) {
close(fd);
}
return ret;
}
在insmod方法中的free(module);后面增加如下代码:
if (0 == ret) {
property_set("ctl.start", CONFIG_UP_NAME);
}
在rmmod方法中的while循环后面增加如下代码:
if (0 == ret) {
property_set("ctl.start", CONFIG_DOWN_NAME);
}
在wifi_load_driver中调用set_wifi_power(1);
在wifi_unload_driver中调用set_wifi_power(0);
编译生成
libhardware_legacy.so
更新so文件
adb push system/lib/libhardware_legacy.so /system/lib
三 修改wpa_supplicant
./external/wpa_supplicant/wpa_supplicant.conf
将 ctrl_interface=wlan0 改成 ctrl_interface=/data/wpa_supplicant
编译生成
wpa_supplicant.conf
更新文件
adb push system/etc/wifi/wpa_supplicant.conf /system/etc/wifi
如果希望log中能打印出所有级别的log信息,则可以更改wpa_supplicant目录下的common.h文件。
将wpa_printf定义中的if ((level) >= MSG_INFO) 改成 if ((level) >= MSG_ERROR) 如下:
#define wpa_printf(level, ...) \
do { \
if ((level) >= MSG_ERROR) { \
android_printf((level), __VA_ARGS__); \
} \
} while (0)
编译生成
wpa_supplicant
更新bin文件
adb push system/bin/wpa_supplicant /system/bin
四 修改dhcpcd
1 ./external/dhcpcd/Android.mk
将以下代码打开
include $(CLEAR_VARS)
LOCAL_MODULE := dhcpcd.conf
LOCAL_MODULE_TAGS := user
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(etc_dir)
LOCAL_SRC_FILES := android.conf
include $(BUILD_PREBUILT)
2 ./external/dhcpcd/android.conf
将interface wlan0注释掉
3 ./external/dhcpcd/dhcp.c
将 return (const uint8_t *)dhcp_opt_buffer; 改成 return (const uint8_t *)&dhcp_opt_buffer;
4 ./external/dhcpcd/dhcpcd-hooks/20-dns.conf
在set_dns_props方法最后加上如下脚本代码:
for i in 1 2 3 4; do
setprop net.dns${i} ""
done
count=1
for dnsaddr in ${new_domain_name_servers}; do
setprop net.dns${count} ${dnsaddr}
count=$(($count + 1))
done
在unset_dns_props方法中加上如下脚本代码:
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
for i in 1 2 3 4; do
setprop net.dns${i} ""
done
编译生成
dhcpcd,dhcpcd.conf, 20-dns.conf
更新文件
adb push system/bin/dhcpcd /system/bin
adb push system/etc/dhcpcd.conf /system/etc/dhcpcd
adb push system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf /system/etc/dhcpcd/dhcpcd-hooks
五 修改system/core
./system/core/init/property_service.c
如下结构体内容:
struct {
const char *prefix;
unsigned int uid;
unsigned int gid;
} property_perms[] = {
{ "net.rmnet0.", AID_RADIO, 0 },
{ "net.gprs.", AID_RADIO, 0 },
{ "net.ppp", AID_RADIO, 0 },
{ "ril.", AID_RADIO, 0 },
{ "gsm.", AID_RADIO, 0 },
{ "persist.radio", AID_RADIO, 0 },
{ "net.dns", AID_RADIO, 0 },
{ "net.", AID_SYSTEM, 0 },
{ "dev.", AID_SYSTEM, 0 },
{ "runtime.", AID_SYSTEM, 0 },
{ "hw.", AID_SYSTEM, 0 },
{ "sys.", AID_SYSTEM, 0 },
{ "service.", AID_SYSTEM, 0 },
{ "wlan.", AID_SYSTEM, 0 },
{ "dhcp.", AID_SYSTEM, 0 },
{ "dhcp.", AID_DHCP, 0 },
{ "net.", AID_DHCP, 0 }, // add to avoid "permission denied" error
{ "net.dns", AID_DHCP, 0 }, // add to avoid "permission denied" error
{ "vpn.", AID_SYSTEM, 0 },
{ "vpn.", AID_VPN, 0 },
{ "debug.", AID_SHELL, 0 },
{ "log.", AID_SHELL, 0 },
{ "service.adb.root", AID_SHELL, 0 },
{ "persist.sys.", AID_SYSTEM, 0 },
{ "persist.service.", AID_SYSTEM, 0 },
{ "persist.security.", AID_SYSTEM, 0 },
{ "xec.", AID_SYSTEM, 0 },
{ "user.", AID_SYSTEM, 0 },
{ "media.", AID_MEDIA, 0 },
{ NULL, 0, 0 }
};
/*
* White list of UID that are allowed to start/stop services.
* Currently there are no user apps that require.
*/
struct {
const char *service;
unsigned int uid;
unsigned int gid;
} control_perms[] = {
{ "dumpstate",AID_SHELL, AID_LOG },
{ "pppd_gprs", AID_RADIO, AID_RADIO },
{ "pppd_gprs2", AID_RADIO, AID_RADIO },
{ NULL, 0, 0 }
};
编译生成
system/lib/libpixelflinger.so
system/bin/test-opengl-codegen
root/init
最后将以上文件更新到设备上
六 更新驱动
adb push dhd.ko /data
adb push fw_bcm4329.bin /data
adb push nvram.txt /data
注意:如果移植后出现设备不能启动,并且log中一直循环打印“NetId1.0......”时,则可以考虑编译环境是否正确,版本是否一致。
比如,你的设备上烧写的是最新的image,kernel等,而你在本地的老版本中更改文件后,编译出的是老版本的bin文件,jar包,
当push到设备中后出现版本不一致,最新版本中很多库文件或者设备的配置环境已经发生改变,造成设备不能正常启动。
最新技术文章: