Android

目录

编译方式

广播

Context

线程

内置apk的方式

adb命令

Linux命令

内置APK

实用方法

mtk解锁方式

Toast

移除一览

setting搜索框过滤某些关键字

在clearallbutton中图标和文本动态居中

Google search替换成可移动可删除的小部件

模拟按键命令

判断屏幕是否旋转

定制侧滑返回

判断WiFi是否连接、数据是否开启

内置销售统计apk,仅启动一次

获取顶部activity

拦截屏幕滑动事件

锁屏事件

android横竖屏判断

打开开发者模式点击次数修改

长按电源键弹出的功能修改

修改默认导航键选项

修改锁屏时录屏是否停止

 单点模式下两点快速触摸会错位

长按google search不显示Glance widget

修改运营商信号格强度标准

修改滑动解锁滑动距离

输入正确的PIN直接解锁

Launcher字体固定

去除按5次启动紧急拨号

如何使apk在编译时生成到指定的目录下

长按打开手电筒

在某些情况下,不应该息屏

修改文本(超强)

修改下拉状态栏QS默认选项

修改长按电源跳出的弹窗选项

修改导航键默认样式

点击5次打开工厂测试

移除长按home 出现的google白色圆球

相机照片添加水印

按电源键不灭屏

置灰和禁用但是不置灰

判断是否为开机后第一次解锁

防止解锁时两声解锁声音

实现动态禁用导航键

Calendar默认显示月

限制recent只显示3个task

仿苹果hotseat底部白条

  launcher移除导航栏后动态布局

修改盘符和蓝牙名称、系统值

Android9 图标去除白边

某些应用未适应屏幕大小

修改系统分区大小

添加可卸载内置apk名单

launcher常见应用classname

修改默认的输入法

 替换开机Logo

修改默认语言

settings总内存修改为3G

Android9添加锁屏壁纸

清除应用数据

    android9静默安装Musicolet

添加图标背景

第三方应用图标修改

android9修改默认Launcher、默认给与权限

修改系统支持的语言

Android9系统层面修改第三方应用icon

Android13新建lunch项

Android13设备名版本修改失败

android 左上角返回上一级的实现


编译方式

编译步骤
1 先进入alps-mp-s0目录  比如编译userdebug版本 命令如下
    source build/envsetup.sh
    export OUT_DIR=out
    lunch vnd_k62v1_64_bsp-usedebug
    make vnd_images krn_images 2>&1 | tee build_vendor.log
    
2 第一步编译完 再进入 alps-mp-t0 再执行这一步
    source build/envsetup.sh
    export OUT_DIR=out_sys
    lunch sys_mssi_64_cn-userdebug
    make sys_images 2>&1 | tee build.log
    
3 执行完第三步  还是在alps-mp-t0这个目录  再执行这一步。 就编译完成了
    python out_sys/target/product/mssi_64_cn/images/split_build.py --system-dir out_sys/target/product/mssi_64_cn/images --vendor-dir ../alps-mp-s0/out/target/product/k62v1_64_bsp/images --kernel-dir ../alps-mp-s0/out/target/product/k62v1_64_bsp/images --output-dir out_sys/target/product/mssi_64_cn/merged/ 2>&1 | tee build_python.log

广播

动态广播

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;

public class hqb {
    private Receiver mReceiver;
    Context mContext;
    void  Send(){//发送
        Intent intent=new Intent();
        intent.setAction("HQB_HQB");
        mContext.sendBroadcast(intent);
    }
    void init(){//注册广播
        mReceiver= new Receiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("HQB_HQB");
        mContext.registerReceiver(mReceiver,intentFilter);
    }
    final class Receiver extends BroadcastReceiver {//接收广播
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals("HQB_HQB")) {
                //要执行的动作
            }
        }
    }
    void onPause(){//销毁广播
        mContext.unregisterReceiver(mReceiver);
    }
}

Context

获取Context的方法

Context mContext;
//在fragment中使用,返回该fragment所依附的activity上下文
mContext=getActivity();
//这个函数返回的这个Application的上下文,所以是与app挂钩的
mContext=getApplicationContext();
//当前类是context的子类,一般是activity application等
mContext=this;
//getApplication只能被Activity和Services使用
mContext=getApplication();
//返回activity的上下文
mContext=getParent();

线程

new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(800);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //执行的方法
            }
        }.start();

内置apk的方式

方法一 不从apk中解压lib库而直接添加
如下例,在Android.mk中添加并配置变量(注意路径对应):

LOCAL_PREBUILT_JNI_LIBS = \
@lib/armeabi-v7a/libcryptox.so \
@lib/armeabi-v7a/libfb.so 
注意前面的 @符号,@标识符会将apk中的so抽离出来,拷贝到对应编译后的apk目录;

方法二 手动解压lib文件到当前apk的编译目录并添加
先解压当前apk内的lib文件夹到当前apk编译目录,同方法一在Android.mk中添加并配置变量(注意路径对应),如下例:

LOCAL_PREBUILT_JNI_LIBS = \
lib/armeabi-v7a/libcryptox.so \
lib/armeabi-v7a/libfb.so 
若当前apk包含的lib库文件数量比较多时,上述代码可以通过修改为如下代码进行优化,优化的思路是用递归搜索来替代手工对lib库文件进行添加:

###清空临时变量JNI_LIBS 
JNI_LIBS :=
###当前目录递归搜索
$(foreach FILE,$(shell find $(LOCAL_PATH)/lib/ -name *.so), $(eval JNI_LIBS += $(FILE)))
###获取搜索文件目录集(相对目录)
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH),,$(JNI_LIBS))
<二>、然后需要注意当前Android环境是否符合apk运行条件(64位和32位)并配置apk运行环境
之所以要配置apk运行环境,是因为包含lib库的apk在添加lib库到编译环境之后,在Android环境和apk运行条件不符的情况下,需要在编译环境中指定环境。举例说明:

目前一般的apk运行环境为32位Android系统环境,当在64位Android系统中预置带有lib库的apk时,手动添加lib库文件到编译环境后,默认情况下编译环境会在编译后apk目录建立64位的环境的lib库路径 /lib/arm64,虽然编译过程未报错,但之后在执行该apk时,会出现apk因找不到lib库而报错

因此,需要在Android.mk中对当前apk编译环境进行配置,配置的方法常见的也有两种:

<1>指定编译目标为 32位 或 64位

在Android目标中添加并配置变量:

LOCAL_MULTILIB := 
###可选值 /32/64/first/both 

<2>指定目标lib库的 类型
在Android.mk中添加并配置变量:

LOCAL_MODULE_TARGET_ARCH := 
###可选值  arm/arm x86/arm64
此处, LOCAL_MODULE_TARGET_ARCH 的值只能是当前编译环境所支持的类型,如果需要配置当前系统不支持类型,则需要配置如下另一个变量

LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH := 
###可选值 arm/arm x86/arm64
与 LOCAL_MODULE_TARGET_ARCH 相反, LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH 的值只能是当前编译环境所不支持的类型,否则编译将不会生效

如下是一个完整的Android.mk脚本示例,其中apk运行环境为32位,系统为64位:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := UCBrowser
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := HK_UCBrowser*.apk
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MULTILIB := 32
JNI_LIBS :=
$(foreach FILE,$(shell find $(LOCAL_PATH)/lib/ -name *.so), $(eval JNI_LIBS += $(FILE)))
LOCAL_PREBUILT_JNI_LIBS := $(subst $(LOCAL_PATH),,$(JNI_LIBS))
include $(BUILD_PREBUILT)

adb命令

当无法启动apk时可通过下面两行命令获取主要的activity

adb shell

dumpsys package  xxx(包名)

获取当前活动

adb shell "dumpsys window |grep mCurrentFocus"

查询是否有这个关键字的进程正在运行

adb shell ps | grep xxx(包名关键字)
获取默认语言
adb shell getprop | findstr local

启动apk

adb shell am start -n com.omix.activateyourdevice/com.omix.activateyourdevice.MainActivity

显示到秒

adb shell pm enable com.android.systemui/com.android.systemui.tuner.TunerActivity

adb shell am start -n com.android.systemui/com.android.systemui.tuner.TunerActivity

Linux命令

拷贝代码

scp -r [email protected]:/media/D/Project/AndroidS .



设置git用户名和邮箱

git config user.name huangqingbin
git config user.email [email protected]
查看
git config user.name
git config user.email


获取服务器公钥

先确定是否已经生成了公钥,查看公钥路径~/.ssh/id_rsa.pub,如果没有生成则需要生成代码为:ssh-keygen -t rsa 并按回车3下即可,切记不需要加sudo不然会生成在root路径中,只需要生成在home路径下即可。



pushcode安装

将pushcode.py拷贝至/usr/bin/目录下,并设置可执行权限
sudo cp pushcode.py /usr/bin/
sudo chmod a+x /usr/bin/pushcode.py
sudo apt install python-pip
sudo pip install pexpect
安装完成后测试pushcode.py是否能正常使用

内置APK

使用拷贝的方式预制apk

$(shell mkdir -p $(TARGET_OUT_VENDOR)/operator/app/Zhangyue) 
$(shell cp packages/apps/Zhangyue/Zhangyue.apk $(TARGET_OUT_VENDOR)/operator/app/Zhangyue) 

MTKandroid9

+++ b/ap/device/mediatek/common/device.mk
@@ -4164,6 +4164,20 @@ endif
 
 #Boot performance
 PRODUCT_COPY_FILES += device/mediatek/common/bootperf.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/bootperf.rc
+PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*.so,$(LOCAL_PATH)/lib/yingyongbao/,/system/lib/)
+PRODUCT_PACKAGES += douying
+PRODUCT_PACKAGES +=    fangqixiaoshuo
+PRODUCT_PACKAGES += kuake
+PRODUCT_PACKAGES += QQ_8.7
+PRODUCT_PACKAGES += tenxunshiping
+PRODUCT_PACKAGES += weixing
+PRODUCT_PACKAGES += wanyiyunyingyue
+PRODUCT_PACKAGES += yingyongbao
 

编译时遇到错误

