标签: android-7.0-nougat

我们如何为Android N证书固定生成X.509证书的SubjectPublicKeyInfo的Base64编码SHA256哈希?

N Developer Preview中有关其网络安全配置的文档提供了以下说明:

证书锁定是通过公钥的哈希提供一组证书(X.509证书的SubjectPublicKeyInfo)来完成的.只有当证书链包含至少一个固定公钥时,证书链才有效.

它们显示的XML已损坏(缺少结束标记),但除此之外表明散列是SHA256并编码为base64:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config>
        <domain includeSubdomains="true">example.com</domain>
        <pin-set expiration="2018-01-01">
            <pin digest="SHA-256">7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=</pin>
            <!-- backup pin -->
            <pin digest="SHA-256">fwza0LRMXouZHRC8Ei+4PyuldPDcf3UKgO/04cDM1oE=</pin>
    </domain-config>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)

我们如何创建这样的哈希?

我试着在接近这个主旨,但openssl x509 -inform der -pubkey -noout不喜欢我的CRT文件.我无法轻易确定问题是否在CRT文件,说明,我的版本openssl或其他内容中.

有没有人有一个已知的良好配方来创建这个哈希?

android x509certificate android-7.0-nougat

20
推荐指数
2
解决办法
9712
查看次数

我们如何使用Android N网络安全配置获得自签名证书?

我试图测试N Developer Preview的网络安全配置功能的所有方面.我有大部分工作,但我被自签名证书场景困扰.

根据文档,Android N应该对PEM或DER文件感到满意,因为它适用于其他证书验证方案.但是,我不使用自签名证书,并且我尝试使用此工作继续运行到证书路径验证异常中.

为了测试,我thin用作服务器,在我的开发机器上运行,可以通过N模拟器访问.自签名证书适用于我的开发机器上的浏览器,如果我切换到运行thinsans SSL,应用程序可以很好地到达服务器.所以,这不是连接问题.

我使用本网站上的说明创建了自签名证书:

sudo openssl genrsa -out "/etc/[webserver]/ssl/example.key" 2048
sudo openssl req -new -key "/etc/[webserver]/ssl/example.key" \
                 -out "/etc/[webserver]/ssl/example.csr"
sudo openssl x509 -req -days 365 -in "/etc/[webserver]/ssl/example.csr" \
                  -signkey "/etc/[webserver]/ssl/example.key"  \
                  -out "/etc/[webserver]/ssl/example.crt"
Run Code Online (Sandbox Code Playgroud)

根据此Stack Overflow回答,该example.crt文件是PEM文件.在其他地方,我看到了创建"组合PEM"文件的说明.但是,我尝试了这两个,没有运气.

在网络安全配置方面的东西,我曾经尝试都<domain-config><debug-overrides>.后者看起来像:

<?xml version="1.0" encoding="utf-8"?>

<network-security-config>
  <debug-overrides>
    <trust-anchors>
      <certificates src="@raw/selfsigned"/>
    </trust-anchors>
  </debug-overrides>
</network-security-config>
Run Code Online (Sandbox Code Playgroud)

但是,在任何一种情况下我都会得到验证错误.

作为原始资源,我们究竟应该将PEM或DER文件作为原始资源投入使用?

ssl android android-7.0-nougat

20
推荐指数
1
解决办法
2074
查看次数

适用于Android N上的启动器图标和其他图像的Android矢量绘图

我将在我的应用程序上使用矢量绘图功能的动作栏图标和通知图标.

随着Android N的宣布,他最重要的功能之一是Screen Zoom(在Accessibility Improvements部分).另一个有趣的功能是多窗口支持(如果您想了解更多信息,请参阅链接).

这是否意味着我们应该使用矢量drawable也用于应用程序上使用的启动器图标和其他图像?

android android-vectordrawable android-7.0-nougat

19
推荐指数
2
解决办法
1万
查看次数

Android N:如何在分屏时单击通知时在当前活动窗口而不是第二个窗口中启动活动?

Android N使用分屏时,我希望activity在用户点击通知时在当前活动窗口中启动,但如果通过单击通知启动,则Android N始终activity在第二个窗口中启动.

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.notification)
                        .setAutoCancel(false)
                        .setContentTitle("Demo Title")
                        .setContentText("Demo");

Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("myIntent", "test");

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

Notification notification = mBuilder.build();

notification.flags = Notification.FLAG_NO_CLEAR;

mNotificationManager.notify(156, notification);
Run Code Online (Sandbox Code Playgroud)

什么时候intent比发射activity.

 Intent in = new Intent(MainActivity.this, SecondActivity.class);
 startActivity(in);
Run Code Online (Sandbox Code Playgroud)

前 - 我在前台有两个应用程序,如第一个窗口中的Chrome浏览器第二个窗口中的Facebook,现在我在Chrome浏览器中搜索某些内容,此时我收到了通知Gmail.现在当我点击Gmail通知而不是通过替换Facebook第二个窗口中 …

android android-intent android-notifications split-screen android-7.0-nougat

19
推荐指数
1
解决办法
2107
查看次数

列出存储在用户凭据中的证书

在Android 7 Nougat中,用户安装的证书转到"用户凭据"而不是"可信凭证"(由系统凭据和用户凭证组成).

我过去通过以下方式访问"受信任的凭据":

KeyStore keystore = KeyStore.getInstance("AndroidCAStore");
Run Code Online (Sandbox Code Playgroud)

