• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.google.uwb.support.ccc;
18 
19 import android.os.Build.VERSION_CODES;
20 import android.os.PersistableBundle;
21 import android.uwb.RangingSession;
22 
23 import androidx.annotation.RequiresApi;
24 
25 /**
26  * Defines parameters for CCC reconfigure operation
27  *
28  * <p>This is passed as a bundle to the client callback
29  * {@link RangingSession.Callback#onReconfigured}.
30  */
31 @RequiresApi(VERSION_CODES.LOLLIPOP)
32 public class CccRangingReconfiguredParams extends CccParams {
33 
34     private static final int BUNDLE_VERSION_1 = 1;
35     private static final int BUNDLE_VERSION_CURRENT = BUNDLE_VERSION_1;
36 
37     @Override
getBundleVersion()38     protected int getBundleVersion() {
39         return BUNDLE_VERSION_CURRENT;
40     }
41 
fromBundle(PersistableBundle bundle)42     public static CccRangingReconfiguredParams fromBundle(PersistableBundle bundle) {
43         if (!isCorrectProtocol(bundle)) {
44             throw new IllegalArgumentException("Invalid protocol");
45         }
46 
47         switch (getBundleVersion(bundle)) {
48             case BUNDLE_VERSION_1:
49                 return parseVersion1(bundle);
50 
51             default:
52                 throw new IllegalArgumentException("Invalid bundle version");
53         }
54     }
55 
parseVersion1(PersistableBundle unusedBundle)56     private static CccRangingReconfiguredParams parseVersion1(PersistableBundle unusedBundle) {
57         // Nothing to parse for now
58         return new CccRangingReconfiguredParams.Builder().build();
59     }
60 
61     /** Builder */
62     public static class Builder {
build()63         public CccRangingReconfiguredParams build() {
64             return new CccRangingReconfiguredParams();
65         }
66     }
67 }
68