FAILED: out/target/common/obj/APPS/ActivateYourDevice_intermediates/enforce_uses_libraries.status
/bin/bash -c "(rm -f out/target/common/obj/APPS/ActivateYourDevice_intermediates/enforce_uses_libraries.status ) && (build/soong/scripts/manifest_check.py 	  --enforce-uses-libraries 	  --enforce-uses-libraries-status out/target/common/obj/APPS/ActivateYourDevice_intermediates/enforce_uses_libraries.status 	  --aapt out/host/linux-x86/bin/aapt 	   	   	   	   	  packages/apps/ActivateYourDevice/ActivateYourDevice.apk )"
error: mismatch in the  tags between the build system and the manifest:
	- required libraries in build system: []
	                 vs. in the manifest: [android.test.runner]
	- optional libraries in build system: []
	                 vs. in the manifest: []
	- tags in the manifest (packages/apps/ActivateYourDevice/ActivateYourDevice.apk):
		uses-library:'android.test.runner'
note: the following options are available:
	- to temporarily disable the check on command line, rebuild with RELAX_USES_LIBRARY_CHECK=true (this will set compiler filter "verify" and disable AOT-compilation in dexpreopt)
	- to temporarily disable the check for the whole product, set PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true in the product makefiles
	- to fix the check, make build system properties coherent with the manifest
	- see build/make/Changes.md for details

此项报错主要是构建系统在Android.bp或Android.mk文件中的信息与Manifest清单之间进行构建时一致性检查,要求声明请求使用的libraries跟AndroidManifest.xml中声明的一致,否则将报错。

解决方法:对应的Android.mk中加上LOCAL_ENFORCE_USES_LIBRARIES := false

实用方法

mtk解锁方式

1、setting -> system -> Developer options -> OEM unlocking
进入开发者模式中打开 OEM 
2 adb reboot bootloader
3 fastboot flashing unlock
4 按音量上键
5 fastboot reboot
6 adb root
7 adb disable-verity
8 adb reboot
9 adb root
10 adb remount

Toast

+++ b/ap/frameworks/base/core/java/android/widget/Toast.java
@@ -39,7 +39,7 @@ import android.view.View;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
-
+import java.util.Locale;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
@@ -131,6 +131,7 @@ public class Toast {
 
         INotificationManager service = getService();
         String pkg = mContext.getOpPackageName();
+               android.util.Log.d("hqb","pkg="+pkg);
         TN tn = mTN;
         tn.mNextView = mNextView;
 
@@ -267,6 +268,24 @@ public class Toast {
      *
      */
     public static Toast makeText(Context context, CharSequence text, @Duration int duration) {
+               android.util.Log.d("hqb","6text="+text.toString());
+               Locale locale = context.getResources().getConfiguration().locale;
+        Log.d("hqb",locale.getLanguage());
+               if(text.toString().contains("关闭中")){
+                                       if(locale.getLanguage().contains("en")){
+                                       text="closing";
+                                       }else if(locale.getLanguage().contains("ja")){
+                                       text="closing";
+                                       }else if(locale.getLanguage().contains("de")){
+                                       text="closing";
+                                       }else if(locale.getLanguage().contains("fr")){
+                                       text="closing";
+                                       }else if(locale.getLanguage().contains("it")){
+                                       text="closing";
+                                       }else if(locale.getLanguage().contains("es")){
+                                       text="closing"; 
+                                       }
+                               }
         return makeText(context, null, text, duration);
     }

移除一览

usb默认为文件传输

X:\AndroidT_2\sprd.mocor13.androidT\frameworks\base\services\usb\java\com\android\server\usb\UsbDeviceManager.java

protected void finishBoot()和public void handleMessage(Message msg) {

//setEnabledFunctions(UsbManager.FUNCTION_NONE, false);
                    setEnabledFunctions(UsbManager.FUNCTION_MTP, false);

移除蓝牙的共享联系人

X:\AndroidT_2\sprd.mocor13.androidT\frameworks\base\packages\SettingsLib\src\com\android\settingslib\bluetooth\PbapServerProfile.java

 public boolean isProfileReady() {
        return false;
    }

移除音量条的震动图标

mShowVibrate

移除锁定屏幕--》通过已锁定的设备。。。

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\src\com\android\settings\display\ControlsTrivialPrivacyPreferenceController.java

UNSUPPORTED_ON_DEVICE;

连接偏好设置移除蓝牙

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\res\xml\connected_devices_advanced.xml

蓝牙加已连接的设备

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\res\xml\connected_devices.xml中的

              android:key="previously_connected_devices_see_all"
            android:title="@string/previous_connected_see_all"
            android:icon="@drawable/ic_chevron_right_24dp"
            android:order="10"
            settings:searchable="false"
            android:fragment="com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment"/>

移到X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\res\xml\bluetooth_screen.xml

移除按流量计费

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\res\layout\wifi_network_config.xml

metered_settings

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\src\com\android\settings\wifi\WifiConfigController2.java

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\src\com\android\settings\wifi\WifiConfigController.java 

mMeteredSettingsSpinner

移除不属于运营商的流量消耗

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\src\com\android\settings\network\NetworkProviderSettings.java

mDataUsagePreference.setVisible(false);

移除锁定屏幕的快捷方式

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Settings\src\com\android\settings\accessibility\AccessibilityShortcutPreferenceController.java

 @Override
    public int getAvailabilityStatus() {
        return UNSUPPORTED_ON_DEVICE;
    }

移除备份和多用户

packages\apps\Settings\src\com\android\settings\SettingsActivity.java

import com.android.settings.backup.UserBackupSettingsActivity;

somethingChanged = setTileEnabled(changedList, //hqb
                new ComponentName(packageName,
                UserBackupSettingsActivity.class.getName()), false, isAdmin)
                || somethingChanged;

 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                        Settings.UserSettingsActivity.class.getName()),false, isAdmin)
                || somethingChanged;

packages/apps/Settingsres/xml/top_level_settings.xml

移除Settings-->壁纸(一级目录)

Y:\AndroidS\sprd.mocor12.androidS\packages\apps\Settings\src\com\android\settings\display\TopLevelWallpaperPreferenceController.java
 @Override
    public int getAvailabilityStatus() {
        if ((TextUtils.isEmpty(mWallpaperClass) && TextUtils.isEmpty(mStylesAndWallpaperClass))
                || TextUtils.isEmpty(mWallpaperPackage)) {
            Log.e(TAG, "No Wallpaper picker specified!");
            return UNSUPPORTED_ON_DEVICE;
        }
        /* return canResolveWallpaperComponent(getComponentClassString())
                ? AVAILABLE_UNSEARCHABLE : CONDITIONALLY_UNAVAILABLE; */
				return UNSUPPORTED_ON_DEVICE;
    }

移动数据和WLAN

Y:\AndroidS\sprd.mocor12.androidS\packages\apps\Settings\src\com\android\settings\applications\appinfo\AppDataUsagePreferenceController.java

无障碍--》震动和触感强度

Y:\AndroidS\sprd.mocor12.androidS\packages\apps\Settings\src\com\android\settings\accessibility\VibrationPreferenceController.java

移除下拉状态栏编辑图标

frameworks/base/packages/SystemUI/src/com/android/systemui/qs/QSFooterView.java

setting搜索框过滤某些关键字

packages/apps/SettingsIntelligence/src/com/android/settings/intelligence/search/SearchResultsAdapter.java

// modify by yxiaobin Search for cast, and no result is displayed begin 
import android.util.Log;
import android.text.TextUtils;
// modify by yxiaobin Search for cast, and no result is displayed end
  
public void postSearchResults(List newSearchResults) {
        final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(
                new SearchResultDiffCallback(mSearchResults, newSearchResults));
        mSearchResults.clear();
		/* modify by yxiaobin Search for cast, and no result is displayed begin */
		notifyDataSetChanged();
		int index = -1;
        if(newSearchResults.size()>0){
            for (int i= 0; i < newSearchResults.size(); i++) {
            SearchResult sr = newSearchResults.get(i);
			String title ="";
			String summary="";
			String dataKey="";
			if(!TextUtils.isEmpty(sr.title)){
			    title = sr.title.toString();}
            if(!TextUtils.isEmpty(sr.summary)){
			    summary=sr.summary.toString();}
			if(!TextUtils.isEmpty(sr.dataKey)){
			    dataKey=sr.dataKey.toString();}
			if("Cast".equalsIgnoreCase(title)||"cast".equalsIgnoreCase(summary)||"cast".equalsIgnoreCase(dataKey)||"Cast options".equalsIgnoreCase(title)||"Wi-Fi calling".equalsIgnoreCase(title) 
			|| title.contains("Wireless") || summary.contains("Receive wireless") || summary.contains("Wireless") || dataKey.contains("Wireless")
			|| title.contains("Face") || summary.contains("Face") 	){//modify by lzerong 20230601 for remove EmergencyBroadcast and Face ID
				index = i;
				newSearchResults.remove(index);
                notifyDataSetChanged();
				i--;
			}
         }
        }

在clearallbutton中图标和文本动态居中

//packages/apps/Launcher3/quickstep/src/com/sprd/ext/clearall/ClearAllButton.java
protected void onDraw(Canvas canvas) {
        Drawable[] drawables = getCompoundDrawables();
        if(drawables !=null) {
            Drawable drawableLeft = drawables[0];
            if(drawableLeft !=null) {
                float textWidth = getPaint().measureText(getText().toString());
                int drawablePadding = getCompoundDrawablePadding();
                int drawableWidth =0;
               drawableWidth = drawableLeft.getIntrinsicWidth();
                float bodyWidth = textWidth + drawableWidth + drawablePadding;
                canvas.translate((getWidth() - bodyWidth) /2,0);
            }
        }
        super.onDraw(canvas);
    }

Google search替换成可移动可删除的小部件

//packages/apps/Launcher3/src/com/android/launcher3/config/FeatureFlags.java
--public static final boolean QSB_ON_FIRST_SCREEN = true;
++public static final boolean QSB_ON_FIRST_SCREEN = false;

//vendor/partner_gms/apps/GmsSampleIntegration/res_dhs_full/xml/partner_default_layout.xml
++


//vendor/partner_gms/apps/SearchLauncher/res/xml/launcher_preferences.xml
-- 

模拟按键命令

public static void sendKeyEvent(final int KeyCode) {
		new Thread() {     
			public void run() {
				try {
					Instrumentation inst = new Instrumentation();
					inst.sendKeyDownUpSync(KeyCode);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		}.start();
	}

判断屏幕是否旋转

import android.content.SharedPreferences;
import com.android.launcher3.Utilities; 
private boolean getHomeRotationEnabled(){
SharedPreferences mSharedPrefs = Utilities.getPrefs(getContext());
boolean mHomeRotationEnabled=mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY,false);
Log.d("TaskView","mHomeRotationEnabled:"+mHomeRotationEnabled);
					return mHomeRotationEnabled;
	}

定制侧滑返回

//frameworks/base/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java

navigation_edge_panel_width 110
navigation_edge_panel_height 200
//mPaint.setStyle(Paint.Style.FILL); 填充线条 Paint.Style.STROKE不填充
//mPaintwt.setColor(Color.LTGRAY); 设置颜色
//mArrowPaint.setStrokeWidth(4); 线条粗细
//mPaintwt.setAlpha(180); 透明度
 private final Paint mPaint = new Paint()
   Path mPath= new Path();
@Override
    protected void onDraw(Canvas canvas) {
    float pointerPosition = mCurrentTranslation - mArrowThickness / 2.0f;
	mPath.reset();
    int factor = mIsLeftPanel ? 1 : -1;
    int currentY = getHeight() / 2;
    int topY = 0;
    int bottomY = getHeight();
    int footX = mIsLeftPanel ? 0 : getWidth();
    int peekX = (int) (footX + factor * (mIsLeftPanel ? pointerPosition : pointerPosition - getStaticArrowWidth()) / 2);
    mPath.moveTo(footX, topY);
    mPath.cubicTo(footX, topY + 75, peekX, topY + 100, peekX, currentY);
    mPath.cubicTo(peekX, bottomY - 100, footX, bottomY - 75, footX, bottomY);
    mPath.close();
	//canvas.drawColor(Color.argb(125,255,0,0));
		canvas.drawPath(mPath, mPaintwt);
	mArrowPath.reset();
    mArrowPath.moveTo(mIsLeftPanel?(peekX-40 + dp(3.5f)):(peekX+40 + dp(3.5f)), getHeight() / 2 - dp(5.5f));
    mArrowPath.lineTo(mIsLeftPanel?(peekX-40 - dp(4f)):(peekX+40 - dp(4f)), getHeight() / 2);
    mArrowPath.lineTo(mIsLeftPanel?(peekX-40 + dp(3.5f)):(peekX+40 + dp(3.5f)), getHeight() / 2 + dp(5.5f));
    canvas.drawPath(mArrowPath, mArrowPaint);
    }

判断WiFi是否连接、数据是否开启

//判断网络是否连接
public boolean isWifiConnect() {
        ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo mWifiInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        return mWifiInfo.isConnected();
    }

//判断数据是否打开
import android.telephony.TelephonyManager;
private TelephonyManager mTelephonyManager;
 if (mTelephonyManager == null) {
                mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
            } 
            if (mTelephonyManager != null && !mTelephonyManager.isDataEnabled()) {
                state.typeId = 0;
            }

内置销售统计apk,仅启动一次

import java.nio.charset.StandardCharsets;
private PhaseCheckParse mPhaseCheckParse = null;
mPhaseCheckParse = PhaseCheckParse.getInstance();
		byte[] bytes = "123456789".getBytes(StandardCharsets.UTF_8);
		byte[] bytes1 =mPhaseCheckParse.readMiscdataOffsetByteArray(769 * 1024,9);
		String a = new String(bytes);
		String b = new String(bytes1);

if(!a.equals(b)){
			Log.d("hqb","1");
			mPhaseCheckParse.writeMiscdataOffsetByteArray(769 * 1024 , bytes);
			Intent mServicesIntent=new Intent();
			mServicesIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			mServicesIntent.setClassName("com.omix.activateomix","com.omix.activateomix.MainActivity");
			context.startActivity(mServicesIntent);
		}

获取顶部activity

private String getPkgName(Context context) {
        try {
             ActivityManager am = context.getSystemService(ActivityManager.class);
             List tasks = am.getRunningTasks(1);
             return tasks.get(0).topActivity.getPackageName();
        } catch (Exception e) {
           //ignore
        }
        return "";
    }

拦截屏幕滑动事件

//frameworks/base/core/java/android/view/ViewGroup.java
 public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.isFromSource(InputDevice.SOURCE_MOUSE)
                && ev.getAction() == MotionEvent.ACTION_DOWN
                && ev.isButtonPressed(MotionEvent.BUTTON_PRIMARY)
                && isOnScrollbarThumb(ev.getX(), ev.getY())) {
            return true;
        }
		if((ev.getPointerCount() >= 3)&&(Settings.Secure.getInt(mContext.getContentResolver(), "screenshot_pointer", 0)==1)){
			return true;//hqingbin 2023.2.14 The screen does not slide when taking a three-finger screenshot
		}
        return false;
    }

锁屏事件

//获取锁屏锁的状态
//Y:\AndroidS\sprd.mocor12.androidS\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\policy\KeyguardStateController.java
mKeyguardStateController.isMethodSecure()

android横竖屏判断

 //获取设置的配置信息
        Configuration mConfiguration = this.getResources().getConfiguration(); 
        //获取屏幕方向
        int ori = mConfiguration.orientation;
        if (ori == mConfiguration.ORIENTATION_LANDSCAPE) {
            //横屏
        } else if (ori == mConfiguration.ORIENTATION_PORTRAIT) {
            //竖屏
        }

打开开发者模式点击次数修改

packages\apps\Settings\src\com\android\settings\deviceinfo\BuildNumberPreferenceController.java里面的TAPS_TO_BE_A_DEVELOPER

长按电源键弹出的功能修改

frameworks/base/core/res/res/values/config.xml中的config_globalActionsList

修改默认导航键选项

frameworks/base/packages/SettingsProvider/res/values/defaults.xml中的def_navigation_bar_config

修改锁屏时录屏是否停止

frameworks/base/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java 

   BroadcastReceiver mShutDownReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
             /* UNISOC: Modify for bug 1880099 stop recording when screen off {@ */
            if (Intent.ACTION_SHUTDOWN.equals(action)) {
                Log.d(TAG, "SHUTDOWN, Stopping Recording.");
                int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
                if (userId == -1) {
                    userId = mUserContextTracker.getUserContext().getUserId();
                }
                stopRecording(userId);
            } else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                Log.d(TAG, "Screen Off, Stopping Recording.");
				//hqingbin 2023.5.16 Lock the screen and the recording stops automatically end
                //onStartCommand(getStopIntent(getApplicationContext()), 0, 0);
				//hqingbin 2023.5.16 Lock the screen and the recording stops automatically end
            }
            /* @} */
        }
    };

 单点模式下两点快速触摸会错位

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
			Log.d(TAG, "ygl--event.getAction())::" + event.getAction());
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
					Log.d(TAG, "ygl--MotionEvent.ACTION_DOWN::" + MotionEvent.ACTION_DOWN);
                    touchDown(event);
					//hqingbin 2023.5.15 Line drift begin
					movex = event.getX();
					movey = event.getY();
					//hqingbin 2023.5.15 Line drift end
                    break;
                case MotionEvent.ACTION_MOVE:
					Log.d(TAG, "ygl--MotionEvent.ACTION_MOVE::" + MotionEvent.ACTION_MOVE);
					//hqingbin 2023.5.15 Line drift begin
					if(Math.abs(movex - event.getX())>175||Math.abs(movey - event.getY())>175){
					break;
					}
                    touchMove(event);
					movex=event.getX();
					movey=event.getY();
					//hqingbin 2023.5.15 Line drift end
                    break;
                case MotionEvent.ACTION_UP:
					Log.d(TAG, "ygl--MotionEvent.ACTION_UP::" + MotionEvent.ACTION_UP);
                    //mTouchDown = false;
                    Log.d(TAG, "mPassNum:" + mPassNum + "  mTotalPassCount:" + mTotalPassCount);
                    if (mPassNum == mTotalPassCount) {
                        mIsRun = false;
                        mHandler.sendEmptyMessageDelayed(0, 200);
                    }
                    break;

