• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.odpclient;
18 
19 import android.app.Activity;
20 import android.content.Context;
21 import android.ondevicepersonalization.OnDevicePersonalizationManager;
22 import android.os.Bundle;
23 import android.view.SurfaceView;
24 import android.view.View;
25 import android.widget.Button;
26 
27 public class MainActivity extends Activity {
28     private OnDevicePersonalizationManager mOdpManager = null;
29 
30     private Button mBindButton;
31     private SurfaceView mRenderedView;
32 
33     private Context mContext;
34 
35     @Override
onCreate(Bundle savedInstanceState)36     public void onCreate(Bundle savedInstanceState) {
37         super.onCreate(savedInstanceState);
38         setContentView(R.layout.activity_main);
39         mContext = getApplicationContext();
40         if (mOdpManager == null) {
41             mOdpManager = new OnDevicePersonalizationManager(mContext);
42         }
43 
44         mRenderedView = findViewById(R.id.rendered_view);
45         mRenderedView.setZOrderOnTop(true);
46         mRenderedView.setVisibility(View.INVISIBLE);
47         mBindButton = findViewById(R.id.bind_service_button);
48         registerBindServiceButton();
49     }
50 
registerBindServiceButton()51     private void registerBindServiceButton() {
52         mBindButton.setOnClickListener(v -> {
53             if (mOdpManager == null) {
54                 mBindButton.setText("OnDevicePersonalizationManager is null");
55             } else {
56                 mBindButton.setText(mOdpManager.getVersion());
57             }
58         });
59     }
60 }
61