基于android8.1源码修改

1.增加新的按键定义
frameworks/native/include/android/keycodes.h
/** all apps /
AKEYCODE_ALL_APPS = 284,
//add new key
AKEYCODE_TORCH = 285,
AKEYCODE_SCAN = 286
device/mediateksample/k63v2_64_bsp/mtk-kpd.kl
key 112 TORCH
key 132 SCAN
***frameworks/native/include/input/InputEventLabels.h
**的数组 static const InputEventLabel KEYCODES[] 中添加
DEFINE_KEYCODE(TORCH),
DEFINE_KEYCODE(SCAN),
frameworks/base/core/res/res/values/attrs.xml

	
	

frameworks/base/core/java/android/view/KeyEvent.java
private static final int LAST_KEYCODE = KEYCODE_ALL_APPS;
//add new key
public static final int KEYCODE_TORCH=285;
public static final int KEYCODE_SCAN=286;
private static final int LAST_KEYCODE = KEYCODE_SCAN;
***frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java***添加相应的按键事件处理(我们是在interceptKeyBeforeQueueing里添加)

Launcher3 源码存在两份,分别位于 package/app/和vendor/mediatek/proprietary/packages/apps/下,vendor下的mk中使用 LOCAL_OVERRIDES_PACKAGES 属性覆盖 package 下的源码,所以我们要改的源码就是 vendor 下的。

2.按power点亮屏幕后直接进入相应解锁界面(双层锁变单层锁)
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
|| mode == SecurityMode.RemoteSmartLock
//add
|| mode == SecurityMode.Pattern
|| mode == SecurityMode.Password
|| mode == SecurityMode.PIN;

3.在PIN码、图案、密码解锁界面添加时间日期的显示
vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/keyguard_bouncer.xml

4.恢复出厂设置后首次开机,主界面下方应用图标会上下浮动
vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
if (shouldShowDiscoveryBounce()) {
//delete
//mAllAppsController.showDiscoveryBounce();
}

5.长按ent键不能调出多任务
frameworks/base/core/res/res/values/config.xml
1

6.开机动画播放完后,屏幕画面卡顿一下
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/ImageWallpaper.java
/*
mLoader = new AsyncTask() {
@Override
protected Bitmap doInBackground(Void… params) {
Throwable exception;
try {
if (needsReset) {
mWallpaperManager.forgetLoadedWallpaper();
}
return mWallpaperManager.getBitmap();
} catch (RuntimeException | OutOfMemoryError e) {
exception = e;
}

                if (isCancelled()) {
                    return null;
                }

                if (exception != null) {
                    // Note that if we do fail at this, and the default wallpaper can't
                    // be loaded, we will go into a cycle.  Don't do a build where the
                    // default wallpaper can't be loaded.
                    Log.w(TAG, "Unable to load wallpaper!", exception);
                    try {
                        mWallpaperManager.clear();
                    } catch (IOException ex) {
                        // now we're really screwed.
                        Log.w(TAG, "Unable reset to default wallpaper!", ex);
                    }

                    if (isCancelled()) {
                        return null;
                    }

                    try {
                        return mWallpaperManager.getBitmap();
                    } catch (RuntimeException | OutOfMemoryError e) {
                        Log.w(TAG, "Unable to load default wallpaper!", e);
                    }
                }
                return null;
            }

            @Override
            protected void onPostExecute(Bitmap b) {
                mBackground = null;
                mBackgroundWidth = -1;
                mBackgroundHeight = -1;

                if (b != null) {
                    mBackground = b;
                    mBackgroundWidth = mBackground.getWidth();
                    mBackgroundHeight = mBackground.getHeight();
                }

                if (DEBUG) {
                    Log.d(TAG, "Wallpaper loaded: " + mBackground);
                }
                updateSurfaceSize(getSurfaceHolder(), getDefaultDisplayInfo(),
                        false);
                if (mNeedsDrawAfterLoadingWallpaper) {
                    drawFrame();
                }

                mLoader = null;
                mNeedsDrawAfterLoadingWallpaper = false;
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
		*/
	Bitmap  b = null;
    Throwable exception = null;
    try {
        if (needsReset) {
            mWallpaperManager.forgetLoadedWallpaper();
        }
        b =  mWallpaperManager.getBitmap();
    } catch (RuntimeException | OutOfMemoryError e) {
        exception = e;
    }
    if (exception != null) {
        // Note that if we do fail at this, and the default wallpaper can't
        // be loaded, we will go into a cycle.  Don't do a build where the
        // default wallpaper can't be loaded.
        Log.w(TAG, "Unable to load wallpaper!", exception);
        try {
            mWallpaperManager.clear();
        } catch (IOException ex) {
            // now we're really screwed.
            Log.w(TAG, "Unable reset to default wallpaper!", ex);
        }
        try {
            b =  mWallpaperManager.getBitmap();
        } catch (RuntimeException | OutOfMemoryError e) {
            Log.w(TAG, "Unable to load default wallpaper!", e);
        }
    }
    mBackground = null;
    mBackgroundWidth = -1;
    mBackgroundHeight = -1;
    if (b != null) {
        mBackground = b;
        mBackgroundWidth = mBackground.getWidth();
        mBackgroundHeight = mBackground.getHeight();
    }
    if (DEBUG) {
        Log.d(TAG, "Wallpaper loaded: " + mBackground);
    }
    updateSurfaceSize(getSurfaceHolder(), getDefaultDisplayInfo(),
            false );
    if (mNeedsDrawAfterLoadingWallpaper) {
        drawFrame();
    }
    mLoader = null;
    mNeedsDrawAfterLoadingWallpaper = false; 
    }