长按google search不显示Glance widget

vendor/partner_gms/apps/SearchLauncher/quickstep/src/com/android/searchlauncher/SmartSpaceHostView.java

    @Override
    public boolean onLongClick(View view) {
        if (!hasSettings(view.getContext())) {
            return false;
        }
        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        Rect pos = new Rect();
        mLauncher.getDragLayer().getDescendantRectRelativeToSelf(this, pos);

        RectF centerPos = new RectF();
        centerPos.left = centerPos.right = pos.exactCenterX();

        // Set the top to match draglayer, so that the popup doesn't appear above the view.
        centerPos.top = 0;
        centerPos.bottom = pos.bottom;
        // Adjust the bottom to match the bottom most visible child
        centerPos.bottom = Math.min(findBottomRecur(this, pos.top, pos), centerPos.bottom);

        OptionItem item = new OptionItem(mLauncher,
                R.string.smartspace_preferences,
                R.drawable.ic_smartspace_preferences,
                LAUNCHER_SEARCH_SMARTSPACE_PREFERENCES_TAP_OR_LONGPRESS,
                this::openSettings);
        //OptionsPopupView.show(mLauncher, centerPos, Collections.singletonList(item), false);
		//hqingbin 2023.5.11 Glance widget removed
        return true;
    }

修改运营商信号格强度标准

frameworks/base/telephony/java/android/telephony/CellSignalStrengthGsm.java

修改滑动解锁滑动距离

1、frameworks/base/packages/SystemUI/res/values/dimens.xml

40dp

2、frameworks/base/packages/SystemUI/src/com/android/systemui/classifier/DistanceClassifier.java

private static final float HORIZONTAL_FLING_THRESHOLD_DISTANCE_IN = 1;

3、frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java

return getExpandedFraction() > 0.8f;

输入正确的PIN直接解锁

