目录
step 2:分析源码如何读取以太网配置(IpConfiguration )
step 4: 那么EthernetServiceImpl start方法是做什么的呢?
android5.1系统修改源码实现隐藏底部状态栏、隐藏通知栏、隐藏上方状态栏、永不熄屏的方法
Android 8.1 去掉Launcher3的默认Google搜索栏
kernel
kernel端口大于1024问题
https://blog.csdn.net/a_ran/article/details/36858089
https://blog.csdn.net/ansondroider/article/details/83144275
//kernel/include/net/sock.h
/* Sockets 0-1023 can't be bound to unless you are superuser */
#define PROT_SOCK 1024
节点权限
这里也是可以的
修改节点权限system/core/rootdir/ueventd.rc
网络相关
以太网固定分配静态IP
Android 5.1 启动有线网卡并为其分配静态IP地址
Android 5.1系统的有线网卡架构参考RK3288架构。系统默认使用DHCP获取IP。下面我们就介绍设置静态IP的方法。
2.1源码
首先看一个代码。路径如下:
frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetConfigStore.java
public class EthernetConfigStore extends IpConfigStore {
private static final String TAG = "EthernetConfigStore";
private static final String ipConfigFile = Environment.getDataDirectory() +
"/misc/ethernet/ipconfig.txt";
public EthernetConfigStore() {
}
注:全路径是/data/misc/ethernet/ipconfig.txt
public IpConfiguration readIpAndProxyConfigurations() {
SparseArray<IpConfiguration> networks = readIpAndProxyConfigurations(ipConfigFile);
if (networks.size() == 0) {// 如果/misc/ethernet/ipconfig.txt这个文件不存在的话,那么我们就使用DHCP方法
Log.w(TAG, "No Ethernet configuration found. Using default.");
return new IpConfiguration(IpAssignment.DHCP, ProxySettings.NONE, null, null);
}
if (networks.size() > 1) {
// Currently we only support a single Ethernet interface.
Log.w(TAG, "Multiple Ethernet configurations detected. Only reading first one.");
}
return networks.valueAt(0);
}
public void writeIpAndProxyConfigurations(IpConfiguration config) {
SparseArray<IpConfiguration> networks = new SparseArray<IpConfiguration>();
networks.put(0, config);
writeIpAndProxyConfigurations(ipConfigFile, networks);
}
}
2.2修改
知道了这个方法。我们就在系统的Ethernet界面采用静态方法设置一下IP及其其他参数。从得到ipconfig.txt文件。然后进入命令行,输入 :
adb root
adb pull /data/misc/ethernet/ipconfig.txt
从而得到ipconfig.txt 。
下面我们通过修改ipconfig.txt 的路径。如下:
private static final String ipConfigFile = Environment.getRootDirectory() +
"/etc/ipconfig.txt";
这样我们就把ipconfig.txt这个文件拷贝到系统的etc目录下就可以了。方法如下:
在device.mk中增加如下代码:
device/rockchip/rk3288/device.mk
PRODUCT_COPY_FILES += $(LOCAL_PATH)/ipconfig.txt:system/etc/ipconfig.txt
从新编译即可验证。
分析
step 1:分析以太网启动流程:
从以太网的服务注册开始
1.一种是通过SystemServiceManager的startService()。该方法用于启动继承于SystemService的服务。主要功能:创建serviceClass类的对象,将刚创建对象添加到SystemServiceManager的成员变量mServices,再调用刚创建对象的onStart()方法,方法中调用publishBinderService将service注册到ServiceManager。当SystemService到一定阶段,进入相应的Phase时,会调用SystemServiceManager的startBootPhase()回调方法,该方法会循环遍历所有向SystemServiceManager注册过的service的onBootPhase()方法,service针对各个阶段需要做怎样的处理或者是不做任何处理。
2.另一种是通过ServiceManager的addService(String name, IBinder service),该方法用于初始化继承于IBinder的服务。主要功能将该服务向Native层的service Manager注册服务。
以太网的Service启动属于第一种. 虽然文字描述相对抽象,但是由于以太网服务的草鸡简单,所以以太网Service的注册和启动完全不是事儿,OK,开启以太网Service服务(EthernetService)注册之旅.先上代码:
先来看看系统的进程的入口SystemServer ,main方法里通过SystemServiceManage启动EthernetService
//frameworks/base/services/Java/com/Android/server/SystemServer.java
public final class SystemServer {
private static final String ETHERNET_SERVICE_CLASS =
"com.android.server.ethernet.EthernetService";
public static void main(String[] args) {
new SystemServer().run();
}
private void run() {
startOtherServices();
}
private void startOtherServices() {
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_ETHERNET)) {
mSystemServiceManager.startService(ETHERNET_SERVICE_CLASS);
}
}
EthernetService 被启动之后就干了三件事儿:
1.构造函数中创建EthernetServiceImpl 对象
2.在onStart()方法 中将EthernetServiceImpl对象注册进了ServiceManager。
3.当系统进入到 PHASE_SYSTEM_SERVICES_READY时状态时,EthernetService的onBootPhase()方法被触发,调用EthernetServiceImpl .Start();
//frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetService.java
public final class EthernetService extends SystemService {
private static final String TAG = "EthernetService";
final EthernetServiceImpl mImpl;
public EthernetService(Context context) {
super(context);
mImpl = new EthernetServiceImpl(context);
}
@Override
public void onStart() {
// 将ServiceImpl注册到ServiceManager
Log.i(TAG, "Registering service " + Context.ETHERNET_SERVICE);
publishBinderService(Context.ETHERNET_SERVICE, mImpl);
}
@Override
public void onBootPhase(int phase) {
//当系统运行到PHASE_SYSTEM_SERVICES_READY状态是时,Service启动EthernetServiceImpl
if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
mImpl.start();
}
}
}
step 2:分析源码如何读取以太网配置(IpConfiguration )
上面说到,EthernetService创建EthernetServiceImpl 对象.调用EthernetServiceImpl start方法.继续跟踪代码…
//frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
public class EthernetServiceImpl extends IEthernetManager.Stub {
private final EthernetConfigStore mEthernetConfigStore;
//以太网配置信息类
private IpConfiguration mIpConfiguration;
private final EthernetNetworkFactory mTracker;
private final RemoteCallbackList<IEthernetServiceListener> mListeners =
new RemoteCallbackList<IEthernetServiceListener>();
public EthernetServiceImpl(Context context) {
mContext = context;
Log.i(TAG, "Creating EthernetConfigStore");
mEthernetConfigStore = new EthernetConfigStore();
//读取以太网信息
mIpConfiguration = mEthernetConfigStore.readIpAndProxyConfigurations();
Log.i(TAG, "Read stored IP configuration: " + mIpConfiguration);
mTracker = new EthernetNetworkFactory(mListeners);
}
public void start() {
Log.i(TAG, "Starting Ethernet service");
HandlerThread handlerThread = new HandlerThread("EthernetServiceThread");
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
mTracker.start(mContext, mHandler);
mStarted.set(true);
/* int ethernet_on = Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ETHERNET_ON, 0);
if(ethernet_on == 0 ) {
setEthernetEnabled(false);
} */
}
可见 EthernetServiceImpl 构造函数中,通过mEthernetConfigStore.readIpAndProxyConfigurations()读取IpConfiguration .IPConfiguration 这个类是干啥的呢? IpConfiguration 这个类就是以太网配置信息类啊!!! 模式是DHCP啊还是静态啊,静态的ip ,网关啥的都存在这里头呢!!!
//frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetConfigStore.java
public class EthernetConfigStore extends IpConfigStore {
private static final String ipConfigFile = Environment.getDataDirectory() +
"/misc/ethernet/ipconfig.txt";
public EthernetConfigStore() {
}
public IpConfiguration readIpAndProxyConfigurations() {
SparseArray<IpConfiguration> networks = readIpAndProxyConfigurations(ipConfigFile);
if (networks.size() == 0) {
Log.w(TAG, "No Ethernet configuration found. Using default.");
return new IpConfiguration(IpAssignment.DHCP, ProxySettings.NONE, null, null);
}
if (networks.size() > 1) {
// Currently we only support a single Ethernet interface.
Log.w(TAG, "Multiple Ethernet configurations detected. Only reading first one.");
}
return networks.valueAt(0);
}
可知,ipconfig存储在 "data/misc/ethernet/ipconfig.txt"中。那么解决方案也就来了
step 3 配置以太网设置默认为静态ip
1.手动配置好一份静态ip,这是ipconfig.txt中存储的就是静态ip了。
2.取出以太网配置文件: ipconfig.txt
进入命令行,输入
adb root
adb pull /data/misc/ethernet/ipconfig.txt
因为是在桌面输入的命令行,所以复制出的ipconfig.txt 的位置在桌面
3.device.mk文件中 将 ipconfig.txt 预设置到固定位置
1)将刚刚拷贝的ipconfig.txt 文件复制到与device.mk同目录下.
2)找到一份源码编译时一定会编译的device.mk 文件,在device.mk中添加
PRODUCT_COPY_FILES += $(LOCAL_PATH)/ipconfig.txt:system/etc/ipconfig.txt
3)将上面提到的EthernetConfigStore 类中的ipConfigFile 修改为
private static final String ipConfigFile = Environment.getRootDirectory() +
"/etc/ipconfig.txt";
完活
step 4: 那么EthernetServiceImpl start方法是做什么的呢?
初步估计是关于网口连接时的广播注册,和 Binder 调用. 有个现象应该和他有关,在没有接网线之前,以太网显示状态位static ,但是没有ip ,网关 , 掩码等信息.调查ing
实现以太网wifi共存
补丁如下:
frameworks/base/services/core/java/com/android/server/ConnectivityService.java
4.1.1修改一
//jq add start
private static final boolean LOGD_BLOCKED_NETWORKINFO = true;
// if true:
// wifi and ethernet can coexist, if wifi and ethernet connect together, prefered to use ethernet
// if false:
// wifi and ethernet can't coexist, if wifi and ethernet connect together, will tear down wifi
// TODO: still have bug in this case to fix (like can't reconnect wifi when ethernet disconnect)
private static final boolean ENABLE_NETWORK_COEXIST = true;
//jq end
4.1.2修改二
//nai.asyncChannel.disconnect();//jq delete
//jq add start
if (ENABLE_NETWORK_COEXIST) {
log("Skip teardownUnneededNetwork: " + nai.name());
} else {
nai.asyncChannel.disconnect();
}
4.1.3说明
注:首先必须解决一个网络起来后另一个网络被踢掉的问题,在网络的核心类ConnectivityService.java找到了调用
把nai.asyncChannel.disconnect()函数注释后, 另一个网络不会被踢掉
两个网络可以共存,通过命令dumpsys connectivity,可以看到当前正在使用的网络
通过命令 ip ru 查看当前的路由表,
也可以通过netcfg来查看,通过这个方法有时不准确,最好不要使用
可以看到 wlan0 和以太网是同时存在的,功能已经基本上实现
但是这样存在问题,当wifi先打开的时候,以太网不能连接,通过跟代码发现。EthernetNetworkFactory.java是核心类,这里不会被调用
4.2wifi访问外网,以太网用于访问局域网
若需要wifi访问外网,以太网用于访问局域网,则打如下补丁:
frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
private static final int NETWORK_SCORE = 30;//jq modify 150 to 30
4.3设置路由
如果用ping命令发现只能ping通以太网wifi中的一个时,输入如下命令:
ip rule add from all lookup main pref 9999
关于这一条是要加在app,同时WiFi和eth0同时存在时wifi不能是192.168.1.X网段
4.3.1增加网络访问权限
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET"/>
4.3.2增加路由
参考:https://www.jianshu.com/p/d1be03c15263
MainActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String commend = "ip rule add from all lookup main pref 9999 \n";
execRootCmd(commend);
HardWdudp.wdudp_image();
HardWdudp.wdudp_trev();
}
String TAG = "execRootCmd test";
/**
* 执行命令并且输出结果
*/
public String execRootCmd(String cmd) {
String result = "";
DataOutputStream dos = null;
DataInputStream dis = null;
try {
Process p = Runtime.getRuntime().exec("su");// 经过Root处理的android系统即有su命令
dos = new DataOutputStream(p.getOutputStream());
dis = new DataInputStream(p.getInputStream());
Log.i(TAG, cmd);
dos.writeBytes(cmd + "\n");
dos.flush();
dos.writeBytes("exit\n");
dos.flush();
String line = null;
while ((line = dis.readLine()) != null) {
Log.d("result", line);
result += line;
}
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (dis != null) {
try {
dis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
4.3.3HardWdudp.java
package com.example.hardlibrary;
public class HardWdudp {
public static native int wdudp_image();
public static native void wdudp_rev();
public static native int wdudp_timage();
public static native void wdudp_trev();
static {
try {
System.loadLibrary("hardwdudp");
} catch (Exception e) {
e.printStackTrace();
}
}
}
4.4优化
共存且wifi优先级高时,若断开wifi后,设置界面以太网也显示未连接,或者先连接wifi后,再连接以太网时,以太网连接失败,则用下面补丁:
frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
//jq add
if (mEthernetCurrentState != EthernetManager.ETHER_STATE_DISCONNECTED){ //注意Android6.0可能是EthernetManager.ETHERNET_CONNECT_STATE_DISCONNECT
return ;
}
//jq end
系统设置相关
android5.1系统修改源码实现隐藏底部状态栏、隐藏通知栏、隐藏上方状态栏、永不熄屏的方法
注:其他版本系统可能有一定的差异
结合其他博客的介绍的方法,对android5.1系统源码进行修改实现隐藏底部状态栏、隐藏通知栏、隐藏上方状态栏、永不熄屏等功能。亲测可用
1.隐藏底部状态栏
到android/frameworks/base/policy/src/com/android/internal/policy/impl目录下修改PhoneWindowManager.java文件.
修改方法: 定位到setInitialDisplaySize函数,找到注释
// Height of thenavigation bar when presented horizontally at bottom
将注解下的源代码修改为
mNavigationBarHeightForRotation[mPortraitRotation]=
mNavigationBarHeightForRotation[mUpsideDownRotation]=
//res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
0;
mNavigationBarHeightForRotation[mLandscapeRotation]=
mNavigationBarHeightForRotation[mSeascapeRotation]=
//res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height_landscape);
0;
2.隐藏通知栏
到android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone目录下打开PhoneStatusBarView.java文件.
找到onTouchEvent()和onInterceptTouchEvent()两个方法,将方法里面的代码注释掉(如下所示),即可实现效果
@Override
public boolean onTouchEvent(MotionEventevent) {
return false;
}
@Override
public booleanonInterceptTouchEvent(MotionEvent event) {
return false;
}
3.隐藏上方的状态栏
到android/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone的目录下打开PhoneStatusBar.java文件.
找到addStatusBarWindow()方法,在方法最后加一行代码mStatusBarView.setVisibility(View.GONE);
变为:
private void addStatusBarWindow() {
makeStatusBarView();
mStatusBarWindowManager = newStatusBarWindowManager(mContext);
mStatusBarWindowManager.add(mStatusBarWindow,getStatusBarHeight());
mStatusBarView.setVisibility(View.GONE);
}
到android/frameworks/base/core/res/res/values目录下,打开dimens.xml文件.修改
<dimenname=”status_bar_height”>25dip</dimen>为
<dimenname=”status_bar_height”>0dip</dimen>
4 永不熄屏
到android/frameworks/base/packages/SettingsProvider/res/values目录下,打开defaults.xml文件
修改.<integername="def_screen_off_timeout">6000</integer>为<integername="def_screen_off_timeout">-1</integer>
到android/frameworks/base/services/core/java/com/android/server/power目录下,打开PowerManagerService.java文件.修改getScreenOffTimeoutLocked()函数为:
private int getScreenOffTimeoutLocked(intsleepTimeout) {
int nosleep;
int timeout = mScreenOffTimeoutSetting;
if(isMaximumScreenOffTimeoutFromDeviceAdminEnforcedLocked()) {
timeout = Math.min(timeout,mMaximumScreenOffTimeoutFromDeviceAdmin);
}
if(mUserActivityTimeoutOverrideFromWindowManager >= 0) {
timeout = (int)Math.min(timeout,mUserActivityTimeoutOverrideFromWindowManager);
}
if (sleepTimeout >= 0) {
timeout = Math.min(timeout,sleepTimeout);
}
nosleep = mScreenOffTimeoutSetting;
if(nosleep <0)
{
nosleep = mMaximumScreenOffTimeoutFromDeviceAdmin;
return Math.max(nosleep,mMaximumScreenOffTimeoutFromDeviceAdmin);
}
return Math.max(timeout,mMinimumScreenOffTimeoutConfig);
}
编译不过,以后在研究
方式二
修改屏幕锁:
(1)frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<integer name="def_screen_off_timeout">60000</integer>
60000改成想要的时间如果是不锁为-1 (2)frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardViewMediator.java
private boolean mExternallyEnabled = true;
将其修改成false,这样更改就不会再进入休眠状态了
第二步这个不存在这个目录
禁用下拉菜单,android5.1源码
前言
对于下拉菜单,总有人想永久禁用,无论在launcher还是在应用,还是在锁屏界面
其实这个很简单,也不需要多麻烦,只要在下拉时候返回一个控制就可以了
目录:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
如下更改:
public PanelView selectPanelForTouch(MotionEvent touch) {
// No double swiping. If either panel is open, nothing else can be pulled down.
// return mNotificationPanel.getExpandedHeight() > 0
// ? null
// : mNotificationPanel;
return null;
}
这时候launcher界面或者app界面都不能下拉了,这样还有一个小问题,锁屏界面的下拉菜单还是可以下拉的,我们还需要做一下更改
目录:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
(1)
private void setQsExpanded(boolean expanded) {
//begin 添加下面四行
if(mKeyguardShowing)
{
return;
}
//end
boolean changed = mQsExpanded != expanded;
if (changed) {
mQsExpanded = expanded;
updateQsState();
requestPanelHeightUpdate();
mNotificationStackScroller.setInterceptDelegateEnabled(expanded);
mStatusBar.setQsExpanded(expanded);
}
}
(2)
private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) {
if (!mQsExpansionEnabled) {
return false;
}
//begin 将下面第一行替换成第二行
View header = mKeyguardShowing ? mKeyguardStatusBar : mHeader;
View header = mHeader;
//end
boolean onHeader = x >= header.getLeft() && x <= header.getRight()
&& y >= header.getTop() && y <= header.getBottom();
if (mQsExpanded) {
return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y);
} else {
return onHeader;
}
}
(3) private boolean onTouchEvent()
{
...
if (!mTwoFingerQsExpand && mQsTracking) {
//begin 添加下面
if(!mKeyguardShowing){
onQsTouch(event);
if (!mConflictingQsExpansionGesture) {
return true;
}
}
//end
}
...
}
有些人可能又说啦,下拉菜单都禁用了,下拉通知还要不要显示出来,这个其实很简单,只需要在布局里面改动一下就可以,添加
<span style="font-size:18px;">android:visibility属性:</span>
目录:frameworks/base/packages/SystemUI/res/layout/status_bar.xml
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/notification_icon_area"
android:visibility="invisible"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android5.1去掉开机默认锁屏
参考而已,在RK3288_5.1中不是这样的也是可以的
参考一
android5.1修改如下:
frameworks/base/core/res/res/values/config.xml
<bool name="config_dreamsSupported">false</bool>
<bool name="config_dreamsEnabledByDefault">false</bool>
frameworks/base/packages/SettingsProvider/res/values/defaults.xml
<bool name="def_lockscreen_disabled">true</bool>
frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
public void goToSleep(long eventTime, int reason, int flags) {
if (true){ return; }
参考二
在5.1上,代码的处理方式变得不一样了,我最开始的做法是更改锁屏默认值,但是第一次刷机有效,第二次开机居然就不进去桌面了.
第一种方法:目录(不推荐):frameworks\base\packages\SystemUI\src\com\android\systemui\keyguard\KeyguardViewMediator.java
<span style="font-size:18px;"> /**
* External apps (like the phone app) can tell us to disable the keygaurd.
*/
<strong> private boolean mExternallyEnabled = true;</strong>
/**
* Remember if an external call to {@link #setKeyguardEnabled} with value
* false caused us to hide the keyguard, so that we need to reshow it once
* the keygaurd is reenabled with another call with value true.
*/
<strong> private boolean mNeedToReshowWhenReenabled = false;</strong>
// cached value of whether we are showing (need to know this to quickly
// answer whether the input should be restricted)
private boolean mShowing;</span>
这个值是去除锁屏的,但是修改了有点问题
第二种方法(推荐)
目录:frameworks\base\packages\SettingsProvider\res\values\defaults.xml
关键字:def_lockscreen_disabled 这个值为true时是默认选择设置里面的无选项
<span style="font-size:18px;"> <bool name="def_lockscreen_disabled">true</bool>
<bool name="def_device_provisioned">false</bool>
<integer name="def_dock_audio_media_enabled">1</integer></span>
如果不起效果,可以在宏定义脚本加上PRODUCT_PROPERTY_OVERRIDES += ro.lockscreen.disable.default=true这个选项
下面去除设置里面的其他锁屏选项,爬代码可看出,这个布局是动态加载的
(packages\apps\settings\src\com\android\settings\FingerSettings.java)
所以我们只需要把布局里面的Preference注释就可以
packages\apps\settings\res\xml\Security_settings_picker.xml
<span style="font-size:18px;"><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/lock_settings_picker_title"
android:key="lock_settings_picker">
<PreferenceScreen
android:key="unlock_set_off"
android:title="@string/unlock_set_unlock_off_title"
android:persistent="false"/>
<!-- <PreferenceScreen
android:key="unlock_set_none"
android:title="@string/unlock_set_unlock_none_title"
android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_biometric_weak"
android:title="@string/unlock_set_unlock_biometric_weak_title"
android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_voice_weak"
android:title="@string/unlock_set_unlock_mode_voice_weak"
android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_pattern"
android:title="@string/unlock_set_unlock_pattern_title"
android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_pin"
android:title="@string/unlock_set_unlock_pin_title"
android:persistent="false"/>
<PreferenceScreen
android:key="unlock_set_password"
android:title="@string/unlock_set_unlock_password_title"
android:persistent="false"/> -->
</PreferenceScreen>
</span>
Android5.1源码改变USB连接方式
https://blog.csdn.net/lcpangs/article/details/52233170
修改默认主页
在如下文件
packages/apps/Browser/res/values/strings.xml
<!-- The default homepage. -->
<string name="homepage_base" translatable="false">
https://www.google.com/webhp?client={CID}&source=android-home</string>
修改一个你喜(e)欢(xin)的主页比如百度:
<!-- The default homepage. -->
<string name="homepage_base" translatable="false">
https://www.baidu.com/</string>
去掉顶部Google搜索栏
[RK3399][Android7.1]
[RK3399][Android7.1]
源码
删除:QuickSearchBox
源码在:packages/apps/QuickSearchBox
正确改法:
在build/target/product/core.mk
去掉 QuickSearchBox
Android 8.1 去掉Launcher3的默认Google搜索栏
没试过
去掉search_container_workspace.xml的fragment
<com.android.launcher3.qsb.QsbContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@id/search_container_workspace"
android:padding="0dp" >
<!-- <fragment
android:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"
android:layout_width="match_parent"
android:tag="qsb_view"
android:layout_height="match_parent"/> -->
</com.android.launcher3.qsb.QsbContainerView>
Workspace.java的public void bindAndInitFirstWorkspaceScreen(View qsb)
if (qsb == null) {
// In transposed layout, we add the QSB in the Grid. As workspace does not touch the
// edges, we do not need a full width QSB.
qsb = LayoutInflater.from(getContext())
.inflate(R.layout.search_container_workspace,firstPage, false);
}
//注释掉
/*CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);
lp.canReorder = false;
if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) {
Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
}*/
APP相关
关于app自启
方式1
这种方式类似手动启动app
注:正式版本没加,只是测试ok
1 内置apk
vendor/rockchip/rpdzkj/apps
放到此路径下,会自动安装,但是升级完之后,需要重启才能实现apk自启操作
2apk自启
参考:
https://blog.csdn.net/com6339663/article/details/87874834
路径:frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
修改代码位置
0, null, null,
android.Manifest.permission.RECEIVE_BOOT_COMPLETED,
AppOpsManager.OP_NONE, true, false, MY_PID, Process.SYSTEM_UID,
userId);
}
}
scheduleStartProfilesLocked();
}
}
//完全开机后启动app by:shihao
startAppOrService(mContext,"com.example.app_3288_leddemo");
}
/**
* start 新增启动第三方应用的方法 by:shihao
*/
private void startAppOrService(Context context,String appPackage) {
PackageManager doupackageManager = context.getPackageManager();
Intent intent = new Intent();
try{
intent = doupackageManager.getLaunchIntentForPackage(appPackage);
if(intent!=null){
context.startActivity(intent);
}
}catch(Exception e){
Log.i(TAG,"startApp_exception");
}
}
/**
* end by:shihao
*/
这个会在Lancher界面起来后再起app
方式2
1.去掉系统默认Launcher
以7寸屏为例
kernel/arch/arm/boot/dts/lcd-rpdzkj_mipi_7.dtsi
10.1寸屏
kernel/arch/arm/boot/dts/lcd-rpdzkj_lvds.dtsi
参考3399
2. apk 内置
vendor/rockchip/rpdzkj/apps
备注:一般这个目录下也有其他的,可以参考一下
3.apps.mk
vendor/rockchip/rpdzkj/apps/apps.mk
增加自己的,示例如下
发现其实去掉这里,也是可以的,在第一次开机就会选择选用哪一个当做HOME来启动
wd-app自启实战(项目中)
1.删除Launcher3
kernel/arch/arm/boot/dts/lcd-rpdzkj_mipi_7.dtsi
以7寸屏为例
这样系统起不来
2.app
1.修改配置文件
在AndroidManifest.xml 配置文件中增加两行即可。
<activity android:name=".MainActivity">
<intent-filter>
<!-- 增加lancher配置-->
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
4.总结
3. apk路径放置对,特别是文件名要对上
4. apk一定要AndroidManifest.xml文件一定要加上两行配置