• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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.server;
18 
19 import android.text.IClipboard;
20 import android.content.Context;
21 
22 /**
23  * Implementation of the clipboard for copy and paste.
24  */
25 public class ClipboardService extends IClipboard.Stub {
26     private CharSequence mClipboard = "";
27 
28     /**
29      * Instantiates the clipboard.
30      */
ClipboardService(Context context)31     public ClipboardService(Context context) { }
32 
33     // javadoc from interface
setClipboardText(CharSequence text)34     public void setClipboardText(CharSequence text) {
35         synchronized (this) {
36             if (text == null) {
37                 text = "";
38             }
39 
40             mClipboard = text;
41         }
42     }
43 
44     // javadoc from interface
getClipboardText()45     public CharSequence getClipboardText() {
46         synchronized (this) {
47             return mClipboard;
48         }
49     }
50 
51     // javadoc from interface
hasClipboardText()52     public boolean hasClipboardText() {
53         synchronized (this) {
54             return mClipboard.length() > 0;
55         }
56     }
57 }
58