[email protected]:/media/matt1/ze550kl-m/out/target/product/Z00L/system/framework$ adb push ./services.jar  /system/framework/
2 KB/s (205 bytes in 0.072s)
[email protected]:/media/matt1/ze550kl-m/out/target/product/Z00L/system/framework$ cd /oat/arm64/
bash: cd: /oat/arm64/: 没有那个文件或目录
[email protected]:/media/matt1/ze550kl-m/out/target/product/Z00L/system/framework$ cd oat/arm64/
[email protected]:/media/matt1/ze550kl-m/out/target/product/Z00L/system/framework/oat/arm64$ adb push ./services.odex  /system/framework/oat/arm64/






void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
        int32_t keyEventAction, int32_t keyEventFlags) {
   getListener()->notifyKey(&args);
}


到了
void InputDispatcher::notifyKey(const NotifyKeyArgs* args) {
           ALOGD("matt-interceptKeyBeforeQueueing5");
    mPolicy->interceptKeyBeforeQueueing(&event, /*byref*/ policyFlags);
 }






 private int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
      Slog.e(TAG, "matt-interceptKeyBeforeQueueing3");
        return mWindowManagerCallbacks.interceptKeyBeforeQueueing(event, policyFlags);
    }
到了
   public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
        Slog.d(WindowManagerService.TAG, "matt-interceptKeyBeforeQueueing2 ");
        return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags);
    }
到了






然后到了
 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {


 if (useHapticFeedback) {
            performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
        }     


}
然后到了


public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) {


            owningUid = android.os.Process.myUid();
            owningPackage = mContext.getOpPackageName();






             if (pattern.length == 1) {
            // One-shot vibration
            mVibrator.vibrate(owningUid, owningPackage, pattern[0], VIBRATION_ATTRIBUTES);//调用震动器
        } else {
            // Pattern vibration
            mVibrator.vibrate(owningUid, owningPackage, pattern, -1, VIBRATION_ATTRIBUTES);//调用震动器
        }
}




到了SystemVibrator.java里
 public void vibrate(int uid, String opPkg, long[] pattern, int repeat,
            AudioAttributes attributes) {
            Log.e(TAG, "matt-+1");
        if (mService == null) {
            Log.w(TAG, "Failed to vibrate; no vibrator service.");
            return;
        }
        // catch this here because the server will do nothing.  pattern may
        // not be null, let that be checked, because the server will drop it
        // anyway
        if (repeat < pattern.length) {
            try {
                mService.vibratePattern(uid, opPkg, pattern, repeat, usageForAttributes(attributes),//启动震动
                        mToken);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to vibrate.", e);
            }
        } else {
            throw new ArrayIndexOutOfBoundsException();
        }
    }
到了
 public void vibratePattern(int uid, String packageName, long[] pattern, int repeat,
            int usageHint, IBinder token) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires VIBRATE permission");
        }
        verifyIncomingUid(uid);
        // so wakelock calls will succeed
        long identity = Binder.clearCallingIdentity();
        try {
            if (DEBUG) {
                String s = "";
                int N = pattern.length;
                for (int i=0; i                     s += " " + pattern[i];
                }
                Slog.d(TAG, "Vibrating with pattern:" + s);
            }


            // we're running in the server so we can't fail
            if (pattern == null || pattern.length == 0
                    || isAll0(pattern)
                    || repeat >= pattern.length || token == null) {
                return;
            }


            Vibration vib = new Vibration(token, pattern, repeat, usageHint, uid, packageName);
            try {
                token.linkToDeath(vib, 0);
            } catch (RemoteException e) {
                return;
            }


            synchronized (mVibrations) {
                removeVibrationLocked(token);
                doCancelVibrateLocked();
                if (repeat >= 0) {
                    mVibrations.addFirst(vib);
                    startNextVibrationLocked(); //启动震动
                } else {
                    // A negative repeat means that this pattern is not meant
                    // to repeat. Treat it like a simple vibration.
                    mCurrentVibration = vib;
                    startVibrationLocked(vib);
                }
                addToPreviousVibrationsLocked(vib);
            }
        }
        finally {
            Binder.restoreCallingIdentity(identity);
        }
    }
