Handle backup transport registration dynamically

Bug 11369873

Change-Id: I9bbdcc21ce25159c6645690123b5d03c553b0ddc
This commit is contained in:
Christopher Tate
2013-11-14 18:10:35 -08:00
parent a951fa56f1
commit cefba58d14
6 changed files with 124 additions and 43 deletions

View File

@ -23,6 +23,12 @@ import android.os.ParcelFileDescriptor;
/** {@hide} */
interface IBackupTransport {
/**
* Ask the transport for the name under which it should be registered. This will
* typically be its host service's component name, but need not be.
*/
String name();
/**
* Ask the transport for an Intent that can be used to launch any internal
* configuration Activity that it wishes to present. For example, the transport

View File

@ -19,6 +19,7 @@ package com.android.internal.backup;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.app.backup.RestoreSet;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
@ -71,6 +72,10 @@ public class LocalTransport extends IBackupTransport.Stub {
}
}
public String name() {
return new ComponentName(mContext, this.getClass()).flattenToShortString();
}
public Intent configurationIntent() {
// The local transport is not user-configurable
return null;

View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.backup;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
public class LocalTransportService extends Service {
private static LocalTransport sTransport = null;
@Override
public void onCreate() {
if (sTransport == null) {
sTransport = new LocalTransport(this);
}
}
@Override
public IBinder onBind(Intent intent) {
return sTransport;
}
}