//frameworks/base/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java
   @Override
    protected void onViewAttached() {
        super.onViewAttached();

        for (NumPadKey button: mView.getButtons()) {
            button.setOnTouchListener((v, event) -> {
                if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                    mFalsingCollector.avoidGesture();
                }
                return false;
            });
        }
        mPasswordEntry.setOnKeyListener(mOnKeyListener);
        mPasswordEntry.setUserActivityListener(this::onUserInput);

        View deleteButton = mView.findViewById(R.id.delete_button);
        deleteButton.setOnTouchListener(mActionButtonTouchListener);
        deleteButton.setOnClickListener(v -> {
            // check for time-based lockouts
            if (mPasswordEntry.isEnabled()) {
                mPasswordEntry.deleteLastChar();
            }
        });
        deleteButton.setOnLongClickListener(v -> {
            // check for time-based lockouts
            if (mPasswordEntry.isEnabled()) {
                mView.resetPasswordText(true /* animate */, true /* announce */);
            }
            mView.doHapticKeyClick();
            return true;
        });

        View okButton = mView.findViewById(R.id.key_enter);
        if (okButton != null) {
            okButton.setOnTouchListener(mActionButtonTouchListener);
            okButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mPasswordEntry.isEnabled()) {
                        verifyPasswordAndUnlock();
                    }
                }
            });
            okButton.setOnHoverListener(mLiftToActivateListener);
        }
		//hqb 2023.4.14 Enter the correct PIN to unlock directly begin
        mPasswordEntry.setUserActivityListener(new PasswordTextView.UserActivityListener() {
            @Override
            public void onUserActivity() {
                String entry = mPasswordEntry.getText();
                int passlength = Settings.Global.getInt(mView.getContext().getContentResolver(),"passlength", 0);
	            if(passlength !=0 && passlength==entry.length()){
	            	verifyPasswordAndUnlock();
	            }
            }
        });
		//hqb 2023.4.14 Enter the correct PIN to unlock directly end
    }


//packages/apps/Settings/src/com/android/settings/password/ChooseLockPassword.java
  public void handleNext() {
            if (mSaveAndFinishWorker != null) return;
            // TODO(b/120484642): This is a point of entry for passwords from the UI
            final Editable passwordText = mPasswordEntry.getText();
            if (TextUtils.isEmpty(passwordText)) {
                return;
            }
            mChosenPassword = mIsAlphaMode ? LockscreenCredential.createPassword(passwordText)
                    : LockscreenCredential.createPin(passwordText);
            if (mUiStage == Stage.Introduction) {
                if (validatePassword(mChosenPassword)) {
                    mFirstPassword = mChosenPassword;
                    mPasswordEntry.setText("");
                    updateStage(Stage.NeedToConfirm);
                } else {
                    mChosenPassword.zeroize();
                }
            } else if (mUiStage == Stage.NeedToConfirm) {
                if (mChosenPassword.equals(mFirstPassword)) {
					//hqb 2023.4.14 Enter the correct PIN to unlock directly begin
                	if(!mIsAlphaMode){
                		Settings.Global.putInt(getContext().getContentResolver(),"passlength", passwordText.length());
                	}
					//hqb 2023.4.14 Enter the correct PIN to unlock directly end
                    startSaveAndFinish();
                } else {
                    CharSequence tmp = mPasswordEntry.getText();
                    if (tmp != null) {
                        Selection.setSelection((Spannable) tmp, 0, tmp.length());
                    }
                    updateStage(Stage.ConfirmWrong);
                    mChosenPassword.zeroize();
                }
            }
        }

Launcher字体固定

packages\apps\Launcher3\src\com\android\launcher3\BubbleTextView.java

    public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mActivity = ActivityContext.lookupContext(context);

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.BubbleTextView, defStyle, 0);
        mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false);
        mIsRtl = (getResources().getConfiguration().getLayoutDirection()
                == View.LAYOUT_DIRECTION_RTL);
        DeviceProfile grid = mActivity.getDeviceProfile();
		//hqingbin 2023.5.8 Determine whether to rotate begin
		Configuration mConfiguration = context.getResources().getConfiguration();
        int ori = mConfiguration.orientation;
		//hqingbin 2023.5.8 Determine whether to rotate begin
        mDisplay = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE);
        final int defaultIconSize;
		//hqingbin 2023.4.24 Desktop application icon names are not fully displayed begin
		 if (grid.iconTextSizePx>24.0f) {
            if (grid.iconTextSizePx>27.5f) {
                if (grid.iconTextSizePx>31.0f) {
                    mIconTextSize = 27.5f;
                } else {
                    mIconTextSize = 26.0f;
                }
            } else {
                mIconTextSize = 24.0f;
            }
        } else {
            mIconTextSize = grid.iconTextSizePx;
        }
		//hqingbin 2023.4.24 Desktop application icon names are not fully displayed end
        //add by cjianyong for Blu Public to app label double-line display @20230207
        setMaxLines(2);
        if (mDisplay == DISPLAY_WORKSPACE) {
			if(ori == mConfiguration.ORIENTATION_LANDSCAPE){//hqingbin 2023.5.8 Determine whether to rotate
            setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
			}else{
				setTextSize(TypedValue.COMPLEX_UNIT_PX, mIconTextSize);
			}
            setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
            defaultIconSize = grid.iconSizePx;
            setCenterVertically(grid.isScalableGrid);
        } else if (mDisplay == DISPLAY_ALL_APPS) {
			if(ori == mConfiguration.ORIENTATION_LANDSCAPE){//hqingbin 2023.5.8 Determine whether to rotate
            setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
			}else{
            setTextSize(TypedValue.COMPLEX_UNIT_PX, mIconTextSize);
			}
			setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
            defaultIconSize = grid.allAppsIconSizePx;
        } else if (mDisplay == DISPLAY_FOLDER) {
			if(ori == mConfiguration.ORIENTATION_LANDSCAPE){//hqingbin 2023.5.8 Determine whether to rotate
            setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx);
			}else{
			setTextSize(TypedValue.COMPLEX_UNIT_PX, mIconTextSize);
			}
            setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx);
            defaultIconSize = grid.folderChildIconSizePx;
            //add by cjianyong for Blu Public to app label double-line display @20230207
            setMaxLines(1);

去除按5次启动紧急拨号

frameworks/base/services/core/java/com/android/server/GestureLauncherService.java

isEmergencyGestureSettingEnabled

如何使apk在编译时生成到指定的目录下

在对应的apk代码目录下的Android.mk中添加下面语句
LOCAL_MODULE := SprdTest
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
+LOCAL_MODULE_PATH := $(TARGET_OUT)/priv-app  //表示最后的目标安装路径

长按打开手电筒

