写错了,应该是Launcher,不是Launcher2

解决方案 »

  1.   

    我也看过launcher的代码,但不知道你所说运营商显示是怎么回事?
      

  2.   

    就是开机完成后界面显示“中国移动“、”China Mobile”等运营商
      

  3.   

    从Android 2.2开始,加入了一个新的锁屏API位于android.app.admin.DevicePolicyManager 包,DevicePolicyManager类的lockNow方法可以锁住屏幕,查看Android源代码发现其实是从 IDevicePolicyManager实现的,整个AIDL接口调用代码为: private final IDevicePolicyManager mService;mService = IDevicePolicyManager.Stub.asInterface(                ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));if (mService != null) {            try {                mService.lockNow();            } catch (RemoteException e) {                Log.w(TAG, "Failed talking with device policy service", e);            }}
    复制代码这里Android123提示大家传统的方法加入
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD">
    </uses- permission>权限,
    使用下面代码可以锁住键盘,但屏幕不行   
    KeyguardManager km =    (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);  KeyguardLock kl= km.newKeyguardLock(KEYGUARD_SERVICE);  kl.reenableKeyguard();
      

  4.   

    我觉得这个运营商的应该是在setting里面
    http://mars5337.javaeye.com/blog/744548让Android设备永不锁屏经过《让Android设备永不锁屏》文章中所述的修改,原以为已经完全让Android设备不锁屏了。后来发现我的Android设备烧录好之后第一次启动永远不会锁屏,但是设备重启之后开机就进入锁屏状态,解锁之后就再也不会锁屏了(因为永远不超时)。看来“革命尚未成功,同志仍需努力”啊。     那么为什么启动之后没有进入锁屏状态呢?是不会系统有把超时锁屏的值给修改了呢?我通过sqlite3去查看settings.db的内容,发现超时锁屏的值仍然是-1。说明启动之后,系统并没有去数据库中查看屏幕超时锁屏的值,就直接锁屏了。     但是怎样才能开机之后不进入锁屏状态呢?这个是个非常费思量的问题。经过go,我知道锁屏的代码在LockScreen.java中,然后顺藤摸瓜,终于找到了可以设置锁屏功能开关的位置。代码位于:frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardViewMediator.java
    该文件中有一个变量定义如下:    /**
         * External apps (like the phone app) can tell us to disable the keygaurd.
         */
        private boolean mExternallyEnabled = true;
    mExternallyEnabled是用来管理是否开启屏幕锁的关键。默认值是打开屏锁,根据注释可以知道他是希望应用程序来修改这个值。但是经过加打印信息发现开机的时候没有任何应用程序会修改它。修改这个值调用如下函数:   /**
         * Same semantics as {@link WindowManagerPolicy#enableKeyguard}; provide
         * a way for external stuff to override normal keyguard behavior.  For instance
         * the phone app disables the keyguard when it receives incoming calls.
         */
        public void setKeyguardEnabled(boolean enabled) {
            synchronized (this) {
                if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")");            mExternallyEnabled = enabled;            if (!enabled && mShowing) {
                    if (mExitSecureCallback != null) {
                        if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring");
                        // we're in the process of handling a request to verify the user
                        // can get past the keyguard. ignore extraneous requests to disable / reenable
                        return;
                    }                // hiding keyguard that is showing, remember to reshow later
                    if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, "
                            + "disabling status bar expansion");
                    mNeedToReshowWhenReenabled = true;
                    hideLocked();
                } else if (enabled && mNeedToReshowWhenReenabled) {
                    // reenabled after previously hidden, reshow
                    if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling "
                            + "status bar expansion");
                    mNeedToReshowWhenReenabled = false;                if (mExitSecureCallback != null) {
                        if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
                        mExitSecureCallback.onKeyguardExitResult(false);
                        mExitSecureCallback = null;
                        resetStateLocked();
                    } else {
                        showLocked();                    // block until we know the keygaurd is done drawing (and post a message
                        // to unblock us after a timeout so we don't risk blocking too long
                        // and causing an ANR).
                        mWaitingUntilKeyguardVisible = true;
                        mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS);
                        if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false");
                        while (mWaitingUntilKeyguardVisible) {
                            try {
                                wait();
                            } catch (InterruptedException e) {
                                Thread.currentThread().interrupt();
                            }
                        }
                        if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible");
                    }
                }
            }
        }
        经过上面的讨论我们可以发现我们有两个解决方法:1、定义变量的时候,给其初始化为false。2、在launcher模块启动的时候,调用setKeyguardEnabled方法,关闭锁屏功能。    我懒得修改Laucher模块,我的解决方法就是在定义mExternallyEnabled时修改其初始值为false。各位朋友可以根据自己的实际情况选择解决方案。我的代码如下:   /**
         * External apps (like the phone app) can tell us to disable the keygaurd.
         */
        private boolean mExternallyEnabled = false;
         这样修改之后,Android设备开机之后,默认不会进入锁屏状态,除非你在应用程序中调用setKeyguardEnabled方法显示打开这个功能。因为设置的超时时间为-1,则永远也不会进入锁屏界面。 
      

  5.   

    非常感谢zhq56030207
    我已经在framework的Telephony里面找到Operator获取的源码了
      

  6.   

    另外关于桌面的那个运营商显示,是在APPS的Settings里面,具体文件是Status.java