1/*
2 * Copyright (C) 2015 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
17package android.support.car.content.pm;
18
19import android.support.car.CarNotConnectedException;
20
21/**
22 * @hide
23 */
24public class CarPackageManagerEmbedded extends CarPackageManager {
25
26    private final android.car.content.pm.CarPackageManager mManager;
27
28    public CarPackageManagerEmbedded(Object manager) {
29        mManager = (android.car.content.pm.CarPackageManager) manager;
30    }
31
32    /** @hide */
33    public android.car.content.pm.CarPackageManager getManager() {
34        return mManager;
35    }
36
37    @Override
38    public boolean isActivityAllowedWhileDriving(String packageName, String className)
39            throws CarNotConnectedException {
40        try {
41            return mManager.isActivityDistractionOptimized(packageName, className);
42        } catch (android.car.CarNotConnectedException e) {
43            throw new CarNotConnectedException(e);
44        }
45    }
46
47    @Override
48    public boolean isServiceAllowedWhileDriving(String packageName, String className)
49            throws CarNotConnectedException {
50        try {
51            return mManager.isServiceDistractionOptimized(packageName, className);
52        } catch (android.car.CarNotConnectedException e) {
53            throw new CarNotConnectedException(e);
54        }
55    }
56
57    @Override
58    public void onCarDisconnected() {
59        // nothing to do
60    }
61}
62