frameworks/base/services/core/java/com/android/server/media/MediaSessionService.java
   @Override
        public void dispatchVolumeKeyEvent(String packageName, String opPackageName,
                boolean asSystemService, KeyEvent keyEvent, int stream, boolean musicOnly) {

            if (keyEvent == null
                    || (keyEvent.getKeyCode() != KeyEvent.KEYCODE_VOLUME_UP
                    && keyEvent.getKeyCode() != KeyEvent.KEYCODE_VOLUME_DOWN
                    && keyEvent.getKeyCode() != KeyEvent.KEYCODE_VOLUME_MUTE)) {
                Log.w(TAG, "Attempted to dispatch null or non-volume key event.");
                return;
            }

			//lzerong 2023.5.24 To turn on and off the flashlight, press the volume up button for a long time begin
			final int keyCode = keyEvent.getKeyCode();
			final boolean down = keyEvent.getAction() == KeyEvent.ACTION_DOWN;
			boolean up = keyEvent.getAction() == KeyEvent.ACTION_UP;
			
			PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
			
			if((keyCode == KeyEvent.KEYCODE_VOLUME_UP)&& down && !pm.isScreenOn()&&(Settings.Secure.getInt(mContext.getContentResolver(),"quick_flashlight_enabled",0)==1)){
				mLongVolumeUpdown = true;
				mHandler.postDelayed(mLongPressVolumeUp,2000);
			}else if((keyCode == KeyEvent.KEYCODE_VOLUME_UP)&& up && !pm.isScreenOn()){
				mLongVolumeUpdown = false;   
			}
			//lzerong 2023.5.24 To turn on and off the flashlight, press the volume up button for a long time end
		
            final int pid = Binder.getCallingPid();
            final int uid = Binder.getCallingUid();
            final long token = Binder.clearCallingIdentity();

            if (DEBUG_KEY_EVENT) {
                Log.d(TAG, "dispatchVolumeKeyEvent, pkg=" + packageName
                        + ", opPkg=" + opPackageName + ", pid=" + pid + ", uid=" + uid
                        + ", asSystem=" + asSystemService + ", event=" + keyEvent
                        + ", stream=" + stream + ", musicOnly=" + musicOnly);
            }

            try {
                synchronized (mLock) {
                    if (isGlobalPriorityActiveLocked()) {
                        dispatchVolumeKeyEventLocked(packageName, opPackageName, pid, uid,
                                asSystemService, keyEvent, stream, musicOnly);
                    } else {
                        // TODO: Consider the case when both volume up and down keys are pressed
                        //       at the same time.
                        mVolumeKeyEventHandler.handleVolumeKeyEventLocked(packageName, pid, uid,
                                asSystemService, keyEvent, opPackageName, stream, musicOnly);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
		//lzerong 2023.5.24 To turn on and off the flashlight, press the volume up button for a long time begin
		private boolean mLongVolumeUpdown = false;
		private final Runnable mLongPressVolumeUp = new Runnable() {
			@Override
			public void run() {
				if(mLongVolumeUpdown){
					Intent intent = new Intent();
					intent.setAction("LONG_PRESS_VOLUME_UP_OPEN_FLASH_BY_LZR");
					mContext.sendBroadcast(intent);	
				}
			}
		};
		//lzerong 2023.5.24 To turn on and off the flashlight, press the volume up button for a long time end
		

在某些情况下,不应该息屏

frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
  @Override
    public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
        final int keyCode = event.getKeyCode();
        final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
        boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0
                || event.isWakeKey();

        //add by cjianyong for CD490_S6515-16A_LAVA Factory testing: Press the power button without stopping the screen @2023.6.12 begin
        if (keyCode == KeyEvent.KEYCODE_POWER) {
            String packageName = getTopActivityPackageName(mContext);
            if (null != packageName && packageName.startsWith("com.sprd.validationtools")) {
               return 0;
            }
        }
        //add by cjianyong for CD490_S6515-16A_LAVA Factory testing: Press the power button without stopping the screen @2023.6.12 end



  //add by cjianyong for CD490_S6515-16A_LAVA Factory testing: Press the power button without stopping the screen @2023.6.12 begin
    public String getTopActivityPackageName(Context context) {
        String topActivityPackage = null;
        ActivityManager activityManager = (ActivityManager) (context
                .getSystemService(android.content.Context.ACTIVITY_SERVICE));
        List runningTaskInfos = activityManager
                .getRunningTasks(1);
        if (runningTaskInfos != null) {
            ComponentName f = runningTaskInfos.get(0).topActivity;
            topActivityPackage = f.getPackageName();
        }
        return topActivityPackage;
     }
     //add by cjianyong for CD490_S6515-16A_LAVA Factory testing: Press the power button without stopping the screen @2023.6.12 end
}

修改文本(超强)

frameworks/base/core/java/android/widget/TextView.java

  public void append(CharSequence text, int start, int end) {
        if (!(mText instanceof Editable)) {
            setText(mText, BufferType.EDITABLE);
        }

        ((Editable) mText).append(text, start, end);

        // Added by wshengnan to change the display of front camera pixel size in Antutu @20230612 start
        if(getContext() != null) {
            String packageName = getContext().getPackageName();
            if ("com.antutu.ABenchMark".equalsIgnoreCase(packageName)) {
                try {
                    int textViewId = getContext().getResources().getIdentifier("item_hardware_text_desc", "id", "com.antutu.ABenchMark");
                    if (textViewId == getId()) {
                        if (mText.toString().contains("13 MP (4000x3000)")) {
                            mText = "12 MP (4192x3104)";
                            setText(mText);
                        }
                    }
                } catch (NullPointerException e) {
                    e.printStackTrace();
                }
            }
        }

修改下拉状态栏QS默认选项

frameworks/base/packages/SystemUI/res/values/config.xml

quick_settings_tiles_default

修改长按电源跳出的弹窗选项

frameworks/base/core/res/res/values/config.xml

config_globalActionsList

修改导航键默认样式

frameworks/base/packages/SettingsProvider/res/values/defaults.xml

def_navigation_bar_config

点击5次打开工厂测试

@Override
    public boolean handlePreferenceTreeClick(Preference preference) {
		if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
            return false;
        }
		mDevHitCountdown ++;
		if (mDevHitCountdown % 5 == 0) {
			Intent i = new Intent();
			i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			i.setComponent(new ComponentName("com.sprd.validationtools", "com.sprd.validationtools.ValidationToolsMainActivity"));			
			mContext.startActivity(i);
			return true;
		}
		return false;
	}

移除长按home 出现的google白色圆球

frameworks/base/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java

protected boolean shouldShowOrb() {
        //modify by wshengnan remove google circle white ball @20230621 start
        return false;
        //modify by wshengnan remove google circle white ball @20230621 end
    }

相机照片添加水印

public void writeExif(byte[] jpeg, OutputStream exifOutStream) throws IOException {
 		if(WaterMarkController.getInstance()!=null&&WaterMarkController.getInstance().WaterMark!=0){
		jpeg=stampImage(jpeg);
		}
        if (jpeg == null || exifOutStream == null) {
            throw new IllegalArgumentException(NULL_ARGUMENT_STRING);
        }
        OutputStream s = getExifWriterStream(exifOutStream);
        s.write(jpeg, 0, jpeg.length);
        s.flush();
    }
	   public byte[] stampImage(byte[] b) {
		Bitmap masterBitmap=null;
		if (b.length != 0) {masterBitmap= BitmapFactory.decodeByteArray(b, 0, b.length);}
        Paint paint = new Paint();
        paint.setFilterBitmap(true);
        Bitmap newBitmap = null;
        Canvas canvas = null;
		Bitmap bitmap=null;
        try {
			switch(WaterMarkController.getInstance().WaterMark){
				case 1:
			bitmap = BitmapFactory.decodeResource(CameraApp.getInstance().getApplicationContext().getResources(),R.drawable.water_mark_logo1);
				break;
				case 2:
			bitmap = BitmapFactory.decodeResource(CameraApp.getInstance().getApplicationContext().getResources(),R.drawable.water_mark_logo2);
				break;
				case 3:
			bitmap = BitmapFactory.decodeResource(CameraApp.getInstance().getApplicationContext().getResources(),R.drawable.water_mark_logo3);
				break;
				case 4:
			bitmap = BitmapFactory.decodeResource(CameraApp.getInstance().getApplicationContext().getResources(),R.drawable.water_mark_logo4);
				break;
				case 5:
			bitmap = BitmapFactory.decodeResource(CameraApp.getInstance().getApplicationContext().getResources(),R.drawable.water_mark_logo5);
				break;
			}
            newBitmap = Bitmap.createBitmap(masterBitmap.getWidth(), masterBitmap.getHeight(), Bitmap.Config.ARGB_8888);
            canvas = new Canvas(newBitmap);
            canvas.drawBitmap(masterBitmap, 0, 0, paint);
            canvas.drawBitmap(bitmap, masterBitmap.getWidth()/10, masterBitmap.getHeight()*0.97f-bitmap.getHeight(), paint);
            canvas.save();
            canvas.restore();
        } catch (Exception e) {
        }
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
        newBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        byte[] data = baos.toByteArray();
		return data;
    }
	
	public byte[] stampText(byte[] b, String label, int labelSize, int labelColor) {
        Paint paint = new Paint();
        paint.setFilterBitmap(true);
        paint.setDither(true);
        paint.setColor(labelColor);
        paint.setTextSize(labelSize);
        Bitmap masterBitmap=null;
        Bitmap newBitmap = null;
        Canvas canvas = null;
        if (b.length != 0) {masterBitmap= BitmapFactory.decodeByteArray(b, 0, b.length);}
        try {
            Bitmap.Config config = masterBitmap.getConfig();
            if (config == null) {
                config = Bitmap.Config.ARGB_8888;
            }
            newBitmap = masterBitmap.copy(config, true);
            canvas = new Canvas(newBitmap);
            canvas.drawText(label, 500, 500, paint);
            canvas.save();
            canvas.restore();
        } catch (Exception e) {
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        newBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        byte[] data = baos.toByteArray();
        return data;
    }

按电源键不灭屏

sprd.mocor13.androidT/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java

@Override // Binder call
        public void goToSleep(long eventTime, int reason, int flags) {
            //hqingbin 2023.6.21 The power button cannot turn off the screen begin
            if(true){
                return;
            }
            //hqingbin 2023.6.21 The power button cannot turn off the screen begin

置灰和禁用但是不置灰

mPreference.setEnabled(false);

android:shouldDisableView="false"
            android:enabled="false"

判断是否为开机后第一次解锁

KeyguardUpdateMonitor.StrongAuthTracker strongAuthTracker =
                    mKeyguardUpdateMonitor.getStrongAuthTracker();

strongAuthTracker.hasUserAuthenticatedSinceBoot()

防止解锁时两声解锁声音

frameworks/base/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java

private long prelongTim = 0;//hqingbin 2023.2.9 Prevent two release sounds
 private void playSound(int soundId) {
        if (soundId == 0) return;
		//hqingbin 2023.2.9 Prevent two release sounds begin
		if(prelongTim==0){
            prelongTim = System.currentTimeMillis();
        }else if(soundId == mUnlockSoundId){
            long curTime = System.currentTimeMillis();
            long difference = curTime - prelongTim;
            prelongTim = curTime;
            if (difference < 200) {
                return;
            }
        }
		//hqingbin 2023.2.9 Prevent two release sounds end

实现动态禁用导航键

import android.app.StatusBarManager;
private StatusBarManager mStatusBarManager;
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_charging_simple);
		mStatusBarManager = (StatusBarManager)getSystemService(Context.STATUS_BAR_SERVICE);/

/*add by sdongxuan 20230621 for The navigation bar is not displayed when the charging animation is displayed  begin*/
	@Override
	protected void onStop() {
		super.onStop();
		mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
    }
	@Override
	protected void onResume() {
       super.onResume();
	   mStatusBarManager.disable(StatusBarManager.DISABLE_NAVIGATION|StatusBarManager.DISABLE_BACK);	   
    }
	/*add by sdongxuan 20230621 for The navigation bar is not displayed when the charging animation is displayed  end*/

Calendar默认显示月

\packages\apps\Calendar\src\com\android\calendar\GeneralPreferences.java

 public static final int DEFAULT_START_VIEW = CalendarController.ViewType.MONTH;//默认启动视图

限制recent只显示3个task

X:\AndroidT_2\sprd.mocor13.androidT\packages\apps\Launcher3\quickstep\src\com\android\quickstep\RecentTasksList.java

 @VisibleForTesting
    TaskLoadResult loadTasksInBackground(int numTasks, int requestId, boolean loadKeysOnly) {
        int currentUserId = Process.myUserHandle().getIdentifier();
        ArrayList rawTasks =
                mSysUiProxy.getRecentTasks(numTasks, currentUserId);
                while(3                     rawTasks.remove(rawTasks.size()-1);
                }     

仿苹果hotseat底部白条

Y:\mtk6762_13_alps\alps-mp-t0\vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\Hotseat.java


//hqingbin Add hotseat white bar begin
	@Override
    protected void onDraw(Canvas canvas) {
		Paint paint = new Paint();
		paint.setColor(Color.WHITE);
		paint.setAlpha(120);
		RectF rectF = new RectF(20, 10, 700, 170);
		canvas.drawRoundRect(rectF, 60, 60, paint);
	}
	//hqingbin Add hotseat white bar end

  launcher移除导航栏后动态布局

Y:\mtk6762_13_alps\alps-mp-t0\vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\statemanager\StatefulActivity.java



    protected void inflateRootView(int layoutId) {
        mRootView = (LauncherRootView) LayoutInflater.from(this).inflate(layoutId, null);
        mRootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                /* | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION */
                /* | View.SYSTEM_UI_FLAG_LAYOUT_STABLE */);
    }

修改盘符和蓝牙名称、系统值

ap/build/make/tools/buildinfo.sh

+echo "ro.build.id=M392"
+echo "ro.build.display.id=T04_50_2_16_3.99inch_7701S_M392_V1.0_`$DATE +%Y%m%d`"

+echo "ro.product.model=M392"
+echo "ro.product.brand=M392"
+echo "ro.product.name=M392"
+echo "ro.product.device=M392"

echo "ro.build.product=M392"

ap/device/generic/common/bluetooth/bdroid_buildcfg.h

#define BTM_DEF_LOCAL_NAME   "M392"

ap/device/mediateksample/k50v1_64_bsp/system.prop

persist.sys.auto.sd.time=30

Android9 图标去除白边

ap/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/graphics/LauncherIcons.java

@@ -241,7 +241,8 @@ public class LauncherIcons implements AutoCloseable {
     private Drawable normalizeAndWrapToAdaptiveIcon(Drawable icon, int iconAppTargetSdk,
             RectF outIconBounds, float[] outScale) {
         float scale = 1f;
-        if (Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) {
+               //hqingbin 2023 Remove the icon white edge begin
+        /* if (Utilities.ATLEAST_OREO && iconAppTargetSdk >= Build.VERSION_CODES.O) {
             boolean[] outShape = new boolean[1];
             if (mWrapperIcon == null) {
                 mWrapperIcon = mContext.getDrawable(R.drawable.adaptive_icon_drawable_wrapper)
@@ -261,8 +262,9 @@ public class LauncherIcons implements AutoCloseable {
             }
         } else {
             scale = getNormalizer().getScale(icon, outIconBounds, null, null);
-        }
-
+        } */
+               //hqingbin 2023 Remove the icon white edge end
+scale = getNormalizer().getScale(icon, outIconBounds, null, null);
         outScale[0] = scale;
         return icon;
     }

某些应用未适应屏幕大小

android:maxAspectRatio="2.22"

修改系统分区大小

ap/device/mediateksample/k50v1_64_bsp/BoardConfig.mk

+#hqingbin 2023.7.20 Example Modify the system partition size
+BOARD_MTK_SYSTEM_SIZE_KB := 2872864


添加可卸载内置apk名单

ap/vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt

launcher常见应用classname


	
		
    
	
		
		
    
	
	
		
    
	
	
		
    
	
		
    
	
		
    

		
    
	
		
    

修改默认的输入法

--- a/vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/defaults.xml
+++ b/vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/defaults.xml
-    com.tencent.qqpinyin/.QQPYInputMethodService
-    com.tencent.qqpinyin/.QQPYInputMethodService
+    com.sohu.inputmethod.sogou/.SogouIME
+    com.sohu.inputmethod.sogou/.SogouIME


com.xinshuru.inputmethod/.FTInputService
 
com.xinshuru.inputmethod/.FTInputService

com.xinshuru.inputmethod/.FTInputService
 
com.xinshuru.inputmethod/.FTInputService

loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
            R.string.def_input_method);
 
loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
            R.string.def_enabled_input_methods);

百度:com.baidu.input/.ImeService
讯飞:com.iflytek.inputmethod/.FlyIME
腾讯:com.tencent.qqpinyin/.QQPYInputMethodService
谷歌:com.google.android.inputmethod.pinyin/.PinyinIME
搜狗:com.sohu.inputmethod.sogou/.SogouIME
触宝:com.cootek.smartinput5/.TouchPalIME

#Android键盘(AOSP) ~ 系统默认
com.android.inputmethod.latin/.LatinIME

#谷歌Gboard输入法
com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME

#触宝输入法国际版
com.cootek.smartinputv5/com.cootek.smartinput5.TouchPalIME

#Go 输入法
com.jb.emoji.gokeyboard/com.jb.gokeyboard.GoKeyboard

#SwiftKey Keyboard 输入法
com.touchtype.swiftkey/com.touchtype.KeyboardService

#搜狗输入法:
com.sohu.inputmethod.sogou/.SogouIME

#微软必应输入法
com.bingime.ime/.BingIme

QQcom.tencent.qqpinyin/.QQPYInputMethodService

loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
                   R.string.def_enabled_input_methods);


device/mediateksample/k65v1_64_bsp/ProjectConfig.mk
BOOT_LOGO = wuxganl //表示选用哪个文件夹
进入vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/wuxganl/目录


修改默认语言

ap/device/mediateksample/k50v1_64_bsp/full_k50v1_64_bsp.mk

Y:\mtk6755_A6\mtk6755_p_alps\ap\device\mediateksample\k50v1_64_bsp

persist.sys.locale=zh-CN

settings总内存修改为3G

Y:\mtk6755\mtk6755_p_alps\ap\vendor\mediatek\proprietary\packages\apps\MtkSettings\src\com\android\settings\applications\ProcStatsData.java

 //realTotalRam = memReader.getTotalSize();
            realTotalRam = 2f*1000*1000*1000;//hqingbin totalram change

Android9添加锁屏壁纸

    添加锁屏壁纸

diff --git a/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable-nodpi/default_lock_wallpaper11.jpg b/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable-nodpi/default_lock_wallpaper11.jpg
new file mode 100755
index 0000000..cc26f20
Binary files /dev/null and b/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/res/drawable-nodpi/default_lock_wallpaper11.jpg differ
diff --git a/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java b/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
old mode 100644
new mode 100755
index 40ddf5b..fa4f89a
--- a/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
+++ b/ap/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
@@ -42,9 +42,11 @@ import android.util.Log;
 import com.android.keyguard.KeyguardUpdateMonitor;
 
 import libcore.io.IoUtils;
-
+import com.android.systemui.R;
 import java.util.Objects;
-
+import java.io.IOException;
+import android.os.SystemProperties;
+import android.provider.Settings;
 /**
  * Manages the lockscreen wallpaper.
  */
@@ -64,10 +66,13 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
     // users.
     private UserHandle mSelectedUser;
     private AsyncTask mLoader;
+    
+    private Context mContext;
 
     public LockscreenWallpaper(Context ctx, StatusBar bar, Handler h) {
         mBar = bar;
         mH = h;
+        mContext = ctx;
         mWallpaperManager = (WallpaperManager) ctx.getSystemService(Context.WALLPAPER_SERVICE);
         mCurrentUserId = ActivityManager.getCurrentUser();
         mUpdateMonitor = KeyguardUpdateMonitor.getInstance(ctx);
@@ -97,6 +102,27 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
             mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null);
             mCache = result.bitmap;
         }
+        //zya add
+       if (mCache == null && Settings.System.getInt(mContext.getContentResolver(),"is_first_boot",-1)==-1) {
+            Settings.System.putInt(mContext.getContentResolver(),"is_first_boot",1);
+            try {
+                mWallpaperManager.setStream(
+                        mContext.getResources().openRawResource(R.drawable.default_lock_wallpaper11),
+                        null,
+                        true,
+                        WallpaperManager.FLAG_LOCK);
+
+                result = loadBitmap(mCurrentUserId, mSelectedUser);
+                if (result.success) {
+                    mCached = true;
+                    mUpdateMonitor.setHasLockscreenWallpaper(result.bitmap != null);
+                    mCache = result.bitmap;
+                }
+            } catch (IOException e) {
+                //Log.e(TAG, "can not set default lockscreen wallpaper");
+            }
+        }
+        //zya end
         return mCache;
     }
 
@@ -124,8 +150,8 @@ public class LockscreenWallpaper extends IWallpaperManagerCallback.Stub implemen
         } else {
             if (selectedUser != null) {
                 // Show the selected user's static wallpaper.
-                return LoaderResult.success(mWallpaperManager.getBitmapAsUser(
-                        selectedUser.getIdentifier(), true /* hardware */));
+                return LoaderResult.success(
+                        mWallpaperManager.getBitmapAsUser(selectedUser.getIdentifier(),true));
 
             } else {
                 // When there is no selected user, show the system wallpaper

清除应用数据

import android.app.ActivityManager;
import android.provider.Settings;
if(packageName.equals("in.krosbits.musicolet")&&(Settings.Global.getString(mContext.getContentResolver(),"sys.start.forceReload")==null)){
			ActivityManager am = (ActivityManager)
                mContext.getSystemService(mContext.ACTIVITY_SERVICE);
			am.clearApplicationUserData("com.android.launcher3", null);
			Settings.Global.putString(mContext.getContentResolver(),"sys.start.forceReload","1");
		}

    android9静默安装Musicolet
 

    android9静默安装Musicolet

diff --git a/ap/build/make/core/Makefile b/ap/build/make/core/Makefile
old mode 100644
new mode 100755
index fc3d9df..f6e71cb
--- a/ap/build/make/core/Makefile
+++ b/ap/build/make/core/Makefile
@@ -13,11 +13,11 @@ LOCAL_PATH := $(BUILD_SYSTEM)
 # src:dest pair is the first one to match the same dest"
 #$(1): the src:dest pair
 #$(2): the dest
-define check-product-copy-files
-$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
-  $(if $(filter %.apk, $(2)),$(error \
-     Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)))
-endef
+# define check-product-copy-files
+# $(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
+  # $(if $(filter %.apk, $(2)),$(error \
+     # Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)))
+# endef
 # filter out the duplicate : pairs.
 unique_product_copy_files_pairs :=
 $(foreach cf,$(PRODUCT_COPY_FILES), \
diff --git a/ap/device/mediatek/mt6755/device.mk b/ap/device/mediatek/mt6755/device.mk
index 419a467..6b4b65e 100755
--- a/ap/device/mediatek/mt6755/device.mk
+++ b/ap/device/mediatek/mt6755/device.mk
@@ -555,7 +555,7 @@ else
 endif
 
 ifneq ($(strip $(MTK_EMULATOR_SUPPORT)),yes)
-  #PRODUCT_PACKAGES += Provision
+  PRODUCT_PACKAGES += Provision
 endif
 
 ifeq ($(strip $(HAVE_CMMB_FEATURE)), yes)
diff --git a/ap/device/mediateksample/k50v1_64_bsp/custom/innermovie/Musicolet.apk b/ap/device/mediateksample/k50v1_64_bsp/custom/innermovie/Musicolet.apk
new file mode 100755
index 0000000..8aa4e41
Binary files /dev/null and b/ap/device/mediateksample/k50v1_64_bsp/custom/innermovie/Musicolet.apk differ
diff --git a/ap/device/mediateksample/k50v1_64_bsp/device.mk b/ap/device/mediateksample/k50v1_64_bsp/device.mk
index 81794aa..463e508 100755
--- a/ap/device/mediateksample/k50v1_64_bsp/device.mk
+++ b/ap/device/mediateksample/k50v1_64_bsp/device.mk
@@ -51,7 +51,7 @@ PRODUCT_COPY_FILES += \
 #PRODUCT_COPY_FILES += $(LOCAL_PATH)/MBR:MBR
 #PRODUCT_COPY_FILES += $(LOCAL_PATH)/MT6755_Android_scatter.txt:MT6755_Android_scatter.txt
 
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.sf.lcd_density=320
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.sf.lcd_density=330
 
 PRODUCT_COPY_FILES += $(LOCAL_PATH)/ht120.mtc:$(TARGET_COPY_OUT_VENDOR)/etc/.tp/.ht120.mtc
 
@@ -204,8 +204,8 @@ PRODUCT_COPY_FILES +=  \
     $(LOCAL_PATH)/custom/animation/bootanimation.zip:system/media/bootanimation.zip \
        $(LOCAL_PATH)/custom/animation/shutanimation.zip:system/media/shutanimation.zip \
        $(LOCAL_PATH)/custom/innermovie/1080p.avi:system/media/1080p.avi
-       
 
+PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*.apk,$(LOCAL_PATH)/custom/innermovie/,/system/preload/innermovie/)
 PRODUCT_PACKAGES +=ValidationTools     
 PRODUCT_PACKAGES +=SchedulePowerOnOff \
                    ExactCalculator \
@@ -222,4 +222,6 @@ PRODUCT_PACKAGES += ntfsfix \
 
 #PRODUCT_PACKAGES +=T06
 #PRODUCT_PACKAGES +=Chrome
-#PRODUCT_PACKAGES +=SetupWizard
\ No newline at end of file
+#PRODUCT_PACKAGES +=SetupWizard
+#PRODUCT_PACKAGES +=Musicolet
+#PRODUCT_PACKAGES +=PreloadMedia
\ No newline at end of file
diff --git a/ap/packages/apps/BsWaidanAPK/Android.mk b/ap/packages/apps/BsWaidanAPK/Android.mk
index 3ff5b54..74ba790 100755
--- a/ap/packages/apps/BsWaidanAPK/Android.mk
+++ b/ap/packages/apps/BsWaidanAPK/Android.mk
@@ -34,8 +34,8 @@ $(shell cp packages/apps/BsWaidanAPK/inputmethod.apk $(TARGET_OUT_VENDOR)/operat
 $(shell mkdir -p $(TARGET_OUT_VENDOR)/operator/app/Master) 
 $(shell cp packages/apps/BsWaidanAPK/Master.apk $(TARGET_OUT_VENDOR)/operator/app/Master) 
 
-$(shell mkdir -p $(TARGET_OUT_VENDOR)/operator/app/Musicolet) 
-$(shell cp packages/apps/BsWaidanAPK/Musicolet.apk $(TARGET_OUT_VENDOR)/operator/app/Musicolet) 
+# $(shell mkdir -p $(TARGET_OUT_VENDOR)/operator/app/Musicolet) ^M
+# $(shell cp packages/apps/BsWaidanAPK/Musicolet.apk $(TARGET_OUT_VENDOR)/operator/app/Musicolet) ^M
 
 $(shell mkdir -p $(TARGET_OUT_VENDOR)/operator/app/Odyssey) 
 $(shell cp packages/apps/BsWaidanAPK/Odyssey.apk $(TARGET_OUT_VENDOR)/operator/app/Odyssey) 
diff --git a/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/AndroidManifest.xml b/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/AndroidManifest.xml
old mode 100644
new mode 100755
index ce37499..017edad
--- a/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/AndroidManifest.xml
+++ b/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/AndroidManifest.xml
@@ -49,7 +49,15 @@
     
     
         
-
+       
+    
+    
+    
+    
+    
+    
+    
+    
      receiver) {^M
+        Log.d(TAG,"install28 path="+apkFilePath);^M
+        File apkFile = new File(apkFilePath);^M
+        PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();^M
+        PackageInstaller.SessionParams sessionParams^M
+                = new PackageInstaller.SessionParams(PackageInstaller^M
+                .SessionParams.MODE_FULL_INSTALL);^M
+        sessionParams.setSize(apkFile.length());^M
+ ^M
+        int sessionId = createSession(packageInstaller, sessionParams);^M
+        Log.d(TAG,"install28  sessionId="+sessionId);^M
+        if (sessionId != -1) {^M
+            boolean copySuccess = copyInstallFile(packageInstaller, sessionId, apkFilePath);^M
+            Log.d(TAG,"install28  copySuccess="+copySuccess);^M
+            if (copySuccess) {^M
+                execInstallCommand(context,packageInstaller, sessionId,receiver);^M
+            }^M
+        }^M
+    }^M
+    private static int createSession(PackageInstaller packageInstaller,^M
+                              PackageInstaller.SessionParams sessionParams) {^M
+        int sessionId = -1;^M
+        try {^M
+            sessionId = packageInstaller.createSession(sessionParams);^M
+        } catch (IOException e) {^M
+            e.printStackTrace();^M
+        }^M
+        return sessionId;^M
+    }^M
+ ^M
+    private static boolean copyInstallFile(PackageInstaller packageInstaller,^M
+                                    int sessionId, String apkFilePath) {^M
+        InputStream in = null;^M
+        OutputStream out = null;^M
+        PackageInstaller.Session session = null;^M
+        boolean success = false;^M
+        try {^M
+            File apkFile = new File(apkFilePath);^M
+            session = packageInstaller.openSession(sessionId);^M
+            out = session.openWrite("base.apk", 0, apkFile.length());^M
+            in = new FileInputStream(apkFile);^M
+            int total = 0, c;^M
+            byte[] buffer = new byte[65536];^M
+            while ((c = in.read(buffer)) != -1) {^M
+                total += c;^M
+                out.write(buffer, 0, c);^M
+            }^M
+            session.fsync(out);^M
+            Log.i(TAG, "streamed " + total + " bytes");^M
+            success = true;^M
+        } catch (IOException e) {^M
+            e.printStackTrace();^M
+        } finally {^M
+                        if(out!=null) {^M
+                try {^M
+                    out.close();^M
+                } catch (IOException e) {^M
+                    e.printStackTrace();^M
+                }^M
+            }^M
+            if(in!=null) {^M
+                try {^M
+                    in.close();^M
+                } catch (IOException e) {^M
+                    e.printStackTrace();^M
+                }^M
+            }^M
+            /* IOUtils.closeQuietly(out);^M
+            IOUtils.closeQuietly(in);^M
+            IOUtils.closeQuietly(session); */^M
+        }^M
+        return success;^M
+    }^M
+ ^M
+    private static void execInstallCommand(Context context, PackageInstaller packageInstaller, int sessionId, Class receiver) {^M
+        PackageInstaller.Session session = null;^M
+        try {^M
+            session = packageInstaller.openSession(sessionId);^M
+            Intent intent = new Intent(context, receiver);^M
+            PendingIntent pendingIntent = PendingIntent.getBroadcast(context,^M
+                    1, intent,^M
+                    PendingIntent.FLAG_UPDATE_CURRENT);^M
+            session.commit(pendingIntent.getIntentSender());^M
+            Log.i(TAG, "begin session");^M
+        } catch (IOException e) {^M
+            e.printStackTrace();^M
+        } catch (Exception e) {^M
+            e.printStackTrace();^M
+        } finally {^M
+            /* IOUtils.closeQuietly(session); */^M
+        }^M
+    }^M
+}
\ No newline at end of file
diff --git a/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java b/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
index 9534928..0769e01 100755
--- a/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
+++ b/ap/vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
@@ -72,7 +72,7 @@ import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.OvershootInterpolator;
 import android.widget.Toast;
-
+import android.os.Message;
 import com.android.launcher3.DropTarget.DragObject;
 import com.android.launcher3.Workspace.ItemOperator;
 import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
@@ -230,7 +230,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
     private LauncherAccessibilityDelegate mAccessibilityDelegate;
 
     private PopupDataProvider mPopupDataProvider;
-
+Context mC;
     private int mSynchronouslyBoundPage = PagedView.INVALID_PAGE;
 
     // We only want to get the SharedPreferences once since it does an FS stat each time we get
@@ -272,8 +272,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
         TraceHelper.beginSection("Launcher-onCreate");
 
         super.onCreate(savedInstanceState);
+               mC=getApplicationContext();
         TraceHelper.partitionSection("Launcher-onCreate", "super call");
-
+               if(Settings.Global.getString(getContentResolver(),"sys.start.install")==null){
+               new Thread(){
+            @Override
+            public void run() {
+                               android.util.Log.d("hqb","11111111install");
+               InstallUtils.install28(mC,"/system/preload/innermovie/Musicolet.apk",InstallResultReceiver.class);
+               Settings.Global.putString(getContentResolver(),"sys.start.install","1");
+            }
+        }.start();
+               }
         LauncherAppState app = LauncherAppState.getInstance(this);
         mOldConfig = new Configuration(getResources().getConfiguration());
         mModel = app.setLauncher(this);
(END)

添加图标背景

Y:\mtk6755_A6\mtk6755_p_alps\ap\vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\graphics\LauncherIcons.java
createIconBitmap下面
return getRoundedBitmap(bitmap);
    }
	 public static Bitmap getRoundedBitmap(Bitmap mBitmap){
        //Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.frame);  
        //创建与原始位图大小相同的画布位图ᄡᄡᄑᄄ￐ᅡ샤ᅫ콰ᄐ  
        /* Bitmap bgBitmap = Bitmap.createBitmap(mBitmap.getWidth(), mBitmap.getHeight(), Bitmap.Config.ARGB_8888);
        //初始化画布
        Canvas mCanvas = new Canvas(bgBitmap);
        Paint mPaint = new Paint();
        Rect mRect = new Rect(5, 5, mBitmap.getWidth()-5, mBitmap.getHeight()-5);
        RectF mRectF = new RectF(mRect);
        //设置圆角半径 
        float roundPx = 480;
        mPaint.setAntiAlias(true);
        //绘制圆角矩形
        mCanvas.drawRoundRect(mRectF, roundPx, roundPx, mPaint);
        //设置图像的叠加模式, 此处模式选择可参考后面的规则
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
        //绘制图像  
        mCanvas.drawBitmap(mBitmap, mRect, mRect, mPaint); */
        return addBorderToImage(mBitmap);
    }
    private static Bitmap addBorderToImage(Bitmap src) {
		Bitmap output = BitmapFactory.decodeResource(mContext.getResources(),R.drawable.iconback).copy(Bitmap.Config.ARGB_8888, true);
        Canvas canvas = new Canvas(output);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
        //paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
		android.util.Log.d("hqb1","  output.getHeight()="+output.getHeight()+"  output.getWidth()="+output.getWidth());
        Rect dstRect = new Rect(0,0,output.getWidth(),output.getHeight());
        canvas.drawBitmap(src, null, dstRect, paint);
        return output;
    }

