|
@@ -16,9 +16,15 @@
|
16
|
16
|
|
17
|
17
|
package org.jitsi.meet;
|
18
|
18
|
|
|
19
|
+import android.content.BroadcastReceiver;
|
|
20
|
+import android.content.Context;
|
19
|
21
|
import android.content.Intent;
|
|
22
|
+import android.content.IntentFilter;
|
|
23
|
+import android.content.RestrictionEntry;
|
|
24
|
+import android.content.RestrictionsManager;
|
20
|
25
|
import android.net.Uri;
|
21
|
26
|
import android.os.Build;
|
|
27
|
+import android.os.Bundle;
|
22
|
28
|
import android.provider.Settings;
|
23
|
29
|
import android.util.Log;
|
24
|
30
|
import android.view.KeyEvent;
|
|
@@ -31,6 +37,7 @@ import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
|
31
|
37
|
import java.lang.reflect.Method;
|
32
|
38
|
import java.net.MalformedURLException;
|
33
|
39
|
import java.net.URL;
|
|
40
|
+import java.util.Collection;
|
34
|
41
|
import java.util.Map;
|
35
|
42
|
|
36
|
43
|
/**
|
|
@@ -48,6 +55,27 @@ public class MainActivity extends JitsiMeetActivity {
|
48
|
55
|
private static final int OVERLAY_PERMISSION_REQUEST_CODE
|
49
|
56
|
= (int) (Math.random() * Short.MAX_VALUE);
|
50
|
57
|
|
|
58
|
+ /**
|
|
59
|
+ * ServerURL configuration key for restriction configuration using {@link android.content.RestrictionsManager}
|
|
60
|
+ */
|
|
61
|
+ public static final String RESTRICTION_SERVER_URL = "SERVER_URL";
|
|
62
|
+
|
|
63
|
+ /**
|
|
64
|
+ * Broadcast receiver for restrictions handling
|
|
65
|
+ */
|
|
66
|
+ private BroadcastReceiver broadcastReceiver;
|
|
67
|
+
|
|
68
|
+ /**
|
|
69
|
+ * Flag if configuration is provided by RestrictionManager
|
|
70
|
+ */
|
|
71
|
+ private boolean configurationByRestrictions = false;
|
|
72
|
+
|
|
73
|
+ /**
|
|
74
|
+ * Default URL as could be obtained from RestrictionManager
|
|
75
|
+ */
|
|
76
|
+ private String defaultURL;
|
|
77
|
+
|
|
78
|
+
|
51
|
79
|
// JitsiMeetActivity overrides
|
52
|
80
|
//
|
53
|
81
|
|
|
@@ -85,16 +113,66 @@ public class MainActivity extends JitsiMeetActivity {
|
85
|
113
|
|
86
|
114
|
@Override
|
87
|
115
|
protected void initialize() {
|
|
116
|
+ broadcastReceiver = new BroadcastReceiver() {
|
|
117
|
+ @Override
|
|
118
|
+ public void onReceive(Context context, Intent intent) {
|
|
119
|
+ // As new restrictions including server URL are received,
|
|
120
|
+ // conference should be restarted with new configuration.
|
|
121
|
+ leave();
|
|
122
|
+ recreate();
|
|
123
|
+ }
|
|
124
|
+ };
|
|
125
|
+ registerReceiver(broadcastReceiver,
|
|
126
|
+ new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED));
|
|
127
|
+
|
|
128
|
+ resolveRestrictions();
|
|
129
|
+ setJitsiMeetConferenceDefaultOptions();
|
|
130
|
+ super.initialize();
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ @Override
|
|
134
|
+ public void onDestroy() {
|
|
135
|
+ if (broadcastReceiver != null) {
|
|
136
|
+ unregisterReceiver(broadcastReceiver);
|
|
137
|
+ broadcastReceiver = null;
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ super.onDestroy();
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+ private void setJitsiMeetConferenceDefaultOptions() {
|
88
|
144
|
// Set default options
|
89
|
145
|
JitsiMeetConferenceOptions defaultOptions
|
90
|
146
|
= new JitsiMeetConferenceOptions.Builder()
|
91
|
|
- .setWelcomePageEnabled(true)
|
92
|
|
- .setServerURL(buildURL("https://meet.jit.si"))
|
93
|
|
- .setFeatureFlag("call-integration.enabled", false)
|
94
|
|
- .build();
|
|
147
|
+ .setWelcomePageEnabled(true)
|
|
148
|
+ .setServerURL(buildURL(defaultURL))
|
|
149
|
+ .setFeatureFlag("call-integration.enabled", false)
|
|
150
|
+ .setFeatureFlag("server-url-change.enabled", !configurationByRestrictions)
|
|
151
|
+ .build();
|
95
|
152
|
JitsiMeet.setDefaultConferenceOptions(defaultOptions);
|
|
153
|
+ }
|
96
|
154
|
|
97
|
|
- super.initialize();
|
|
155
|
+ private void resolveRestrictions() {
|
|
156
|
+ RestrictionsManager manager =
|
|
157
|
+ (RestrictionsManager) getSystemService(Context.RESTRICTIONS_SERVICE);
|
|
158
|
+ Bundle restrictions = manager.getApplicationRestrictions();
|
|
159
|
+ Collection<RestrictionEntry> entries = manager.getManifestRestrictions(
|
|
160
|
+ getApplicationContext().getPackageName());
|
|
161
|
+ for (RestrictionEntry restrictionEntry : entries) {
|
|
162
|
+ String key = restrictionEntry.getKey();
|
|
163
|
+ if (RESTRICTION_SERVER_URL.equals(key)) {
|
|
164
|
+ // If restrictions are passed to the application.
|
|
165
|
+ if (restrictions != null &&
|
|
166
|
+ restrictions.containsKey(RESTRICTION_SERVER_URL)) {
|
|
167
|
+ defaultURL = restrictions.getString(RESTRICTION_SERVER_URL);
|
|
168
|
+ configurationByRestrictions = true;
|
|
169
|
+ // Otherwise use default URL from app-restrictions.xml.
|
|
170
|
+ } else {
|
|
171
|
+ defaultURL = restrictionEntry.getSelectedString();
|
|
172
|
+ configurationByRestrictions = false;
|
|
173
|
+ }
|
|
174
|
+ }
|
|
175
|
+ }
|
98
|
176
|
}
|
99
|
177
|
|
100
|
178
|
@Override
|