一起来记录程序员的日常

发布随笔
  • 小智 4年以前

    Life was like a box of chocolates.You never know what you're going to get.

  • yuruihen 4年以前

    ANDROID

  • ggflxb 4年以前

    泡在网上的日子的第一天!

  • 120313058@qq.com 4年以前

    第一天

  • 一哥 4年以前

    烟花三月下扬州~

  • fxtayj 4年以前

    未来不迎,当下不杂,过往不恋

  • 丘吉尔曾说过这样的一句话:资本主义之恶,在于幸福之不均,社会主义之恶,在于痛苦共享。

  • lamisss 4年以前

    新的开始

  • sklin 4年以前

    善于收藏

  • gissundan 4年以前

    2015-02-28 学无止境

  • muzik 4年以前

    好难发现一个好的网站。。。

  • aidenchi 4年以前

    啦啦啦!

  • 汤小泽 4年以前

    Android TP 手势
    需求:黑屏下,在屏幕上画C,M,W,O手势,进入相应的应用
    字符驱动为TP厂商修改
    驱动部分:
    drivers/input/touchscreen/gt9xx.c
    #if GTP_GESTURE_WAKEUP //进行注册,否则底层键值无法报到上层
    input_set_capability(ts->input_dev, EV_KEY, KEY_POWER);
    input_set_capability(ts->input_dev, EV_KEY, KEY_UP);
    input_set_capability(ts->input_dev, EV_KEY, KEY_DOWN);
    input_set_capability(ts->input_dev, EV_KEY, KEY_LEFT);
    input_set_capability(ts->input_dev, EV_KEY, KEY_RIGHT);

    #if GTP_GESTURE_WAKEUP
    if (DOZE_ENABLED == doze_status)
    {
    ret = gtp_i2c_read(i2c_connect_client, doze_buf, 3);
    GTP_DEBUG("0x814B = 0x%02X", doze_buf[2]);
    if (ret > 0)
    {
    if ((doze_buf[2] == 'a') || (doze_buf[2] == 'b') || (doze_buf[2] == 'c') ||
    (doze_buf[2] == 'd') || (doze_buf[2] == 'e') || (doze_buf[2] == 'g') ||
    (doze_buf[2] == 'h') || (doze_buf[2] == 'm') || (doze_buf[2] == 'o') ||
    (doze_buf[2] == 'q') || (doze_buf[2] == 's') || (doze_buf[2] == 'v') ||
    (doze_buf[2] == 'w') || (doze_buf[2] == 'y') || (doze_buf[2] == 'z') ||
    (doze_buf[2] == 0x5E) /* ^ */
    )
    {
    if (doze_buf[2] != 0x5E)
    {
    GTP_INFO("Wakeup by gesture(%c), light up the screen!", doze_buf[2]);
    }
    else
    {
    GTP_INFO("Wakeup by gesture(^), light up the screen!");
    }

    doze_status = DOZE_WAKEUP; //唤醒操作,先报power按键,再报字符按键

    input_report_key(ts->input_dev, KEY_POWER, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_POWER, 0);
    input_sync(ts->input_dev);

    if (doze_buf[2] == 'c')
    {
    printk("renliang000000000000000000key_up=%d\n",KEY_UP);
    input_report_key(ts->input_dev, KEY_UP, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_UP, 0);
    input_sync(ts->input_dev);
    }
    else if (doze_buf[2] == 'm')
    {
    printk("renliang11111111111111111111111111key_up=%d\n",KEY_DOWN);
    input_report_key(ts->input_dev, KEY_DOWN, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_DOWN, 0);
    input_sync(ts->input_dev);
    }
    else if (doze_buf[2] =='w')
    {
    printk("renliang33333333333333333333333333key_up=%d\n",KEY_LEFT);
    input_report_key(ts->input_dev, KEY_LEFT, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_LEFT, 0);
    input_sync(ts->input_dev);
    }
    else if (doze_buf[2] =='o')
    {
    printk("renliang444444444444444444444444444key_up=%d\n",KEY_RIGHT);
    input_report_key(ts->input_dev, KEY_RIGHT, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_RIGHT, 0);
    input_sync(ts->input_dev);
    }
    // clear 0x814B
    doze_buf[2] = 0x00;
    gtp_i2c_write(i2c_connect_client, doze_buf, 3);
    }
    else if ( (doze_buf[2] == 0xAA) || (doze_buf[2] == 0xBB) ||
    (doze_buf[2] == 0xAB) || (doze_buf[2] == 0xBA) )
    {
    char *direction[4] = {"Right", "Down", "Up", "Left"};
    u8 type = ((doze_buf[2] & 0x0F) - 0x0A) + (((doze_buf[2] >> 4) & 0x0F) - 0x0A) * 2;

    GTP_INFO("%s slide to light up the screen!", direction[type]);
    doze_status = DOZE_WAKEUP;
    input_report_key(ts->input_dev, KEY_POWER, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_POWER, 0);
    input_sync(ts->input_dev);
    // clear 0x814B
    doze_buf[2] = 0x00;
    gtp_i2c_write(i2c_connect_client, doze_buf, 3);
    }
    else if (0xCC == doze_buf[2])
    {
    GTP_INFO("Double click to light up the screen!");
    doze_status = DOZE_WAKEUP;
    input_report_key(ts->input_dev, KEY_POWER, 1);
    input_sync(ts->input_dev);
    input_report_key(ts->input_dev, KEY_POWER, 0);
    input_sync(ts->input_dev);
    // clear 0x814B
    doze_buf[2] = 0x00;
    gtp_i2c_write(i2c_connect_client, doze_buf, 3);
    }
    else
    {
    // clear 0x814B
    doze_buf[2] = 0x00;
    gtp_i2c_write(i2c_connect_client, doze_buf, 3);
    gtp_enter_doze(ts);
    }
    }
    if (ts->use_irq)
    {
    gtp_irq_enable(ts);
    }
    return;
    }
    #endif

    应用部分:
    code/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
    index d5e46db..85ba7ac 100755
    @@ -120,7 +120,8 @@ import java.util.concurrent.atomic.AtomicBoolean;

    import com.sprd.android.config.APCTOption;
    /* @} */
    -
    +import android.content.pm.PackageInfo;
    +import android.content.pm.PackageManager.NameNotFoundException;
    /**
    * WindowManagerPolicy implementation for the Android phone UI. This
    * introduces a new method suffix, Lp, for an internal lock of the
    @@ -3892,7 +3893,131 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }
    }
    }
    -
    + //add by wanghui start
    + private final static int HOME = 0;
    + private final static int CAMERA = 1;
    + private final static int MUSIC = 2;
    + private final static int WHATSAPP = 3;
    + private final static int OPERA_MINI = 4;
    +
    + //private static final String CAMERA_CLASS = "com.android.camera.Camera";
    + private void handleLockUp(int flag) {
    + Log.i(TAG, "handleLockUp mKeyguardMediator.isSecure()="+mKeyguardDelegate.isSecure());
    + /*
    + if(mKeyguardMediator.isSecure()){
    + mKeyguardMediator.wakeUp();
    + }else{
    + mKeyguardMediator.keyguardDone(true, true);
    + }
    + */
    + //mKeyguardMediator.wakeUp();
    + mPowerManager.wakeUp(SystemClock.uptimeMillis());
    + mHandler.post(new Runnable() {
    + @Override
    + public void run() {
    + if(mKeyguardDelegate.isSecure()){
    + //mKeyguardMediator.wakeUp();
    + }else{
    + mKeyguardDelegate.keyguardDone(true, true);
    + }
    + }
    + });
    + Log.i(TAG,"handleLockUp");
    + if(flag==HOME) {
    + startActivityFor(HOME);
    + } else if (flag==CAMERA) {
    + startActivityFor(CAMERA);
    + } else if(flag==MUSIC) {
    + startActivityFor(MUSIC);
    + } else if(flag==WHATSAPP) {
    + startActivityFor(WHATSAPP);
    + } else if(flag==OPERA_MINI) {
    + startActivityFor(OPERA_MINI);
    + }
    + }
    +
    + private void startActivityFor(int name) {
    + switch(name) {
    + case HOME:
    + isGotoUnlockscreen(null) ;
    + Log.i(TAG, "HOME");
    + break;
    + case CAMERA:
    + Intent cameraIntent = new Intent(Intent.ACTION_MAIN);
    + cameraIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    + cameraIntent.setClassName("com.android.camera2", "com.android.camera.CameraLauncher");
    + cameraIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    + isGotoUnlockscreen(cameraIntent);
    + Log.i(TAG, "CAMERA");
    + break;
    + case WHATSAPP:
    + Intent whatsappIntent = new Intent(Intent.ACTION_MAIN);
    + whatsappIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    + whatsappIntent.setClassName("com.whatsapp", "com.whatsapp.Main");
    + whatsappIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    + isGotoUnlockscreen(whatsappIntent);
    + Log.i(TAG, "WHATSAPP");
    + break;
    +
    + case OPERA_MINI:
    + Intent operaMini_Intent = new Intent(Intent.ACTION_MAIN);
    + operaMini_Intent.addCategory(Intent.CATEGORY_LAUNCHER);
    + operaMini_Intent.setClassName("com.opera.mini.android", "com.opera.mini.android.Browser");
    + operaMini_Intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    + isGotoUnlockscreen(operaMini_Intent);
    + Log.i(TAG, "OPERA_MINI");
    + break;
    +
    + case MUSIC:
    + Intent musicIntent = new Intent(Intent.ACTION_MAIN);
    + musicIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    + musicIntent.setClassName("com.android.music", "com.android.music.MusicBrowserActivity");
    + musicIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    + isGotoUnlockscreen(musicIntent);
    + Log.i(TAG, "MUSIC");
    + break;
    + }
    + }
    + public void isGotoUnlockscreen(Intent intent) {
    + if(intent!=null){
    + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_CLEAR_TOP);
    + mContext.startActivity(intent);
    + }
    + }
    + public void handleKeyEventForLock(KeyEvent event){
    + final int keyCode = event.getKeyCode();
    + Log.i(TAG, "handleKeyEventForLock keyCode="+keyCode);
    + if(keyCode==KeyEvent.KEYCODE_F2){
    + handleLockUp(HOME);
    + }else if(keyCode== KeyEvent.KEYCODE_DPAD_UP){
    + handleLockUp(CAMERA);
    + }else if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN){
    + handleLockUp(MUSIC);
    + }else if(keyCode==KeyEvent.KEYCODE_DPAD_LEFT){
    + if(isApkExist("com.whatsapp"))
    + handleLockUp(WHATSAPP);
    + }else if(keyCode==KeyEvent.KEYCODE_DPAD_RIGHT){
    + if(isApkExist("com.opera.mini.android"))
    + handleLockUp(OPERA_MINI);
    + }
    + }
    + private boolean isApkExist(String packagename){
    + PackageInfo packageInfo;
    + try {
    + packageInfo = mContext.getPackageManager().getPackageInfo(
    + packagename, 0);
    +
    + } catch (NameNotFoundException e) {
    + packageInfo = null;
    + e.printStackTrace();
    + }
    + if(packageInfo ==null){
    + return false;
    + }else{
    + return true;
    + }
    + }
    + //add by wanghui end
    /** {@inheritDoc} */
    @Override
    public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
    @@ -3930,6 +4055,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    + " isWakeKey=" + isWakeKey);
    //}

    + handleKeyEventForLock(event);//add by wanghui
    if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0
    && event.getRepeatCount() == 0) {
    performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);

  • sklin 4年以前

    OK

  • 汤小泽 4年以前

    Go for broken

  • 使用material主题的时候,必须设定targetSdkVersion = 21,否则界面看起来是模糊的

  • yanweimin7 4年以前

    这个站不错。

  • zhao0722 4年以前

    一个好的开端,是做事的起点!

  • 前路黑暗,踽踽独行,每一步都艰难而痛苦。更关键的,你根本不知道他干吗这么伤痕累累了还要往前走

  • 500miles 电影<醉乡民谣> 主题曲 中英字幕 (Fang1169)
    -- Justin Timberlake http://v.yinyuetai.com/video/781734

  • 水,看似清澈, 并非因为它不含杂质, 而是在于懂得沉淀; 心,看似通透, 不是因为没有杂念, 而是在于明白

  • laksg2009 4年以前

    态度觉得生活质量

  • angcyo 4年以前

    run with you

  • jilimi 4年以前

    加油.

  • 菠萝 4年以前

    今天是第一次上这里