1 /*
2  * Copyright (C) 2011 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.tradefed.device;
17 
18 import com.android.ddmlib.IDevice;
19 
20 /**
21  * A placeholder {@link IDevice} used by {@link DeviceManager} to allocate when
22  * {@link IDeviceSelection#nullDeviceRequested()} is <code>true</code>
23  */
24 public class NullDevice extends StubDevice {
25 
26     /** Naming pattern for auto-created null devices */
27     public static final String TEMP_NULL_DEVICE_PREFIX = "null-device-temp-";
28 
29     private boolean mTemporaryDevice = false;
30 
NullDevice(String serial)31     public NullDevice(String serial) {
32         super(serial, false);
33     }
34 
NullDevice(String serial, boolean isTemporary)35     public NullDevice(String serial, boolean isTemporary) {
36         this(serial);
37         mTemporaryDevice = isTemporary;
38     }
39 
40     /**
41      * Returns true if the device was created temporarily for the invocation and should be deleted
42      * afterward.
43      */
isTemporary()44     public final boolean isTemporary() {
45         return mTemporaryDevice;
46     }
47 }
48