Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/android/memconsumer/java/src/org/chromium/memconsumer/ResidentService.java

Issue 672533002: Enable separatorWrap module in CheckStyle and fix all the issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.memconsumer; 5 package org.chromium.memconsumer;
6 6
7 import android.app.Notification; 7 import android.app.Notification;
8 import android.app.PendingIntent; 8 import android.app.PendingIntent;
9 import android.app.Service; 9 import android.app.Service;
10 import android.content.Intent; 10 import android.content.Intent;
(...skipping 22 matching lines...) Expand all
33 return mBinder; 33 return mBinder;
34 } 34 }
35 35
36 public void useMemory(long memory) { 36 public void useMemory(long memory) {
37 if (memory > 0) { 37 if (memory > 0) {
38 Intent notificationIntent = new Intent(this, MemConsumer.class); 38 Intent notificationIntent = new Intent(this, MemConsumer.class);
39 notificationIntent.setAction(MemConsumer.NOTIFICATION_ACTION); 39 notificationIntent.setAction(MemConsumer.NOTIFICATION_ACTION);
40 PendingIntent pendingIntent = 40 PendingIntent pendingIntent =
41 PendingIntent.getActivity(this, 0, notificationIntent, 0); 41 PendingIntent.getActivity(this, 0, notificationIntent, 0);
42 Notification notification = 42 Notification notification =
43 new Notification.Builder(getApplicationContext()). 43 new Notification.Builder(getApplicationContext())
44 setContentTitle("MC running (" + memory + "Mb)"). 44 .setContentTitle("MC running (" + memory + "Mb)")
45 setSmallIcon(R.drawable.notification_icon). 45 .setSmallIcon(R.drawable.notification_icon)
46 setDeleteIntent(pendingIntent). 46 .setDeleteIntent(pendingIntent)
47 setContentIntent(pendingIntent). 47 .setContentIntent(pendingIntent)
48 build(); 48 .build();
49 startForeground(RESIDENT_NOTIFICATION_ID, notification); 49 startForeground(RESIDENT_NOTIFICATION_ID, notification);
50 mIsInForeground = true; 50 mIsInForeground = true;
51 } 51 }
52 if (mIsInForeground && memory == 0) { 52 if (mIsInForeground && memory == 0) {
53 stopForeground(true); 53 stopForeground(true);
54 mIsInForeground = false; 54 mIsInForeground = false;
55 } 55 }
56 nativeUseMemory(memory * 1024 * 1024); 56 nativeUseMemory(memory * 1024 * 1024);
57 } 57 }
58 58
59 // Allocate the amount of memory in native code. Otherwise the memory 59 // Allocate the amount of memory in native code. Otherwise the memory
60 // allocation is limited by the framework. 60 // allocation is limited by the framework.
61 private native void nativeUseMemory(long memory); 61 private native void nativeUseMemory(long memory);
62 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698