7.灭屏状态下,按Ent键无法点亮屏幕
frameworks/base/core/java/android/view/KeyEvent.java
/** @hide */
public static final boolean isWakeKey(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_MENU:
// 灭屏点亮屏幕add
case KeyEvent.KEYCODE_HOME:

8.连按camera快捷键进入camera拍照取景界面
/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
return handled;
}

//add
private void interceptCameraKeyDown(KeyEvent event, boolean interactive) {
GestureLauncherService gestureService = LocalServices.getService(
GestureLauncherService.class);
boolean gesturedServiceIntercepted = false;
if (gestureService != null) {
gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive,
mTmpBoolean);
if (mTmpBoolean.value && mRequestedOrGoingToSleep) {
mCameraGestureTriggeredDuringGoingToSleep = true;
}
}
}
case KeyEvent.KEYCODE_CAMERA: {
if (down) {
interceptCameraKeyDown(event, interactive);
} else {
interceptPowerKeyUp(event, interactive, canceled);
}
break;
}

9.去掉屏幕下方虚拟按键
/frameworks/base/core/res/res/values/dimens.xml
<-- Height of the bottom navigation / system bar. -->
0dp

0dp

10.首次开机会弹出电子邮件界面,修改成不弹出电子邮件界面
vendor/mediatek/proprietary/packages/providers/ContactsProvider/src/com/android/providers/contacts/ContactDirectoryManager.java
for (ProviderInfo provider : providers) {
if (isDirectoryProvider(provider)) {
// add
//Log.d(TAG, “lexiao providers :” +providerDescription(provider));
if(!provider.packageName.equals(“com.android.exchange”)){
queryDirectoriesForAuthority(directories, provider);
}

11.音乐播放界面,播放列表,随机播放,重复播放图标显示异常
vendor/mediatek/proprietary/packages/apps/Music/src/com/android/music/MediaPlaybackActivity.java
/// @}
updateDuration(pos);
//lexiao add
MusicLogUtils.v(TAG, "refreshNow() lexiao updateui " );
if (!mIsLandscape) {
mRepeatButton.setVisibility(View.VISIBLE);
mShuffleButton.setVisibility(View.VISIBLE);
mQueueButton.setVisibility(View.VISIBLE);
}
/// @}
setRepeatButtonImage();
setShuffleButtonImage();
setPauseButtonImage();

12.锁屏密码界面,添加密码确认按键
vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/drawable-xhdpi/ic_done_wht.png
vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/keyguard_password_view.xml



vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/values/strings.xml
Switch input method ok

vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/keyguard/KeyguardPasswordView.java
protected static final boolean PASSWORD_CHECKED = true;
// If there’s more than one IME, enable the IME switcher button
if(!PASSWORD_CHECKED){
updateSwitchImeButton();
}
//add
View switchOkButton = findViewById(R.id.switch_ok_button);
if (switchOkButton != null ) {
if(PASSWORD_CHECKED){
switchOkButton.setVisibility(View.VISIBLE);
}else{
switchOkButton.setVisibility(View.GONE);
}
switchOkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
doHapticKeyClick();
//Log.d(TAG, “lexiao doHapticKeyClick”);
if (mPasswordEntry.isEnabled()) {
verifyPasswordAndUnlock();
}
}
});
}

