|
7 | 7 | package org.deviceconnect.android.manager; |
8 | 8 |
|
9 | 9 | import android.app.Activity; |
| 10 | +import android.app.AlertDialog; |
| 11 | +import android.app.Dialog; |
| 12 | +import android.app.SearchManager; |
10 | 13 | import android.app.Service; |
11 | 14 | import android.content.BroadcastReceiver; |
| 15 | +import android.content.ContentResolver; |
| 16 | +import android.content.ContentValues; |
12 | 17 | import android.content.Intent; |
| 18 | +import android.net.Uri; |
13 | 19 | import android.os.Binder; |
| 20 | +import android.os.Build; |
| 21 | +import android.os.Bundle; |
14 | 22 | import android.os.IBinder; |
15 | 23 | import android.os.PowerManager; |
| 24 | +import android.provider.MediaStore; |
| 25 | +import android.provider.Settings; |
16 | 26 | import android.security.KeyChain; |
| 27 | + |
| 28 | +import androidx.annotation.NonNull; |
17 | 29 | import androidx.annotation.Nullable; |
| 30 | +import androidx.fragment.app.DialogFragment; |
| 31 | + |
18 | 32 | import android.util.Log; |
| 33 | +import android.widget.Toast; |
19 | 34 |
|
20 | 35 | import org.deviceconnect.android.deviceplugin.host.HostDevicePlugin; |
| 36 | +import org.deviceconnect.android.deviceplugin.host.activity.profile.CanvasProfileActivity; |
| 37 | +import org.deviceconnect.android.deviceplugin.host.file.HostFileProvider; |
21 | 38 | import org.deviceconnect.android.localoauth.DevicePluginXmlUtil; |
22 | 39 | import org.deviceconnect.android.manager.core.DConnectManager; |
23 | 40 | import org.deviceconnect.android.manager.core.DConnectSettings; |
|
31 | 48 | import org.deviceconnect.android.manager.core.util.VersionName; |
32 | 49 | import org.deviceconnect.android.manager.profile.DConnectSettingProfile; |
33 | 50 | import org.deviceconnect.android.manager.setting.KeywordDialogActivity; |
| 51 | +import org.deviceconnect.android.manager.setting.SecuritySettingDialogActivity; |
| 52 | +import org.deviceconnect.android.manager.setting.SecuritySettingDialogFragment; |
34 | 53 | import org.deviceconnect.android.manager.setting.SettingActivity; |
35 | 54 | import org.deviceconnect.android.manager.util.NotificationUtil; |
36 | 55 | import org.deviceconnect.android.profile.SystemProfile; |
| 56 | +import org.deviceconnect.android.provider.FileManager; |
37 | 57 | import org.deviceconnect.android.ssl.KeyStoreCallback; |
38 | 58 | import org.deviceconnect.android.ssl.KeyStoreError; |
39 | 59 | import org.deviceconnect.message.intent.message.IntentDConnectMessage; |
40 | 60 |
|
41 | 61 | import java.io.File; |
| 62 | +import java.io.FileInputStream; |
| 63 | +import java.io.FileNotFoundException; |
42 | 64 | import java.io.IOException; |
| 65 | +import java.io.InputStream; |
| 66 | +import java.io.OutputStream; |
43 | 67 | import java.io.UnsupportedEncodingException; |
44 | 68 | import java.security.KeyStore; |
45 | 69 | import java.security.NoSuchAlgorithmException; |
46 | 70 | import java.security.cert.Certificate; |
| 71 | +import java.security.cert.CertificateEncodingException; |
| 72 | +import java.util.Enumeration; |
47 | 73 | import java.util.concurrent.ExecutorService; |
48 | 74 | import java.util.concurrent.Executors; |
49 | 75 | import java.util.logging.Level; |
@@ -278,6 +304,7 @@ public void onError(final Exception e) { |
278 | 304 | } |
279 | 305 | } |
280 | 306 | } |
| 307 | + |
281 | 308 | /** |
282 | 309 | * Hostプラグインを追加します. |
283 | 310 | */ |
@@ -427,7 +454,7 @@ public void openPluginSettings(final String pluginId) { |
427 | 454 | * プラグインの有効・無効を設定します. |
428 | 455 | * |
429 | 456 | * @param pluginId プラグインID |
430 | | - * @param enable 有効の場合はtrue、無効の場合はfalse |
| 457 | + * @param enable 有効の場合はtrue、無効の場合はfalse |
431 | 458 | */ |
432 | 459 | public void setEnablePlugin(final String pluginId, final boolean enable) { |
433 | 460 | final DevicePlugin plugin = mManager.getPluginManager().getDevicePlugin(pluginId); |
@@ -479,12 +506,21 @@ public void installRootCertificate() { |
479 | 506 | mManager.requestKeyStore(ipAddress, new KeyStoreCallback() { |
480 | 507 | @Override |
481 | 508 | public void onSuccess(final KeyStore keyStore, final Certificate cert, final Certificate rootCert) { |
| 509 | + |
482 | 510 | try { |
483 | | - Intent installIntent = KeyChain.createInstallIntent(); |
484 | | - installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
485 | | - installIntent.putExtra(KeyChain.EXTRA_NAME, "Device Connect Root CA"); |
486 | | - installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, rootCert.getEncoded()); |
487 | | - startActivity(installIntent); |
| 511 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { |
| 512 | + Intent installIntent = new Intent(); |
| 513 | + installIntent.setClass(getApplicationContext(), SecuritySettingDialogActivity.class); |
| 514 | + installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 515 | + installIntent.putExtra(SecuritySettingDialogFragment.EXTRA_ROOT_CERT, rootCert.getEncoded()); |
| 516 | + startActivity(installIntent); |
| 517 | + } else { |
| 518 | + Intent installIntent = KeyChain.createInstallIntent(); |
| 519 | + installIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 520 | + installIntent.putExtra(KeyChain.EXTRA_NAME, "Device Connect Root CA"); |
| 521 | + installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, rootCert.getEncoded()); |
| 522 | + startActivity(installIntent); |
| 523 | + } |
488 | 524 | } catch (Exception e) { |
489 | 525 | mLogger.log(Level.SEVERE, "Failed to encode server certificate.", e); |
490 | 526 | } |
|
0 commit comments