Distance sensors are usually phone call, if not close to the face, distance sensor will work, put out the screen to make the screen to prevent misuse.
I demand is, in this case (when the broadcast is received CALL_STATE_OFFHOOK), wake up the screen to be, how?
The following code is invalid, after PhoneApp put out the screen, but also do other processing, makes the following code can not power the screen.
PowerManager pm = (PowerManager) context.getSystemService (Context.POWER_SERVICE);
WakeLock wl = pm.newWakeLock (PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.SCREEN_DIM_WAKE_LOCK |
PowerManager.ON_AFTER_RELEASE, "TAG");
wl.acquire ();
I think in two directions:
1, using a method similar to the lighting of the screen.
May I ask how to modify the above code?
2, into my program before, change the phone "Call", "call automatically turn off the screen" option, and then change it back when you highlight the program.
How to modify "Call off the screen automatically" setting?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
No news day, their top.
Reply:
1 Try adding wakeUp
before wakelock2 need to modify the data / datacom.android.provider.settings / db inside the corresponding key. By ContentProvider to modify.
Reply:
Thank guoyoulei520!
The first method I'll try.
The second I thought, but could not find "call automatically turn off the screen," in which db specific key.
Reply:
PROXIMITY sensor off because after you get the lock screen is not lit screen, this is dealt with in PowerManagerServiceYou do have a third-party application or system source code?
If the system source code, then it is better to change, if only third-party applications may not be easy getting the words
Reply:
on
I was doing third-party applications.
Ah, I have found so difficult to deal directly.
It seems that only use the second method, the direction toward the effort to modify the system settings.
Reply:
Ordinarily you can be the first method, you is not no system-level privileges
Reply:
Permissions are added, the problem should not privilege.
I think it should be the 4th floor of the brothers that reason.
Reply:
The second direction may be feasible.
By comparing the settings where I call "a call automatically turn off the screen," respectively open and close are the settings.db (opened with sqlitemanager) file, found inside a proximity_sensor change in value between 1 and 0.
I try to use ContentProvider modifications, to see if it works.
Reply:
Pro, by modifying settings.db, problem solved.
ContentResolver r = context.getContentResolver ();
String callscreenoff = Settings.System.getString (r, "proximity_sensor");
if (callscreenoff.equals ("1")) {
Settings.System.putString (r, "proximity_sensor", "0");
}
Reply:
This database looks like a plus of 4.0 will go after
This will turn off the p-sensor, remember to change it back after, oh, otherwise p-sensor is invalid
Reply:
Positive solution!
No comments:
Post a Comment