通过上面的代码,我可以访问系统和用户可信凭证.

但现在,在Android 7中,用户安装的证书将转到一个名为"用户凭据"的单独位置Settings --> Security --> User credentials.

我的问题是如何以编程方式列出User credentialsAndroid 7 中的凭据?

ssl android pkcs#12 android-7.0-nougat android-7.1-nougat

19
推荐指数
2
解决办法
8411
查看次数

以编程方式接受Nougat中的呼叫

从一年开始,我一直在研究物联网产品,所附的应用程序工作正常.现在我无法在更高版本的android中以编程方式接受调用.功能对产品非常重要.任何帮助都非常感谢.

2016年11月安全补丁更新之前,Runtime.getRunTime.exec("Command")以编程方式接受呼叫工作正常.

Runtime.getRuntime().exec("input keyevent " +Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK));
Run Code Online (Sandbox Code Playgroud)

如何在Nougat版本的android中实现它.

寻找任何类型的黑客.

我已经为增强功能打开了一个帖子.

https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=231938

注意*如果您中的任何一方遇到同样的问题,请请求加入Android Dev Team并提供用户获得运行时许可的条款.按照上面提到的URL来请求.

android android-security android-7.0-nougat android-7.1-nougat

19
推荐指数
2
解决办法
5224
查看次数

Android N Java8 java.time

我更新到最新的Android N sdk.我唯一不理解的是为什么我无法导入java.time我的代码?我认为Java8可以通过Android N获得.那么为什么谷歌没有添加java.time包?

android java-8 java-time android-7.0-nougat

18
推荐指数
4
解决办法
7326
查看次数

sdk platform-tools(23.1)太旧了,无法检查使用API​​ 24编译的API; 请更新

我在最新版本的Android Studio上收到此错误,同时我安装了Android SDK Platform API 24 Revision 1和Android SDK Build-Tools 24.

我还尝试过File> Invalidate Caches/Restart ...和Build> Rebuild Project.

编辑:我也遵循Android开发者的所有说明,但我仍然得到这个错误.

提前感谢您的任何答案.

android android-studio platform-tools android-7.0-nougat

18
推荐指数
1
解决办法
2万
查看次数

Android:如何获取内容://外部存储PUBLIC目录中文件的URI

我已经按照这个Google教程开始了一个捕获图像的意图new Intent(MediaStore.ACTION_IMAGE_CAPTURE).本教程建议使用getExternalStoragePublicDirectory适用于我的应用程序的公共目录.但后来他们的例子反而使用了getExternalFilesDir.然后将文件的URI传递给intent,MediaStore.EXTRA_OUTPUT必须得到一个内容URI,因为我想要定位Android N.在定位NI之前,只需传递一个文件:// URI,除了Google之外的所有人都很高兴.现在NI开始接受FileUriExposedException这似乎并不是非常有利.

所以鉴于我有这样的文件......

private File createImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "MyAppFolder");
    if (!storageDir.exists() && !storageDir.mkdir())
        Log.w(TAG, "Couldn't create photo folder: " + storageDir.getAbsolutePath());
    File image = new File(storageDir, timeStamp + ".jpg");
    mCurrentPhotoPath = image.getAbsolutePath();
    return image;
}
Run Code Online (Sandbox Code Playgroud)

...我可以使用公共图片目录的内置提供程序来获取内容URI吗?如果是这样的话?

我尝试过类似的东西

takePictureIntent.putExtra(
    MediaStore.EXTRA_OUTPUT, 
    FileProvider.getUriForFile(this, MediaStore.AUTHORITY, createImageFile()));
Run Code Online (Sandbox Code Playgroud)

但它只是抛出

IllegalArgumentException:缺少android.support.FILE_PROVIDER_PATHS元数据

该权威是否正确?如果我必须使用自己的提供程序来共享公共文件,那么我可以在FILE_PROVIDER_PATHS元数据中指定哪条路径?我能找到的所有选项都是针对私人目录的.

android android-intent android-contentprovider android-7.0-nougat

18
推荐指数
2
解决办法
1万
查看次数

NestedScrollView阻止Nougat上的bug(API 25)

我在Nexus 5x(7.1.2)和Google Pixel(7.1.1)上使用NestedScrollView时遇到了一个奇怪的问题.在其他操作系统版本上它运行正常.

举起动画有时会在举起手指后立即停止.它会停滞不前,接下来的几次飞行也可能会停止.为了重现它,你需要上下几次投掷.

在日志中,这些flings在速度,方向等方面看起来几乎相同,所以我找不到这个bug的真正原因.

NestedScrollView并不一定需要的内部CoordinatorLayout,也可以没有NestedScrollingChild在所有.

例如,此错误可以使用以下NestedScrollView子项之一重现:

1)LinearLayout填充TextViews

2) WebView

3)LinearLayout填充RecyclerViews.

我知道RecyclerView内部和行为的可能问题CoordinatorLayout,但它没有关系.所以请不要提及任何

recyclerView.getLayoutManager().setAutoMeasureEnabled(true);
recyclerView.setNestedScrollingEnabled(false);
Run Code Online (Sandbox Code Playgroud)

或类似的东西.

代码示例:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:text="Put a super long text here"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:text="Put a super long text here"/>

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

android scroll android-support-library nestedscrollview android-7.0-nougat

18
推荐指数
1
解决办法
2094
查看次数