• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.dialer.voicemailstatus;
18 
19 import android.os.Build.VERSION;
20 import android.os.Build.VERSION_CODES;
21 import android.provider.VoicemailContract.Status;
22 import android.support.annotation.RequiresApi;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.List;
26 
27 /** The query for the call voicemail status table. */
28 public class VoicemailStatusQuery {
29 
30   // TODO(maxwelb): Column indices should be removed in favor of Cursor#getColumnIndex
31   public static final int SOURCE_PACKAGE_INDEX = 0;
32   public static final int SETTINGS_URI_INDEX = 1;
33   public static final int VOICEMAIL_ACCESS_URI_INDEX = 2;
34   public static final int CONFIGURATION_STATE_INDEX = 3;
35   public static final int DATA_CHANNEL_STATE_INDEX = 4;
36   public static final int NOTIFICATION_CHANNEL_STATE_INDEX = 5;
37   public static final int QUOTA_OCCUPIED_INDEX = 6;
38   public static final int QUOTA_TOTAL_INDEX = 7;
39 
40   @RequiresApi(VERSION_CODES.N_MR1)
41   // The PHONE_ACCOUNT columns were added in M, but aren't queryable until N MR1
42   public static final int PHONE_ACCOUNT_COMPONENT_NAME = 8;
43 
44   @RequiresApi(VERSION_CODES.N_MR1)
45   public static final int PHONE_ACCOUNT_ID = 9;
46 
47   @RequiresApi(VERSION_CODES.N_MR1)
48   public static final int SOURCE_TYPE_INDEX = 10;
49 
50   @RequiresApi(VERSION_CODES.N)
51   private static final String[] PROJECTION_N =
52       new String[] {
53         Status.SOURCE_PACKAGE, // 0
54         Status.SETTINGS_URI, // 1
55         Status.VOICEMAIL_ACCESS_URI, // 2
56         Status.CONFIGURATION_STATE, // 3
57         Status.DATA_CHANNEL_STATE, // 4
58         Status.NOTIFICATION_CHANNEL_STATE, // 5
59         Status.QUOTA_OCCUPIED, // 6
60         Status.QUOTA_TOTAL // 7
61       };
62 
63   @RequiresApi(VERSION_CODES.N_MR1)
64   private static final String[] PROJECTION_NMR1;
65 
66   static {
67     List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_N));
68     projectionList.add(Status.PHONE_ACCOUNT_COMPONENT_NAME); // 8
69     projectionList.add(Status.PHONE_ACCOUNT_ID); // 9
70     projectionList.add(Status.SOURCE_TYPE); // 10
71     PROJECTION_NMR1 = projectionList.toArray(new String[projectionList.size()]);
72   }
73 
getProjection()74   public static String[] getProjection() {
75     return VERSION.SDK_INT >= VERSION_CODES.N_MR1 ? PROJECTION_NMR1 : PROJECTION_N;
76   }
77 }
78