项目:notificationtest
文件:AlarmNotificationReceiver.java
@SuppressWarnings("deprecation")
private static void wakeUpScreen (Context ctx) {
PowerManager pm = (PowerManager)ctx.getSystemService(Context.POWER_SERVICE);
boolean isScreenOn = true;
// greater or equal to api level 20
if (Build.VERSION.SDK_INT > AlarmNotificationUtil.FAKE_KITKAT_WATCH) {
isScreenOn = pm.isInteractive();
Log.v("cpeng","alarm screen is interactive");
}
else if (Build.VERSION.SDK_INT <= AlarmNotificationUtil.FAKE_KITKAT_WATCH) {
isScreenOn = pm.isScreenOn();
Log.v("cpeng","alarm screen is on");
}
else {
Log.v("cpeng","alarm screen OFF");
}
if(isScreenOn==false)
{
WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,"ALock");
wl.acquire(10000);
wl.release();
// WakeLock wl_cpu = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"AcpuLock");
// wl_cpu.acquire(10000);
}
}
项目:PeSanKita-android
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"Migration");
try {
wakeLock.acquire();
setState(new ImportState(ImportState.STATE_MIGrating_BEGIN,null));
SmsMigrator.migrateDatabase(ApplicationMigrationService.this,masterSecret,ApplicationMigrationService.this);
setState(new ImportState(ImportState.STATE_MIGrating_COMPLETE,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
public static ComponentName startWakefulService(Context context,Intent intent) {
ComponentName comp;
synchronized (mActiveWakeLocks) {
int id = mNextId;
mNextId++;
if (mNextId <= 0) {
mNextId = 1;
}
intent.putExtra(EXTRA_WAKE_LOCK_ID,id);
comp = context.startService(intent);
if (comp == null) {
comp = null;
} else {
WakeLock wl = ((PowerManager) context.getSystemService("power")).newWakeLock(1,"wake:" + comp.flattenToShortString());
wl.setReferenceCounted(false);
wl.acquire(60000);
mActiveWakeLocks.put(id,wl);
}
}
return comp;
}
public static boolean completeWakefulIntent(Intent intent) {
int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID,0);
if (id == 0) {
return false;
}
synchronized (mActiveWakeLocks) {
WakeLock wl = (WakeLock) mActiveWakeLocks.get(id);
if (wl != null) {
wl.release();
mActiveWakeLocks.remove(id);
return true;
}
Log.w("WakefulbroadcastReceiver","No active wake lock id #" + id);
return true;
}
}
public static ComponentName startWakefulService(Context context,wl);
}
}
return comp;
}
public static boolean completeWakefulIntent(Intent intent) {
int id = intent.getIntExtra(EXTRA_WAKE_LOCK_ID,"No active wake lock id #" + id);
return true;
}
}
项目:Cable-Android
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:AndroidModulePattern
文件:ScreenLockUtil.java
/**
* 保持屏幕常亮
*
* @param activity you kNow
*/
public static void keepScreenOn(Activity activity) {
WakeLock wakeLock = mWakeLockArray.get(activity);
if (wakeLock == null) {
PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK,activity.getClass().getName());
}
if (!wakeLock.isHeld()) {
wakeLock.acquire();
}
mWakeLockArray.put(activity,wakeLock);
cancelLockScreen(activity);
Log.i(TAG,"开启屏幕常亮");
}
/**
* Sets alarm on ACTION_BOOT_COMPLETED. Resets alarm on
* TIME_SET,TIMEZONE_CHANGED
*/
@Override
public void onReceive(final Context context,Intent intent) {
final String action = intent.getAction();
Log.d("AlarmInitReceiver" + action);
if (App.fejlsøgning) App.langToast("AlarmInitReceiver onReceive(" + intent);
//final PendingResult result = goAsync();
final WakeLock wl = AlarmAlertWakeLock.createPartialWakeLock(context);
if (wl!=null) wl.acquire(); // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/3315048120
Alarms.setNextAlert(context);
// result.finish();
Log.d("AlarmInitReceiver finished");
if (wl!=null) wl.release(); // fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/3315048120
}
项目:BasePedo
文件:StepService.java
synchronized private PowerManager.WakeLock getLock(Context context) {
if (mWakeLock != null) {
if (mWakeLock.isHeld())
mWakeLock.release();
mWakeLock = null;
}
if (mWakeLock == null) {
PowerManager mgr = (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
mWakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,StepService.class.getName());
mWakeLock.setReferenceCounted(true);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
int hour = c.get(Calendar.HOUR_OF_DAY);
if (hour >= 23 || hour <= 6) {
mWakeLock.acquire(5000);
} else {
mWakeLock.acquire(300000);
}
}
return (mWakeLock);
}
项目:Running
文件:StepService.java
synchronized private WakeLock getLock(Context context) {
if (mWakeLock != null) {
if (mWakeLock.isHeld())
mWakeLock.release();
mWakeLock = null;
}
if (mWakeLock == null) {
PowerManager mgr = (PowerManager) context
.getSystemService(Context.POWER_SERVICE);
mWakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,StepService.class.getName());
mWakeLock.setReferenceCounted(true);
Calendar c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
int hour = c.get(Calendar.HOUR_OF_DAY);
if (hour >= 23 || hour <= 6) {
mWakeLock.acquire(5000);
} else {
mWakeLock.acquire(300000);
}
}
return (mWakeLock);
}
项目:TextSecure
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:TowerCollector
文件:CollectorService.java
private void registerWakeLockAcquirer() {
if (keepScreenOnMode == KeepScreenOnMode.disabled) {
Log.d("registerWakeLockAcquirer(): WakeLock not configured");
return;
}
periodicalWakeLockAcquirer = new Timer();
// run scheduled cell listener
periodicalWakeLockAcquirer.schedule(new TimerTask() {
private final String INNER_TAG = TAG + ".Periodical" + WakeLock.class.getSimpleName() + "Acquirer";
@Override
public void run() {
synchronized (reacquireWakeLockLock) {
WakeLock oldWakeLock = wakeLock;
Log.d(INNER_TAG,"run(): New WakeLock acquire");
wakeLock = createWakeLock(keepScreenOnMode);
wakeLock.acquire(WAKE_LOCK_TIMEOUT);
Log.d(INNER_TAG,"run(): Old WakeLock release");
if (oldWakeLock != null && oldWakeLock.isHeld())
oldWakeLock.release();
}
}
},WAKE_LOCK_ACQUIRE_INTERVAL);
}
项目:Sparkplug
文件:MqttService.java
@Override
@SuppressLint("Wakelock")
public void onReceive(Context context,Intent intent) {
traceDebug(TAG,"Internal network status receive.");
// we protect against the phone switching off
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the cpu running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MQTT");
wl.acquire();
traceDebug(TAG,"Reconnect for Network recovery.");
if (isOnline()) {
traceDebug(TAG,"Online,reconnect.");
// we have an internet connection - have another try at
// connecting
reconnect();
} else {
notifyClientsOffline();
}
wl.release();
}
项目:sdl_mobileweather_tutorial_android
文件:WeatherLocationServices.java
private WeatherLocation processLocation(Location location) {
if (location != null) {
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MobileWeatherProcessLocation");
try {
wakeLock.acquire();
WeatherLocation loc = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent()) {
loc = reverseGeocode(location);
}
else {
loc = new WeatherLocation();
GPSLocation gpsLoc = new GPSLocation();
gpsLoc.latitude = String.valueOf(location.getLatitude());
gpsLoc.longitude = String.valueOf(location.getLongitude());
loc.gpsLocation = gpsLoc;
}
return loc;
} finally {
wakeLock.release();
}
}
return null;
}
项目:FMTech
文件:ReschedulerStrategy.java
protected static void loadPrerequisites(Runnable paramRunnable)
{
final PowerManager.WakeLock localWakeLock = ((PowerManager)FinskyApp.get().getSystemService("power")).newWakeLock(1,"ReschedulerStrategy");
Runnable local1 = new Runnable()
{
private int mloaded;
public final void run()
{
this.mloaded = (1 + this.mloaded);
if (this.mloaded == 3)
{
this.val$onPrerequisitesLoaded.run();
localWakeLock.release();
}
}
};
localWakeLock.acquire();
FinskyApp.get().mLibraries.load(local1);
FinskyApp.get().mAppStates.load(local1);
GearheadStateMonitor.getInstance().initialize(local1);
}
public static boolean completeWakefulIntent(Intent paramIntent)
{
int i = paramIntent.getIntExtra("android.support.content.wakelockid",0);
if (i == 0) {
return false;
}
synchronized (mActiveWakeLocks)
{
PowerManager.WakeLock localWakeLock = (PowerManager.WakeLock)mActiveWakeLocks.get(i);
if (localWakeLock != null)
{
localWakeLock.release();
mActiveWakeLocks.remove(i);
return true;
}
Log.w("WakefulbroadcastReceiver","No active wake lock id #" + i);
return true;
}
}
public static ComponentName startWakefulService(Context paramContext,Intent paramIntent)
{
synchronized (mActiveWakeLocks)
{
int i = mNextId;
int j = 1 + mNextId;
mNextId = j;
if (j <= 0) {
mNextId = 1;
}
paramIntent.putExtra("android.support.content.wakelockid",i);
ComponentName localComponentName = paramContext.startService(paramIntent);
if (localComponentName == null) {
return null;
}
PowerManager.WakeLock localWakeLock = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(1,"wake:" + localComponentName.flattenToShortString());
localWakeLock.setReferenceCounted(false);
localWakeLock.acquire(60000L);
mActiveWakeLocks.put(i,localWakeLock);
return localComponentName;
}
}
项目:FMTech
文件:gk.java
public static ComponentName a(Context paramContext,Intent paramIntent)
{
synchronized (a)
{
int i = b;
int j = 1 + b;
b = j;
if (j <= 0) {
b = 1;
}
paramIntent.putExtra("android.support.content.wakelockid","wake:" + localComponentName.flattenToShortString());
localWakeLock.setReferenceCounted(false);
localWakeLock.acquire(60000L);
a.put(i,localWakeLock);
return localComponentName;
}
}
项目:FMTech
文件:gk.java
public static boolean a(Intent paramIntent)
{
int i = paramIntent.getIntExtra("android.support.content.wakelockid",0);
if (i == 0) {
return false;
}
synchronized (a)
{
PowerManager.WakeLock localWakeLock = (PowerManager.WakeLock)a.get(i);
if (localWakeLock != null)
{
localWakeLock.release();
a.remove(i);
return true;
}
new StringBuilder("No active wake lock id #").append(i);
return true;
}
}
项目:FMTech
文件:hac.java
final int a()
{
synchronized (this.a)
{
int i = 1 + this.d;
this.d = i;
if (i <= 0) {
this.d = 1;
}
PowerManager.WakeLock localWakeLock = ((PowerManager)this.c.getSystemService("power")).newWakeLock(1,"BackgroundTaskService");
localWakeLock.setReferenceCounted(false);
localWakeLock.acquire(60000L);
this.a.put(this.d,localWakeLock);
return this.d;
}
}
项目:TextSecureSMP
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:Silence
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:spotify-tv
文件:EspressoTestRule.java
@SuppressWarnings("deprecation")
private void riseAndShine(Activity activity) {
KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Context.KEyguard_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(activity.getLocalClassName());
keyguardLock.disableKeyguard();
activity.getwindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
PowerManager powerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
WakeLock lock = powerManager.newWakeLock(
PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,"wakeup!");
lock.acquire();
lock.release();
}
项目:QuizUpWinner
文件:Con-6.java
public static ComponentName ˊ(Context paramContext,Intent paramIntent)
{
synchronized (ˊ)
{
int i = ˋ;
int j = 1 + ˋ;
ˋ = j;
if (j <= 0)
ˋ = 1;
paramIntent.putExtra("android.support.content.wakelockid",i);
ComponentName localComponentName = paramContext.startService(paramIntent);
if (localComponentName == null)
return null;
PowerManager.WakeLock localWakeLock = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(1,"wake:" + localComponentName.flattenToShortString());
localWakeLock.setReferenceCounted(false);
localWakeLock.acquire(60000L);
ˊ.put(i,localWakeLock);
return localComponentName;
}
}
项目:QuizUpWinner
文件:Con-6.java
public static boolean ˊ(Intent paramIntent)
{
int i = paramIntent.getIntExtra("android.support.content.wakelockid",0);
if (i == 0)
return false;
synchronized (ˊ)
{
PowerManager.WakeLock localWakeLock = (PowerManager.WakeLock)ˊ.get(i);
if (localWakeLock != null)
{
localWakeLock.release();
ˊ.remove(i);
return true;
}
return true;
}
}
项目:droidblu
文件:MqttService.java
@Override
public void onReceive(Context context,"MQTT");
wl.acquire();
if (isOnline()) {
// we have an internet connection - have another try at
// connecting
reconnect();
} else {
notifyClientsOffline();
}
wl.release();
}
项目:Securecom-Messaging
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:Securecom-Text
文件:ApplicationMigrationService.java
@Override
public void run() {
notification = initializeBackgroundNotification();
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,null));
setDatabaseImported(ApplicationMigrationService.this);
stopForeground(true);
notifyImportComplete();
stopSelf();
} finally {
wakeLock.release();
}
}
项目:SlimChat.Android
文件:MqttService.java
@Override
public void onReceive(Context context,"MQTT");
wl.acquire();
if (isOnline()) {
// we have an internet connection - have another try at
// connecting
reconnect();
} else {
notifyClientsOffline();
}
wl.release();
}
项目:konekti
文件:GPSservice.java
@Override
public void onReceive(Context ctx,Intent intent)
{
// we protect against the phone switching off while we're doing this
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the cpu running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MQTT");
wl.acquire();
if (isOnline())
{
// we have an internet connection - have another try at connecting
if (connectTobroker())
{
// we subscribe to a topic - registering to receive push
// notifications with a particular key
subscribetoTopic(topicName);
}
}
// we're finished - if the phone is switched off,it's okay for the cpu
// to sleep Now
wl.release();
}
@Override
public void onReceive(Context ctx,Intent intent) {
//Unlock device screen
PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,"TAG");
wl.acquire(30*1000);
mKeyguardManager = (KeyguardManager) ctx.getSystemService(Context.KEyguard_SERVICE);
KeyguardLock mlock = mKeyguardManager.newKeyguardLock("com.inostudio.alar_clock");
mlock.disableKeyguard();
//Create notification
creatNotification(ctx);
//Start dialog
Intent dialog = new Intent();
dialog.setClassName("com.inostudio.alarm_clock","com.inostudio.alarm_clock.RootActivity");
dialog.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(dialog);
//release screen
wl.release();
}
项目:buildAPKsApps
文件:ScreenLightActivity.java
项目:buildAPKsApps
文件:ScreenLightActivity.java
项目:Dendroid-HTTP-RAT
文件:MyService.java
@SuppressLint("Wakelock") @Override
protected String doInBackground(String... params) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
final WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE,"");
wl.acquire();
return "Executed";
}
项目:AndroidModulePattern
文件:ScreenLockUtil.java
项目:TenguChat
文件:XmlReader.java
public XmlReader(WakeLock wakeLock) {
this.parser = Xml.newPullParser();
try {
this.parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,true);
} catch (XmlPullParserException e) {
Log.d(Config.LOGTAG,"error setting namespace feature on parser");
}
this.wakeLock = wakeLock;
}
项目:react-native-incall-manager
文件:InCallWakeLockUtils.java
private boolean _acquireWakeLock(WakeLock lock,long timeout) {
synchronized (lock) {
if (!lock.isHeld()) {
if (timeout > 0) {
lock.acquire(timeout);
} else {
lock.acquire();
}
return true;
}
}
return false;
}
项目:react-native-incall-manager
文件:InCallWakeLockUtils.java
private boolean _releaseWakeLock(WakeLock lock) {
synchronized (lock) {
if (lock.isHeld()) {
lock.release();
return true;
}
}
return false;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。