到了
private void startVibrationLocked(final Vibration vib) {
        try {
            if (mLowPowerMode
                    && vib.mUsageHint != AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
                return;
            }


            int mode = mAppOpsService.checkAudioOperation(AppOpsManager.OP_VIBRATE,
                    vib.mUsageHint, vib.mUid, vib.mOpPkg);
            if (mode == AppOpsManager.MODE_ALLOWED) {
                mode = mAppOpsService.startOperation(AppOpsManager.getToken(mAppOpsService),
                    AppOpsManager.OP_VIBRATE, vib.mUid, vib.mOpPkg);
            }
            if (mode != AppOpsManager.MODE_ALLOWED) {
                if (mode == AppOpsManager.MODE_ERRORED) {
                    Slog.w(TAG, "Would be an error: vibrate from uid " + vib.mUid);
                }
                mH.post(mVibrationRunnable);
                return;
            }
        } catch (RemoteException e) {
        }
        if (vib.mTimeout != 0) {
            doVibratorOn(vib.mTimeout, vib.mUid, vib.mUsageHint);
            //
            switch (asus_PRJ_ID) {
                case 1://ASUS600KL
                    mH.postDelayed(mVibrationRunnable, vib.mTimeout + VIB_CAL_MS);
                    break;
                default:
                    mH.postDelayed(mVibrationRunnable, vib.mTimeout);
                    break;
            }
            //
        } else {
            // mThread better be null here. doCancelVibrate should always be
            // called before startNextVibrationLocked or startVibrationLocked.
            mThread = new VibrateThread(vib);  //启动一个新的线程
            mThread.start();
        }
    }
跑到了run函数
public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_DISPLAY);
            synchronized (this) {
                final long[] pattern = mVibration.mPattern;
                final int len = pattern.length;
                final int repeat = mVibration.mRepeat;
                final int uid = mVibration.mUid;
                final int usageHint = mVibration.mUsageHint;
                int index = 0;
                long duration = 0;


                while (!mDone) {
                    // add off-time duration to any accumulated on-time duration
                    if (index < len) {
                        duration += pattern[index++];
                    }


                    // sleep until it is time to start the vibrator
                    delay(duration);
                    if (mDone) {
                        break;
                    }


                    if (index < len) {
                        // read on-time duration and start the vibrator
                        // duration is saved for delay() at top of loop
                        duration = pattern[index++];
                        if (duration > 0) {
                            VibratorService.this.doVibratorOn(duration, uid, usageHint);//最后是这边震动
                        }
                    } else {
                        if (repeat < 0) {
                            break;
                        } else {
                            index = repeat;
                            duration = 0;
                        }
                    }
                }
                mWakeLock.release();
            }
            synchronized (mVibrations) {
                if (mThread == this) {
                    mThread = null;
                }
                if (!mDone) {
                    // If this vibration finished naturally, start the next
                    // vibration.
                    unlinkVibration(mVibration);
                    startNextVibrationLocked();
                }
            }
        }
    }
跑到
private void doVibratorOn(long millis, int uid, int usageHint) {
        synchronized (mInputDeviceVibrators) {
            if (DEBUG) {
                Slog.d(TAG, "Turning vibrator on for " + millis + " ms.");
            }
            try {
                mBatteryStatsService.noteVibratorOn(uid, millis);
                mCurVibUid = uid;
            } catch (RemoteException e) {
            }
            final int vibratorCount = mInputDeviceVibrators.size();
            if (vibratorCount != 0) {
                final AudioAttributes attributes = new AudioAttributes.Builder().setUsage(usageHint)
                        .build();
                for (int i = 0; i < vibratorCount; i++) {
                    mInputDeviceVibrators.get(i).vibrate(millis, attributes);
                }
            } else {
//
                switch (asus_PRJ_ID) {
                    case 1://ASUS600KL
                        vibratorOn(millis + VIB_CAL_MS);
                        break;
                    default:
                        vibratorOn(millis);
                        break;
                }
                //
            }
        }
    }

更多相关文章

  1. Ubuntu 编译Android若干错误及解决方法
  2. Android(安卓)7.0 FileUriExposedException 的处理
  3. Android(安卓)由图片资源ID获取图片的文件名
  4. Android(安卓)内核编绎错误解决方案
  5. Android(安卓)Wifi Driver Porting
  6. 《Android(安卓)Framework 之路》Android5.1 Camera Framework(一
  7. Android(安卓)之 远程图片获取和本地缓存
  8. 将Android(安卓)SQLite db 文件转化成xml保存在xml
  9. 在Android(安卓)Studio中导入jar包

随机推荐

  1. 最全的Android开源音乐播放器源码汇总
  2. android设置屏幕禁止休眠的方法
  3. android动画Android(安卓)动画实践
  4. 使用NDK开发SQLite3
  5. 豆瓣开源许可-android
  6. android中LayoutInflater的使用
  7. android Camera照相机技术(一)
  8. Android四大基本组件介绍与生命周期
  9. Android(安卓)4.4 KitKat 支持 u 盘功能
  10. Android单个模块编译