OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chromecast/base/android/system_time_change_notifier_android.h" | 5 #include "chromecast/base/android/system_time_change_notifier_android.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | |
8 #include "jni/SystemTimeChangeNotifierAndroid_jni.h" | 7 #include "jni/SystemTimeChangeNotifierAndroid_jni.h" |
9 | 8 |
10 using base::android::JavaParamRef; | 9 using base::android::JavaParamRef; |
11 | 10 |
12 namespace chromecast { | 11 namespace chromecast { |
13 | 12 |
14 // static | 13 // static |
15 bool SystemTimeChangeNotifierAndroid::RegisterJni(JNIEnv* env) { | 14 bool SystemTimeChangeNotifierAndroid::RegisterJni(JNIEnv* env) { |
16 return RegisterNativesImpl(env); | 15 return RegisterNativesImpl(env); |
17 } | 16 } |
18 | 17 |
19 SystemTimeChangeNotifierAndroid::SystemTimeChangeNotifierAndroid() { | 18 SystemTimeChangeNotifierAndroid::SystemTimeChangeNotifierAndroid() { |
20 } | 19 } |
21 | 20 |
22 SystemTimeChangeNotifierAndroid::~SystemTimeChangeNotifierAndroid() { | 21 SystemTimeChangeNotifierAndroid::~SystemTimeChangeNotifierAndroid() { |
23 } | 22 } |
24 | 23 |
25 void SystemTimeChangeNotifierAndroid::Initialize() { | 24 void SystemTimeChangeNotifierAndroid::Initialize() { |
26 JNIEnv* env = base::android::AttachCurrentThread(); | 25 JNIEnv* env = base::android::AttachCurrentThread(); |
27 java_notifier_.Reset(Java_SystemTimeChangeNotifierAndroid_create( | 26 java_notifier_.Reset(Java_SystemTimeChangeNotifierAndroid_create(env)); |
28 env, base::android::GetApplicationContext())); | |
29 Java_SystemTimeChangeNotifierAndroid_initializeFromNative( | 27 Java_SystemTimeChangeNotifierAndroid_initializeFromNative( |
30 env, java_notifier_, reinterpret_cast<jlong>(this)); | 28 env, java_notifier_, reinterpret_cast<jlong>(this)); |
31 } | 29 } |
32 | 30 |
33 void SystemTimeChangeNotifierAndroid::Finalize() { | 31 void SystemTimeChangeNotifierAndroid::Finalize() { |
34 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
35 Java_SystemTimeChangeNotifierAndroid_finalizeFromNative(env, java_notifier_); | 33 Java_SystemTimeChangeNotifierAndroid_finalizeFromNative(env, java_notifier_); |
36 } | 34 } |
37 | 35 |
38 void SystemTimeChangeNotifierAndroid::OnTimeChanged( | 36 void SystemTimeChangeNotifierAndroid::OnTimeChanged( |
39 JNIEnv* env, | 37 JNIEnv* env, |
40 const JavaParamRef<jobject>& jobj) { | 38 const JavaParamRef<jobject>& jobj) { |
41 NotifySystemTimeChanged(); | 39 NotifySystemTimeChanged(); |
42 } | 40 } |
43 | 41 |
44 } // namespace chromecast | 42 } // namespace chromecast |
OLD | NEW |