Home | History | Annotate | Download | only in devicepolicy
      1 /*
      2  * Copyright (C) 2017 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 package com.android.server.devicepolicy;
     17 
     18 import android.annotation.UserIdInt;
     19 import android.app.admin.IDevicePolicyManager;
     20 import android.content.ComponentName;
     21 import android.os.PersistableBundle;
     22 import android.security.keymaster.KeymasterCertificateChain;
     23 import android.security.keystore.ParcelableKeyGenParameterSpec;
     24 import android.telephony.data.ApnSetting;
     25 
     26 import com.android.server.SystemService;
     27 
     28 import java.util.ArrayList;
     29 import java.util.Collections;
     30 import java.util.List;
     31 
     32 /**
     33  * Defines the required interface for IDevicePolicyManager implemenation.
     34  *
     35  * <p>The interface consists of public parts determined by {@link IDevicePolicyManager} and also
     36  * several package private methods required by internal infrastructure.
     37  *
     38  * <p>Whenever adding an AIDL method to {@link IDevicePolicyManager}, an empty override method
     39  * should be added here to avoid build breakage in downstream branches.
     40  */
     41 abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub {
     42     /**
     43      * To be called by {@link DevicePolicyManagerService#Lifecycle} during the various boot phases.
     44      *
     45      * @see {@link SystemService#onBootPhase}.
     46      */
     47     abstract void systemReady(int phase);
     48     /**
     49      * To be called by {@link DevicePolicyManagerService#Lifecycle} when a new user starts.
     50      *
     51      * @see {@link SystemService#onStartUser}
     52      */
     53     abstract void handleStartUser(int userId);
     54     /**
     55      * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being unlocked.
     56      *
     57      * @see {@link SystemService#onUnlockUser}
     58      */
     59     abstract void handleUnlockUser(int userId);
     60     /**
     61      * To be called by {@link DevicePolicyManagerService#Lifecycle} when a user is being stopped.
     62      *
     63      * @see {@link SystemService#onStopUser}
     64      */
     65     abstract void handleStopUser(int userId);
     66 
     67     public void setSystemSetting(ComponentName who, String setting, String value){}
     68 
     69     public void transferOwnership(ComponentName admin, ComponentName target, PersistableBundle bundle) {}
     70 
     71     public PersistableBundle getTransferOwnershipBundle() {
     72         return null;
     73     }
     74 
     75     public boolean generateKeyPair(ComponentName who, String callerPackage, String algorithm,
     76             ParcelableKeyGenParameterSpec keySpec, int idAttestationFlags,
     77             KeymasterCertificateChain attestationChain) {
     78         return false;
     79     }
     80 
     81     public boolean isUsingUnifiedPassword(ComponentName who) {
     82         return true;
     83     }
     84 
     85     public boolean setKeyPairCertificate(ComponentName who, String callerPackage, String alias,
     86             byte[] cert, byte[] chain, boolean isUserSelectable) {
     87         return false;
     88     }
     89 
     90     @Override
     91     public void setStartUserSessionMessage(
     92             ComponentName admin, CharSequence startUserSessionMessage) {}
     93 
     94     @Override
     95     public void setEndUserSessionMessage(ComponentName admin, CharSequence endUserSessionMessage) {}
     96 
     97     @Override
     98     public String getStartUserSessionMessage(ComponentName admin) {
     99         return null;
    100     }
    101 
    102     @Override
    103     public String getEndUserSessionMessage(ComponentName admin) {
    104         return null;
    105     }
    106 
    107     @Override
    108     public List<String> setMeteredDataDisabledPackages(ComponentName admin, List<String> packageNames) {
    109         return packageNames;
    110     }
    111 
    112     @Override
    113     public List<String> getMeteredDataDisabledPackages(ComponentName admin) {
    114         return new ArrayList<>();
    115     }
    116 
    117     @Override
    118     public int addOverrideApn(ComponentName admin, ApnSetting apnSetting) {
    119         return -1;
    120     }
    121 
    122     @Override
    123     public boolean updateOverrideApn(ComponentName admin, int apnId, ApnSetting apnSetting) {
    124         return false;
    125     }
    126 
    127     @Override
    128     public boolean removeOverrideApn(ComponentName admin, int apnId) {
    129         return false;
    130     }
    131 
    132     @Override
    133     public List<ApnSetting> getOverrideApns(ComponentName admin) {
    134         return Collections.emptyList();
    135     }
    136 
    137     @Override
    138     public void setOverrideApnsEnabled(ComponentName admin, boolean enabled) {}
    139 
    140     @Override
    141     public boolean isOverrideApnEnabled(ComponentName admin) {
    142         return false;
    143     }
    144 
    145     public void clearSystemUpdatePolicyFreezePeriodRecord() {
    146     }
    147 
    148     @Override
    149     public boolean isMeteredDataDisabledPackageForUser(ComponentName admin,
    150             String packageName, int userId) {
    151         return false;
    152     }
    153 
    154     @Override
    155     public long forceSecurityLogs() {
    156         return 0;
    157     }
    158 
    159     @Override
    160     public void setDefaultSmsApplication(ComponentName admin, String packageName) {
    161     }
    162 }
    163