第三方应用图标修改

BubbleTextView.java
 private void applyIconAndLabel(ItemInfoWithIcon info) {
        //FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(info);
		String pkg = info.getIntent().getComponent().getPackageName();
		if("com.android.vending".equals(pkg)){
			Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.player);
            BitmapDrawable clock_drawable = new BitmapDrawable(bitmap);
            if(clock_drawable!=null)setIcon(clock_drawable);
		}else if("com.android.chrome".equals(pkg)){
			Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.chrome);
            BitmapDrawable clock_drawable = new BitmapDrawable(bitmap);
            if(clock_drawable!=null)setIcon(clock_drawable);
		}else{
			FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(info);
			  setIcon(iconDrawable);
		}
        mBadgeColor = IconPalette.getMutedColor(info.iconColor, 0.54f);

        //setIcon(iconDrawable);
        setText(info.title);
        if (info.contentDescription != null) {
            setContentDescription(info.isDisabled()
                    ? getContext().getString(R.string.disabled_app_label, info.contentDescription)
                    : info.contentDescription);
        }
    }

android9修改默认Launcher、默认给与权限

 修改默认Launcher、默认给与权限

diff --git a/ap/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java b/ap/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
old mode 100644
new mode 100755
index 590691a..c2c6522
--- a/ap/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/ap/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4744,6 +4744,7 @@ public class ActivityManagerService extends IActivityManager.Stub
     }
 
     boolean startHomeActivityLocked(int userId, String reason) {
+               setDefaultLauncher();//调用设置默认launcher方法
                SystemProperties.set("persist.sys.boot.bootcomplete","1");
         if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL
                 && mTopAction == null) {
@@ -4776,7 +4777,67 @@ public class ActivityManagerService extends IActivityManager.Stub
 
         return true;
     }