@Override
public void run() {
if(!PASSWORD_CHECKED){
updateSwitchImeButton();
}
}

13.编辑短信,附件添加录音,无法录音,弹出报错信息无法使用SD卡
packages/apps/SoundRecorder/src/com/android/soundrecorder/SoundRecorder.java
import android.Manifest;
import android.os.Build;
import android.content.pm.PackageManager;
private BroadcastReceiver mSDCardMountEventReceiver = null;
//add
public static String[] STORAGE = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.RECORD_AUDIO};
setContentView(R.layout.main);
if (Build.VERSION.SDK_INT >= 6.0) {// add
this.requestPermissions(STORAGE,1000);
}

updateUi();
}

//add
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults){
if (requestCode == 1000) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
//同意申请权限
} else{
// 用户拒绝申请权限
//Toast.makeText(context,“请同意调起相机权限”, Toast.LENGTH_SHORT).show();
}
return;
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

14.电量充满后电池图标仍是显示充电状态
frameworks/base/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
if (mCharging&& level < 100) {

15.下拉菜单中的手电筒无效
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java
if (flashAvailable != null /&& flashAvailable/

16.电量低于15%,在使用手电筒时,添加电量低于15%,闪光灯停止工作的提示信息
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java
import android.os.BatteryManager;
import android.widget.Toast;
import com.android.systemui.R;
public void setFlashlight(boolean enabled) {
// add
BatteryManager batteryManager=(BatteryManager)mContext.getSystemService(mContext.BATTERY_SERVICE);
int counter = batteryManager.getIntProperty( BatteryManager.BATTERY_PROPERTY_CAPACITY);//BATTERY_PROPERTY_CHARGE_COUNTER
int averge = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE);
int current_now = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW);
Log.d(TAG,“FlashlightControllerImpl::setFlashlight…counter:”+counter+", averge:"+averge+", current_now:"+current_now);
boolean enoughtBatteryLevel = counter >15;
if(!enoughtBatteryLevel){
Toast.makeText(mContext,R.string.flashlight_low_power_reminder, 3000).show();
}
enabled = enabled&enoughtBatteryLevel;
boolean pendingError = false;
synchronized (this) {
vendor/mediatek/proprietary/packages/apps/SystemUI/res/values-zh-rCN/strings.xml
添加"电量低于15%,闪光灯停止工作"
vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/strings.xml
添加"The battery power is less than 15% and the flash stops working"

17.apk 支持卸载
vendor/mediatek/proprietary/packages/3rd-party/Micro/Android.mk
//add
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/operator/app 可卸载
#LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/operator/app 不可卸载
LOCAL_MULTILIB := 32

18.进行录音录制停止并选择完成后,录音将直接退出;无法直接找到或播放录音文件
packages/apps/SoundRecorder/res/values-zh-rCN/strings.xml
“录音文件可以在音乐播放器中的我的播放列表/我的录音查看”
packages/apps/SoundRecorder/res/values/strings.xml
Recording files can be viewed in my playlist / my recording in the music player
packages/apps/SoundRecorder/src/com/android/soundrecorder/SoundRecorder.java
import android.widget.Toast;
Toast.makeText(this, getString(R.string.record_dir), Toast.LENGTH_SHORT).show();
}
/*
* Called on destroy to unregister the SD card mount event receiver.
*/

你可能感兴趣的:(mtk,定制修改)