Create an interface to access the two pane state

Create an new interface in the embedding provider,
this interface tells if settings app is in two pane or not.

To access the activity in the content provider, we need to store
the activity reference in the app application layer.

Test: See if two pane state is correct.
Bug: 203763572
Change-Id: Iae2245b84af2683d932f1900df9959dad98370d7
This commit is contained in:
Tsung-Mao Fang
2021-10-21 21:24:49 +08:00
parent fce8565e5e
commit 54b9d60783
3 changed files with 28 additions and 0 deletions

View File

@@ -16,13 +16,18 @@
package com.android.settings;
import android.app.Activity;
import android.app.Application;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import java.lang.ref.WeakReference;
/** Settings application which sets up activity embedding rules for the large screen device. */
public class SettingsApplication extends Application {
private WeakReference<Activity> mHomeActivity = new WeakReference<>(null);
@Override
public void onCreate() {
super.onCreate();
@@ -31,4 +36,12 @@ public class SettingsApplication extends Application {
new ActivityEmbeddingRulesController(this);
controller.initRules();
}
public void setHomeActivity(Activity homeActivity) {
mHomeActivity = new WeakReference<>(homeActivity);
}
public Activity getHomeActivity() {
return mHomeActivity.get();
}
}