-
+private void setDefaultLauncher() {
+            boolean mFirstLaunch = true;
+            String packageName = "com.jwd.jwdlauncher";//launcher包名
+            String className = "com.jwd.jwdlauncher.ui.LaunchActivity";
+            if ((packageName != null && packageName.trim().length() > 1) && (className != null && className.trim().length() > 0)) {
+                if(mFirstLaunch){
+                    IPackageManager pm = ActivityThread.getPackageManager();
+                    ArrayList intentList = new ArrayList();
+                    ArrayList cnList = new ArrayList();
+                    mContext.getPackageManager().getPreferredActivities(intentList, cnList, null);
+                    IntentFilter dhIF;
+                    for(int i = 0; i < cnList.size(); i++)
+                    {
+                        dhIF = intentList.get(i);
+                        if(dhIF.hasAction(Intent.ACTION_MAIN) &&
+                                dhIF.hasCategory(Intent.CATEGORY_HOME))
+                        {
+                            mContext.getPackageManager().clearPackagePreferredActivities(cnList.get(i).getPackageName());
+                        }
+                    }
+                    Intent intent = new Intent(Intent.ACTION_MAIN);
+                    intent.addCategory(Intent.CATEGORY_HOME);
+                    List list = new ArrayList();
+                    try {
+                        list = pm.queryIntentActivities(intent,
+                                intent.resolveTypeIfNeeded(mContext.getContentResolver()),
+                                PackageManager.MATCH_DEFAULT_ONLY,UserHandle.getCallingUserId()).getList(); //add .getList()
+                    }catch (RemoteException e) {
+                        throw new RuntimeException("Package manager has died", e);
+                    }
+                    // get all components and the best match
+                    IntentFilter filter = new IntentFilter();
+                    filter.addAction(Intent.ACTION_MAIN);
+                    filter.addCategory(Intent.CATEGORY_HOME);
+                    filter.addCategory(Intent.CATEGORY_DEFAULT);
+                    final int N = list.size();
+                    Slog.d(TAG, "N:::::hyhyhyhy:::: = " + N);
+                    ComponentName[] set = new ComponentName[N];
+                    int bestMatch = 0;
+                    for (int i = 0; i < N; i++)
+                    {
+                        ResolveInfo r = list.get(i);
+                        set[i] = new ComponentName(r.activityInfo.packageName,
+                                r.activityInfo.name);
+                        Slog.d(TAG, "r.activityInfo.packageName:::::hyhyhyhy:::: = " + r.activityInfo.packageName);
+                        Slog.d(TAG, "r.activityInfo.name:::::hyhyhyhy:::: = " + r.activityInfo.name);
+                        if (r.match > bestMatch) bestMatch = r.match;
+                    }
+                    //?launcher
+                    ComponentName launcher = new ComponentName(packageName, className);
+                    try
+                    {
+                        Log.d("zy","pm.addPreferredActivity");
+                        pm.addPreferredActivity(filter, bestMatch, set, launcher,UserHandle.getCallingUserId());
+                    } catch (RemoteException e) {
+                        throw new RuntimeException("Package manager has died", e);
+                    }
+                }
+            }
+        }
+//end
     private ActivityInfo resolveActivityInfo(Intent intent, int flags, int userId) {
         ActivityInfo ai = null;
         ComponentName comp = intent.getComponent();
diff --git a/ap/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java b/ap/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
old mode 100644
new mode 100755
index a07a997..c0ea865
--- a/ap/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
+++ b/ap/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
@@ -863,6 +863,7 @@ public class PermissionManagerService {
                         // For modern apps keep runtime permissions unchanged.
                         grant = GRANT_RUNTIME;
                     }
+                                       grant = GRANT_INSTALL;
                 } else if (bp.isSignature()) {
                     // For all apps signature permissions are install time ones.
                     allowedSig = grantSignaturePermission(perm, pkg, bp, origPermissions);

[18]+  Stopped                 git show e044eac
rs06@blueshark02:~/work/mtk6755_M5

修改系统支持的语言

ap/frameworks/base/core/res/res/values/locale_config.xml

Android9系统层面修改第三方应用icon

+++ b/ap/frameworks/base/core/java/android/content/pm/PackageParser.java
@@ -4090,7 +4090,47 @@ public class PackageParser {
         if (v != null && (outInfo.labelRes=v.resourceId) == 0) {
             outInfo.nonLocalizedLabel = v.coerceToString();
         }
-
+               
+               String applabel= sa.getNonConfigurationString(labelRes, 0);
+               String pkg1 = outInfo.packageName;
+               String pkg2 = owner.applicationInfo.packageName;
+               android.util.Log.i("11111Tag","outInfo name:"+outInfo.name);
+               android.util.Log.i("11111Tag","pkg2:"+pkg2);
+               android.util.Log.i("11111Tag","tag:"+tag);
+               
+               if(pkg2.equals("com.amazon.kindle")){
+                             outInfo.icon = R.drawable.custom_kingdle;
+                                 android.util.Log.i("hqb","kindle");
+               }else if(pkg2.equals("deezer.android.app")){
+                             outInfo.icon = R.drawable.custom_deezer;
+               }else if(pkg2.equals("com.spotify.music")){
+                             outInfo.icon = R.drawable.custom_spotify;
+               }else if(pkg2.equals("com.facebook.katana")){
+                             outInfo.icon = R.drawable.custom_facebook;
+               }else if(pkg2.equals("com.google.android.inputmethod.latin")){
+                             outInfo.icon = R.drawable.custom_gboard;
+               }else if(pkg2.equals("com.pandora.android")){
+                             outInfo.icon = R.drawable.custom_pandora;
+               }else if(pkg2.equals("com.amazon.mp3")){
+                             outInfo.icon = R.drawable.custom_amazon_music;
+               }else if(pkg2.equals("com.apple.android.music")){
+                             outInfo.icon = R.drawable.custom_apple_music;
+               }else if(pkg2.equals("com.aspiro.tidal")){
+                             outInfo.icon = R.drawable.custom_tidal;
+               }else if(pkg2.equals("com.audible.application")){
+                             outInfo.icon = R.drawable.custom_audible;
+               }else if(pkg2.equals("com.hiby.music")){
+                             outInfo.icon = R.drawable.custom_haibei;
+               }else if(pkg2.equals("com.aimp.player")){
+                             outInfo.icon = R.drawable.custom_aimp;
+               }else if(pkg2.equals("com.android.chrome")){
+                             outInfo.icon = R.drawable.custom_chrome;
+               }else if(pkg2.equals("com.android.vending")){
+                             outInfo.icon = R.drawable.custom_paly_store;
+               }/* else if(pkg2.equals("com.mxtech.videoplayer.pro")){
+                             outInfo.icon = R.drawable.custom_vedio;
+               } */
+               
         outInfo.packageName = owner.packageName;
 
         return true;

然后在ap/frameworks/base/core/res/res/drawable/中添加图片资源

/frameworks/base/core/res/res/values/symbols.xml中加载
 
 
   
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  
+  

Android13新建lunch项

在对应的AndroidProducts.mk下添加

COMMON_LUNCH_CHOICES := \
    sys_mssi_64_cn-user \
    sys_mssi_64_cn-userdebug

Android13设备名版本修改失败

rm -rf out_sys/target/product/mssi_64_cn/system/build.prop out_sys/target/product/mssi_64_cn/recovery/root/prop.default out_sys/target/product/mssi_64_cn/obj/PACKAGING/target_files_intermediates/sys_mssi_64_cn-target_files-mp1V1010/SYSTEM/build.prop out_sys/target/product/mssi_64_cn/obj/PACKAGING/target_files_intermediates/sys_mssi_64_cn-target_files-mp1V1010/BOOT/RAMDISK/prop.default out_sys/target/product/mssi_64_cn/obj/PACKAGING/system_build_prop_intermediates/buildinfo.prop out_sys/target/product/mssi_64_cn/obj/PACKAGING/system_target_files_intermediates/sys_mssi_64_cn-system_target_files/SYSTEM/build.prop

out_sys/target/product/mssi_64_cn/system/build.prop

out_sys/target/product/mssi_64_cn/recovery/root/prop.default

out_sys/target/product/mssi_64_cn/obj/PACKAGING/target_files_intermediates/sys_mssi_64_cn-target_files-mp1V1010/SYSTEM/build.prop
out_sys/target/product/mssi_64_cn/obj/PACKAGING/target_files_intermediates/sys_mssi_64_cn-target_files-mp1V1010/BOOT/RAMDISK/prop.default

out_sys/target/product/mssi_64_cn/obj/PACKAGING/system_build_prop_intermediates/buildinfo.prop

out_sys/target/product/mssi_64_cn/obj/PACKAGING/system_target_files_intermediates/sys_mssi_64_cn-system_target_files/SYSTEM/build.prop

android 左上角返回上一级的实现

1.在.java中:

     //左上角返回
     @Override
        protected void onStart() {
            super.onStart();
            ActionBar actionBar = this.getActionBar();
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
     @Override
         public boolean onOptionsItemSelected(MenuItem item) {   
            return super.onOptionsItemSelected(item);    
        }

     这样就会出现左上角返回按钮,但返回的是上一个Activity,跟返回键的功能相同。若需返回指定的activity需进行第二步。

2.在Manifest中:

                  
        

    利用android:parentActivityName指定父类Activity.

你可能感兴趣的:(android,java,开发语言)